diff --git a/Mage.Sets/src/mage/cards/t/TreasonousOgre.java b/Mage.Sets/src/mage/cards/t/TreasonousOgre.java index ea75543fd4..478ba8d150 100644 --- a/Mage.Sets/src/mage/cards/t/TreasonousOgre.java +++ b/Mage.Sets/src/mage/cards/t/TreasonousOgre.java @@ -5,6 +5,8 @@ import java.util.UUID; import mage.MageInt; import mage.Mana; import mage.abilities.costs.common.PayLifeCost; +import mage.abilities.dynamicvalue.common.ControllerLifeDividedValue; +import mage.abilities.effects.mana.BasicManaEffect; import mage.abilities.keyword.DethroneAbility; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; @@ -31,7 +33,10 @@ public final class TreasonousOgre extends CardImpl { // Dethrone this.addAbility(new DethroneAbility()); // Pay 3 life: Add {R}. - this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new Mana(ColoredManaSymbol.R), new PayLifeCost(3))); + + this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, + new BasicManaEffect(new Mana(ColoredManaSymbol.R), new ControllerLifeDividedValue(3)), + new PayLifeCost(3))); } public TreasonousOgre(final TreasonousOgre card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/NonTappingManaAbilitiesTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/NonTappingManaAbilitiesTest.java index f23ff170a0..e2bbecd5ba 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/mana/NonTappingManaAbilitiesTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/NonTappingManaAbilitiesTest.java @@ -236,7 +236,7 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase { assertManaOptions("{C}{C}{U}{R}{G}", manaOptions); } - @Test + @Test public void TestSquanderedResourcesWithManaConfluence() { setStrictChooseMode(true); addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); @@ -254,5 +254,22 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase { ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame); Assert.assertEquals("mana variations don't fit", 1, manaOptions.size()); assertManaOptions("{G}{Any}{Any}", manaOptions); - } + } + + @Test + public void TestTreasonousOgre() { + setStrictChooseMode(true); + // Dethrone + // Pay 3 life: Add {R}. + addCard(Zone.BATTLEFIELD, playerA, "Treasonous Ogre", 1); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertAllCommandsUsed(); + + ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame); + Assert.assertEquals("mana variations don't fit", 1, manaOptions.size()); + assertManaOptions("{R}{R}{R}{R}{R}{R}", manaOptions); + } } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLifeDividedValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLifeDividedValue.java new file mode 100644 index 0000000000..d6a3138440 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerLifeDividedValue.java @@ -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.game.Game; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class ControllerLifeDividedValue implements DynamicValue { + + private final Integer divider; + + public ControllerLifeDividedValue(Integer divider) { + this.divider = divider; + } + + public ControllerLifeDividedValue(final ControllerLifeDividedValue dynamicValue) { + this.divider = dynamicValue.divider; + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + Player p = game.getPlayer(sourceAbility.getControllerId()); + if (p != null) { + return p.getLife() / divider; + } + return 0; + } + + @Override + public ControllerLifeDividedValue copy() { + return new ControllerLifeDividedValue(this); + } + + @Override + public String toString() { + return "X"; + } + + @Override + public String getMessage() { + return ""; + } +}