-
Notifications
You must be signed in to change notification settings - Fork 18
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
6 changed files
with
216 additions
and
67 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 was deleted.
Oops, something went wrong.
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,48 @@ | ||
import AbilityDsl from '../../../abilitydsl'; | ||
import { Locations } from '../../../Constants'; | ||
import DrawCard from '../../../drawcard'; | ||
import { parseGameMode } from '../../../GameMode'; | ||
|
||
const ACTIVE_LOCATIONS = [Locations.Hand, Locations.PlayArea]; | ||
|
||
export default class LuckyCoin extends DrawCard { | ||
static id = 'lucky-coin'; | ||
|
||
setupCardAbilities() { | ||
this.reaction({ | ||
title: 'Replace all cards in your provinces', | ||
when: { | ||
onRevealFacedownDynastyCards: (_, context) => { | ||
const totalCost = context.player | ||
.getDynastyCardsInProvince(Locations.Provinces) | ||
.reduce((totalCost: number, card: DrawCard) => { | ||
const cost = !card.facedown && !isNaN(card.printedCost) ? card.printedCost : 0; | ||
return totalCost + cost; | ||
}, 0); | ||
return totalCost < 6 || totalCost > 12; | ||
} | ||
}, | ||
cost: AbilityDsl.costs.removeSelfFromGame({ location: ACTIVE_LOCATIONS }), | ||
location: ACTIVE_LOCATIONS, | ||
gameAction: AbilityDsl.actions.handler({ | ||
handler: ({ player, game }) => { | ||
const cardsToMulligan = player.getDynastyCardsInProvince(Locations.Provinces); | ||
|
||
for (const nonStrongholdProvince of parseGameMode(game.gameMode).setupNonStrongholdProvinces) { | ||
if (player.dynastyDeck.size() > 0) { | ||
player.moveCard(player.dynastyDeck.first(), nonStrongholdProvince); | ||
} | ||
} | ||
|
||
for (const card of cardsToMulligan) { | ||
const originalLocation = card.location; | ||
player.moveCard(card, 'dynasty deck bottom'); | ||
player.replaceDynastyCard(originalLocation); | ||
} | ||
player.shuffleDynastyDeck(); | ||
} | ||
}), | ||
effect: 'to replace all cards in their provinces' | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,60 +1,174 @@ | ||
describe('Lucky Coin', function() { | ||
integration(function() { | ||
beforeEach(function() { | ||
describe('Lucky Coin - ATTENTION: FLAKY!!', function () { | ||
integration(function () { | ||
beforeEach(function () { | ||
this.setupTest({ | ||
phase: 'conflict', | ||
phase: 'fate', | ||
player1: { | ||
inPlay: ['doji-kuwanan', 'doji-challenger'], | ||
hand: ['lucky-coin', 'a-new-name'] | ||
}, | ||
player2: { | ||
inPlay: ['young-harrier'], | ||
hand: ['noble-sacrifice'] | ||
inPlay: ['doji-kuwanan'], | ||
hand: ['lucky-coin'], | ||
dynastyDiscard: [ | ||
'iron-mine', | ||
'miya-mystic', | ||
'aranat', | ||
'fushicho', | ||
'imperial-storehouse', | ||
'miya-library' | ||
] | ||
} | ||
}); | ||
|
||
this.kuwanan = this.player1.findCardByName('doji-kuwanan'); | ||
this.challenger = this.player1.findCardByName('doji-challenger'); | ||
this.coin = this.player1.findCardByName('lucky-coin'); | ||
this.ann = this.player1.findCardByName('a-new-name'); | ||
|
||
this.harrier = this.player2.findCardByName('young-harrier'); | ||
this.sac = this.player2.findCardByName('noble-sacrifice'); | ||
this.mine = this.player1.findCardByName('iron-mine'); | ||
this.mystic = this.player1.findCardByName('miya-mystic'); | ||
this.aranat = this.player1.findCardByName('aranat'); | ||
this.fushicho = this.player1.findCardByName('fushicho'); | ||
this.storehouse = this.player1.findCardByName('imperial-storehouse'); | ||
this.library = this.player1.findCardByName('miya-library'); | ||
}); | ||
|
||
this.kuwanan.dishonor(); | ||
this.harrier.honor(); | ||
describe('for flips with ok cost', function () { | ||
beforeEach(function () { | ||
this.player1.placeCardInProvince(this.mine, 'province 1'); | ||
this.mine.facedown = true; | ||
this.player1.placeCardInProvince(this.library, 'province 2'); | ||
this.library.facedown = true; | ||
this.player1.placeCardInProvince(this.fushicho, 'province 3'); | ||
this.fushicho.facedown = true; | ||
this.player1.placeCardInProvince(this.mystic, 'province 4'); | ||
this.mystic.facedown = true; | ||
}); | ||
|
||
this.player1.playAttachment(this.coin, this.kuwanan); | ||
}); | ||
describe('with attachment in play', function () { | ||
beforeEach(function () { | ||
this.player1.playAttachment(this.coin, this.kuwanan); | ||
|
||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('nothing happens', function () { | ||
expect(this.player1).not.toHavePrompt('Triggered Abilities'); | ||
}); | ||
}); | ||
|
||
describe('with attachment in hand', function () { | ||
beforeEach(function () { | ||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('should have no effect if not during a conflict', function() { | ||
expect(this.kuwanan.getMilitarySkill()).toBe(2); | ||
expect(this.kuwanan.getPoliticalSkill()).toBe(1); | ||
it('nothing happens', function () { | ||
expect(this.player1).not.toHavePrompt('Triggered Abilities'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should stop dishonor status modifying both skills', function() { | ||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.challenger], | ||
defenders: [] | ||
describe('for too expensive flips', function () { | ||
beforeEach(function () { | ||
this.player1.placeCardInProvince(this.mine, 'province 1'); | ||
this.mine.facedown = true; | ||
this.player1.placeCardInProvince(this.aranat, 'province 2'); | ||
this.aranat.facedown = true; | ||
this.player1.placeCardInProvince(this.fushicho, 'province 3'); | ||
this.fushicho.facedown = true; | ||
this.player1.placeCardInProvince(this.mystic, 'province 4'); | ||
this.mystic.facedown = true; | ||
}); | ||
|
||
describe('with attachment in play', function () { | ||
beforeEach(function () { | ||
this.player1.playAttachment(this.coin, this.kuwanan); | ||
|
||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('mulligan everything', function () { | ||
expect(this.player1).toHavePrompt('Triggered Abilities'); | ||
|
||
this.player1.clickCard(this.coin); | ||
expect(this.getChatLogs(3)).toContain( | ||
'player1 uses Lucky Coin, removing Lucky Coin from the game to to replace all cards in their provinces' | ||
); | ||
}); | ||
}); | ||
|
||
describe('with attachment in hand', function () { | ||
beforeEach(function () { | ||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('mulligan everything', function () { | ||
expect(this.player1).toHavePrompt('Triggered Abilities'); | ||
|
||
this.player1.clickCard(this.coin); | ||
expect(this.getChatLogs(3)).toContain( | ||
'player1 uses Lucky Coin, removing Lucky Coin from the game to to replace all cards in their provinces' | ||
); | ||
}); | ||
}); | ||
expect(this.kuwanan.getMilitarySkill()).toBe(5); | ||
expect(this.kuwanan.getPoliticalSkill()).toBe(4); | ||
}); | ||
|
||
// it('should stop dishonor status losing honor on leaving play', function() { | ||
// let honor = this.player1.honor; | ||
|
||
// this.noMoreActions(); | ||
// this.initiateConflict({ | ||
// attackers: [this.challenger], | ||
// defenders: [] | ||
// }); | ||
// this.player2.clickCard(this.sac); | ||
// this.player2.clickCard(this.kuwanan); | ||
// this.player2.clickCard(this.harrier); | ||
|
||
// expect(this.kuwanan.location).toBe('dynasty discard pile'); | ||
// expect(this.player1.honor).toBe(honor); | ||
// }); | ||
describe('for too cheap flips', function () { | ||
beforeEach(function () { | ||
this.player1.placeCardInProvince(this.mine, 'province 1'); | ||
this.mine.facedown = true; | ||
this.player1.placeCardInProvince(this.library, 'province 2'); | ||
this.library.facedown = true; | ||
this.player1.placeCardInProvince(this.storehouse, 'province 3'); | ||
this.storehouse.facedown = true; | ||
this.player1.placeCardInProvince(this.mystic, 'province 4'); | ||
this.mystic.facedown = true; | ||
}); | ||
|
||
describe('with attachment in play', function () { | ||
beforeEach(function () { | ||
this.player1.playAttachment(this.coin, this.kuwanan); | ||
|
||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('mulligan everything', function () { | ||
expect(this.player1).toHavePrompt('Triggered Abilities'); | ||
|
||
this.player1.clickCard(this.coin); | ||
expect(this.getChatLogs(3)).toContain( | ||
'player1 uses Lucky Coin, removing Lucky Coin from the game to to replace all cards in their provinces' | ||
); | ||
}); | ||
}); | ||
|
||
describe('with attachment in hand', function () { | ||
beforeEach(function () { | ||
this.noMoreActions(); | ||
this.player2.clickPrompt('Done'); | ||
this.player2.clickPrompt('End Round'); | ||
this.player1.clickPrompt('End Round'); | ||
}); | ||
|
||
it('mulligan everything', function () { | ||
expect(this.player1).toHavePrompt('Triggered Abilities'); | ||
|
||
this.player1.clickCard(this.coin); | ||
expect(this.getChatLogs(3)).toContain( | ||
'player1 uses Lucky Coin, removing Lucky Coin from the game to to replace all cards in their provinces' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |