From 15d80f6532042d5db520131e8959ea4d9a1aa7b3 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Tue, 19 Sep 2023 16:59:26 +0200 Subject: [PATCH 1/3] Rework script --- .../res/cardsfolder/p/primitive_justice.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/forge-gui/res/cardsfolder/p/primitive_justice.txt b/forge-gui/res/cardsfolder/p/primitive_justice.txt index d1177288c82..00816bd3a8f 100644 --- a/forge-gui/res/cardsfolder/p/primitive_justice.txt +++ b/forge-gui/res/cardsfolder/p/primitive_justice.txt @@ -1,12 +1,12 @@ Name:Primitive Justice ManaCost:1 R Types:Sorcery -A:SP$ Destroy | Cost$ X 1 R | XColor$ RG | AnnounceTitle$ how many times to pay the additional cost | Announce$ AdditionalCostPayTimes | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | TargetMin$ TargetNum | TargetMax$ TargetNum | SubAbility$ DBGainLife | SpellDescription$ Destroy target artifact. For each additional {1}{R} you paid, destroy another target artifact. For each additional {1}{G} you paid, destroy another target artifact, and you gain 1 life. -S:Mode$ RaiseCost | ValidCard$ Card.Self | Type$ Spell | Amount$ IncreaseCost | EffectZone$ All | Description$ As an additional cost to cast this spell, you may pay {1}{R} and/or {1}{G} any number of times. -SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ GManaPaid -SVar:AdditionalCostPayTimes:Number$0 -SVar:TargetNum:SVar$AdditionalCostPayTimes/Plus.1 -SVar:IncreaseCost:SVar$AdditionalCostPayTimes -SVar:X:SVar$AdditionalCostPayTimes -SVar:GManaPaid:Count$xColorPaid G +A:SP$ Destroy | Cost$ 1 R | AnnounceTitle$ how many times to pay the additional cost | Announce$ AdditionalCostPayTimesR,AdditionalCostPayTimesG | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | TargetMin$ TargetNum | TargetMax$ TargetNum | SubAbility$ DBGainLife | SpellDescription$ Destroy target artifact. For each additional {1}{R} you paid, destroy another target artifact. For each additional {1}{G} you paid, destroy another target artifact, and you gain 1 life. +S:Mode$ RaiseCost | ValidCard$ Card.Self | Type$ Spell | Cost$ 1 R | Amount$ AdditionalCostPayTimesR | EffectZone$ All | Description$ As an additional cost to cast this spell, you may pay {1}{R} and/or {1}{G} any number of times. +S:Mode$ RaiseCost | ValidCard$ Card.Self | Type$ Spell | Cost$ 1 G | Amount$ AdditionalCostPayTimesG | EffectZone$ All +SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ AdditionalCostPayTimesG +SVar:AdditionalCostPayTimesR:Number$0 +SVar:AdditionalCostPayTimesG:Number$0 +SVar:TargetNum:SVar$AdditionalCostPayTimesR/Plus.TargetNum2 +SVar:TargetNum2:SVar$AdditionalCostPayTimesG/Plus.1 Oracle:As an additional cost to cast this spell, you may pay {1}{R} and/or {1}{G} any number of times.\nDestroy target artifact. For each additional {1}{R} you paid, destroy another target artifact. For each additional {1}{G} you paid, destroy another target artifact, and you gain 1 life. From fff528291ac7caf7d6bc4943afbf3cc6ed5ab449 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Tue, 19 Sep 2023 17:15:24 +0200 Subject: [PATCH 2/3] XColor fixes --- .../forge/game/mana/ManaCostBeingPaid.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java index 0ddf9d044ce..0ef7a8c75da 100644 --- a/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java +++ b/forge-game/src/main/java/forge/game/mana/ManaCostBeingPaid.java @@ -302,7 +302,7 @@ public final void decreaseShard(final ManaCostShard shard, final int manaToSubtr for (Entry e : unpaidShards.entrySet()) { final ManaCostShard eShard = e.getKey(); sc = e.getValue(); - if (eShard.isOfKind(shard.getShard()) && !eShard.isMonoColor()) { + if (eShard != ManaCostShard.COLORED_X && eShard.isOfKind(shard.getShard()) && !eShard.isMonoColor()) { if (otherSubtract >= sc.totalCount) { otherSubtract -= sc.totalCount; sc.xCount = sc.totalCount = 0; @@ -377,6 +377,20 @@ public final void decreaseShard(final ManaCostShard shard, final int manaToSubtr // nothing more left in otherSubtract return; } + } else if (sc.xCount > 0) { // X part that can only be paid by specific color + if (otherSubtract >= sc.xCount) { + otherSubtract -= sc.xCount; + sc.totalCount -= sc.xCount; + sc.xCount = 0; + if (sc.totalCount == 0) { + toRemove.add(eShard); + } + } else { + sc.totalCount -= otherSubtract; + sc.xCount -= otherSubtract; + // nothing more left in otherSubtract + return; + } } } } @@ -717,10 +731,10 @@ public final byte getUnpaidColors() { } return result; } - + public boolean hasAnyKind(int kind) { - for (ManaCostShard s : unpaidShards.keySet()) { - if (s.isOfKind(kind)) { + for (Map.Entry e : unpaidShards.entrySet()) { + if (e.getKey().isOfKind(kind) && e.getValue().totalCount > e.getValue().xCount) { return true; } } From f33bf7989d51f39969b25c6e22ce736c826de1c7 Mon Sep 17 00:00:00 2001 From: tool4EvEr Date: Tue, 19 Sep 2023 17:17:56 +0200 Subject: [PATCH 3/3] clean up --- forge-ai/src/main/java/forge/ai/ComputerUtilMana.java | 6 +++--- .../src/main/java/forge/game/cost/CostAdjustment.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index fe2f5dfcc6e..739312bfbc5 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -990,7 +990,7 @@ private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player a continue; } - if (!sa.allowsPayingWithShard(m.getSourceCard(), ManaAtom.fromName(s))) { + if (!sa.allowsPayingWithShard(sourceCard, ManaAtom.fromName(s))) { continue; } @@ -1008,7 +1008,7 @@ private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player a continue; } - if (!sa.allowsPayingWithShard(m.getSourceCard(), c)) { + if (!sa.allowsPayingWithShard(sourceCard, c)) { continue; } @@ -1020,7 +1020,7 @@ private static boolean canPayShardWithSpellAbility(ManaCostShard toPay, Player a return false; } - if (!sa.allowsPayingWithShard(m.getSourceCard(), MagicColor.fromName(m.getOrigProduced()))) { + if (!sa.allowsPayingWithShard(sourceCard, MagicColor.fromName(m.getOrigProduced()))) { return false; } diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index dc99fc7c8ba..ccd1fe5afac 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -411,7 +411,7 @@ private static int applyReduceCostAbility(final StaticAbility staticAbility, fin minMana = Integer.valueOf(staticAbility.getParam("MinMana")); } - final int maxReduction = Math.max(0, manaCost.getConvertedManaCost() - minMana - sumReduced); + final int maxReduction = manaCost.getConvertedManaCost() - minMana - sumReduced; if (maxReduction > 0) { return Math.min(value, maxReduction); }