* Changed return class of copy method.

This commit is contained in:
LevelX2 2015-07-30 11:29:36 +02:00
parent 2aa2ad7252
commit 67bd4956d9
34 changed files with 148 additions and 120 deletions

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.abilities.dynamicvalue;
import mage.abilities.Ability;
@ -36,8 +35,8 @@ import mage.game.Game;
*
* @author LevelX2
*/
public class IntPlusDynamicValue implements DynamicValue {
private final DynamicValue value;
private final int baseValue;
@ -57,7 +56,7 @@ public class IntPlusDynamicValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public IntPlusDynamicValue copy() {
return new IntPlusDynamicValue(this);
}

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.abilities.dynamicvalue;
import mage.abilities.Ability;
@ -36,8 +35,8 @@ import mage.game.Game;
*
* @author LevelX2
*/
public class MultipliedValue implements DynamicValue {
private final DynamicValue value;
private final int multplier;
@ -57,7 +56,7 @@ public class MultipliedValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public MultipliedValue copy() {
return new MultipliedValue(this);
}

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.abilities.dynamicvalue.common;
import mage.abilities.Ability;
@ -38,8 +37,6 @@ import mage.game.combat.CombatGroup;
*
* @author LevelX2
*/
public class AttackingCreatureCount implements DynamicValue {
private String message;
@ -67,7 +64,7 @@ public class AttackingCreatureCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public AttackingCreatureCount copy() {
return new AttackingCreatureCount(this);
}

View file

@ -27,15 +27,14 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -74,7 +73,7 @@ public class AuraAttachedCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public AuraAttachedCount copy() {
return new AuraAttachedCount(this);
}

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.abilities.dynamicvalue.common;
import java.util.UUID;
@ -72,7 +71,7 @@ public class CardsInAllGraveyardsCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public CardsInAllGraveyardsCount copy() {
return new CardsInAllGraveyardsCount(this);
}

View file

@ -44,7 +44,7 @@ public class CardsInControllerGraveyardCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public CardsInControllerGraveyardCount copy() {
return new CardsInControllerGraveyardCount(this);
}

View file

@ -7,6 +7,7 @@ import mage.game.Game;
import mage.players.Player;
public class CardsInControllerHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {
@ -19,7 +20,7 @@ public class CardsInControllerHandCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public CardsInControllerHandCount copy() {
return new CardsInControllerHandCount();
}

View file

@ -22,7 +22,7 @@ public class CardsInTargetPlayerHandCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public CardsInTargetPlayerHandCount copy() {
return new CardsInTargetPlayerHandCount();
}
@ -30,5 +30,5 @@ public class CardsInTargetPlayerHandCount implements DynamicValue {
public String getMessage() {
return "cards in target player's hand";
}
}

View file

@ -25,9 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.dynamicvalue.common;
import java.io.ObjectStreamException;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.abilities.dynamicvalue.DynamicValue;
@ -35,18 +36,14 @@ import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.watchers.common.PlayerGainedLifeWatcher;
import java.io.ObjectStreamException;
import java.util.UUID;
/**
* Amount of life the controller got this turn.
*
*
* @author LevelX2
*/
public class ControllerGotLifeCount implements DynamicValue, MageSingleton {
private static final ControllerGotLifeCount fINSTANCE = new ControllerGotLifeCount();
private static final ControllerGotLifeCount fINSTANCE = new ControllerGotLifeCount();
private Object readResolve() throws ObjectStreamException {
return fINSTANCE;
@ -70,7 +67,7 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton {
}
@Override
public DynamicValue copy() {
public ControllerGotLifeCount copy() {
return new ControllerGotLifeCount();
}

View file

@ -7,6 +7,7 @@ import mage.game.Game;
import mage.players.Player;
public class ControllerLifeCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player p = game.getPlayer(sourceAbility.getControllerId());
@ -17,7 +18,7 @@ public class ControllerLifeCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public ControllerLifeCount copy() {
return new ControllerLifeCount();
}

View file

@ -29,7 +29,7 @@ public class CountersCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public CountersCount copy() {
return new CountersCount(this);
}

View file

@ -4,6 +4,8 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.ArrayList;
import java.util.Arrays;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
@ -12,11 +14,9 @@ import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you control counts toward your devotion to that color.
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you
* control counts toward your devotion to that color.
*
* @author LevelX2
*/
@ -36,8 +36,8 @@ public class DevotionCount implements DynamicValue {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int devotion = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
for(ManaCost manaCost :permanent.getManaCost()) {
for(ColoredManaSymbol coloredManaSymbol: devotionColors) {
for (ManaCost manaCost : permanent.getManaCost()) {
for (ColoredManaSymbol coloredManaSymbol : devotionColors) {
if (manaCost.containsColor(coloredManaSymbol)) {
devotion++;
break; // count each manaCost maximum of one time (Hybrid don't count for multiple colors of devotion)
@ -49,7 +49,7 @@ public class DevotionCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public DevotionCount copy() {
return new DevotionCount(this);
}
@ -62,7 +62,7 @@ public class DevotionCount implements DynamicValue {
public String getMessage() {
StringBuilder sb = new StringBuilder("devotion to ");
int count = 0;
for (ColoredManaSymbol coloredManaSymbol:devotionColors) {
for (ColoredManaSymbol coloredManaSymbol : devotionColors) {
if (count > 0) {
sb.append(" and ");
}

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.abilities.dynamicvalue.common;
import mage.abilities.Ability;
@ -40,7 +39,6 @@ import mage.game.permanent.Permanent;
*
* @author LevelX2
*/
public class DevouredCreaturesCount implements DynamicValue {
int multiplier;
@ -65,7 +63,7 @@ public class DevouredCreaturesCount implements DynamicValue {
if (sourcePermanent != null) {
for (Ability ability : sourcePermanent.getAbilities()) {
if (ability instanceof DevourAbility) {
for (Effect abilityEffect: ability.getEffects()) {
for (Effect abilityEffect : ability.getEffects()) {
if (abilityEffect instanceof DevourEffect) {
DevourEffect devourEffect = (DevourEffect) abilityEffect;
return devourEffect.getDevouredCreaturesAmount(game, sourcePermanent.getId()) * multiplier;

View file

@ -15,11 +15,11 @@ public class DiscardCostCardConvertedMana implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof DiscardCardCost) {
DiscardCardCost discardCost = (DiscardCardCost) cost;
int cmc = 0;
for (Card card :discardCost.getCards()) {
for (Card card : discardCost.getCards()) {
cmc += card.getManaCost().convertedManaCost();
}
return cmc;
@ -29,7 +29,7 @@ public class DiscardCostCardConvertedMana implements DynamicValue {
}
@Override
public DynamicValue copy() {
public DiscardCostCardConvertedMana copy() {
return new DiscardCostCardConvertedMana();
}
@ -38,7 +38,6 @@ public class DiscardCostCardConvertedMana implements DynamicValue {
return "";
}
@Override
public String getMessage() {
return "the discarded card's converted mana cost";

View file

@ -74,7 +74,7 @@ public class DomainValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public DomainValue copy() {
return new DomainValue(this);
}

View file

@ -27,15 +27,14 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.UUID;
/**
*
* @author North, noxx
@ -73,7 +72,7 @@ public class EquipmentAttachedCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public EquipmentAttachedCount copy() {
return new EquipmentAttachedCount(this);
}

View file

@ -36,20 +36,18 @@ import mage.cards.Card;
import mage.game.Game;
/**
* Calculates the converted mana costs of a card that was
* exiled from hand as cost.
* If no card was exiled the getManaCostsToPay().getX() will
* be used as value.
* Calculates the converted mana costs of a card that was exiled from hand as
* cost. If no card was exiled the getManaCostsToPay().getX() will be used as
* value.
*
*
* @author LevelX2
*/
public class ExileFromHandCostCardConvertedMana implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost.isPaid() && cost instanceof ExileFromHandCost) {
int xValue = 0;
for (Card card : ((ExileFromHandCost) cost).getCards()) {
@ -62,7 +60,7 @@ public class ExileFromHandCostCardConvertedMana implements DynamicValue {
}
@Override
public DynamicValue copy() {
public ExileFromHandCostCardConvertedMana copy() {
return new ExileFromHandCostCardConvertedMana();
}

View file

@ -39,9 +39,9 @@ import mage.game.stack.Spell;
*
* @author LevelX2
*/
public class ManaSpentToCastCount implements DynamicValue{
public class ManaSpentToCastCount implements DynamicValue {
public ManaSpentToCastCount(){
public ManaSpentToCastCount() {
}
@Override
@ -61,7 +61,7 @@ public class ManaSpentToCastCount implements DynamicValue{
}
@Override
public DynamicValue copy() {
public ManaSpentToCastCount copy() {
return new ManaSpentToCastCount();
}

View file

@ -34,7 +34,7 @@ public class ManaTypeInManaPoolCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public ManaTypeInManaPoolCount copy() {
return new ManaTypeInManaPoolCount(this);
}

View file

@ -25,22 +25,19 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.dynamicvalue.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.watchers.common.PlayerLostLifeWatcher;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public class OpponentsLostLifeCount implements DynamicValue {
@Override
@ -52,7 +49,7 @@ public class OpponentsLostLifeCount implements DynamicValue {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher");
if (watcher != null) {
int amountLifeLost = 0;
for(UUID opponent: game.getOpponents(controllerId)){
for (UUID opponent : game.getOpponents(controllerId)) {
amountLifeLost += watcher.getLiveLost(opponent);
}
return amountLifeLost;
@ -61,7 +58,7 @@ public class OpponentsLostLifeCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public OpponentsLostLifeCount copy() {
return new OpponentsLostLifeCount();
}

View file

@ -81,7 +81,7 @@ public class ParleyCount implements DynamicValue, MageSingleton {
}
@Override
public DynamicValue copy() {
public ParleyCount copy() {
return fINSTANCE;
}

View file

@ -1,3 +1,30 @@
/*
* 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.dynamicvalue.common;
import mage.abilities.Ability;
@ -43,7 +70,7 @@ public class PermanentsOnBattlefieldCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public PermanentsOnBattlefieldCount copy() {
return new PermanentsOnBattlefieldCount(this);
}

View file

@ -1,3 +1,30 @@
/*
* 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.dynamicvalue.common;
import mage.abilities.Ability;
@ -11,7 +38,6 @@ import mage.game.Game;
*
* @author LoneFox
*/
public class PermanentsTargetOpponentControlsCount implements DynamicValue {
private FilterPermanent filter;
@ -36,25 +62,24 @@ public class PermanentsTargetOpponentControlsCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public PermanentsTargetOpponentControlsCount copy() {
return new PermanentsTargetOpponentControlsCount(this);
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if(sourceAbility.getFirstTarget() != null) {
if (sourceAbility.getFirstTarget() != null) {
filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget()));
int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
return multiplier * value;
}
else {
} else {
return 0;
}
}
@Override
public String toString() {
if(multiplier != null) {
if (multiplier != null) {
return multiplier.toString();
}
return "X";

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
@ -21,7 +20,7 @@ public class RemovedCountersForCostValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof RemoveVariableCountersSourceCost) {
return ((RemoveVariableCountersSourceCost) cost).getAmount();
}
@ -31,11 +30,11 @@ public class RemovedCountersForCostValue implements DynamicValue {
@Override
public String getMessage() {
return "number of removed counters";
return "number of removed counters";
}
@Override
public DynamicValue copy() {
public RemovedCountersForCostValue copy() {
return new RemovedCountersForCostValue();
}

View file

@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
@ -21,7 +20,7 @@ public class RevealTargetFromHandCostCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof RevealTargetFromHandCost) {
return ((RevealTargetFromHandCost) cost).getNumberRevealedCards();
}
@ -31,11 +30,11 @@ public class RevealTargetFromHandCostCount implements DynamicValue {
@Override
public String getMessage() {
return "number of revealed cards";
return "number of revealed cards";
}
@Override
public DynamicValue copy() {
public RevealTargetFromHandCostCount copy() {
return new RevealTargetFromHandCostCount();
}

View file

@ -15,11 +15,11 @@ public class SacrificeCostCreaturesPower implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
int powerSum = 0;
for (Permanent permanent :sacrificeCost.getPermanents()) {
for (Permanent permanent : sacrificeCost.getPermanents()) {
powerSum += permanent.getPower().getValue();
}
return powerSum;
@ -29,7 +29,7 @@ public class SacrificeCostCreaturesPower implements DynamicValue {
}
@Override
public DynamicValue copy() {
public SacrificeCostCreaturesPower copy() {
return new SacrificeCostCreaturesPower();
}
@ -38,7 +38,6 @@ public class SacrificeCostCreaturesPower implements DynamicValue {
return "X";
}
@Override
public String getMessage() {
return "the sacrificed creature's power";

View file

@ -15,11 +15,11 @@ public class SacrificeCostCreaturesToughness implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
int toughnessSum = 0;
for (Permanent permanent :sacrificeCost.getPermanents()) {
for (Permanent permanent : sacrificeCost.getPermanents()) {
toughnessSum += permanent.getToughness().getValue();
}
return toughnessSum;
@ -29,7 +29,7 @@ public class SacrificeCostCreaturesToughness implements DynamicValue {
}
@Override
public DynamicValue copy() {
public SacrificeCostCreaturesToughness copy() {
return new SacrificeCostCreaturesToughness();
}
@ -38,7 +38,6 @@ public class SacrificeCostCreaturesToughness implements DynamicValue {
return "X";
}
@Override
public String getMessage() {
return "the sacrificed creature's toughness";

View file

@ -6,6 +6,7 @@ import mage.abilities.effects.Effect;
import mage.game.Game;
public class SignInversionDynamicValue implements DynamicValue {
private final DynamicValue value;
public SignInversionDynamicValue(DynamicValue value) {
@ -22,7 +23,7 @@ public class SignInversionDynamicValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public SignInversionDynamicValue copy() {
return new SignInversionDynamicValue(this);
}

View file

@ -21,7 +21,7 @@ public class SourcePermanentPowerCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public SourcePermanentPowerCount copy() {
return new SourcePermanentPowerCount();
}

View file

@ -1,18 +1,19 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
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;
@ -29,7 +30,7 @@ public class StaticValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public StaticValue copy() {
return new StaticValue(this);
}

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.abilities.dynamicvalue.common;
import mage.Mana;
@ -40,33 +39,32 @@ import mage.game.stack.StackObject;
*
* @author Nicolas
*/
public class SunburstCount implements DynamicValue {
public SunburstCount() {
public class SunburstCount implements DynamicValue{
public SunburstCount(){
}
@Override
public int calculate(Game game, Ability source, Effect effect) {
int count = 0;
if (!game.getStack().isEmpty()) {
StackObject spell = game.getStack().getFirst();
if (spell != null && spell instanceof Spell && ((Spell)spell).getSourceId().equals(source.getSourceId())) {
Mana mana = ((Spell)spell).getSpellAbility().getManaCostsToPay().getPayment();
if(mana.getBlack() > 0) {
if (spell != null && spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) {
Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment();
if (mana.getBlack() > 0) {
count++;
}
if(mana.getBlue() > 0) {
if (mana.getBlue() > 0) {
count++;
}
if(mana.getGreen() > 0) {
if (mana.getGreen() > 0) {
count++;
}
if(mana.getRed() > 0) {
if (mana.getRed() > 0) {
count++;
}
if(mana.getWhite() > 0) {
if (mana.getWhite() > 0) {
count++;
}
}
@ -75,14 +73,13 @@ public class SunburstCount implements DynamicValue{
}
@Override
public DynamicValue copy() {
public SunburstCount copy() {
return new SunburstCount();
}
@Override
public String getMessage() {
return "color of mana spent to cast it";
}
}

View file

@ -49,7 +49,7 @@ public class TargetConvertedManaCost implements DynamicValue {
}
@Override
public DynamicValue copy() {
public TargetConvertedManaCost copy() {
return new TargetConvertedManaCost();
}

View file

@ -54,7 +54,7 @@ public class TargetPermanentPowerCount implements DynamicValue {
}
@Override
public DynamicValue copy() {
public TargetPermanentPowerCount copy() {
return new TargetPermanentPowerCount();
}

View file

@ -8,6 +8,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
public class UrzaTerrainValue implements DynamicValue {
private final int value;
public UrzaTerrainValue(int value) {
@ -19,24 +20,21 @@ public class UrzaTerrainValue implements DynamicValue {
FilterControlledPermanent pp = new FilterControlledPermanent("Urza's Power Plant");
pp.add(new SubtypePredicate("Urza's Power-Plant"));
PermanentsOnBattlefieldCount ppP = new PermanentsOnBattlefieldCount(pp);
if (ppP.calculate(game, sourceAbility, effect) < 1)
{
if (ppP.calculate(game, sourceAbility, effect) < 1) {
return 1;
}
FilterControlledPermanent to = new FilterControlledPermanent("Urza's Tower");
to.add(new SubtypePredicate("Urza's Tower"));
PermanentsOnBattlefieldCount toP = new PermanentsOnBattlefieldCount(to);
if (toP.calculate(game, sourceAbility, effect) < 1)
{
if (toP.calculate(game, sourceAbility, effect) < 1) {
return 1;
}
FilterControlledPermanent mi = new FilterControlledPermanent("Urza's Mine");
mi.add(new SubtypePredicate("Urza's Mine"));
PermanentsOnBattlefieldCount miP = new PermanentsOnBattlefieldCount(mi);
if (miP.calculate(game, sourceAbility, effect) < 1)
{
if (miP.calculate(game, sourceAbility, effect) < 1) {
return 1;
}
@ -44,7 +42,7 @@ public class UrzaTerrainValue implements DynamicValue {
}
@Override
public DynamicValue copy() {
public UrzaTerrainValue copy() {
return new UrzaTerrainValue(value);
}