import { IProjectCard } from '../IProjectCard' ; import { Tags } from '../Tags' ; import { Card } from '../Card' ; import { CardType } from '../CardType' ; import { Player } from '../../Player' ; import { ISpace } from '../../boards/ISpace' ; import { SelectSpace } from '../../inputs/SelectSpace' ; import { Resources } from '../../Resources' ; import { CardName } from '../../CardName' ; import { Board } from '../../boards/Board' ; import { CardRenderer } from '../render/CardRenderer' ; import { Units } from '../../Units' ; export class UrbanizedArea extends Card implements IProjectCard { constructor ( ) { super ( { cardType : CardType . AUTOMATED , name : CardName . URBANIZED_AREA , tags : [ Tags . CITY , Tags . BUILDING ] , cost : 10 , productionBox : Units . of ( { energy : - 1 , megacredits : 2 } ) , metadata : { cardNumber : '120' , renderData : CardRenderer . builder ( ( b ) => { b . production ( ( pb ) => { pb . minus ( ) . energy ( 1 ) . br ; pb . plus ( ) . megacredits ( 2 ) ; } ) . city ( ) . asterix ( ) ; } ) , description : 'Decrease your Energy production 1 step and increase your M€ production 2 steps. Place a city tile ADJACENT TO AT LEAST 2 OTHER CITY TILES.' , } , } ) ; } private getAvailableSpaces ( player ) { return player . game . board . getAvailableSpacesOnLand ( player ) . filter ( ( space ) => player . game . board . getAdjacentSpaces ( space ) . filter ( ( adjacentSpace ) => Board . isCitySpace ( adjacentSpace ) ) . length >= 2 ) ; } public canPlay ( player ) { return player . getProduction ( Resources . ENERGY ) >= 1 && this . getAvailableSpaces ( player ) . length > 0 ; } public play ( player ) { return new SelectSpace ( 'Select space next to at least 2 other city tiles' , this . getAvailableSpaces ( player ) , ( foundSpace ) => { player . game . addCityTile ( player , foundSpace . id ) ; player . addProduction ( Resources . ENERGY , - 1 ) ; player . addProduction ( Resources . MEGACREDITS , 2 ) ; return undefined ; } ) ; } }