Added Darien, King of Kjeldor, Captain Sisay, Howltooth Hollow, Blackmail, Cao Cao, Lord of Wei and Diaochan Artful Beauty.

This commit is contained in:
LevelX2 2014-04-04 16:44:19 +02:00
parent 73885ab01d
commit 87dd02ecfc
16 changed files with 959 additions and 161 deletions

View file

@ -27,59 +27,150 @@
*/
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.TargetController;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
* Cards in controller hand condition. This condition can decorate other conditions
* as well as be used standalone.
* Cards in controller hand condition. This condition can decorate other
* conditions as well as be used standalone.
*
*
* @author LevelX
*/
public class CardsInHandCondition implements Condition {
public static enum CountType { MORE_THAN, FEWER_THAN, EQUAL_TO };
public static enum CountType {
MORE_THAN, FEWER_THAN, EQUAL_TO
};
private Condition condition;
private CountType type;
private int count;
private TargetController targetController;
public CardsInHandCondition() {
this(CountType.EQUAL_TO, 0);
}
public CardsInHandCondition (CountType type, int count ) {
this.type = type;
this.count = count;
public CardsInHandCondition() {
this(CountType.EQUAL_TO, 0);
}
public CardsInHandCondition (CountType type, int count, Condition conditionToDecorate ) {
this(type, count);
public CardsInHandCondition(CountType type, int count) {
this(type, count, null);
}
public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate) {
this(type, count, conditionToDecorate, TargetController.YOU);
}
public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate, TargetController targetController) {
this.type = type;
this.count = count;
this.condition = conditionToDecorate;
this.targetController = targetController;
}
@Override
public boolean apply(Game game, Ability source) {
public boolean apply(Game game, Ability source) {
boolean conditionApplies = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
switch (targetController) {
case YOU:
switch (this.type) {
case FEWER_THAN:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() < this.count;
break;
case MORE_THAN:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() > this.count;
break;
case EQUAL_TO:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() == this.count;
break;
}
break;
case ANY:
boolean conflict = false;
switch (this.type) {
case FEWER_THAN:
for (UUID playerId :controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().size() >= this.count) {
conflict = true;
break;
}
}
}
break;
case MORE_THAN:
for (UUID playerId :controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().size() <= this.count) {
conflict = true;
break;
}
}
}
break;
case EQUAL_TO:
for (UUID playerId :controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().size() != this.count) {
conflict = true;
break;
}
}
}
break;
}
conditionApplies = !conflict;
break;
default:
throw new UnsupportedOperationException("Value of TargetController not supported for this class.");
}
switch ( this.type ) {
case FEWER_THAN:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() < this.count;
break;
case MORE_THAN:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() > this.count;
break;
case EQUAL_TO:
conditionApplies = game.getPlayer(source.getControllerId()).getHand().size() == this.count;
break;
}
//If a decorated condition exists, check it as well and apply them together.
if ( this.condition != null ) {
conditionApplies = conditionApplies && this.condition.apply(game, source);
//If a decorated condition exists, check it as well and apply them together.
if (this.condition != null) {
conditionApplies = conditionApplies && this.condition.apply(game, source);
}
}
return conditionApplies;
}
@Override
public String toString() {
int workCount = count;
StringBuilder sb = new StringBuilder("if ");
switch (targetController) {
case YOU:
sb.append(" you have");
break;
case ANY:
sb.append(" each player has");
break;
}
switch (this.type) {
case FEWER_THAN:
sb.append(" less or equal than ");
workCount++;
break;
case MORE_THAN:
sb.append(" more than ");
break;
}
if (count == 0) {
sb.append(" no ");
} else {
sb.append(CardUtil.numberToText(workCount));
}
sb.append("cards in hand");
return sb.toString();
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.TurnPhase;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class MyTurnBeforeAttackersDeclaredCondition implements Condition {
private static final MyTurnBeforeAttackersDeclaredCondition fInstance = new MyTurnBeforeAttackersDeclaredCondition();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
if (game.getActivePlayerId().equals(source.getControllerId())) {
TurnPhase turnPhase = game.getTurn().getPhase().getType();
if (turnPhase.equals(TurnPhase.BEGINNING) || turnPhase.equals(TurnPhase.PRECOMBAT_MAIN)) {
return true;
}
if (turnPhase.equals(TurnPhase.COMBAT)) {
return !game.getTurn().isDeclareAttackersStepStarted();
}
}
return false;
}
@Override
public String toString() {
return "during your turn, before attackers are declared";
}
}

View file

