forked from External/mage
refactor together experience counter DynamicValue
This commit is contained in:
parent
8843bd387f
commit
74adbf222c
6 changed files with 129 additions and 145 deletions
|
|
@ -1,11 +1,9 @@
|
|||
package mage.cards.k;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.SourceControllerCountersCount;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
|
||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||
|
|
@ -16,8 +14,6 @@ import mage.constants.*;
|
|||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -53,8 +49,13 @@ public final class KalemneDiscipleOfIroas extends CardImpl {
|
|||
), filterSpell, false));
|
||||
|
||||
// Kalemne, Disciple of Iroas gets +1/+1 for each experience counter you have.
|
||||
DynamicValue value = new SourceControllerExperienceCountersCount();
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(value, value, Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
new BoostSourceEffect(
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
Duration.WhileOnBattlefield
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
private KalemneDiscipleOfIroas(final KalemneDiscipleOfIroas card) {
|
||||
|
|
@ -65,32 +66,4 @@ public final class KalemneDiscipleOfIroas extends CardImpl {
|
|||
public KalemneDiscipleOfIroas copy() {
|
||||
return new KalemneDiscipleOfIroas(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SourceControllerExperienceCountersCount implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int amount = 0;
|
||||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (player != null) {
|
||||
amount = player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceControllerExperienceCountersCount copy() {
|
||||
return new SourceControllerExperienceCountersCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "experience counter you have";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,7 @@ import mage.abilities.common.SimpleActivatedAbility;
|
|||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.delayed.WhenTargetDiesDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.SourceControllerCountersCount;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
|
|
@ -19,8 +18,6 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -46,7 +43,8 @@ public final class KelsienThePlague extends CardImpl {
|
|||
|
||||
// Kelsien, the Plague gets +1/+1 for each experience counter you have.
|
||||
this.addAbility(new SimpleStaticAbility(new BoostSourceEffect(
|
||||
KelsienThePlagueCount.instance, KelsienThePlagueCount.instance,
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
Duration.WhileOnBattlefield
|
||||
)));
|
||||
|
||||
|
|
@ -67,33 +65,4 @@ public final class KelsienThePlague extends CardImpl {
|
|||
public KelsienThePlague copy() {
|
||||
return new KelsienThePlague(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum KelsienThePlagueCount implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int amount = 0;
|
||||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (player != null) {
|
||||
amount = player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KelsienThePlagueCount copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "experience counter you have";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,8 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.RevoltCondition;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.SourceControllerCountersCount;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostAllEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
|
||||
import mage.abilities.keyword.WardAbility;
|
||||
|
|
@ -16,8 +15,6 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.RevoltWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -37,8 +34,7 @@ public final class MintharaMercilessSoul extends CardImpl {
|
|||
this.toughness = new MageInt(2);
|
||||
|
||||
// Ward {X}, where X is the number of experience counters you have.
|
||||
DynamicValue value = new MintharaMercilessSoulCount();
|
||||
Ability ability = new WardAbility(value, "the number of experience counters you have");
|
||||
Ability ability = new WardAbility(SourceControllerCountersCount.EXPERIENCE, "the number of experience counters you have");
|
||||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of your end step, if a permanent you controlled left the battlefield this turn, you get an experience counter.
|
||||
|
|
@ -48,8 +44,13 @@ public final class MintharaMercilessSoul extends CardImpl {
|
|||
), new RevoltWatcher());
|
||||
|
||||
// Creatures you control get +1/+0 for each experience counter you have.
|
||||
this.addAbility(new SimpleStaticAbility(new BoostAllEffect(value, StaticValue.get(0),
|
||||
Duration.WhileOnBattlefield, StaticFilters.FILTER_CONTROLLED_CREATURES, false)));
|
||||
this.addAbility(new SimpleStaticAbility(new BoostAllEffect(
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
StaticValue.get(0),
|
||||
Duration.WhileOnBattlefield,
|
||||
StaticFilters.FILTER_CONTROLLED_CREATURES,
|
||||
false
|
||||
)));
|
||||
}
|
||||
|
||||
private MintharaMercilessSoul(final MintharaMercilessSoul card) {
|
||||
|
|
@ -60,32 +61,4 @@ public final class MintharaMercilessSoul extends CardImpl {
|
|||
public MintharaMercilessSoul copy() {
|
||||
return new MintharaMercilessSoul(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MintharaMercilessSoulCount implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int amount = 0;
|
||||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (player != null) {
|
||||
amount = player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MintharaMercilessSoulCount copy() {
|
||||
return new MintharaMercilessSoulCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "experience counter you have";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,7 @@ import mage.abilities.common.AttacksTriggeredAbility;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapTargetCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.SourceControllerCountersCount;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlSourceEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
|
||||
|
|
@ -20,9 +19,7 @@ import mage.constants.*;
|
|||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.permanent.TappedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.RebelRedToken;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -56,11 +53,13 @@ public final class OtharriSunsGlory extends CardImpl {
|
|||
// Haste
|
||||
this.addAbility(HasteAbility.getInstance());
|
||||
|
||||
// Whenever Otharri, Suns' Glory attacks, you get an experience counter.
|
||||
// Then create a 2/2 red Rebel creature token that’s tapped and attacking for each experience counter you have.
|
||||
// Whenever Otharri, Suns' Glory attacks, you get an experience counter. Then create a 2/2 red Rebel creature token that’s tapped and attacking for each experience counter you have.
|
||||
Ability ability = new AttacksTriggeredAbility(new AddCountersPlayersEffect(CounterType.EXPERIENCE.createInstance(), TargetController.YOU));
|
||||
DynamicValue value = new OtharriSunsGloryCount();
|
||||
ability.addEffect(new CreateTokenEffect(new RebelRedToken(), value, true, true).concatBy("Then"));
|
||||
ability.addEffect(new CreateTokenEffect(
|
||||
new RebelRedToken(),
|
||||
SourceControllerCountersCount.EXPERIENCE,
|
||||
true, true
|
||||
).concatBy("Then"));
|
||||
this.addAbility(ability);
|
||||
|
||||
// {2}{R}{W}, Tap an untapped Rebel you control: Return Otharri from your graveyard to the battlefield tapped.
|
||||
|
|
@ -81,32 +80,4 @@ public final class OtharriSunsGlory extends CardImpl {
|
|||
public OtharriSunsGlory copy() {
|
||||
return new OtharriSunsGlory(this);
|
||||
}
|
||||
}
|
||||
|
||||
class OtharriSunsGloryCount implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int amount = 0;
|
||||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (player != null) {
|
||||
amount = player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OtharriSunsGloryCount copy() {
|
||||
return new OtharriSunsGloryCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "experience counter you have";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package org.mage.test.cards.single.onc;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.players.Player;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class OtharriSunsGloryTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* {@link mage.cards.o.OtharriSunsGlory Otharri, Suns' Glory} {3}{R}{W}
|
||||
* Legendary Creature — Phoenix
|
||||
* Flying, lifelink, haste
|
||||
* Whenever Otharri, Suns’ Glory attacks, you get an experience counter. Then create a 2/2 red Rebel creature token that’s tapped and attacking for each experience counter you have.
|
||||
* {2}{R}{W}, Tap an untapped Rebel you control: Return Otharri from your graveyard to the battlefield tapped.
|
||||
* 3/3
|
||||
*/
|
||||
private static final String otharri = "Otharri, Suns' Glory";
|
||||
|
||||
private static void checkExperienceCounter(String message, Player player, int expected) {
|
||||
Assert.assertEquals(message, expected, player.getCounters().getCount(CounterType.EXPERIENCE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Experience_Rebels() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, otharri);
|
||||
|
||||
attack(1, playerA, otharri, playerB);
|
||||
runCode("experience count playerA after first attack", 1, PhaseStep.POSTCOMBAT_MAIN, playerA,
|
||||
(info, player, game) -> checkExperienceCounter(info, player, 1));
|
||||
|
||||
attack(3, playerA, otharri, playerB);
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 + 3 * 2);
|
||||
assertLife(playerB, 20 - 3 * 2 - 2 * (1 + 2));
|
||||
assertPermanentCount(playerA, "Rebel Token", 1 + 2);
|
||||
assertCounterCount(playerA, CounterType.EXPERIENCE, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public enum SourceControllerCountersCount implements DynamicValue {
|
||||
EXPERIENCE(CounterType.EXPERIENCE),
|
||||
RAD(CounterType.RAD);
|
||||
|
||||
private final CounterType counterType;
|
||||
|
||||
|
||||
SourceControllerCountersCount(CounterType counterType) {
|
||||
this.counterType = counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceControllerCountersCount copy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int amount = 0;
|
||||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (player != null) {
|
||||
amount = player.getCounters().getCount(counterType);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return counterType.getName() + " you have";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue