import { CardRenderItemType } from './CardRenderItemType' ; import { CardRenderItem } from './CardRenderItem' ; import { Size } from './Size' ; import { ResourceType } from '../../ResourceType' ; import { Tags } from '../../cards/Tags' ; const RESOURCE_TO_ITEM_TYPE = new Map ( [ [ ResourceType . MICROBE , CardRenderItemType . MICROBES ] , [ ResourceType . ANIMAL , CardRenderItemType . ANIMALS ] , [ ResourceType . CAMP , CardRenderItemType . CAMPS ] , [ ResourceType . DATA , CardRenderItemType . DATA_RESOURCE ] , [ ResourceType . SCIENCE , CardRenderItemType . SCIENCE ] , [ ResourceType . RESOURCE_CUBE , CardRenderItemType . RESOURCE_CUBE ] , [ ResourceType . PRESERVATION , CardRenderItemType . PRESERVATION ] , [ ResourceType . ASTEROID , CardRenderItemType . ASTEROIDS ] , [ ResourceType . FIGHTER , CardRenderItemType . FIGHTER ] , [ ResourceType . FLOATER , CardRenderItemType . FLOATERS ] , [ ResourceType . VENUSIAN_HABITAT , CardRenderItemType . VENUSIAN_HABITAT ] , [ ResourceType . SPECIALIZED_ROBOT , CardRenderItemType . SPECIALIZED_ROBOT ] , ] ) ; export class CardRenderDynamicVictoryPoints { public targetOneOrMore : boolean = false ; public anyPlayer : boolean = false ; constructor ( public item , public points , public target ) { } public getPointsHtml ( ) { if ( this . item === undefined && this . points === 0 && this . target === 0 ) return '?' ; if ( this . item === undefined ) return `${ this . points }` ; if ( this . target === this . points || this . target === 1 ) return `${ this . points }/` ; return `${ this . points }/${ this . target }` ; } public static asteroids ( points , target ) { return new CardRenderDynamicVictoryPoints ( new CardRenderItem ( CardRenderItemType . ASTEROIDS ) , points , target ) ; } public static resource ( type , points , target ) { const itemType = RESOURCE_TO_ITEM_TYPE . get ( type ) ; if ( itemType === undefined ) { throw new Error ( 'Unknown item type ' + type ) ; } return new CardRenderDynamicVictoryPoints ( new CardRenderItem ( itemType ) , points , target ) ; } public static tag ( type , points , target ) { const map = new Map < Tags , CardRenderItemType > ( [ [ Tags . JOVIAN , CardRenderItemType . JOVIAN ] , [ Tags . MOON , CardRenderItemType . MOON ] , [ Tags . VENUS , CardRenderItemType . VENUS ] , ] ) ; const itemType = map . get ( type ) ; if ( itemType === undefined ) { throw new Error ( 'Unknown item type ' + type ) ; } return new CardRenderDynamicVictoryPoints ( new CardRenderItem ( itemType , 1 , { played : true } ) , points , target ) ; } public static oceans ( points , target ) { const item = new CardRenderItem ( CardRenderItemType . OCEANS ) ; item . size = Size . SMALL ; return new CardRenderDynamicVictoryPoints ( item , points , target ) ; } public static cities ( points , target , any = false ) { const item = new CardRenderItem ( CardRenderItemType . CITY ) ; item . size = Size . SMALL ; item . anyPlayer = any ; return new CardRenderDynamicVictoryPoints ( item , points , target ) ; } public static searchForLife ( ) { const item = new CardRenderDynamicVictoryPoints ( new CardRenderItem ( CardRenderItemType . SCIENCE ) , 3 , 3 ) ; item . targetOneOrMore = true ; return item ; } public static colonies ( points , target , any = false ) { const item = new CardRenderItem ( CardRenderItemType . COLONIES ) ; item . size = Size . SMALL ; item . anyPlayer = any ; return new CardRenderDynamicVictoryPoints ( item , points , target ) ; } public static moonMiningTile ( points , any = false ) { const item = new CardRenderItem ( CardRenderItemType . MOON_MINE ) ; item . size = Size . SMALL ; item . anyPlayer = any ; return new CardRenderDynamicVictoryPoints ( item , points , points ) ; } public static moonColonyTile ( points ) { const item = new CardRenderItem ( CardRenderItemType . MOON_COLONY ) ; item . size = Size . SMALL ; return new CardRenderDynamicVictoryPoints ( item , points , 1 ) ; } public static moonRoadTile ( points , any = false ) { const item = new CardRenderItem ( CardRenderItemType . MOON_ROAD ) ; item . size = Size . SMALL ; item . anyPlayer = any ; return new CardRenderDynamicVictoryPoints ( item , points , 1 ) ; } public static questionmark ( ) { return new CardRenderDynamicVictoryPoints ( undefined , 0 , 0 ) ; } public static any ( points ) { const item = new CardRenderDynamicVictoryPoints ( undefined , points , points ) ; item . anyPlayer = true ; return item ; } }