[WHO] fix Truth or Consequences not correctly picking an opponent at random (fixes #14110)

This commit is contained in:
theelk801 2025-12-07 11:23:45 -05:00
parent fa1dfb8a42
commit a5483496f8

View file

@ -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;
} }
} }