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;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -10,8 +11,9 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
import java.util.Optional;
|
||||
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);
|
||||
vote.doVotes(source, game);
|
||||
player.drawCards(vote.getVoteCount(true), source, game);
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
target.setRandom(true);
|
||||
target.choose(outcome, source.getControllerId(), source.getSourceId(), source, game);
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
return opponent == null || opponent.damage(3 * vote.getVoteCount(false), source, game) > 0;
|
||||
Optional.of(player)
|
||||
.map(MageItem::getId)
|
||||
.map(game::getOpponents)
|
||||
.map(RandomUtil::randomFromCollection)
|
||||
.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