diff --git a/forge-ai/src/main/java/forge/ai/AiController.java b/forge-ai/src/main/java/forge/ai/AiController.java index a21ba44c75e..9c1f45f977c 100644 --- a/forge-ai/src/main/java/forge/ai/AiController.java +++ b/forge-ai/src/main/java/forge/ai/AiController.java @@ -1859,6 +1859,8 @@ public class AiController { maxCreatures = Math.max(maxCreatures, opp.getCreaturesInPlay().size()); } return Math.min(choiceLimit, Math.max(minAllowedChoice, maxCreatures)); + } else if ("Random".equals(logic)) { + return MyRandom.getRandom().nextInt((max - min) + 1) + min; } return max; } diff --git a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java index 1233d9be5ad..5dcb8fa85c3 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityFactory.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityFactory.java @@ -53,7 +53,7 @@ public final class AbilityFactory { public static final List additionalAbilityKeys = Lists.newArrayList( "WinSubAbility", "OtherwiseSubAbility", // Clash "BidSubAbility", // BidLifeEffect - "ChooseNumberSubAbility", "Lowest", "Highest", "NotLowest", "GuessCorrect", "GuessWrong", // ChooseNumber + "ChooseNumberSubAbility", "Lowest", "Highest", "NotLowest", "GuessCorrect", "GuessWrong", "MatchedAbility", "UnmatchedAbility", // ChooseNumber "HeadsSubAbility", "TailsSubAbility", "LoseSubAbility", // FlipCoin "TrueSubAbility", "FalseSubAbility", // Branch "ChosenPile", "UnchosenPile", // MultiplePiles & TwoPiles diff --git a/forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java b/forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java index aca7c591281..a8424d67be9 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/ChooseNumberEffect.java @@ -141,6 +141,7 @@ public class ChooseNumberEffect extends SpellAbilityEffect { lowestNum.add(player); } } + boolean matched = highestNum.size() == chooseMap.size(); card.getGame().getAction().notifyOfValue(sa, card, sb.toString(), null); if (sa.hasParam("ChooseNumberSubAbility")) { SpellAbility sub = sa.getAdditionalAbility("ChooseNumberSubAbility"); @@ -208,6 +209,16 @@ public class ChooseNumberEffect extends SpellAbilityEffect { card.clearChosenNumber(); card.removeRemembered(guessPair.getKey()); } + + if (matched && sa.hasParam("MatchedAbility")) { + SpellAbility sub = sa.getAdditionalAbility("MatchedAbility"); + AbilityUtils.resolve(sub); + } + + if (!matched && sa.hasParam("UnmatchedAbility")) { + SpellAbility sub = sa.getAdditionalAbility("UnmatchedAbility"); + AbilityUtils.resolve(sub); + } } if (sa.hasParam("RememberChosen")) card.addRemembered(chooseMap.values()); diff --git a/forge-gui/res/cardsfolder/e/expert_level_safe.txt b/forge-gui/res/cardsfolder/e/expert_level_safe.txt new file mode 100644 index 00000000000..a46bae1f8c4 --- /dev/null +++ b/forge-gui/res/cardsfolder/e/expert_level_safe.txt @@ -0,0 +1,11 @@ +Name:Expert-Level Safe +ManaCost:2 +Types:Artifact +T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigExile | TriggerDescription$ When CARDNAME enters the battlefield, exile the top two cards of your library face down. +SVar:TrigExile:DB$ Dig | Defined$ You | DigNum$ 2 | ChangeNum$ All | DestinationZone$ Exile | ExileFaceDown$ True | NoReveal$ True +A:AB$ Pump | Cost$ 1 T | ValidTgts$ Opponent | TgtPrompt$ Target an opponent to choose a number 1, 2, or 3 | SubAbility$ ChooseNumber | StackDescription$ SpellDescription | SpellDescription$ You and target opponent each secretly choose 1, 2, or 3. Then those choices are revealed. If they match, sacrifice CARDNAME and put all cards exiled with it into their owners’ hands. Otherwise, exile the top card of your library face down. +SVar:ChooseNumber:DB$ ChooseNumber | Defined$ TargetedAndYou | Min$ 1 | Max$ 3 | AILogic$ Random | MatchedAbility$ DBSacrifice | UnmatchedAbility$ DBFillSafe | SecretlyChoose$ True | SpellDescription$ None +SVar:DBSacrifice:DB$ Sacrifice | Defined$ You | ValidCard$ Card.Self | SubAbility$ DBOpenSafe +SVar:DBOpenSafe:DB$ ChangeZoneAll | ChangeNum$ All | Origin$ Exile | Destination$ Hand | ChangeType$ Card.ExiledWithSource +SVar:DBFillSafe:DB$ Dig | Defined$ You | DigNum$ 1 | ChangeNum$ All | DestinationZone$ Exile | ExileFaceDown$ True | NoReveal$ True +Oracle:When Expert-Level Safe enters the battlefield, exile the top two cards of your library face down.\n{1}, {T}: You and target opponent each secretly choose 1, 2, or 3. Then those choices are revealed. If they match, sacrifice Expert-Level Safe and put all cards exiled with it into their owners’ hands. Otherwise, exile the top card of your library face down. \ No newline at end of file