From 063ebf2f705b3fcdb6a9bc92c6e2769e355b452a Mon Sep 17 00:00:00 2001 From: Agetian Date: Mon, 4 Mar 2019 15:04:21 +0300 Subject: [PATCH] - Added puzzle PS_RNA5. --- .../src/main/java/forge/ai/GameState.java | 30 +++++++++++++++++++ forge-gui/res/puzzle/PS_RNA5.pzl | 18 +++++++++++ 2 files changed, 48 insertions(+) create mode 100644 forge-gui/res/puzzle/PS_RNA5.pzl diff --git a/forge-ai/src/main/java/forge/ai/GameState.java b/forge-ai/src/main/java/forge/ai/GameState.java index db79263a93e..bd4c26c19b0 100644 --- a/forge-ai/src/main/java/forge/ai/GameState.java +++ b/forge-ai/src/main/java/forge/ai/GameState.java @@ -74,6 +74,7 @@ public abstract class GameState { private final Map cardToEnchantPlayerId = new HashMap<>(); private final Map markedDamage = new HashMap<>(); private final Map> cardToChosenClrs = new HashMap<>(); + private final Map cardToChosenCards = new HashMap<>(); private final Map cardToChosenType = new HashMap<>(); private final Map> cardToRememberedId = new HashMap<>(); private final Map> cardToImprintedId = new HashMap<>(); @@ -211,6 +212,10 @@ public abstract class GameState { // Remember the IDs of imprinted cards cardsReferencedByID.add(i); } + for (Card i : card.getChosenCards()) { + // Remember the IDs of chosen cards + cardsReferencedByID.add(i); + } if (game.getCombat() != null && game.getCombat().isAttacking(card)) { // Remember the IDs of attacked planeswalkers GameEntity def = game.getCombat().getDefenderByAttacker(card); @@ -312,6 +317,17 @@ public abstract class GameState { newText.append("|NamedCard:").append(c.getNamedCard()); } + List chosenCardIds = Lists.newArrayList(); + for (Object obj : c.getChosenCards()) { + if (obj instanceof Card) { + int id = ((Card)obj).getId(); + chosenCardIds.add(String.valueOf(id)); + } + } + if (!chosenCardIds.isEmpty()) { + newText.append("|ChosenCards:").append(TextUtil.join(chosenCardIds, ",")); + } + List rememberedCardIds = Lists.newArrayList(); for (Object obj : c.getRemembered()) { if (obj instanceof Card) { @@ -552,6 +568,7 @@ public abstract class GameState { cardToExiledWithId.clear(); markedDamage.clear(); cardToChosenClrs.clear(); + cardToChosenCards.clear(); cardToChosenType.clear(); cardToScript.clear(); cardAttackMap.clear(); @@ -947,6 +964,12 @@ public abstract class GameState { Card c = entry.getKey(); c.setNamedCard(entry.getValue()); } + + // Chosen cards + for (Entry entry : cardToChosenCards.entrySet()) { + Card c = entry.getKey(); + c.setChosenCards(entry.getValue()); + } } private void handleCardAttachments() { @@ -1143,6 +1166,13 @@ public abstract class GameState { cardToChosenClrs.put(c, Arrays.asList(info.substring(info.indexOf(':') + 1).split(","))); } else if (info.startsWith("ChosenType:")) { cardToChosenType.put(c, info.substring(info.indexOf(':') + 1)); + } else if (info.startsWith("ChosenCards:")) { + CardCollection chosen = new CardCollection(); + String[] idlist = info.substring(info.indexOf(':') + 1).split(","); + for (String id : idlist) { + chosen.add(idToCard.get(Integer.parseInt(id))); + } + cardToChosenCards.put(c, chosen); } else if (info.startsWith("NamedCard:")) { cardToNamedCard.put(c, info.substring(info.indexOf(':') + 1)); } else if (info.startsWith("ExecuteScript:")) { diff --git a/forge-gui/res/puzzle/PS_RNA5.pzl b/forge-gui/res/puzzle/PS_RNA5.pzl new file mode 100644 index 00000000000..c66ddea8afa --- /dev/null +++ b/forge-gui/res/puzzle/PS_RNA5.pzl @@ -0,0 +1,18 @@ +[metadata] +Name:Possibility Storm - Ravnica Allegiance #05 +URL:http://www.possibilitystorm.com/wp-content/uploads/2019/02/102.-RNA5.jpg +Goal:Win +Turns:1 +Difficulty:Rare +Description:What the... you have no lands? Who did that? (You did that.) Start at the beginning of your first main phase as you choose targets for Fall of the Thran's second chapter ability. You just drew the final card in your library. Win this turn. +[state] +humanlife=17 +ailife=16 +turn=1 +activeplayer=human +activephase=DRAW +activephaseadvance=MAIN1 +humanhand=Enter the Unknown;Wildgrowth Walker;Depths of Desire;Merfolk Branchwalker;Song of Freyalise;Rallying Roar +humangraveyard=Plains;Hallowed Fountain;Forest;Swamp;Island;Temple Garden +humanbattlefield=Jace, Ingenious Mind-Mage|Counters:LOYALTY=3;Famished Paladin;Vona, Butcher of Magan;Tenth District Guard;Cacophodon;Path of Discovery;Fall of the Thran|Counters:LORE=1 +aibattlefield=Temple Altisaur;Everdawn Champion;Baird, Steward of Argive;Imperial Ceratops|Id:1;Dauntless Bodyguard|ChosenCards:1