* Fixed a problem with commander game resatrt from Karn Liberated.

This commit is contained in:
LevelX2 2019-01-20 19:40:38 +01:00
parent fa859a6bfd
commit 678118c79d

View file

@ -1,4 +1,3 @@
package mage.game; package mage.game;
import java.util.Map; import java.util.Map;
@ -44,18 +43,20 @@ public abstract class GameCommanderImpl extends GameImpl {
for (UUID playerId : state.getPlayerList(startingPlayerId)) { for (UUID playerId : state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId); Player player = getPlayer(playerId);
if (player != null) { if (player != null) {
if (player.getSideboard().isEmpty()) { // needed for restart game of e.g. Karn Liberated
for (UUID commanderId : player.getCommandersIds()) {
Card commander = this.getCard(commanderId);
if (commander != null) {
initCommander(commander, ability, player);
}
}
} else {
while (!player.getSideboard().isEmpty()) { while (!player.getSideboard().isEmpty()) {
Card commander = this.getCard(player.getSideboard().iterator().next()); Card commander = this.getCard(player.getSideboard().iterator().next());
if (commander != null) { if (commander != null) {
player.addCommanderId(commander.getId()); player.addCommanderId(commander.getId());
commander.moveToZone(Zone.COMMAND, null, this, true); initCommander(commander, ability, player);
commander.getAbilities().setControllerId(player.getId()); }
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
ability.addEffect(new CommanderCostModification(commander.getId()));
getState().setValue(commander.getId() + "_castCount", 0);
CommanderInfoWatcher watcher = new CommanderInfoWatcher(commander.getId(), checkCommanderDamage);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
} }
} }
} }
@ -67,6 +68,17 @@ public abstract class GameCommanderImpl extends GameImpl {
} }
} }
private void initCommander(Card commander, Ability ability, Player player) {
commander.moveToZone(Zone.COMMAND, null, this, true);
commander.getAbilities().setControllerId(player.getId());
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
ability.addEffect(new CommanderCostModification(commander.getId()));
getState().setValue(commander.getId() + "_castCount", 0);
CommanderInfoWatcher watcher = new CommanderInfoWatcher(commander.getId(), checkCommanderDamage);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
}
//20130711 //20130711
/*903.8. The Commander variant uses an alternate mulligan rule. /*903.8. The Commander variant uses an alternate mulligan rule.
* Each time a player takes a mulligan, rather than shuffling their entire hand of cards into their library, that player exiles any number of cards from their hand face down. * Each time a player takes a mulligan, rather than shuffling their entire hand of cards into their library, that player exiles any number of cards from their hand face down.