finished adding support for multiple copies of Krark's Thumb

This commit is contained in:
Evan Kranzler 2019-01-16 18:20:36 -05:00
parent 4736a608b1
commit 1144bf3b4f
2 changed files with 24 additions and 3 deletions

View file

@ -55,7 +55,7 @@ class KrarksThumbEffect extends ContinuousEffectImpl {
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
controller.setExtraCoinFlips(controller.getExtraCoinFlips() + 1); controller.setExtraCoinFlips(2 * controller.getExtraCoinFlips());
} }
return true; return true;
} }

View file

@ -2587,13 +2587,34 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean chosen = false; boolean chosen = false;
if (winnable) { if (winnable) {
chosen = this.chooseUse(Outcome.Benefit, "Heads or tails?", "", "Heads", "Tails", source, game); chosen = this.chooseUse(Outcome.Benefit, "Heads or tails?", "", "Heads", "Tails", source, game);
game.informPlayers(getLogName() + " chose " + (chosen ? "heads." : "tails.")); game.informPlayers(getLogName() + " chose " + CardUtil.booleanToFlipName(chosen));
} }
boolean result = RandomUtil.nextBoolean(); boolean result = RandomUtil.nextBoolean();
FlipCoinEvent event = new FlipCoinEvent(playerId, source.getSourceId(), result, chosen, winnable); FlipCoinEvent event = new FlipCoinEvent(playerId, source.getSourceId(), result, chosen, winnable);
event.addAppliedEffects(appliedEffects); event.addAppliedEffects(appliedEffects);
game.replaceEvent(event); game.replaceEvent(event);
game.informPlayers(getLogName() + " got " + (event.getResult() ? "heads" : "tails")); if (extraCoinFlips > 1) {
boolean canChooseHeads = event.getResult();
boolean canChooseTails = !event.getResult();
boolean tempFlip;
for (int i = 0; i < extraCoinFlips; i++) {
tempFlip = RandomUtil.nextBoolean();
canChooseHeads = canChooseHeads || tempFlip;
canChooseTails = canChooseTails || !tempFlip;
game.informPlayers(getLogName() + " flipped " + CardUtil.booleanToFlipName(tempFlip));
}
if (canChooseHeads && canChooseTails) {
event.setResult(chooseUse(Outcome.Benefit, "Choose which flip to keep",
(event.isWinnable() ? "(You called " + event.getChosenName() + ")" : null),
"Heads", "Tails", source, game
));
} else if (canChooseHeads) {
event.setResult(true);
} else {
event.setResult(false);
}
}
game.informPlayers(getLogName() + " got " + CardUtil.booleanToFlipName(event.getResult()));
if (event.isWinnable()) { if (event.isWinnable()) {
game.informPlayers(getLogName() + " " + (event.getResult() == event.getChosen() ? "won" : "lost") + " the flip"); game.informPlayers(getLogName() + " " + (event.getResult() == event.getChosen() ? "won" : "lost") + " the flip");
} }