import { Tags } from '../Tags' ; import { Player } from '../../Player' ; import { IProjectCard } from '../IProjectCard' ; import { Card } from '../Card' ; import { CorporationCard } from '../corporation/CorporationCard' ; import { SelectOption } from '../../inputs/SelectOption' ; import { OrOptions } from '../../inputs/OrOptions' ; import { ResourceType } from '../../ResourceType' ; import { CardName } from '../../CardName' ; import { CardType } from '../CardType' ; import { CardRenderer } from '../render/CardRenderer' ; import { Size } from '../render/Size' ; import { Resources } from '../../Resources' ; import { all , played } from '../Options' ; export class Splice extends Card implements CorporationCard { constructor ( ) { super ( { cardType : CardType . CORPORATION , name : CardName . SPLICE , tags : [ Tags . MICROBE ] , startingMegaCredits : 48 , initialActionText : 'Draw a card with a microbe tag' , metadata : { cardNumber : 'R28' , description : 'You start with 44 M€. As your first action, reveal cards until you have revealed a microbe tag. Take it and discard the rest.' , renderData : CardRenderer . builder ( ( b ) => { b . megacredits ( 44 ) . nbsp . cards ( 1 , { secondaryTag : Tags . MICROBE } ) ; b . corpBox ( 'effect' , ( ce ) => { ce . vSpace ( Size . LARGE ) ; ce . effect ( undefined , ( eb ) => { eb . microbes ( 1 , { played , all } ) . startEffect ; eb . megacredits ( 2 , { all } ) . or ( ) . microbes ( 1 , { all } ) . asterix ( ) ; } ) ; ce . vSpace ( ) ; ce . effect ( 'when a microbe tag is played, incl. this, THAT PLAYER gains 2 M€, or adds a microbe to THAT card, and you gain 2 M€.' , ( eb ) => { eb . microbes ( 1 , { played , all } ) . startEffect ; eb . megacredits ( 2 ) ; } ) ; } ) ; } ) , } , } ) ; } public initialAction ( player ) { player . drawCard ( 1 , { tag : Tags . MICROBE } ) ; return undefined ; } public onCardPlayed ( player , card ) { return this . _onCardPlayed ( player , card ) ; } public onCorpCardPlayed ( player , card ) { return this . _onCardPlayed ( player , card ) ; } private _onCardPlayed ( player , card ) { if ( card . tags . includes ( Tags . MICROBE ) === false ) { return undefined ; } const gainPerMicrobe = 2 ; const microbeTagsCount = card . tags . filter ( ( tag ) => tag === Tags . MICROBE ) . length ; const megacreditsGain = microbeTagsCount * gainPerMicrobe ; const addResource = new SelectOption ( 'Add a microbe resource to this card' , 'Add microbe' , ( ) => { player . addResourceTo ( card ) ; return undefined ; } ) ; const getMegacredits = new SelectOption ( `Gain ${ megacreditsGain } MC` , 'Gain M€' , ( ) => { player . addResource ( Resources . MEGACREDITS , megacreditsGain , { log : true } ) ; return undefined ; } ) ; player . game . getCardPlayer ( this . name ) . addResource ( Resources . MEGACREDITS , megacreditsGain , { log : true } ) ; if ( card . resourceType !== undefined && card . resourceType === ResourceType . MICROBE ) { return new OrOptions ( addResource , getMegacredits ) ; } else { player . addResource ( Resources . MEGACREDITS , megacreditsGain , { log : true } ) ; return undefined ; } } public play ( ) { return undefined ; } }