mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
[refactor] removed BoostCounter implementations
This commit is contained in:
parent
44785267ec
commit
ca1af753eb
12 changed files with 31 additions and 170 deletions
|
@ -86,23 +86,6 @@ public class Contagion extends CardImpl<Contagion> {
|
|||
}
|
||||
}
|
||||
|
||||
class ContagionCounter extends BoostCounter {
|
||||
|
||||
public ContagionCounter(int count) {
|
||||
super(-2, -1);
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public ContagionCounter(final ContagionCounter counter) {
|
||||
super(counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContagionCounter copy() {
|
||||
return new ContagionCounter(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DistributeCountersEffect extends OneShotEffect<DistributeCountersEffect> {
|
||||
|
||||
|
||||
|
@ -126,7 +109,8 @@ class DistributeCountersEffect extends OneShotEffect<DistributeCountersEffect> {
|
|||
for (UUID target: multiTarget.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
permanent.addCounters(new ContagionCounter(multiTarget.getTargetAmount(target)), game);
|
||||
int amount = multiTarget.getTargetAmount(target);
|
||||
permanent.addCounters(new BoostCounter(-2, -1, amount), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
@ -63,9 +63,9 @@ public class SavageFirecat extends CardImpl<SavageFirecat> {
|
|||
// Trample
|
||||
this.addAbility(TrampleAbility.getInstance());
|
||||
// Savage Firecat enters the battlefield with seven +1/+1 counters on it.
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(new PlusOneCounter(7))));
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(7))));
|
||||
// Whenever you tap a land for mana, remove a +1/+1 counter from Savage Firecat.
|
||||
this.addAbility(new SavageFirecatTriggeredAbility(new RemoveCounterSourceEffect(new PlusOneCounter(1))));
|
||||
this.addAbility(new SavageFirecatTriggeredAbility(new RemoveCounterSourceEffect(CounterType.P1P1.createInstance())));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.abilities.keyword.FlyingAbility;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class Soulcatcher extends CardImpl<Soulcatcher> {
|
|||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
// Whenever a creature with flying dies, put a +1/+1 counter on Soulcatcher.
|
||||
this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersSourceEffect(new PlusOneCounter()), false, filter));
|
||||
this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false, filter));
|
||||
}
|
||||
|
||||
public Soulcatcher(final Soulcatcher card) {
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,7 +53,7 @@ public class IvyElemental extends CardImpl<IvyElemental> {
|
|||
this.toughness = new MageInt(0);
|
||||
|
||||
// Ivy Elemental enters the battlefield with X +1/+1 counters on it.
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(new PlusOneCounter(), new ManacostVariableValue(), true), "with X +1/+1 counters on it"));
|
||||
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(), new ManacostVariableValue(), true), "with X +1/+1 counters on it"));
|
||||
}
|
||||
|
||||
public IvyElemental(final IvyElemental card) {
|
||||
|
|
|
@ -95,7 +95,7 @@ class WallOfRootsCost extends CostImpl<WallOfRootsCost> {
|
|||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null) {
|
||||
permanent.addCounters(new WallOfRootsCounter(), game);
|
||||
permanent.addCounters(new BoostCounter(0, -1), game);
|
||||
this.paid = true;
|
||||
}
|
||||
return paid;
|
||||
|
@ -106,19 +106,3 @@ class WallOfRootsCost extends CostImpl<WallOfRootsCost> {
|
|||
return new WallOfRootsCost(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WallOfRootsCounter extends BoostCounter {
|
||||
|
||||
public WallOfRootsCounter() {
|
||||
super(0, -1);
|
||||
}
|
||||
|
||||
public WallOfRootsCounter(final WallOfRootsCounter counter) {
|
||||
super(counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WallOfRootsCounter copy() {
|
||||
return new WallOfRootsCounter(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.abilities.costs.mana.GenericManaCost;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
@ -129,10 +129,10 @@ class BladeOfTheBloodchiefEffect extends OneShotEffect<BladeOfTheBloodchiefEffec
|
|||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
if ( creature.hasSubtype("Vampire") ) {
|
||||
creature.addCounters(new PlusOneCounter(2), game);
|
||||
creature.addCounters(CounterType.P1P1.createInstance(2), game);
|
||||
}
|
||||
else {
|
||||
creature.addCounters(new PlusOneCounter(1), game);
|
||||
creature.addCounters(CounterType.P1P1.createInstance(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
|||
import mage.abilities.effects.common.UntapTargetEffect;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ public class MarkOfMutiny extends CardImpl<MarkOfMutiny> {
|
|||
this.color.setRed(true);
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(new AddCountersTargetEffect(new PlusOneCounter()));
|
||||
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
|
||||
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(new UntapTargetEffect());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
@ -70,7 +70,7 @@ public class AddPlusOneCountersAttachedEffect extends OneShotEffect<AddPlusOneCo
|
|||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
creature.addCounters(new PlusOneCounter(amount), game);
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amount), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -32,13 +32,17 @@ package mage.counters;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class BoostCounter extends Counter {
|
||||
public class BoostCounter extends Counter {
|
||||
|
||||
protected int power;
|
||||
protected int toughness;
|
||||
|
||||
public BoostCounter(int power, int toughness) {
|
||||
super(String.format("%1$+d/%2$+d", power, toughness));
|
||||
this(power, toughness, 1);
|
||||
}
|
||||
|
||||
public BoostCounter(int power, int toughness, int count) {
|
||||
super(String.format("%1$+d/%2$+d", power, toughness), count);
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
@ -57,4 +61,8 @@ public abstract class BoostCounter extends Counter {
|
|||
return toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoostCounter copy() {
|
||||
return new BoostCounter(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
|
||||
package mage.counters;
|
||||
|
||||
import mage.counters.common.MinusOneCounter;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
|
||||
/**
|
||||
* Enum for counters, names and instances.
|
||||
*
|
||||
|
@ -63,9 +60,9 @@ public enum CounterType {
|
|||
LEVEL("Level"),
|
||||
LORE("Lore"),
|
||||
LOYALTY("Loyalty"),
|
||||
M1M1(new MinusOneCounter().name),
|
||||
M1M1(new BoostCounter(-1, -1).name),
|
||||
MINING("Mining"),
|
||||
P1P1(new PlusOneCounter().name),
|
||||
P1P1(new BoostCounter(1, 1).name),
|
||||
PAGE("Page"),
|
||||
PAIN("Pain"),
|
||||
PETRIFICATION("Petrification"),
|
||||
|
@ -116,9 +113,9 @@ public enum CounterType {
|
|||
public Counter createInstance(int amount) {
|
||||
switch (this) {
|
||||
case P1P1:
|
||||
return new PlusOneCounter(amount);
|
||||
return new BoostCounter(1, 1, amount);
|
||||
case M1M1:
|
||||
return new MinusOneCounter(amount);
|
||||
return new BoostCounter(-1, -1, amount);
|
||||
default:
|
||||
return new Counter(name, amount);
|
||||
}
|
||||
|
|
|
@ -1,56 +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.counters.common;
|
||||
|
||||
import mage.counters.BoostCounter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class MinusOneCounter extends BoostCounter {
|
||||
|
||||
public MinusOneCounter() {
|
||||
super(-1, -1);
|
||||
}
|
||||
|
||||
public MinusOneCounter(int amount) {
|
||||
super(-1, -1);
|
||||
this.count = amount;
|
||||
}
|
||||
|
||||
public MinusOneCounter(final MinusOneCounter counter) {
|
||||
super(counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinusOneCounter copy() {
|
||||
return new MinusOneCounter(this);
|
||||
}
|
||||
}
|
|
@ -1,56 +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.counters.common;
|
||||
|
||||
import mage.counters.BoostCounter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PlusOneCounter extends BoostCounter {
|
||||
|
||||
public PlusOneCounter() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public PlusOneCounter(int amount) {
|
||||
super(1, 1);
|
||||
this.count = amount;
|
||||
}
|
||||
|
||||
public PlusOneCounter(final PlusOneCounter counter) {
|
||||
super(counter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlusOneCounter copy() {
|
||||
return new PlusOneCounter(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue