* Tiny Leaders - Added logic to load the commander from deck name.

This commit is contained in:
LevelX2 2015-03-04 23:36:19 +01:00
parent d090904448
commit 4d0dbb2327
4 changed files with 32 additions and 8 deletions

View file

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

View file

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

View file

@ -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<Player> {
boolean isInPayManaMode();
void setMatchPlayer(MatchPlayer matchPlayer);
MatchPlayer getMatchPlayer();
}

View file

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