From 07915701c30d7925bfa486b6c64d626d589854f2 Mon Sep 17 00:00:00 2001 From: swordshine Date: Tue, 18 Feb 2014 02:45:28 +0000 Subject: [PATCH] - Added Jeweled Amulet --- .gitattributes | 1 + forge-ai/src/main/java/forge/ai/ComputerUtilMana.java | 2 +- .../src/main/java/forge/game/ability/AbilityUtils.java | 5 +++++ .../java/forge/game/ability/effects/ManaEffect.java | 10 ++++++++++ forge-game/src/main/java/forge/game/mana/ManaPool.java | 4 ++-- .../java/forge/game/spellability/SpellAbility.java | 7 +++++-- forge-gui/res/cardsfolder/j/jeweled_amulet.txt | 9 +++++++++ forge-gui/res/cardsfolder/s/souls_might.txt | 2 +- 8 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 forge-gui/res/cardsfolder/j/jeweled_amulet.txt diff --git a/.gitattributes b/.gitattributes index 8d17c6f59aa..f3fd4fc0669 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6530,6 +6530,7 @@ forge-gui/res/cardsfolder/j/jesters_mask.txt svneol=native#text/plain forge-gui/res/cardsfolder/j/jesters_scepter.txt -text forge-gui/res/cardsfolder/j/jet_medallion.txt svneol=native#text/plain forge-gui/res/cardsfolder/j/jetting_glasskite.txt -text +forge-gui/res/cardsfolder/j/jeweled_amulet.txt -text forge-gui/res/cardsfolder/j/jeweled_bird.txt -text forge-gui/res/cardsfolder/j/jeweled_spirit.txt svneol=native#text/plain forge-gui/res/cardsfolder/j/jeweled_torque.txt -text diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 814d998b9d4..8bf216789e6 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -121,7 +121,7 @@ public class ComputerUtilMana { } else { if (ai.getManaPool().tryPayCostWithMana(sa, cost, mana)) { - manaSpentToPay.add(mana); + manaSpentToPay.add(0, mana); } } } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index daad889a178..31eb78fa5ca 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1273,6 +1273,11 @@ public class AbilityUtils { } } + if (sa.hasParam("RememberCostMana")) { + host.clearRemembered(); + host.getRemembered().addAll(sa.getPayingMana()); + } + if (sa.hasParam("RememberCostCards")) { if (sa.getParam("Cost").contains("Exile")) { final List paidListExiled = sa.getPaidList("Exiled"); diff --git a/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java index 08940d00f1f..89278721eea 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ManaEffect.java @@ -9,12 +9,15 @@ import forge.game.ability.AbilityUtils; import forge.game.ability.SpellAbilityEffect; import forge.game.card.Card; import forge.game.card.CounterType; +import forge.game.mana.Mana; import forge.game.player.Player; import forge.game.spellability.AbilityManaPart; import forge.game.spellability.SpellAbility; import forge.game.spellability.TargetRestrictions; import org.apache.commons.lang3.StringUtils; +import com.google.common.collect.Iterables; + import java.util.List; public class ManaEffect extends SpellAbilityEffect { @@ -125,6 +128,13 @@ public class ManaEffect extends SpellAbilityEffect { } } abMana.setExpressChoice(sb.toString().trim()); + } else if (type.equals("LastNotedType")) { + Mana manaType = (Mana) Iterables.getFirst(card.getRemembered(), null); + if (manaType == null) { + return; + } + String cs = manaType.toString(); + abMana.setExpressChoice(cs); } if (abMana.getExpressChoice().isEmpty()) { diff --git a/forge-game/src/main/java/forge/game/mana/ManaPool.java b/forge-game/src/main/java/forge/game/mana/ManaPool.java index 5eb8e3f329c..c7424618320 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -171,7 +171,7 @@ public class ManaPool implements Iterable { paidAbs.add(saPayment); // assumes some part on the mana produced by the ability will get used for (final Mana mana : abManaPart.getLastManaProduced()) { if( tryPayCostWithMana(saPaidFor, manaCost, mana) ) - saPaidFor.getPayingMana().add(mana); + saPaidFor.getPayingMana().add(0, mana); } } @@ -196,7 +196,7 @@ public class ManaPool implements Iterable { boolean result = manaFound != null && tryPayCostWithMana(saPaidFor, manaCost, manaFound); if(result) - saPaidFor.getPayingMana().add(manaFound); + saPaidFor.getPayingMana().add(0, manaFound); return result; } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index 92f363762e5..0c2296a78af 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -1628,12 +1628,15 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit // Return whether this spell tracks what color mana is spent to cast it for the sake of the effect public boolean tracksManaSpent() { if (this.hostCard == null) { return false; } - if (!this.isSpell()) { return false; } if (this.hostCard.hasKeyword("Sunburst")) { return true; } - if (this.hostCard.getRules().getOracleText().contains("was spent to cast")) { + String text = this.hostCard.getRules().getOracleText(); + if (this.isSpell() && text.contains("was spent to cast")) { + return true; + } + if (this.isAbility() && text.contains("mana spent to pay")) { return true; } return false; diff --git a/forge-gui/res/cardsfolder/j/jeweled_amulet.txt b/forge-gui/res/cardsfolder/j/jeweled_amulet.txt new file mode 100644 index 00000000000..a7919555518 --- /dev/null +++ b/forge-gui/res/cardsfolder/j/jeweled_amulet.txt @@ -0,0 +1,9 @@ +Name:Jeweled Amulet +ManaCost:0 +Types:Artifact +A:AB$ PutCounter | Cost$ 1 T | RememberCostMana$ True | CounterType$ CHARGE | CounterNum$ 1 | CheckSVar$ X | SVarCompare$ EQ0 | References$ X | SpellDescription$ Put a charge counter on CARDNAME. Note the type of mana spent to pay this activation cost. Activate this ability only if there are no charge counters on CARDNAME. +SVar:X:Count$CardCounters.CHARGE +A:AB$ Mana | Cost$ T SubCounter<1/CHARGE> | Produced$ Special LastNotedType | SpellDescription$ Add one mana of CARDNAME's last noted type to your mana pool. +SVar:RemAIDeck:True +SVar:Picture:http://www.wizards.com/global/images/magic/general/jeweled_amulet.jpg +Oracle:{1}, {T}: Put a charge counter on Jeweled Amulet. Note the type of mana spent to pay this activation cost. Activate this ability only if there are no charge counters on Jeweled Amulet.\n{T}, Remove a charge counter from Jeweled Amulet: Add one mana of Jeweled Amulet's last noted type to your mana pool. diff --git a/forge-gui/res/cardsfolder/s/souls_might.txt b/forge-gui/res/cardsfolder/s/souls_might.txt index 37973916a20..ecf2cf70910 100644 --- a/forge-gui/res/cardsfolder/s/souls_might.txt +++ b/forge-gui/res/cardsfolder/s/souls_might.txt @@ -1,7 +1,7 @@ Name:Soul's Might ManaCost:4 G Types:Sorcery -A:SP$ PutCounter | Cost$ 4 G | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ X | SpellDescription$ Put X +1/+1 counters on target creature, where X is that creature's power. +A:SP$ PutCounter | Cost$ 4 G | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ X | References$ X | SpellDescription$ Put X +1/+1 counters on target creature, where X is that creature's power. SVar:X:Targeted$CardPower SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/souls_might.jpg