diff --git a/Mage/src/mage/game/GameTinyLeadersImpl.java b/Mage/src/mage/game/GameTinyLeadersImpl.java index 126f787739..0862757890 100644 --- a/Mage/src/mage/game/GameTinyLeadersImpl.java +++ b/Mage/src/mage/game/GameTinyLeadersImpl.java @@ -38,6 +38,8 @@ import mage.abilities.effects.common.continuous.CommanderManaReplacementEffect; import mage.abilities.effects.common.continuous.CommanderReplacementEffect; import mage.abilities.effects.common.cost.CommanderCostModification; import mage.cards.Card; +import mage.cards.repository.CardInfo; +import mage.cards.repository.CardRepository; import mage.constants.MultiplayerAttackOption; import mage.constants.PhaseStep; import mage.constants.RangeOfInfluence; @@ -73,14 +75,20 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ Player player = getPlayer(playerId); if (player != null){ if (player.getSideboard().size() > 0){ - Card commander = getCard((UUID)player.getSideboard().toArray()[0]); - if (commander != null) { - player.setCommanderId(commander.getId()); - commander.moveToZone(Zone.COMMAND, null, this, true); - ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary)); - ability.addEffect(new CommanderCostModification(commander.getId())); - ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander))); - getState().setValue(commander.getId() + "_castCount", 0); + CardInfo cardInfo = CardRepository.instance.findCard(player.getMatchPlayer().getDeck().getName()); + if (cardInfo != null) { + Card commander = cardInfo.getCard(); + Set cards = new HashSet<>(); + cards.add(commander); + this.loadCards(cards, playerId); + if (commander != null) { + player.setCommanderId(commander.getId()); + commander.moveToZone(Zone.COMMAND, null, this, true); + ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoLibrary)); + ability.addEffect(new CommanderCostModification(commander.getId())); + ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander))); + getState().setValue(commander.getId() + "_castCount", 0); + } } } } diff --git a/Mage/src/mage/game/match/MatchImpl.java b/Mage/src/mage/game/match/MatchImpl.java index 8fee424999..7bb0ea4d25 100644 --- a/Mage/src/mage/game/match/MatchImpl.java +++ b/Mage/src/mage/game/match/MatchImpl.java @@ -98,6 +98,7 @@ public abstract class MatchImpl implements Match { @Override public void addPlayer(Player player, Deck deck) { MatchPlayer matchPlayer = new MatchPlayer(player, deck); + player.setMatchPlayer(matchPlayer); players.add(matchPlayer); } diff --git a/Mage/src/mage/players/Player.java b/Mage/src/mage/players/Player.java index a9d847a803..cedc5c8a30 100644 --- a/Mage/src/mage/players/Player.java +++ b/Mage/src/mage/players/Player.java @@ -61,6 +61,7 @@ import java.io.Serializable; import java.util.*; import mage.constants.PlayerAction; import mage.game.combat.CombatGroup; +import mage.game.match.MatchPlayer; /** * @@ -531,4 +532,6 @@ public interface Player extends MageItem, Copyable { boolean isInPayManaMode(); + void setMatchPlayer(MatchPlayer matchPlayer); + MatchPlayer getMatchPlayer(); } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 4354e2c148..c860ded14d 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -118,6 +118,7 @@ import mage.game.events.DamagePlayerEvent; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; +import mage.game.match.MatchPlayer; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; import mage.game.stack.Spell; @@ -228,6 +229,7 @@ public abstract class PlayerImpl implements Player, Serializable { protected boolean payManaMode = false; protected UserData userData; + protected MatchPlayer matchPlayer; /** * During some steps we can't play anything @@ -2921,4 +2923,14 @@ public abstract class PlayerImpl implements Player, Serializable { return usersAllowedToSeeHandCards; } + @Override + public void setMatchPlayer(MatchPlayer matchPlayer) { + this.matchPlayer = matchPlayer; + } + + @Override + public MatchPlayer getMatchPlayer() { + return matchPlayer; + } + }