From 298ff0465ef93022c5084a32d99651e35711fa27 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Wed, 15 Mar 2023 16:05:50 +0100 Subject: [PATCH] Fix Thelon --- .../main/java/forge/ai/AiCostDecision.java | 2 +- .../src/main/java/forge/game/cost/Cost.java | 8 ++++- .../main/java/forge/game/cost/CostExile.java | 30 +++++++++++-------- .../res/cardsfolder/t/thelon_of_havenwood.txt | 2 +- .../java/forge/player/HumanCostDecision.java | 4 +-- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiCostDecision.java b/forge-ai/src/main/java/forge/ai/AiCostDecision.java index d0ab1a1106c..9e5f95d5e6e 100644 --- a/forge-ai/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-ai/src/main/java/forge/ai/AiCostDecision.java @@ -173,7 +173,7 @@ public class AiCostDecision extends CostDecisionMakerBase { if (cost.getFrom().equals(ZoneType.Library)) { return PaymentDecision.card(player.getCardsIn(ZoneType.Library, c)); } - else if (cost.sameZone) { + else if (cost.zoneRestriction == 0) { // TODO Determine exile from same zone for AI return null; } else { diff --git a/forge-game/src/main/java/forge/game/cost/Cost.java b/forge-game/src/main/java/forge/game/cost/Cost.java index 35221a8e753..e5222a5f05c 100644 --- a/forge-game/src/main/java/forge/game/cost/Cost.java +++ b/forge-game/src/main/java/forge/game/cost/Cost.java @@ -448,10 +448,16 @@ public class Cost implements Serializable { return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Library); } + if (parse.startsWith("ExileAnyGrave<")) { + final String[] splitStr = abCostParse(parse, 3); + final String description = splitStr.length > 2 ? splitStr[2] : null; + return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard, -1); + } + if (parse.startsWith("ExileSameGrave<")) { final String[] splitStr = abCostParse(parse, 3); final String description = splitStr.length > 2 ? splitStr[2] : null; - return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard, true); + return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard, 0); } if (parse.startsWith("Return<")) { diff --git a/forge-game/src/main/java/forge/game/cost/CostExile.java b/forge-game/src/main/java/forge/game/cost/CostExile.java index b5b29c5f56f..79a1cfbdeae 100644 --- a/forge-game/src/main/java/forge/game/cost/CostExile.java +++ b/forge-game/src/main/java/forge/game/cost/CostExile.java @@ -46,20 +46,20 @@ public class CostExile extends CostPartWithList { */ private static final long serialVersionUID = 1L; public final ZoneType from; - public final boolean sameZone; + public final int zoneRestriction; public final ZoneType getFrom() { return this.from; } public CostExile(final String amount, final String type, final String description, final ZoneType from) { - this(amount, type, description, from, false); + this(amount, type, description, from, 1); } - public CostExile(final String amount, final String type, final String description, final ZoneType from, final boolean sameZone) { + public CostExile(final String amount, final String type, final String description, final ZoneType from, final int zoneMode) { super(amount, type, description); this.from = from != null ? from : ZoneType.Battlefield; - this.sameZone = sameZone; + this.zoneRestriction = zoneMode; } @Override @@ -68,7 +68,7 @@ public class CostExile extends CostPartWithList { final Game game = source.getGame(); CardCollectionView typeList; - if (this.sameZone) { + if (zoneRestriction != 1) { typeList = game.getCardsIn(this.from); } else { typeList = payer.getCardsIn(this.from); @@ -105,15 +105,21 @@ public class CostExile extends CostPartWithList { } if (!desc.equals("Card") && !desc.contains("card")) { - if (this.sameZone) { - return String.format("Exile %s from the same %s", Lang.nounWithNumeralExceptOne(this.getAmount(), - desc + " card"), origin); + StringBuilder sb = new StringBuilder(); + sb.append("Exile %s from "); + if (zoneRestriction == 0) { + sb.append("the same"); + } else if (zoneRestriction == -1) { + sb.append("a"); + } else { + sb.append("your"); } - return String.format("Exile %s from your %s", Lang.nounWithNumeralExceptOne(this.getAmount(), + sb.append(" %s"); + return String.format(sb.toString(), Lang.nounWithNumeralExceptOne(this.getAmount(), desc + " card"), origin); } - if (this.sameZone) { + if (zoneRestriction == 0) { return String.format("Exile %s from the same %s", Cost.convertAmountTypeToWords(i, this.getAmount(), desc), origin); } @@ -143,7 +149,7 @@ public class CostExile extends CostPartWithList { } CardCollectionView list; - if (this.sameZone) { + if (zoneRestriction != 1) { list = game.getCardsIn(this.from); } else { list = payer.getCardsIn(this.from); @@ -168,7 +174,7 @@ public class CostExile extends CostPartWithList { return false; } - if (this.sameZone) { + if (zoneRestriction == 0) { boolean foundPayable = false; FCollectionView players = game.getPlayers(); for (Player p : players) { diff --git a/forge-gui/res/cardsfolder/t/thelon_of_havenwood.txt b/forge-gui/res/cardsfolder/t/thelon_of_havenwood.txt index 8e341ce975b..9ee3e345ab0 100644 --- a/forge-gui/res/cardsfolder/t/thelon_of_havenwood.txt +++ b/forge-gui/res/cardsfolder/t/thelon_of_havenwood.txt @@ -3,7 +3,7 @@ ManaCost:G G Types:Legendary Creature Elf Druid PT:2/2 S:Mode$ Continuous | Affected$ Creature.Fungus | AffectedZone$ Battlefield | AddPower$ AffectedX | AddToughness$ AffectedX | Description$ Each Fungus creature gets +1/+1 for each spore counter on it. -A:AB$ PutCounterAll | Cost$ B G ExileFromGrave<1/Fungus> | ValidCards$ Fungus | CounterType$ SPORE | CounterNum$ 1 | SpellDescription$ Put a spore counter on each Fungus on the battlefield. +A:AB$ PutCounterAll | Cost$ B G ExileAnyGrave<1/Fungus> | ValidCards$ Fungus | CounterType$ SPORE | CounterNum$ 1 | SpellDescription$ Put a spore counter on each Fungus on the battlefield. SVar:AffectedX:Count$CardCounters.SPORE SVar:BuffedBy:Fungus Oracle:Each Fungus creature gets +1/+1 for each spore counter on it.\n{B}{G}, Exile a Fungus card from a graveyard: Put a spore counter on each Fungus on the battlefield. diff --git a/forge-gui/src/main/java/forge/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/player/HumanCostDecision.java index d38c8bdf1e1..e867b8a4d7b 100644 --- a/forge-gui/src/main/java/forge/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/player/HumanCostDecision.java @@ -244,7 +244,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { } CardCollection list; - if (cost.sameZone) { + if (cost.zoneRestriction != 1) { list = new CardCollection(game.getCardsIn(cost.from)); } else { list = new CardCollection(player.getCardsIn(cost.from)); @@ -275,7 +275,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { if (cost.from == ZoneType.Library) { return exileFromTop(cost, ability, player, c); } if (fromTopGrave) { return exileFromTopGraveType(ability, c, list); } - if (!cost.sameZone) { return exileFromMiscZone(cost, ability, c, list); } + if (cost.zoneRestriction != 0) { return exileFromMiscZone(cost, ability, c, list); } final FCollectionView players = game.getPlayers(); final List payableZone = new ArrayList<>();