From b5c93cf2da9d77f5bf703bd1a05e8f7512f02181 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 28 Jul 2020 01:03:33 +0200 Subject: [PATCH] * Fixed available mana generation of Druids Repository, Workhouse, Iceberg, Krak Clan Ironworks, Rasputin Dreamweaver and Sirk Prospector (#6698). --- .../src/mage/cards/d/DruidsRepository.java | 6 ++- Mage.Sets/src/mage/cards/i/Iceberg.java | 5 ++- .../src/mage/cards/k/KrarkClanIronworks.java | 6 ++- .../src/mage/cards/r/RasputinDreamweaver.java | 5 ++- .../src/mage/cards/s/SkirkProspector.java | 6 ++- Mage.Sets/src/mage/cards/w/Workhorse.java | 4 +- .../cards/mana/TappedForManaRelatedTest.java | 17 ++++++++ .../effects/mana/BasicManaEffect.java | 41 +++++++++++++++++++ .../abilities/mana/SimpleManaAbility.java | 16 +++++++- 9 files changed, 99 insertions(+), 7 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DruidsRepository.java b/Mage.Sets/src/mage/cards/d/DruidsRepository.java index 55d3333580..132f1be2ce 100644 --- a/Mage.Sets/src/mage/cards/d/DruidsRepository.java +++ b/Mage.Sets/src/mage/cards/d/DruidsRepository.java @@ -2,9 +2,11 @@ package mage.cards.d; import java.util.UUID; +import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.mana.AddManaOfAnyColorEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.SimpleManaAbility; @@ -29,7 +31,9 @@ public final class DruidsRepository extends CardImpl { this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()))); // Remove a charge counter from Druids' Repository: Add one mana of any color. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())); + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Mana.AnyMana(1), + new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()), + new CountersSourceCount(CounterType.CHARGE)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/i/Iceberg.java b/Mage.Sets/src/mage/cards/i/Iceberg.java index 98fd771829..87e904940f 100644 --- a/Mage.Sets/src/mage/cards/i/Iceberg.java +++ b/Mage.Sets/src/mage/cards/i/Iceberg.java @@ -7,6 +7,7 @@ import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.SimpleManaAbility; @@ -32,7 +33,9 @@ public final class Iceberg extends CardImpl { this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.ICE.createInstance(1)), new ManaCostsImpl("{3}"))); // Remove an ice counter from Iceberg: Add {C}. - this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), new RemoveCountersSourceCost(CounterType.ICE.createInstance(1)))); + this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), + new RemoveCountersSourceCost(CounterType.ICE.createInstance(1)), + new CountersSourceCount(CounterType.ICE))); } public Iceberg(final Iceberg card) { diff --git a/Mage.Sets/src/mage/cards/k/KrarkClanIronworks.java b/Mage.Sets/src/mage/cards/k/KrarkClanIronworks.java index adb05023d6..2ac48444d8 100644 --- a/Mage.Sets/src/mage/cards/k/KrarkClanIronworks.java +++ b/Mage.Sets/src/mage/cards/k/KrarkClanIronworks.java @@ -5,11 +5,13 @@ import java.util.UUID; import mage.Mana; import mage.abilities.Ability; import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Zone; +import mage.filter.StaticFilters; import mage.filter.common.FilterControlledArtifactPermanent; import mage.target.common.TargetControlledPermanent; @@ -23,7 +25,9 @@ public final class KrarkClanIronworks extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}"); // Sacrifice an artifact: Add {C}{C}. - Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(2), new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledArtifactPermanent("an artifact")))); + Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(2), + new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledArtifactPermanent("an artifact"))), + new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java index e3fc6822f8..2533fb1aeb 100644 --- a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java +++ b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java @@ -14,6 +14,7 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.condition.Condition; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.PreventDamageToSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.SimpleManaAbility; @@ -47,7 +48,9 @@ public final class RasputinDreamweaver extends CardImpl { this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.DREAM.createInstance(7)), "seven dream counters on it")); // Remove a dream counter from Rasputin: Add {C}. - this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), new RemoveCountersSourceCost(CounterType.DREAM.createInstance()))); + this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), + new RemoveCountersSourceCost(CounterType.DREAM.createInstance()), + new CountersSourceCount(CounterType.DREAM))); // Remove a dream counter from Rasputin: Prevent the next 1 damage that would be dealt to Rasputin this turn. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToSourceEffect(Duration.EndOfTurn, 1), new RemoveCountersSourceCost(CounterType.DREAM.createInstance()))); diff --git a/Mage.Sets/src/mage/cards/s/SkirkProspector.java b/Mage.Sets/src/mage/cards/s/SkirkProspector.java index b359eb40ae..a8ae761bd6 100644 --- a/Mage.Sets/src/mage/cards/s/SkirkProspector.java +++ b/Mage.Sets/src/mage/cards/s/SkirkProspector.java @@ -5,12 +5,14 @@ import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; +import mage.filter.StaticFilters; import mage.filter.common.FilterControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; @@ -34,7 +36,9 @@ public final class SkirkProspector extends CardImpl { this.toughness = new MageInt(1); // Sacrifice a Goblin: Add {R}. - this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.RedMana(1), new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,filter,true)))); + this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.RedMana(1), + new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,filter,true)), + new PermanentsOnBattlefieldCount(filter))); } public SkirkProspector(final SkirkProspector card) { diff --git a/Mage.Sets/src/mage/cards/w/Workhorse.java b/Mage.Sets/src/mage/cards/w/Workhorse.java index 35bd41e750..deb2f895b4 100644 --- a/Mage.Sets/src/mage/cards/w/Workhorse.java +++ b/Mage.Sets/src/mage/cards/w/Workhorse.java @@ -6,6 +6,7 @@ import mage.MageInt; import mage.Mana; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; @@ -32,7 +33,8 @@ public final class Workhorse extends CardImpl { // Remove a +1/+1 counter from Workhorse: Add {C}. this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(1), - new RemoveCountersSourceCost(CounterType.P1P1.createInstance()))); + new RemoveCountersSourceCost(CounterType.P1P1.createInstance()), + new CountersSourceCount(CounterType.P1P1))); } public Workhorse(final Workhorse card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/TappedForManaRelatedTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/TappedForManaRelatedTest.java index c91d0756b2..a487708cff 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/mana/TappedForManaRelatedTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/TappedForManaRelatedTest.java @@ -343,4 +343,21 @@ public class TappedForManaRelatedTest extends CardTestPlayerBase { assertManaOptions("{G}{G}{G}{G}{G}{G}{G}", manaOptions); } + @Test + public void TestWorkhorse() { + setStrictChooseMode(true); + + // Workhorse enters the battlefield with four +1/+1 counters on it. + // Remove a +1/+1 counter from Workhorse: Add {C}. + addCard(Zone.BATTLEFIELD, playerA, "Workhorse", 1); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertAllCommandsUsed(); + + ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame); + Assert.assertEquals("mana variations don't fit", 1, manaOptions.size()); + assertManaOptions("{C}{C}{C}{C}", manaOptions); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/mana/BasicManaEffect.java b/Mage/src/main/java/mage/abilities/effects/mana/BasicManaEffect.java index 60314cecc1..2371f386e7 100644 --- a/Mage/src/main/java/mage/abilities/effects/mana/BasicManaEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/mana/BasicManaEffect.java @@ -1,33 +1,74 @@ package mage.abilities.effects.mana; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import mage.ConditionalMana; import mage.Mana; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.common.ManaEffect; import mage.game.Game; public class BasicManaEffect extends ManaEffect { protected Mana manaTemplate; + private final DynamicValue netAmount; public BasicManaEffect(Mana mana) { + this(mana, null); + this.manaTemplate = mana; + } + + public BasicManaEffect(Mana mana, DynamicValue netAmount) { super(); this.manaTemplate = mana; staticText = "add " + mana.toString(); + this.netAmount = netAmount; } public BasicManaEffect(ConditionalMana conditionalMana) { super(); this.manaTemplate = conditionalMana; staticText = "add " + manaTemplate.toString() + " " + conditionalMana.getDescription(); + this.netAmount = null; } public BasicManaEffect(final BasicManaEffect effect) { super(effect); this.manaTemplate = effect.manaTemplate.copy(); + this.netAmount = effect.netAmount; } + @Override + public List getNetMana(Game game, Ability source) { + if (game != null && game.inCheckPlayableState() && netAmount != null) { + // calculate the maximum available mana + int count = netAmount.calculate(game, source, this); + Mana computedMana = new Mana(); + if (manaTemplate.getBlack() > 0) { + computedMana.setBlack(count * manaTemplate.getBlack()); + } else if (manaTemplate.getBlue() > 0) { + computedMana.setBlue(count * manaTemplate.getBlue()); + } else if (manaTemplate.getGreen() > 0) { + computedMana.setGreen(count * manaTemplate.getGreen()); + } else if (manaTemplate.getRed() > 0) { + computedMana.setRed(count * manaTemplate.getRed()); + } else if (manaTemplate.getWhite() > 0) { + computedMana.setWhite(count * manaTemplate.getWhite()); + } else if (manaTemplate.getColorless() > 0) { + computedMana.setColorless(count * manaTemplate.getColorless()); + } else if (manaTemplate.getAny() > 0) { + computedMana.setAny(count * manaTemplate.getAny()); + } else if (manaTemplate.getGeneric() > 0){ + computedMana.setGeneric(count * manaTemplate.getGeneric()); + } + return new ArrayList<>(Arrays.asList(computedMana)); + } + return super.getNetMana(game, source); + } + @Override public BasicManaEffect copy() { return new BasicManaEffect(this); diff --git a/Mage/src/main/java/mage/abilities/mana/SimpleManaAbility.java b/Mage/src/main/java/mage/abilities/mana/SimpleManaAbility.java index dc469b3a7a..501ab6f5a3 100644 --- a/Mage/src/main/java/mage/abilities/mana/SimpleManaAbility.java +++ b/Mage/src/main/java/mage/abilities/mana/SimpleManaAbility.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import mage.Mana; import mage.abilities.costs.Cost; +import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.common.ManaEffect; import mage.abilities.effects.mana.BasicManaEffect; import mage.constants.Zone; @@ -35,7 +36,20 @@ public class SimpleManaAbility extends ActivatedManaAbilityImpl { } public SimpleManaAbility(Zone zone, Mana mana, Cost cost) { - super(zone, new BasicManaEffect(mana), cost); + this(zone, mana, cost, null); + this.netMana.add(mana.copy()); + this.predictable = true; + } + + /** + * + * @param zone + * @param mana + * @param cost cost for one usage + * @param netAmount DynamicValu to calculate the max available mana if effect is repeatable + */ + public SimpleManaAbility(Zone zone, Mana mana, Cost cost, DynamicValue netAmount) { + super(zone, new BasicManaEffect(mana, netAmount), cost); this.netMana.add(mana.copy()); this.predictable = true; }