forked from terraforming-mars/terraforming-mars
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request terraforming-mars#2368 from kberg/moon8
Moon #8 Add Mare Serenitatis Mine, which uses the Moon Road deferred Action, also enable some game pieces so I can test.
- Loading branch information
Showing
9 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {CardName} from '../../CardName'; | ||
import {Player} from '../../Player'; | ||
import {CardType} from '../CardType'; | ||
import {Tags} from '../Tags'; | ||
import {CardRenderer} from '../render/CardRenderer'; | ||
import {Resources} from '../../Resources'; | ||
import {MoonSpaces} from '../../moon/MoonSpaces'; | ||
import {MoonExpansion} from '../../moon/MoonExpansion'; | ||
import {PlaceMoonRoadTile} from '../../moon/PlaceMoonRoadTile'; | ||
import {Units} from '../../Units'; | ||
import {SpaceType} from '../../SpaceType'; | ||
import {IProjectCard} from '../IProjectCard'; | ||
import {Card} from '../Card'; | ||
|
||
export class MareSerenitatisMine extends Card implements IProjectCard { | ||
constructor() { | ||
super({ | ||
name: CardName.MARE_SERENITATIS_MINE, | ||
cardType: CardType.AUTOMATED, | ||
tags: [Tags.MOON, Tags.BUILDING], | ||
cost: 21, | ||
|
||
metadata: { | ||
description: 'Spend 2 titanium and 1 steel. Increase your steel production 1 step and your titanium production 1 step. ' + | ||
'Place a mine ON THE RESERVED AREA and adjacent to it road tile. Raise Mining Rate 1 step and Logistic Rate 1 step.', | ||
cardNumber: 'M04', | ||
renderData: CardRenderer.builder((b) => { | ||
b.minus().titanium(2).minus().steel(1).br; | ||
b.production((pb) => pb.steel(1).titanium(1)).br; | ||
b.moonMine().asterix().nbsp.moonRoad().asterix(); | ||
}), | ||
}, | ||
}); | ||
} | ||
|
||
public reserveUnits = Units.of({titanium: 2, steel: 1}); | ||
|
||
public play(player: Player) { | ||
Units.deductUnits(this.reserveUnits, player); | ||
player.addProduction(Resources.STEEL, 1); | ||
player.addProduction(Resources.TITANIUM, 1); | ||
MoonExpansion.addMineTile(player, MoonSpaces.MARE_SERENITATIS, this.name); | ||
MoonExpansion.raiseMiningRate(player); | ||
const moon = MoonExpansion.moonData(player.game).moon; | ||
const spaces = moon.getAdjacentSpaces(moon.getSpace(MoonSpaces.MARE_SERENITATIS)); | ||
const availableRoadSpaces = spaces.filter((space) => { | ||
return space.player === undefined && space.spaceType === SpaceType.LAND; | ||
}); | ||
player.game.defer(new PlaceMoonRoadTile(player, 'Select a space next to Mare Serintatis to play a road', availableRoadSpaces)); | ||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {Game} from '../../src/Game'; | ||
import {IMoonData} from '../../src/moon/IMoonData'; | ||
import {MoonExpansion} from '../../src/moon/MoonExpansion'; | ||
import {Player} from '../../src/Player'; | ||
import {setCustomGameOptions, TestPlayers} from '../TestingUtils'; | ||
import {MareSerenitatisMine} from '../../src/cards/moon/MareSerenitatisMine'; | ||
import {expect} from 'chai'; | ||
import {Resources} from '../../src/Resources'; | ||
import {PlaceMoonRoadTile} from '../../src/moon/PlaceMoonRoadTile'; | ||
import {MoonSpaces} from '../../src/moon/MoonSpaces'; | ||
import {TileType} from '../../src/TileType'; | ||
|
||
const MOON_OPTIONS = setCustomGameOptions({moonExpansion: true}); | ||
|
||
describe('MareSerenitatisMine', () => { | ||
let game: Game; | ||
let player: Player; | ||
let moonData: IMoonData; | ||
let card: MareSerenitatisMine; | ||
|
||
beforeEach(() => { | ||
player = TestPlayers.BLUE.newPlayer(); | ||
game = Game.newInstance('id', [player], player, MOON_OPTIONS); | ||
moonData = MoonExpansion.moonData(game); | ||
card = new MareSerenitatisMine(); | ||
}); | ||
|
||
it('can play', () => { | ||
// TODO: Ensuring resources is going to require changes coming later. | ||
}); | ||
|
||
it('play', () => { | ||
player.titanium = 3; | ||
player.steel = 3; | ||
expect(player.getProduction(Resources.STEEL)).eq(0); | ||
expect(player.getProduction(Resources.TITANIUM)).eq(0); | ||
expect(player.getTerraformRating()).eq(14); | ||
expect(moonData.miningRate).eq(0); | ||
|
||
card.play(player); | ||
|
||
expect(player.titanium).eq(1); | ||
expect(player.steel).eq(2); | ||
expect(player.getProduction(Resources.STEEL)).eq(1); | ||
expect(player.getProduction(Resources.TITANIUM)).eq(1); | ||
expect(player.getTerraformRating()).eq(15); | ||
expect(moonData.miningRate).eq(1); | ||
|
||
const mareSerenitatis = moonData.moon.getSpace(MoonSpaces.MARE_SERENITATIS); | ||
expect(mareSerenitatis.player).eq(player); | ||
expect(mareSerenitatis.tile!.tileType).eq(TileType.MOON_MINE); | ||
|
||
const deferredAction = game.deferredActions.next() as PlaceMoonRoadTile; | ||
const roadSpace = deferredAction.spaces![0]; | ||
expect(roadSpace.tile).is.undefined; | ||
expect(roadSpace.player).is.undefined; | ||
expect(moonData.logisticRate).eq(0); | ||
|
||
deferredAction!.execute()!.cb(roadSpace); | ||
expect(roadSpace.tile!.tileType).eq(TileType.MOON_ROAD); | ||
expect(roadSpace.player).eq(player); | ||
expect(moonData.logisticRate).eq(1); | ||
expect(player.getTerraformRating()).eq(16); | ||
}); | ||
}); | ||
|