import { Player } from '../../Player' ; import { PartyName } from './PartyName' ; import { SpaceType } from '../../SpaceType' ; import { Phase } from '../../Phase' ; import { PolicyId } from '../Policy' ; import { Resources } from '../../Resources' ; import { ISpace } from '../../boards/ISpace' ; import { GREENS_POLICY_1 } from './Greens' ; import { TurmoilPolicy } from '../TurmoilPolicy' ; import { PoliticalAgendas } from '../PoliticalAgendas' ; import { Turmoil } from '../Turmoil' ; export class PartyHooks { static applyMarsFirstRulingPolicy ( player , spaceType ) { if ( this . shouldApplyPolicy ( player , PartyName . MARS , TurmoilPolicy . MARS_FIRST_DEFAULT_POLICY ) && spaceType !== SpaceType . COLONY ) { player . addResource ( Resources . STEEL , 1 ) ; } } static applyGreensRulingPolicy ( player , space ) { if ( this . shouldApplyPolicy ( player , PartyName . GREENS , TurmoilPolicy . GREENS_DEFAULT_POLICY ) ) { const greensPolicy = GREENS_POLICY_1 ; greensPolicy . onTilePlaced ( player , space ) ; } } static shouldApplyPolicy ( player , partyName , policyId ? ) { const game = player . game ; return Turmoil . ifTurmoilElse ( game , ( turmoil ) => { if ( game . phase !== Phase . ACTION ) return false ; const rulingParty = turmoil . rulingParty ; if ( rulingParty === undefined ) return false ; if ( policyId === undefined ) { policyId = rulingParty . policies [ 0 ] . id ; } const currentPolicyId = ( turmoil . politicalAgendasData === undefined ) ? rulingParty . policies [ 0 ] . id : PoliticalAgendas . currentAgenda ( turmoil ) . policyId ; return rulingParty . name === partyName && currentPolicyId === policyId ; } , ( ) => false ) ; } }