* Commander mulligan - changed to Vancouver mulligan rule.

This commit is contained in:
LevelX2 2016-05-26 15:33:41 +02:00
parent 85c3fe425b
commit 24fe679c34

View file

@ -39,16 +39,12 @@ import mage.abilities.effects.common.continuous.CommanderReplacementEffect;
import mage.abilities.effects.common.cost.CommanderCostModification; import mage.abilities.effects.common.cost.CommanderCostModification;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.MultiplayerAttackOption; import mage.constants.MultiplayerAttackOption;
import mage.constants.Outcome;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence; import mage.constants.RangeOfInfluence;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.turn.TurnMod; import mage.game.turn.TurnMod;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.watchers.common.CommanderInfoWatcher; import mage.watchers.common.CommanderInfoWatcher;
public abstract class GameCommanderImpl extends GameImpl { public abstract class GameCommanderImpl extends GameImpl {
@ -116,69 +112,73 @@ public abstract class GameCommanderImpl extends GameImpl {
//TODO implement may look at exile cards //TODO implement may look at exile cards
@Override @Override
public void mulligan(UUID playerId) { public void mulligan(UUID playerId) {
Player player = getPlayer(playerId); super.mulligan(playerId);
TargetCardInHand target = new TargetCardInHand(1, player.getHand().size(), new FilterCard("card to mulligan")); // Paris mulligan - no longer used by default for commander
target.setNotTarget(true); // Player player = getPlayer(playerId);
target.setRequired(false); // TargetCardInHand target = new TargetCardInHand(1, player.getHand().size(), new FilterCard("card to mulligan"));
if (player.choose(Outcome.Exile, player.getHand(), target, this)) { // target.setNotTarget(true);
int numCards = target.getTargets().size(); // target.setRequired(false);
for (UUID uuid : target.getTargets()) { // if (player.choose(Outcome.Exile, player.getHand(), target, this)) {
Card card = player.getHand().get(uuid, this); // int numCards = target.getTargets().size();
if (card != null) { // for (UUID uuid : target.getTargets()) {
if (!mulliganedCards.containsKey(playerId)) { // Card card = player.getHand().get(uuid, this);
mulliganedCards.put(playerId, new CardsImpl()); // if (card != null) {
} // if (!mulliganedCards.containsKey(playerId)) {
player.getHand().remove(card); // mulliganedCards.put(playerId, new CardsImpl());
getExile().add(card); // }
getState().setZone(card.getId(), Zone.EXILED); // player.getHand().remove(card);
card.setFaceDown(true, this); // getExile().add(card);
mulliganedCards.get(playerId).add(card); // getState().setZone(card.getId(), Zone.EXILED);
} // card.setFaceDown(true, this);
} // mulliganedCards.get(playerId).add(card);
int deduction = 1; // }
if (freeMulligans > 0) { // }
if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) { // int deduction = 1;
int used = usedFreeMulligans.get(player.getId()); // if (freeMulligans > 0) {
if (used < freeMulligans) { // if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
deduction = 0; // int used = usedFreeMulligans.get(player.getId());
usedFreeMulligans.put(player.getId(), used + 1); // if (used < freeMulligans) {
} // deduction = 0;
} else { // usedFreeMulligans.put(player.getId(), used + 1);
deduction = 0; // }
{ // } else {
// deduction = 0;
} // {
usedFreeMulligans.put(player.getId(), 1); //
} // }
} // usedFreeMulligans.put(player.getId(), 1);
player.drawCards(numCards - deduction, this); // }
fireInformEvent(new StringBuilder(player.getLogName()) // }
.append(" mulligans ") // player.drawCards(numCards - deduction, this);
.append(numCards) // fireInformEvent(new StringBuilder(player.getLogName())
.append(numCards == 1 ? " card" : " cards") // .append(" mulligans ")
.append(deduction == 0 ? " for free and draws " : " down to ") // .append(numCards)
.append(Integer.toString(player.getHand().size())) // .append(numCards == 1 ? " card" : " cards")
.append(player.getHand().size() <= 1 ? " card" : " cards").toString()); // .append(deduction == 0 ? " for free and draws " : " down to ")
} // .append(Integer.toString(player.getHand().size()))
// .append(player.getHand().size() <= 1 ? " card" : " cards").toString());
// }
} }
@Override @Override
public void endMulligan(UUID playerId) { public void endMulligan(UUID playerId) {
//return cards to super.endMulligan(playerId);
Player player = getPlayer(playerId); // Paris mulligan - no longer used by default for commander
if (player != null && mulliganedCards.containsKey(playerId)) { // //return cards to
for (Card card : mulliganedCards.get(playerId).getCards(this)) { // Player player = getPlayer(playerId);
if (card != null) { // if (player != null && mulliganedCards.containsKey(playerId)) {
getExile().removeCard(card, this); // for (Card card : mulliganedCards.get(playerId).getCards(this)) {
player.getLibrary().putOnTop(card, this); // if (card != null) {
getState().setZone(card.getId(), Zone.LIBRARY); // getExile().removeCard(card, this);
card.setFaceDown(false, this); // player.getLibrary().putOnTop(card, this);
} // getState().setZone(card.getId(), Zone.LIBRARY);
} // card.setFaceDown(false, this);
if (mulliganedCards.get(playerId).size() > 0) { // }
player.shuffleLibrary(null, this); // }
} // if (mulliganedCards.get(playerId).size() > 0) {
} // player.shuffleLibrary(null, this);
// }
// }
} }
/* 20130711 /* 20130711