Merge remote-tracking branch 'magefree/master'

This commit is contained in:
Samuel Sandeen 2016-09-02 19:44:51 -04:00
commit 85dc15c5dc
61 changed files with 1443 additions and 702 deletions

View file

@ -0,0 +1,71 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author Styxo
*/
public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
private FilterCreaturePermanent filter;
private int minAttackers;
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
this(effect, minAttackers, new FilterCreaturePermanent("creatures"));
}
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers, FilterCreaturePermanent filter) {
super(Zone.BATTLEFIELD, effect);
this.filter = filter;
this.minAttackers = minAttackers;
}
public AttacksWithCreaturesTriggeredAbility(final AttacksWithCreaturesTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.minAttackers = ability.minAttackers;
}
@Override
public AttacksWithCreaturesTriggeredAbility copy() {
return new AttacksWithCreaturesTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int attackerCount = 0;
for (UUID attacker : game.getCombat().getAttackers()) {
if (filter.match(game.getPermanent(attacker), game)) {
attackerCount++;
}
}
return attackerCount >= minAttackers && game.getCombat().getAttackerId().equals(getControllerId());
}
@Override
public String getRule() {
StringBuilder sb = new StringBuilder("Whenever you attack with " + minAttackers + " or more ");
sb.append(filter.getMessage());
sb.append(", ");
sb.append(super.getRule());
return sb.toString();
}
}

View file

@ -0,0 +1,82 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
/**
*
* @author Styxo
*/
public class CreatureCountCondition implements Condition {
private FilterCreaturePermanent filter;
private int creatureCount;
private TargetController targetController;
public CreatureCountCondition(FilterCreaturePermanent filter, int creatureCount, TargetController targetController) {
this.filter = filter;
this.creatureCount = creatureCount;
this.targetController = targetController;
}
public CreatureCountCondition(int creatureCount, TargetController targetController) {
this.filter = new FilterCreaturePermanent();
this.creatureCount = creatureCount;
this.targetController = targetController;
}
@Override
public boolean apply(Game game, Ability source) {
switch (targetController) {
case YOU:
return game.getBattlefield().countAll(filter, source.getControllerId(), game) == creatureCount;
case OPPONENT:
for (UUID opponent : game.getOpponents(source.getControllerId())) {
if (game.getBattlefield().countAll(filter, opponent, game) != creatureCount) {
return false;
}
}
return true;
case ANY:
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == creatureCount;
default:
throw new UnsupportedOperationException("Value for targetController not supported: " + targetController.toString());
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
switch (targetController) {
case YOU:
sb.append("you");
break;
case OPPONENT:
sb.append("your opponents");
break;
case ANY:
sb.append("if ");
sb.append(creatureCount);
sb.append(" ");
sb.append(filter.getMessage());
sb.append(" are on the battlefield");
return sb.toString();
}
sb.append(" control exactly ");
sb.append(creatureCount);
sb.append(" ");
sb.append(filter.getMessage());
return sb.toString();
}
}

View file

@ -1,52 +0,0 @@
/*
* 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.filter.common.FilterCreaturePermanent;
import mage.game.Game;
/**
* @author noxx
*/
public class NoControlledCreatureCondition implements Condition {
private static NoControlledCreatureCondition fInstance = new NoControlledCreatureCondition();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
return game.getBattlefield().countAll(filter, source.getControllerId(), game) == 0;
}
}

View file

@ -1,52 +0,0 @@
/*
* 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.filter.common.FilterCreaturePermanent;
import mage.game.Game;
/**
* @author nantuko
*/
public class NoCreatureCondition implements Condition {
private static final NoCreatureCondition fInstance = new NoCreatureCondition();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0;
}
}

View file

@ -1,62 +0,0 @@
/*
* 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 java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
/**
* @author jeff
*/
public class NoCreatureOpponentCondition implements Condition {
private static NoCreatureOpponentCondition fInstance = new NoCreatureOpponentCondition();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
int condition = 0;
for (UUID opponent : game.getOpponents(source.getControllerId())) {
if (game.getBattlefield().countAll(filter, opponent, game) == 0) {
condition++;
}
}
if (condition == 0)
return false;
else return true;
}
}

View file

@ -1,58 +0,0 @@
/*
* 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.filter.common.FilterCreaturePermanent;
import mage.game.Game;
/**
* @author noxx
*/
public class OneControlledCreatureCondition implements Condition {
private static final OneControlledCreatureCondition fInstance = new OneControlledCreatureCondition();
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
return game.getBattlefield().countAll(filter, source.getControllerId(), game) == 1;
}
@Override
public String toString() {
return "you control exactly one creature";
}
}

View file

@ -1,5 +1,6 @@
package mage.abilities.condition.common;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
@ -11,17 +12,21 @@ import mage.game.permanent.Permanent;
*/
public class SourceHasSubtypeCondition implements Condition {
private final String subtype;
public SourceHasSubtypeCondition(String subtype) {
this.subtype = subtype;
private final List<String> subtypes;
public SourceHasSubtypeCondition(List<String> subtypes) {
this.subtypes = subtypes;
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
return permanent.hasSubtype(subtype, game);
for (String subtype : subtypes) {
if (permanent.hasSubtype(subtype, game)) {
return true;
}
}
}
return false;
}

View file

@ -30,9 +30,11 @@ package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
@ -44,10 +46,19 @@ import mage.util.CardUtil;
public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
protected int amount;
protected boolean putToGraveyard;
public LookLibraryTopCardTargetPlayerEffect(int amount) {
super(Outcome.Benefit);
this.amount = amount;
this.putToGraveyard = false;
setText();
}
public LookLibraryTopCardTargetPlayerEffect(int amount, boolean putToGraveyard) {
super(Outcome.Benefit);
this.amount = amount;
this.putToGraveyard = putToGraveyard;
setText();
}
@ -58,6 +69,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
public LookLibraryTopCardTargetPlayerEffect(final LookLibraryTopCardTargetPlayerEffect effect) {
super(effect);
amount = effect.amount;
putToGraveyard = effect.putToGraveyard;
}
@Override
@ -74,21 +86,38 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
Cards cards = new CardsImpl();
cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount));
player.lookAtCards(sourceObject.getName(), cards, game);
if (putToGraveyard) {
for (Card card : cards.getCards(game)) {
if (player.chooseUse(outcome, "Do you wish to put card into the player's graveyard?", source, game)) {
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
} else {
game.informPlayers(player.getLogName() + " puts the card back on top of the library.");
}
}
}
return true;
}
return false;
}
private void setText() {
StringBuilder sb = new StringBuilder("look at the top ");
StringBuilder sb = new StringBuilder("look at the top ");
if (amount > 1) {
sb.append(CardUtil.numberToText(amount));
sb.append(" cards ");
}
else {
} else {
sb.append(" card ");
}
sb.append("of target player's library");
if (putToGraveyard) {
sb.append(". You may put ");
if (amount > 1) {
sb.append("those cards");
} else {
sb.append("that card");
}
sb.append(" into that player's graveyard");
}
this.staticText = sb.toString();
}
}

View file

@ -0,0 +1,60 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author Styxo
*/
public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
public ShuffleIntoLibraryTargetEffect() {
super(Outcome.Detriment);
}
public ShuffleIntoLibraryTargetEffect(String effectText) {
super(Outcome.Detriment);
this.staticText = effectText;
}
public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) {
super(effect);
}
@Override
public ShuffleIntoLibraryTargetEffect copy() {
return new ShuffleIntoLibraryTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true)) {
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
return true;
}
}
return false;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
} else {
return "choose target " + mode.getTargets().get(0).getTargetName() + ". Its owner shuffles it into his or her library";
}
}
}

View file

@ -0,0 +1,59 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
/**
*
* @author Styxo
*/
public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl {
private Class activatedAbility;
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) {
super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit);
this.activatedAbility = activatedAbility;
staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant";
}
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) {
super(effect);
this.activatedAbility = effect.activatedAbility;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() {
return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
if (affectedAbility.getControllerId().equals(source.getControllerId())
&& activatedAbility.isInstance(affectedAbility)) {
return true;
}
return false;
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return false; // Not used
}
}

View file

@ -0,0 +1,50 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.cost;
import mage.abilities.Ability;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.util.CardUtil;
/**
*
* @author Styxo
*/
public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl {
private Class activatedAbility;
public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
this.activatedAbility = activatedAbility;
staticText = activatedAbilityName + " costs you pay cost {1} less";
}
public AbilitiesCostReductionControllerEffect(AbilitiesCostReductionControllerEffect effect) {
super(effect);
this.activatedAbility = effect.activatedAbility;
}
@java.lang.Override
public AbilitiesCostReductionControllerEffect copy() {
return new AbilitiesCostReductionControllerEffect(this);
}
@java.lang.Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
CardUtil.reduceCost(abilityToModify, 1);
return true;
}
@java.lang.Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getControllerId().equals(source.getControllerId())
&& activatedAbility.isInstance(abilityToModify);
}
}

View file

@ -65,6 +65,8 @@ public interface Card extends MageObject {
String getExpansionSetCode();
String getTokenSetCode();
String getTokenDescriptor();
void checkForCountersToAdd(Permanent permanent, Game game);

View file

@ -74,6 +74,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected String cardNumber;
public String expansionSetCode;
protected String tokenSetCode;
protected String tokenDescriptor;
protected Rarity rarity;
protected boolean canTransform;
protected Card secondSideCard;
@ -316,6 +317,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
public String getTokenSetCode() {
return tokenSetCode;
}
@Override
public String getTokenDescriptor() {
return tokenDescriptor;
}
@Override
public List<Mana> getMana() {

View file

@ -86,6 +86,7 @@ public class PermanentToken extends PermanentImpl {
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
this.supertype = token.getSupertype();
this.subtype = token.getSubtype(game);
this.tokenDescriptor = token.getTokenDescriptor();
}
@Override

View file

@ -55,6 +55,7 @@ public class Token extends MageObjectImpl {
private int tokenType;
private String originalCardNumber;
private String originalExpansionSetCode;
private String tokenDescriptor;
private boolean expansionSetCodeChecked;
private Card copySourceCard; // the card the Token is a copy from
@ -113,6 +114,26 @@ public class Token extends MageObjectImpl {
this.copySourceCard = token.copySourceCard; // will never be changed
this.availableImageSetCodes = token.availableImageSetCodes;
}
private void setTokenDescriptor() {
this.tokenDescriptor = tokenDescriptor();
}
public String getTokenDescriptor() {
this.tokenDescriptor = tokenDescriptor();
return tokenDescriptor;
}
private String tokenDescriptor() {
String name = this.name.replaceAll("[^a-zA-Z0-9]", "");
String color = this.color.toString().replaceAll("[^a-zA-Z0-9]", "");
String subtype = this.subtype.toString().replaceAll("[^a-zA-Z0-9]", "");
String cardType = this.cardType.toString().replaceAll("[^a-zA-Z0-9]", "");
String originalset = this.getOriginalExpansionSetCode();
String descriptor = name + "." + color + "." + subtype + "." + cardType + "." + this.power + "." + this.toughness ;
descriptor = descriptor.toUpperCase();
return descriptor;
}
public String getDescription() {
return description;
@ -241,13 +262,14 @@ public class Token extends MageObjectImpl {
public void setOriginalCardNumber(String originalCardNumber) {
this.originalCardNumber = originalCardNumber;
}
public String getOriginalExpansionSetCode() {
public String getOriginalExpansionSetCode() {
return originalExpansionSetCode;
}
public void setOriginalExpansionSetCode(String originalExpansionSetCode) {
this.originalExpansionSetCode = originalExpansionSetCode;
setTokenDescriptor();
}
public Card getCopySourceCard() {
@ -264,15 +286,20 @@ public class Token extends MageObjectImpl {
if (availableImageSetCodes.size() > 0) {
if (availableImageSetCodes.contains(code)) {
setOriginalExpansionSetCode(code);
} else // we should not set random set if appropriate set is already used
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
} else {
// we should not set random set if appropriate set is already used
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
}
}
} else {
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
setOriginalExpansionSetCode(code);
}
} else if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()) {
setOriginalExpansionSetCode(code);
}
}
setTokenDescriptor();
}
public boolean updateExpansionSetCode(String setCode) {
if (setCode == null || setCode.isEmpty()) {

View file

@ -572,6 +572,11 @@ public class Spell extends StackObjImpl implements Card {
public String getTokenSetCode() {
return card.getTokenSetCode();
}
@Override
public String getTokenDescriptor() {
return card.getTokenDescriptor();
}
@Override
public void setFaceDown(boolean value, Game game) {

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.target.common;
import mage.filter.common.FilterControlledCreaturePermanent;
@ -44,6 +43,10 @@ public class TargetControlledCreaturePermanent extends TargetControlledPermanent
this(numTargets, numTargets, new FilterControlledCreaturePermanent(), false);
}
public TargetControlledCreaturePermanent(int minNumTargets, int maxNumTargets) {
this(minNumTargets, maxNumTargets, new FilterControlledCreaturePermanent(), false);
}
public TargetControlledCreaturePermanent(FilterControlledCreaturePermanent filter) {
super(1, 1, filter, false);
}