mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
game: fixed game error with battle protector choosing on no opponents;
This commit is contained in:
parent
0db46ba3da
commit
640e5394c9
1 changed files with 12 additions and 2 deletions
|
|
@ -1693,21 +1693,31 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
@Override
|
||||
public void chooseProtector(Game game, Ability source) {
|
||||
Set<UUID> opponents = game.getOpponents(this.getControllerId());
|
||||
Player controller = game.getPlayer(this.getControllerId());
|
||||
if (controller == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player newProtector;
|
||||
if (opponents.size() > 1) {
|
||||
TargetPlayer target = new TargetPlayer(new FilterOpponent("protector for " + getName()));
|
||||
target.setNotTarget(true);
|
||||
target.setRequired(true);
|
||||
game.getPlayer(getControllerId()).choose(Outcome.Neutral, target, source, game);
|
||||
controller.choose(Outcome.Neutral, target, source, game);
|
||||
newProtector = game.getPlayer(target.getFirstTarget());
|
||||
} else {
|
||||
} else if (opponents.size() == 1) {
|
||||
newProtector = game.getPlayer(opponents.iterator().next());
|
||||
} else {
|
||||
newProtector = null;
|
||||
}
|
||||
|
||||
if (newProtector != null) {
|
||||
String protectorName = newProtector.getLogName();
|
||||
game.informPlayers(protectorName + " has been chosen to protect " + this.getLogName());
|
||||
this.addInfo("protector", "Protected by " + protectorName, game);
|
||||
this.setProtectorId(newProtector.getId());
|
||||
} else {
|
||||
game.informPlayers(controller.getLogName() + " remains in protect of " + this.getLogName() + " as there are no opponents for new protector");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue