From 66c152a2e71465be09cf638513e0ec4b53a408b8 Mon Sep 17 00:00:00 2001 From: jmharmon <37360760+jmharmon@users.noreply.github.com> Date: Wed, 19 Sep 2018 14:00:47 -0700 Subject: [PATCH 1/4] Implement Chamber Sentry --- Mage.Sets/src/mage/cards/c/ChamberSentry.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ChamberSentry.java diff --git a/Mage.Sets/src/mage/cards/c/ChamberSentry.java b/Mage.Sets/src/mage/cards/c/ChamberSentry.java new file mode 100644 index 00000000000..aa5ac14be9b --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChamberSentry.java @@ -0,0 +1,57 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; +import mage.abilities.keyword.SunburstAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.target.common.TargetAnyTarget; + +import java.util.UUID; + +/** + * + * @author jmharmon + */ + +public final class ChamberSentry extends CardImpl { + + public ChamberSentry(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT,CardType.CREATURE}, "{X}"); + + this.subtype.add(SubType.CONSTRUCT); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Chamber Sentry enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it. + this.addAbility(new SunburstAbility(this)); + + // {X}, {T}, Remove X +1/+1 counters from Chamber Sentry: It deals X damage to any target. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new ManacostVariableValue()), new ManaCostsImpl("{X}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetAnyTarget()); + this.addAbility(ability); + + // {W}{U}{B}{R}{G}: Return Chamber Sentry from your graveyard to your hand. + this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToHandEffect(), new ManaCostsImpl("{W}{U}{B}{R}{G}"))); + } + + public ChamberSentry(final ChamberSentry card) { + super(card); + } + + @Override + public ChamberSentry copy() { + return new ChamberSentry(this); + } +} From 1603f1fe2c1b971ad1c4d0d16a503768eef77f54 Mon Sep 17 00:00:00 2001 From: jmharmon <37360760+jmharmon@users.noreply.github.com> Date: Wed, 19 Sep 2018 14:03:51 -0700 Subject: [PATCH 2/4] Implement Chamber Sentry --- Mage.Sets/src/mage/sets/GuildsOfRavnica.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java index f7a15336120..bc706b86ca0 100644 --- a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java +++ b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java @@ -46,6 +46,7 @@ public final class GuildsOfRavnica extends ExpansionSet { cards.add(new SetCardInfo("Burglar Rat", 64, Rarity.COMMON, mage.cards.b.BurglarRat.class)); cards.add(new SetCardInfo("Camaraderie", 157, Rarity.RARE, mage.cards.c.Camaraderie.class)); cards.add(new SetCardInfo("Centaur Peacemaker", 158, Rarity.COMMON, mage.cards.c.CentaurPeacemaker.class)); + cards.add(new SetCardInfo("Chamber Sentry", 232, Rarity.RARE, mage.cards.c.ChamberSentry.class)); cards.add(new SetCardInfo("Chance for Glory", 159, Rarity.MYTHIC, mage.cards.c.ChanceForGlory.class)); cards.add(new SetCardInfo("Charnel Troll", 160, Rarity.RARE, mage.cards.c.CharnelTroll.class)); cards.add(new SetCardInfo("Chemister's Insight", 32, Rarity.UNCOMMON, mage.cards.c.ChemistersInsight.class)); From 84d587868efc24e4f20fc71cc5d1a19097b91515 Mon Sep 17 00:00:00 2001 From: jmharmon <37360760+jmharmon@users.noreply.github.com> Date: Wed, 19 Sep 2018 14:38:55 -0700 Subject: [PATCH 3/4] Update ChamberSentry.java --- Mage.Sets/src/mage/cards/c/ChamberSentry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/c/ChamberSentry.java b/Mage.Sets/src/mage/cards/c/ChamberSentry.java index aa5ac14be9b..3cb86b0e9ad 100644 --- a/Mage.Sets/src/mage/cards/c/ChamberSentry.java +++ b/Mage.Sets/src/mage/cards/c/ChamberSentry.java @@ -34,7 +34,7 @@ public final class ChamberSentry extends CardImpl { this.toughness = new MageInt(0); // Chamber Sentry enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it. - this.addAbility(new SunburstAbility(this)); + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(), ColorsOfManaSpentToCastCount.getInstance(), true))); // {X}, {T}, Remove X +1/+1 counters from Chamber Sentry: It deals X damage to any target. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new ManacostVariableValue()), new ManaCostsImpl("{X}")); From f267152200a9f156f3a034f2f22f43e2ff6bf108 Mon Sep 17 00:00:00 2001 From: jmharmon <37360760+jmharmon@users.noreply.github.com> Date: Wed, 19 Sep 2018 15:26:01 -0700 Subject: [PATCH 4/4] Update ChamberSentry.java --- Mage.Sets/src/mage/cards/c/ChamberSentry.java | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/ChamberSentry.java b/Mage.Sets/src/mage/cards/c/ChamberSentry.java index 3cb86b0e9ad..1cf6c1fd911 100644 --- a/Mage.Sets/src/mage/cards/c/ChamberSentry.java +++ b/Mage.Sets/src/mage/cards/c/ChamberSentry.java @@ -2,19 +2,27 @@ package mage.cards.c; import mage.MageInt; import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.VariableCostImpl; +import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount; import mage.abilities.dynamicvalue.common.ManacostVariableValue; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; -import mage.abilities.keyword.SunburstAbility; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; import mage.target.common.TargetAnyTarget; import java.util.UUID; @@ -39,6 +47,7 @@ public final class ChamberSentry extends CardImpl { // {X}, {T}, Remove X +1/+1 counters from Chamber Sentry: It deals X damage to any target. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new ManacostVariableValue()), new ManaCostsImpl("{X}")); ability.addCost(new TapSourceCost()); + ability.addCost(new ChamberSentryRemoveVariableCountersSourceCost(CounterType.P1P1.createInstance())); ability.addTarget(new TargetAnyTarget()); this.addAbility(ability); @@ -55,3 +64,68 @@ public final class ChamberSentry extends CardImpl { return new ChamberSentry(this); } } + +class ChamberSentryRemoveVariableCountersSourceCost extends VariableCostImpl { + + protected int minimalCountersToPay = 0; + private String counterName; + + public ChamberSentryRemoveVariableCountersSourceCost(Counter counter) { + this(counter, 0); + } + + public ChamberSentryRemoveVariableCountersSourceCost(Counter counter, String text) { + this(counter, 0,text); + } + + public ChamberSentryRemoveVariableCountersSourceCost(Counter counter, int minimalCountersToPay) { + this(counter, minimalCountersToPay, ""); + } + + public ChamberSentryRemoveVariableCountersSourceCost(Counter counter, int minimalCountersToPay, String text) { + super(counter.getName() + " counters to remove"); + this.minimalCountersToPay = minimalCountersToPay; + this.counterName = counter.getName(); + if (text == null || text.isEmpty()) { + this.text = "Remove X " + counterName + " counters from {this}"; + } else { + this.text = text; + } + } + + public ChamberSentryRemoveVariableCountersSourceCost(final ChamberSentryRemoveVariableCountersSourceCost cost) { + super(cost); + this.minimalCountersToPay = cost.minimalCountersToPay; + this.counterName = cost.counterName; + } + + @Override + public ChamberSentryRemoveVariableCountersSourceCost copy() { + return new ChamberSentryRemoveVariableCountersSourceCost(this); + } + + @Override + public Cost getFixedCostsFromAnnouncedValue(int xValue) { + return new RemoveCountersSourceCost(new Counter(counterName, xValue)); + } + + @Override + public int getMinValue(Ability source, Game game) { + return minimalCountersToPay; + } + + @Override + public int getMaxValue(Ability source, Game game) { + int maxValue = 0; + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + maxValue = permanent.getCounters(game).getCount(counterName); + } + return maxValue; + } + + @Override + public int announceXValue(Ability source, Game game) { + return source.getManaCostsToPay().getX(); + } +}