mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[WHO] fix Truth or Consequences not correctly picking an opponent at random (fixes #14110)
This commit is contained in:
parent
fa1dfb8a42
commit
a5483496f8
1 changed files with 13 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
|
import mage.MageItem;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -10,8 +11,9 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,10 +66,15 @@ class TruthOrConsequencesEffect extends OneShotEffect {
|
||||||
TwoChoiceVote vote = new TwoChoiceVote("Truth (draw card)", "Consequences (deal damage)", Outcome.DrawCard, true);
|
TwoChoiceVote vote = new TwoChoiceVote("Truth (draw card)", "Consequences (deal damage)", Outcome.DrawCard, true);
|
||||||
vote.doVotes(source, game);
|
vote.doVotes(source, game);
|
||||||
player.drawCards(vote.getVoteCount(true), source, game);
|
player.drawCards(vote.getVoteCount(true), source, game);
|
||||||
TargetOpponent target = new TargetOpponent(true);
|
Optional.of(player)
|
||||||
target.setRandom(true);
|
.map(MageItem::getId)
|
||||||
target.choose(outcome, source.getControllerId(), source.getSourceId(), source, game);
|
.map(game::getOpponents)
|
||||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
.map(RandomUtil::randomFromCollection)
|
||||||
return opponent == null || opponent.damage(3 * vote.getVoteCount(false), source, game) > 0;
|
.map(game::getPlayer)
|
||||||
|
.ifPresent(opponent -> {
|
||||||
|
game.informPlayers(opponent.getLogName() + " has been chosen at random.");
|
||||||
|
opponent.damage(3 * vote.getVoteCount(false), source, game);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue