Added ChokingFumes card

Added AddCountersAllEffect
Refactoring and fixes for Counter adding effects
This commit is contained in:
North 2011-06-24 00:28:07 +03:00
parent a121913f22
commit 273ab90154
23 changed files with 213 additions and 143 deletions

View file

@ -30,9 +30,7 @@ package mage.sets.guildpact;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.effects.common.TapSourceUnlessPaysEffect;

View file

@ -36,22 +36,21 @@ import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.SubLayer;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effects;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.AddPlusOneCountersControlledEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -74,7 +73,7 @@ public class AjaniGoldmane extends CardImpl<AjaniGoldmane> {
this.addAbility(new LoyaltyAbility(new GainLifeEffect(2), 1));
Effects effects1 = new Effects();
effects1.add(new AddPlusOneCountersControlledEffect(1));
effects1.add(new AddCountersAllEffect(CounterType.P1P1.createInstance(), new FilterControlledCreaturePermanent()));
effects1.add(new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn, FilterCreaturePermanent.getDefault()));
this.addAbility(new LoyaltyAbility(effects1, -1));

View file

@ -41,6 +41,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.counters.Counter;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
@ -138,7 +139,7 @@ class PhylacteryLichEffect extends OneShotEffect<PhylacteryLichEffect> {
if (player.choose(Outcome.Neutral, target, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.addCounters("phylactery", 1);
permanent.addCounters(new Counter("phylactery"));
}
}
}

View file

@ -31,12 +31,14 @@ package mage.sets.magic2011;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.counter.AddPlusOneCountersControlledEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.Filter.ComparisonScope;
import mage.filter.FilterPermanent;
@ -46,12 +48,13 @@ import mage.filter.FilterPermanent;
*/
public class SteelOverseer extends CardImpl<SteelOverseer> {
private static final FilterPermanent filter = new FilterPermanent("artifact creature");
private static final FilterPermanent filter = new FilterPermanent("artifact creature you control");
static {
filter.getCardType().add(CardType.ARTIFACT);
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(ComparisonScope.All);
filter.setTargetController(TargetController.YOU);
}
public SteelOverseer(UUID ownerId) {
@ -61,7 +64,7 @@ public class SteelOverseer extends CardImpl<SteelOverseer> {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddPlusOneCountersControlledEffect(1, filter), new TapSourceCost()));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersAllEffect(CounterType.P1P1.createInstance(), filter), new TapSourceCost()));
}
public SteelOverseer(final SteelOverseer card) {

View file

@ -0,0 +1,63 @@
/*
* 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.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.common.FilterAttackingCreature;
/**
*
* @author North
*/
public class ChokingFumes extends CardImpl<ChokingFumes> {
private static final FilterAttackingCreature filter = new FilterAttackingCreature();
public ChokingFumes(UUID ownerId) {
super(ownerId, 4, "Choking Fumes", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
this.expansionSetCode = "MBS";
this.color.setWhite(true);
this.getSpellAbility().addEffect(new AddCountersAllEffect(CounterType.M1M1.createInstance(), filter));
}
public ChokingFumes(final ChokingFumes card) {
super(card);
}
@Override
public ChokingFumes copy() {
return new ChokingFumes(this);
}
}

View file

@ -42,6 +42,7 @@ import mage.counters.CounterType;
import mage.target.TargetPermanent;
import java.util.UUID;
import mage.counters.common.ChargeCounter;
/**
*
@ -52,7 +53,7 @@ public class LuxCannon extends CardImpl<LuxCannon> {
public LuxCannon (UUID ownerId) {
super(ownerId, 173, "Lux Cannon", Rarity.MYTHIC, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "SOM";
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.getName(), 1), new TapSourceCost()));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(new ChargeCounter()), new TapSourceCost()));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new TapSourceCost());
ability.addCost(new RemoveCountersSourceCost(CounterType.CHARGE.getName(), 3));
ability.addTarget(new TargetPermanent());

View file

@ -45,6 +45,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.ChargeCounter;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
@ -58,7 +59,7 @@ public class TrigonofCorruption extends CardImpl<TrigonofCorruption> {
super(ownerId, 213, "Trigon of Corruption", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "SOM";
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter(3))));
Costs costs = new CostsImpl();
costs.add(new ManaCostsImpl("{2}"));

View file

@ -45,6 +45,7 @@ import mage.counters.CounterType;
import mage.game.permanent.token.InsectInfectToken;
import java.util.UUID;
import mage.counters.common.ChargeCounter;
/**
* @author nantuko
@ -57,7 +58,7 @@ public class TrigonofInfestation extends CardImpl<TrigonofInfestation> {
super(ownerId, 214, "Trigon of Infestation", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "SOM";
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter(3))));
Costs costs = new CostsImpl();
costs.add(new ManaCostsImpl("{2}"));

View file

@ -44,6 +44,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.ChargeCounter;
/**
* @author nantuko
@ -54,7 +55,7 @@ public class TrigonofMending extends CardImpl<TrigonofMending> {
super(ownerId, 215, "Trigon of Mending", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "SOM";
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter(3))));
Costs costs = new CostsImpl();
costs.add(new ManaCostsImpl("{2}"));

View file

@ -47,6 +47,7 @@ import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.ChargeCounter;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
@ -59,7 +60,7 @@ public class TrigonofRage extends CardImpl<TrigonofRage> {
super(ownerId, 216, "Trigon of Rage", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "SOM";
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter(3))));
Costs costs = new CostsImpl();
costs.add(new ManaCostsImpl("{2}"));

View file

@ -44,6 +44,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.ChargeCounter;
/**
* @author nantuko
@ -54,7 +55,7 @@ public class TrigonofThought extends CardImpl<TrigonofThought> {
super(ownerId, 217, "Trigon of Thought", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{5}");
this.expansionSetCode = "SOM";
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 3)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter(3))));
Costs costs = new CostsImpl();
costs.add(new ManaCostsImpl("{2}"));

View file

@ -39,27 +39,28 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.LandfallAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddPlusOneCountersControlledEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.Filter.ComparisonScope;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.permanent.token.PlantToken;
import mage.game.permanent.token.Token;
/**
*
* @author Loki, nantuko
* @author Loki, nantuko, North
*/
public class AvengerofZendikar extends CardImpl<AvengerofZendikar> {
private static FilterPermanent filter = new FilterPermanent("Plant creature");
private static final FilterPermanent filter = new FilterPermanent("Plant creature you control");
static {
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(ComparisonScope.Any);
filter.getSubtype().add("Plant");
filter.setScopeSubtype(ComparisonScope.Any);
filter.setTargetController(TargetController.YOU);
}
public AvengerofZendikar (UUID ownerId) {
@ -70,7 +71,7 @@ public class AvengerofZendikar extends CardImpl<AvengerofZendikar> {
this.power = new MageInt(5);
this.toughness = new MageInt(5);
this.addAbility(new EntersBattlefieldAbility(new AvengerofZendikarTokensCreateEffect(), "put a 0/1 green Plant creature token onto the battlefield for each land you control"));
this.addAbility(new LandfallAbility(new AddPlusOneCountersControlledEffect(1, filter), false));
this.addAbility(new LandfallAbility(new AddCountersAllEffect(CounterType.P1P1.createInstance(), filter), false));
}
public AvengerofZendikar (final AvengerofZendikar card) {
@ -84,7 +85,7 @@ public class AvengerofZendikar extends CardImpl<AvengerofZendikar> {
}
class AvengerofZendikarTokensCreateEffect extends OneShotEffect<AvengerofZendikarTokensCreateEffect> {
private static FilterPermanent filter = new FilterPermanent();
private static final FilterPermanent filter = new FilterPermanent();
private Token token = new PlantToken();
static {

View file

@ -45,6 +45,7 @@ import mage.abilities.keyword.MultikickerAbility;
import mage.abilities.mana.ManaAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.counters.common.ChargeCounter;
import mage.game.Game;
/**
@ -56,7 +57,7 @@ public class EverflowingChalice extends CardImpl<EverflowingChalice> {
public EverflowingChalice(UUID ownerId) {
super(ownerId, 123, "Everflowing Chalice", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{0}");
this.expansionSetCode = "WWK";
Ability ability1 = new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.getName(), 1));
Ability ability1 = new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(new ChargeCounter()));
MultikickerAbility ability = new MultikickerAbility(new GainAbilitySourceEffect(ability1, Duration.WhileOnBattlefield), false);
ability.addManaCost(new GenericManaCost(2));
this.addAbility(ability);

View file

@ -39,6 +39,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.counters.common.QuestCounter;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -73,7 +74,7 @@ public class BeastmasterAscension extends CardImpl<BeastmasterAscension> {
class BeastmasterAscensionAbility extends TriggeredAbilityImpl<BeastmasterAscensionAbility> {
public BeastmasterAscensionAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect("quest", 1), true);
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(new QuestCounter()), true);
}
public BeastmasterAscensionAbility(final BeastmasterAscensionAbility ability) {

View file

@ -42,6 +42,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.counters.common.QuestCounter;
import mage.filter.common.FilterBasicLandCard;
import mage.target.common.TargetCardInLibrary;
@ -56,7 +57,7 @@ public class KhalniHeartExpedition extends CardImpl<KhalniHeartExpedition> {
this.expansionSetCode = "ZEN";
this.color.setGreen(true);
this.addAbility(new LandfallAbility(new AddCountersSourceEffect("quest", 1), true));
this.addAbility(new LandfallAbility(new AddCountersSourceEffect(new QuestCounter()), true));
this.addAbility(new KhalniHeartExpeditionAbility());
}

View file

@ -42,6 +42,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.counters.common.QuestCounter;
/**
*
@ -54,7 +55,7 @@ public class SunspringExpedition extends CardImpl<SunspringExpedition> {
this.expansionSetCode = "ZEN";
this.color.setWhite(true);
this.addAbility(new LandfallAbility(new AddCountersSourceEffect("quest", 1), true));
this.addAbility(new LandfallAbility(new AddCountersSourceEffect(new QuestCounter()), true));
Costs costs = new CostsImpl();
costs.add(new RemoveCountersSourceCost("quest", 3));
costs.add(new SacrificeSourceCost());

View file

@ -0,0 +1,94 @@
/*
* 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.effects.common.counter;
import java.util.List;
import java.util.UUID;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.counters.Counter;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class AddCountersAllEffect extends OneShotEffect<AddCountersAllEffect> {
private Counter counter;
private FilterPermanent filter;
public AddCountersAllEffect(Counter counter, FilterPermanent filter) {
super(Outcome.Benefit);
this.counter = counter;
this.filter = filter;
}
public AddCountersAllEffect(final AddCountersAllEffect effect) {
super(effect);
this.counter = effect.counter.copy();
this.filter = effect.filter.copy();
}
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
if (counter != null) {
UUID controllerId = source.getControllerId();
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents();
for (Permanent permanent : permanents) {
if (filter.match(permanent, controllerId, game)) {
permanent.addCounters(counter);
applied = true;
}
}
}
return applied;
}
@Override
public String getText(Ability source) {
StringBuilder sb = new StringBuilder();
sb.append("put ");
if (counter.getCount() > 1) {
sb.append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters on each ");
} else {
sb.append("a ").append(counter.getName()).append(" counter on each ");
}
sb.append(filter.getMessage());
return sb.toString();
}
@Override
public AddCountersAllEffect copy() {
return new AddCountersAllEffect(this);
}
}

View file

@ -40,27 +40,15 @@ import mage.game.permanent.Permanent;
*/
public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffect> {
private int amount;
private String name;
private Counter counter;
public AddCountersSourceEffect(String name, int amount) {
super(Outcome.Benefit);
this.name = name;
this.amount = amount;
}
public AddCountersSourceEffect(Counter counter) {
super(Outcome.Benefit);
this.name = counter.getName();
this.counter = counter.copy();
this.amount = counter.getCount();
}
public AddCountersSourceEffect(final AddCountersSourceEffect effect) {
super(effect);
this.amount = effect.amount;
this.name = effect.name;
if (effect.counter != null)
this.counter = effect.counter.copy();
}
@ -71,8 +59,6 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
if (permanent != null) {
if (counter != null) {
permanent.addCounters(counter);
} else {
permanent.addCounters(name, amount);
}
}
return true;
@ -80,12 +66,12 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
@Override
public String getText(Ability source) {
if (amount > 1) {
if (counter.getCount() > 1) {
StringBuilder sb = new StringBuilder();
sb.append("put ").append(Integer.toString(amount)).append(" ").append(name).append(" counters on {this}");
sb.append("put ").append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters on {this}");
return sb.toString();
} else
return "put a " + name + " counter on {this}";
return "put a " + counter.getName() + " counter on {this}";
}
@Override

View file

@ -44,20 +44,15 @@ import java.util.UUID;
*/
public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffect> {
private int amount;
private String name;
private Counter counter;
public AddCountersTargetEffect(Counter counter) {
super(Outcome.Benefit);
this.name = counter.getName();
this.counter = counter;
}
public AddCountersTargetEffect(final AddCountersTargetEffect effect) {
super(effect);
this.amount = effect.amount;
this.name = effect.name;
this.counter = effect.counter.copy();
}
@ -69,13 +64,13 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
if (permanent != null) {
if (counter != null) {
permanent.addCounters(counter);
} else {
permanent.addCounters(name, amount);
affectedTargets ++;
}
} else {
Player player = game.getPlayer(uuid);
if (player != null) {
player.getCounters().addCounter(counter);
affectedTargets ++;
}
}
}
@ -86,11 +81,11 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
public String getText(Ability source) {
StringBuilder sb = new StringBuilder();
sb.append("put ");
if (amount > 1) {
sb.append(Integer.toString(amount)).append(" ").append(name).append(" counters on ");
if (counter.getCount() > 1) {
sb.append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters on target ");
}
else {
sb.append("a ").append(name).append(" counter on target ");
sb.append("a ").append(counter.getName()).append(" counter on target ");
}
sb.append(source.getTargets().get(0).getTargetName());
return sb.toString();

View file

@ -1,87 +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.effects.common.counter;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.counters.common.PlusOneCounter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class AddPlusOneCountersControlledEffect extends OneShotEffect<AddPlusOneCountersControlledEffect> {
private int amount;
private FilterPermanent filter;
public AddPlusOneCountersControlledEffect(int amount) {
this(amount, FilterCreaturePermanent.getDefault());
}
public AddPlusOneCountersControlledEffect(int amount, FilterPermanent filter) {
super(Outcome.Benefit);
this.amount = amount;
this.filter = filter;
}
public AddPlusOneCountersControlledEffect(final AddPlusOneCountersControlledEffect effect) {
super(effect);
this.amount = effect.amount;
this.filter = effect.filter.copy();
}
@Override
public AddPlusOneCountersControlledEffect copy() {
return new AddPlusOneCountersControlledEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
perm.getCounters().addCounter(new PlusOneCounter(amount)); }
return true;
}
@Override
public String getText(Ability source) {
StringBuilder sb = new StringBuilder();
sb.append("Put ").append(amount).append(" +1/+1 counter");
if (amount > 1)
sb.append("s");
sb.append(" on each ").append(filter.getName()).append(" you control");
return sb.toString();
}
}

View file

@ -33,6 +33,7 @@ import mage.Constants.Zone;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.counters.common.LevelCounter;
/**
*
@ -41,7 +42,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
public class LevelUpAbility extends ActivatedAbilityImpl<LevelUpAbility> {
public LevelUpAbility(ManaCosts costs) {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect("Level", 1), costs);
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(new LevelCounter()), costs);
this.timing = TimingRule.SORCERY;
}

View file

@ -41,8 +41,14 @@ public class Counter<T extends Counter<T>> implements Serializable {
public Counter(String name) {
this.name = name;
this.count = 1;
}
public Counter(String name, int count) {
this.name = name;
this.count = count;
}
public Counter(Counter counter) {
this.name = counter.name;
this.count = counter.count;

View file

@ -35,7 +35,7 @@ import mage.cards.CardImpl;
/**
*
* @author Loki
* @author North
*/
public class [=$classname=] extends CardImpl<[=$classname=]> {