@ -20,7 +20,7 @@ import mage.game.permanent.Permanent;
*/
public class DevotionCount implements DynamicValue {
private ArrayList<ColoredManaSymbol> devotionColors = new ArrayList();
private ArrayList<ColoredManaSymbol> devotionColors = new ArrayList<>();
public DevotionCount(ColoredManaSymbol... devotionColor) {
this.devotionColors.addAll(Arrays.asList(devotionColor));

View file

@ -7,13 +7,19 @@ import mage.game.Game;
public class StaticValue implements DynamicValue {
private int value = 0;
private String message;
public StaticValue(int value) {
this(value, "");
}
public StaticValue(int value, String message) {
this.value = value;
this.message = message;
}
public StaticValue(final StaticValue staticValue) {
this.value = staticValue.value;
this.message = staticValue.message;
}
@Override
@ -33,6 +39,6 @@ public class StaticValue implements DynamicValue {
@Override
public String getMessage() {
return "";
return message;
}
}

View file

@ -27,9 +27,15 @@
*/
package mage.abilities.effects.common.discard;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
@ -37,6 +43,8 @@ import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
/**
*
@ -46,6 +54,8 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect<DiscardCardY
private FilterCard filter;
private TargetController targetController;
private DynamicValue numberCardsToReveal;
private boolean revealAllCards;
public DiscardCardYouChooseTargetEffect() {
this(new FilterCard("a card"));
@ -58,36 +68,90 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect<DiscardCardY
public DiscardCardYouChooseTargetEffect(FilterCard filter) {
this(filter, TargetController.OPPONENT);
}
public DiscardCardYouChooseTargetEffect(TargetController targetController, int numberCardsToReveal) {
this(new FilterCard("one card"), targetController,
new StaticValue(numberCardsToReveal, new StringBuilder(CardUtil.numberToText(numberCardsToReveal)).append(" cards").toString()));
}
public DiscardCardYouChooseTargetEffect(TargetController targetController, DynamicValue numberCardsToReveal) {
this(new FilterCard("one card"), targetController, numberCardsToReveal);
}
public DiscardCardYouChooseTargetEffect(FilterCard filter, TargetController targetController, DynamicValue numberCardsToReveal) {
super(Outcome.Discard);
this.targetController = targetController;
this.filter = filter;
this.revealAllCards = false;
this.numberCardsToReveal = numberCardsToReveal;
staticText = this.setText();
}
public DiscardCardYouChooseTargetEffect(FilterCard filter, TargetController targetController) {
super(Outcome.Discard);
this.targetController = targetController;
this.filter = filter;
staticText = this.setText();
this.numberCardsToReveal = null;
this.revealAllCards = true;
staticText = this.setText();
}
public DiscardCardYouChooseTargetEffect(final DiscardCardYouChooseTargetEffect effect) {
super(effect);
this.filter = effect.filter;
this.targetController = effect.targetController;
this.numberCardsToReveal = effect.numberCardsToReveal;
this.revealAllCards = effect.revealAllCards;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (player != null && you != null) {
player.revealCards(sourceCard != null ? sourceCard.getName() :"Discard", player.getHand(), game);
if (player.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
TargetCard target = new TargetCard(Zone.PICK, filter);
target.setRequired(true);
if (you.choose(Outcome.Benefit, player.getHand(), target, game)) {
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.discard(card, source, game);
if (player != null && controller != null) {
if (revealAllCards) {
this.numberCardsToReveal = new StaticValue(player.getHand().size());
}
int number = this.numberCardsToReveal.calculate(game, source);
if (number > 0) {
Cards revealedCards = new CardsImpl(Zone.HAND);
number = Math.min(player.getHand().size(), number);
if (player.getHand().size() > number) {
TargetCardInHand chosenCards = new TargetCardInHand(number, number, new FilterCard("card in target player's hand"));
chosenCards.setRequired(true);
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(player.getId(), game) && player.choose(Outcome.Discard, player.getHand(), chosenCards, game)) {
if (!chosenCards.getTargets().isEmpty()) {
List<UUID> targets = chosenCards.getTargets();
for (UUID targetid : targets) {
Card card = game.getCard(targetid);
if (card != null) {
revealedCards.add(card);
}
}
}
}
} else {
revealedCards.addAll(player.getHand());
}
player.revealCards(sourceCard != null ? sourceCard.getName() :"Discard", revealedCards, game);
if (revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
TargetCard target = new TargetCard(Zone.HAND, filter);
target.setRequired(true);
if (controller.choose(Outcome.Benefit, revealedCards, target, game)) {
Card card = revealedCards.get(target.getFirstTarget(), game);
if (card != null) {
return player.discard(card, source, game);
}
}
}
}
return true;
}
@ -111,8 +175,27 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect<DiscardCardY
default:
throw new UnsupportedOperationException("target controller not supported");
}
sb.append(" reveals his or her hand. You choose ")
.append(filter.getMessage()).append(" from it. That player discards that card").toString();
if (revealAllCards) {
sb.append(" reveals his or her hand");
} else {
if (numberCardsToReveal instanceof StaticValue) {
sb.append(" reveales ");
sb.append(numberCardsToReveal.getMessage());
sb.append(" from his or her hand");
} else {
sb.append(" reveals a number of cards from his or her hand equal to ");
sb.append(numberCardsToReveal.getMessage());
}
}
sb.append(". You choose ");
sb.append(filter.getMessage());
if (revealAllCards) {
sb.append(" from it.");
} else {
sb.append(" of them.");
}
sb.append(" That player discards that card").toString();
return sb.toString();
}
}

View file

@ -40,12 +40,13 @@ public class SoldierToken extends Token {
public SoldierToken() {
super("Soldier", "1/1 white Soldier creature token");
this.setOriginalExpansionSetCode("10E");
cardType.add(CardType.CREATURE);
color = ObjectColor.WHITE;
subtype.add("Soldier");
power = new MageInt(1);
toughness = new MageInt(1);
this.setOriginalExpansionSetCode("10E");
}
}