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.
- Loading branch information
Showing
8 changed files
with
116 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {CardName} from '../../../common/cards/CardName'; | ||
import {CardRenderer} from '../render/CardRenderer'; | ||
import {PlayerInput} from '../../PlayerInput'; | ||
import {Player} from '../../Player'; | ||
import {CeoCard} from './CeoCard'; | ||
import {all, cancelled} from '../Options'; | ||
|
||
export class Huan extends CeoCard { | ||
constructor() { | ||
super({ | ||
name: CardName.HUAN, | ||
metadata: { | ||
cardNumber: 'L29', | ||
renderData: CardRenderer.builder((b) => { | ||
b.opgArrow().text('ACTIVATE THE BELOW ABILITY'); | ||
b.br.br; | ||
b.trade({all, cancelled}).asterix().tradeFleet(); | ||
b.br.br; | ||
}), | ||
description: 'ALL OPPONENTS CANNOT TRADE NEXT GENERATION. Gain 1 Trade Fleet.', | ||
}, | ||
}); | ||
} | ||
|
||
public action(player: Player): PlayerInput | undefined { | ||
const game = player.game; | ||
player.colonies.increaseFleetSize(); | ||
game.syndicatePirateRaider = player.id; | ||
|
||
game.log( | ||
'All players except ${0} may not trade next generation.', | ||
(b) => b.player(player), | ||
); | ||
|
||
this.isDisabled = true; | ||
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
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 {expect} from 'chai'; | ||
import {Huan} from '../../../src/server/cards/ceos/Huan'; | ||
import {IGame} from '../../../src/server/IGame'; | ||
import {Player} from '../../../src/server/Player'; | ||
import {testGame} from '../../TestGame'; | ||
import {forceGenerationEnd, runAllActions} from '../../TestingUtils'; | ||
|
||
describe('Huan', () => { | ||
let card: Huan; | ||
let game: IGame; | ||
let player: Player; | ||
let player2: Player; | ||
|
||
beforeEach(() => { | ||
card = new Huan(); | ||
|
||
[game, player, player2] = testGame(2, {coloniesExtension: true}); | ||
player.playedCards.push(card); | ||
}); | ||
|
||
it('Takes action', () => { | ||
game.colonies[0].trade(player); | ||
game.colonies[1].trade(player2); | ||
|
||
expect(player.colonies.tradesThisGeneration).eq(1); | ||
expect(player2.colonies.tradesThisGeneration).eq(1); | ||
expect(game.colonies[0].visitor).eq(player.id); | ||
expect(game.colonies[1].visitor).eq(player2.id); | ||
|
||
// Blocks opponents from trading, but clears all colony visitors | ||
const initialFleetSize = player.colonies.getFleetSize(); | ||
card.action(player); | ||
forceGenerationEnd(game); | ||
|
||
expect(player.colonies.tradesThisGeneration).eq(0); | ||
expect(player2.colonies.tradesThisGeneration).eq(50); | ||
expect(game.colonies[0].visitor).is.undefined; | ||
expect(game.colonies[1].visitor).is.undefined; | ||
|
||
// Player gains an extra trade fleet | ||
expect(player.colonies.getFleetSize()).to.eq(initialFleetSize + 1); | ||
}); | ||
|
||
it('Can only act once per game', () => { | ||
card.action(player); | ||
runAllActions(game); | ||
|
||
forceGenerationEnd(game); | ||
expect(card.isDisabled).is.true; | ||
expect(card.canAct(player)).is.false; | ||
}); | ||
}); |