From 93bcfaaf7c206918341deff19cd369ffde7342a2 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Sat, 29 Oct 2022 12:47:16 +0200 Subject: [PATCH 1/3] Cleanup --- .../java/forge/game/ability/AbilityUtils.java | 16 ---------------- .../java/forge/game/trigger/TriggerHandler.java | 2 +- forge-gui/res/cardsfolder/b/blood_divination.txt | 2 +- .../c/charge_of_the_forever_beast.txt | 2 +- .../res/cardsfolder/e/evelyn_the_covetous.txt | 3 +-- forge-gui/res/cardsfolder/s/swallow_whole.txt | 2 +- 6 files changed, 5 insertions(+), 22 deletions(-) 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 079c456f231..05ab6ce2870 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1317,22 +1317,6 @@ public class AbilityUtils { final Object o = root.getTriggeringObject(AbilityKey.fromString(triggeringType)); if (o instanceof SpellAbility) { s = (SpellAbility) o; - // if there is no target information in SA but targets are listed in SpellAbilityTargeting cards, copy that - // information so it's not lost if the calling code is interested in targets of the triggered SA. - if (triggeringType.equals("SpellAbility")) { - final List tgtList = (List) root.getTriggeringObject(AbilityKey.SpellAbilityTargets); - if (s.getTargets() != null && s.getTargets().size() == 0) { - if (tgtList != null && tgtList.size() > 0) { - TargetChoices tc = new TargetChoices(); - for (GameEntity ge : tgtList) { - if (ge instanceof Card) { - tc.add((Card) ge); - } - } - s.setTargets(tc); - } - } - } } else if (o instanceof SpellAbilityStackInstance) { s = ((SpellAbilityStackInstance) o).getSpellAbility(true); } diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java index add5f20f3e3..6b9f883e483 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerHandler.java @@ -561,7 +561,7 @@ public class TriggerHandler { sa.setTriggerRemembered(regtrig.getTriggerRemembered()); if (regtrig.hasParam("TriggerController")) { - Player p = AbilityUtils.getDefinedPlayers(regtrig.getHostCard(), regtrig.getParam("TriggerController"), sa).get(0); + Player p = AbilityUtils.getDefinedPlayers(host, regtrig.getParam("TriggerController"), sa).get(0); sa.setActivatingPlayer(p); } diff --git a/forge-gui/res/cardsfolder/b/blood_divination.txt b/forge-gui/res/cardsfolder/b/blood_divination.txt index 8c49e5cb747..4ec54afaf4e 100644 --- a/forge-gui/res/cardsfolder/b/blood_divination.txt +++ b/forge-gui/res/cardsfolder/b/blood_divination.txt @@ -1,6 +1,6 @@ Name:Blood Divination ManaCost:3 B Types:Sorcery -A:SP$ Draw | Cost$ 3 B Sac<1/Creature> | NumCards$ 3 | SpellDescription$ As an additional cost to cast this spell, sacrifice a creature. Draw three cards. +A:SP$ Draw | Cost$ 3 B Sac<1/Creature> | NumCards$ 3 | SpellDescription$ Draw three cards. SVar:AIPreference:SacCost$Creature.token,Creature.cmcLE3 Oracle:As an additional cost to cast this spell, sacrifice a creature.\nDraw three cards. diff --git a/forge-gui/res/cardsfolder/c/charge_of_the_forever_beast.txt b/forge-gui/res/cardsfolder/c/charge_of_the_forever_beast.txt index c3c27a2391e..291996078f2 100644 --- a/forge-gui/res/cardsfolder/c/charge_of_the_forever_beast.txt +++ b/forge-gui/res/cardsfolder/c/charge_of_the_forever_beast.txt @@ -1,7 +1,7 @@ Name:Charge of the Forever-Beast ManaCost:2 G Types:Sorcery -A:SP$ DealDamage | Cost$ 2 G Reveal<1/Creature> | ValidTgts$ Creature,Planeswalker | TgtPrompt$ Select target creature or planeswalker | NumDmg$ X | SpellDescription$ As an additional cost to cast this spell, reveal a creature card from your hand. CARDNAME deals damage to target creature or planeswalker equal to the revealed card's power. +A:SP$ DealDamage | Cost$ 2 G Reveal<1/Creature> | ValidTgts$ Creature,Planeswalker | TgtPrompt$ Select target creature or planeswalker | NumDmg$ X | SpellDescription$ CARDNAME deals damage to target creature or planeswalker equal to the revealed card's power. SVar:X:Revealed$CardPower AI:RemoveDeck:All Oracle:As an additional cost to cast this spell, reveal a creature card from your hand.\nCharge of the Forever-Beast deals damage to target creature or planeswalker equal to the revealed card's power. diff --git a/forge-gui/res/cardsfolder/e/evelyn_the_covetous.txt b/forge-gui/res/cardsfolder/e/evelyn_the_covetous.txt index 1293ff019d9..fa12031fb35 100644 --- a/forge-gui/res/cardsfolder/e/evelyn_the_covetous.txt +++ b/forge-gui/res/cardsfolder/e/evelyn_the_covetous.txt @@ -7,5 +7,4 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S SVar:TrigExile:DB$ Dig | DigNum$ 1 | ChangeNum$ All | Defined$ Player | DestinationZone$ Exile | ExileWithCounter$ COLLECTION S:Mode$ Continuous | MayPlayLimit$ 1 | Affected$ Card.ExiledByYou+counters_GE1_COLLECTION | AffectedZone$ Exile | MayPlay$ True | MayPlayIgnoreColor$ True | Description$ Once each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were any color to cast it. DeckHints:Type$Vampire -Oracle:Flash\nWhenever Evelyn, the Covetous or another Vampire enters the battlefield under your control, exile the top card of each player's library with a collection counter on it. -\nOnce each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were mana of any color to cast it. \ No newline at end of file +Oracle:Flash\nWhenever Evelyn, the Covetous or another Vampire enters the battlefield under your control, exile the top card of each player's library with a collection counter on it.\nOnce each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were mana of any color to cast it. \ No newline at end of file diff --git a/forge-gui/res/cardsfolder/s/swallow_whole.txt b/forge-gui/res/cardsfolder/s/swallow_whole.txt index e0c2dd1596c..083287f559d 100644 --- a/forge-gui/res/cardsfolder/s/swallow_whole.txt +++ b/forge-gui/res/cardsfolder/s/swallow_whole.txt @@ -1,7 +1,7 @@ Name:Swallow Whole ManaCost:W Types:Sorcery -A:SP$ ChangeZone | Cost$ W tapXType<1/Creature> | ValidTgts$ Creature.tapped | TgtPrompt$ Select target tapped creature | Origin$ Battlefield | Destination$ Exile | SubAbility$ DBPutCounter | SpellDescription$ As an additional cost to cast this spell, tap an untapped creature you control. Exile target tapped creature. +A:SP$ ChangeZone | Cost$ W tapXType<1/Creature> | ValidTgts$ Creature.tapped | TgtPrompt$ Select target tapped creature | Origin$ Battlefield | Destination$ Exile | SubAbility$ DBPutCounter | SpellDescription$ Exile target tapped creature. SVar:DBPutCounter:DB$ PutCounter | Defined$ Tapped | CounterType$ P1P1 | SpellDescription$ Put a +1/+1 counter on the creature tapped to cast this spell. DeckHas:Ability$Counters Oracle:As an additional cost to cast this spell, tap an untapped creature you control.\nExile target tapped creature. Put a +1/+1 counter on the creature tapped to pay this spell's additional cost. From c14df1832a2e53e286f942e0cd167f337dc3d055 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Sat, 29 Oct 2022 12:48:36 +0200 Subject: [PATCH 2/3] Improve logic --- forge-game/src/main/java/forge/game/mana/ManaPool.java | 5 ++++- forge-game/src/main/java/forge/game/zone/MagicStack.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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 a6c02f33736..a9aa3bc2c93 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaPool.java +++ b/forge-game/src/main/java/forge/game/mana/ManaPool.java @@ -303,10 +303,13 @@ public class ManaPool extends ManaConversionMatrix implements Iterable { // Send all mana back to your mana pool, before accounting for it. // move non-undoable paying mana back to floating - refundMana(sa.getPayingMana(), owner, sa); List payingAbilities = sa.getPayingManaAbilities(); + + // start with the most recent + Collections.reverse(payingAbilities); + for (final SpellAbility am : payingAbilities) { // undo paying abilities if we can am.undo(); diff --git a/forge-game/src/main/java/forge/game/zone/MagicStack.java b/forge-game/src/main/java/forge/game/zone/MagicStack.java index d2a0be730fb..fcdfe3302f6 100644 --- a/forge-game/src/main/java/forge/game/zone/MagicStack.java +++ b/forge-game/src/main/java/forge/game/zone/MagicStack.java @@ -210,12 +210,12 @@ public class MagicStack /* extends MyObservable */ implements Iterable filterUndoStackByHost(final Card c) { From f40a26f52c1645b8986789c8d6c051f6de06272b Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Sat, 29 Oct 2022 12:48:59 +0200 Subject: [PATCH 3/3] Fix color choice --- forge-ai/src/main/java/forge/ai/ComputerUtilCard.java | 4 +--- .../forge/game/ability/effects/ChooseColorEffect.java | 3 +-- .../src/main/java/forge/player/PlayerControllerHuman.java | 8 ++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java index bbfb57ccf9a..3f0e6ef9e41 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilCard.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.stream.Collectors; import forge.card.mana.ManaCost; import org.apache.commons.lang3.StringUtils; @@ -1082,8 +1081,7 @@ public class ComputerUtilCard { //chosen.add(MagicColor.Constant.GREEN); chosen.add(getMostProminentColor(ai.getAllCards(), colorChoices)); } - //convert to proper case same with the colorChoices.. - return chosen.stream().map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)).collect(Collectors.toList()); + return chosen; } public static boolean useRemovalNow(final SpellAbility sa, final Card c, final int dmg, ZoneType destination) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseColorEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseColorEffect.java index 257545caf44..75c5655960d 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseColorEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseColorEffect.java @@ -82,14 +82,13 @@ public class ChooseColorEffect extends SpellAbilityEffect { } noNotify = null; } else { - colorChoices = colorChoices.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList()); chosenColors = p.getController().chooseColors(prompt, sa, cntMin, cntMax, colorChoices); - chosenColors = chosenColors.stream().map(DeckRecognizer::getColorNameByLocalisedName).collect(Collectors.toList()); } if (chosenColors.isEmpty()) { return; } card.setChosenColors(chosenColors); + chosenColors = chosenColors.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList()); p.getGame().getAction().notifyOfValue(sa, p, Lang.joinHomogenous(chosenColors), noNotify); } } diff --git a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java index 1ddc397d326..b0d5b77cfdf 100644 --- a/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java +++ b/forge-gui/src/main/java/forge/player/PlayerControllerHuman.java @@ -16,6 +16,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.stream.Collectors; import java.util.TreeSet; import forge.util.ImageUtil; @@ -49,6 +50,7 @@ import forge.card.mana.ManaCost; import forge.card.mana.ManaCostShard; import forge.deck.CardPool; import forge.deck.Deck; +import forge.deck.DeckRecognizer; import forge.deck.DeckSection; import forge.game.Game; import forge.game.GameEntity; @@ -1712,8 +1714,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont @Override public List chooseColors(final String message, final SpellAbility sa, final int min, final int max, - final List options) { - return getGui().getChoices(message, min, max, options); + List options) { + options = options.stream().map(DeckRecognizer::getLocalisedMagicColorName).collect(Collectors.toList()); + List choices = getGui().getChoices(message, min, max, options); + return choices.stream().map(DeckRecognizer::getColorNameByLocalisedName).collect(Collectors.toList()); } @Override