From a81e15ca315c7db8c44ed5823c33db6bfed7fec8 Mon Sep 17 00:00:00 2001 From: friarsol Date: Sat, 5 Sep 2020 23:09:23 -0400 Subject: [PATCH] Adding initial handling for Party --- .../java/forge/game/card/CardFactoryUtil.java | 60 +++++++++++++++++++ .../upcoming/ZNR/acquisitions_expert.txt | 9 +++ 2 files changed, 69 insertions(+) create mode 100644 forge-gui/res/cardsfolder/upcoming/ZNR/acquisitions_expert.txt diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 7e196ff891c..36e81be690f 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -1192,6 +1192,66 @@ public class CardFactoryUtil { return doXMath(cl.size(), m, c); } + if (sq[0].contains("Party")) { + CardCollection adventurers = CardLists.getValidCards(cc.getGame().getCardsIn(ZoneType.Battlefield), + "Creature.Cleric,Creature.Rogue,Creature.Warrior,Creature.Wizard", cc, c, null); + + CardCollection changelings = CardLists.getKeyword(cc.getGame().getCardsIn(ZoneType.Battlefield), Keyword.CHANGELING); + + Set partyTypes = new HashSet<>(Arrays.asList(new String[]{"Cleric", "Rogue", "Warrior", "Wizard"})); + int partySize = 0; + + HashMap chosenParty = new HashMap<>(); + List wildcard = Lists.newArrayList(changelings); + HashMap> multityped = new HashMap<>(); + + // Figure out how to count each class separately. + for (Card card : adventurers) { + Set creatureTypes = card.getType().getCreatureTypes(); + creatureTypes.retainAll(partyTypes); + + if (creatureTypes.size() == 4) { + wildcard.add(card); + + if (wildcard.size() >= 4) { + break; + } + continue; + } else if (creatureTypes.size() == 1) { + String type = (String)(creatureTypes.toArray()[0]); + + if (!chosenParty.containsKey(type)) { + chosenParty.put(type, card); + } + } else { + multityped.put(card, creatureTypes); + } + } + + partySize = Math.min(chosenParty.size() + wildcard.size(), 4); + + if (partySize < 4) { + partyTypes.removeAll(chosenParty.keySet()); + + // Here I'm left with just the party types that I haven't selected. + for(Card multi : multityped.keySet()) { + Set types = multityped.get(multi); + types.retainAll(partyTypes); + + for(String type : types) { + chosenParty.put(type, multi); + partySize++; + partyTypes.remove(type); + break; + } + } + } + + partySize = Math.min(chosenParty.size() + wildcard.size(), 4); + + return doXMath(partySize, m, c); + } + if (sq[0].contains("CardPower")) { return doXMath(c.getNetPower(), m, c); } diff --git a/forge-gui/res/cardsfolder/upcoming/ZNR/acquisitions_expert.txt b/forge-gui/res/cardsfolder/upcoming/ZNR/acquisitions_expert.txt new file mode 100644 index 00000000000..d6f9376fc11 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/ZNR/acquisitions_expert.txt @@ -0,0 +1,9 @@ +Name:Acquisitions Expert +ManaCost:1 B +Types:Creature Human Rogue +PT:1/2 +T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ DBDiscard | TriggerDescription$ When CARDNAME enters the battlefield, target opponent reveals a number of cards from their hand equal to the number of creatures in your your party. You choose one of those cards. That player discards that card. +SVar:DBDiscard:DB$ Discard | ValidTgts$ Opponent | NumCards$ 1 | RevealNumber$ X | Mode$ RevealYouChoose | References$ X +SVar:X:Count$Party +DeckHas:Ability$Party +Oracle:When Acquisitions Expert enters the battlefield, target opponent reveals a number of cards from their hand equal to the number of creatures in your party. You choose one of those cards. That player discards that card. (Your party consists of up to one each of Cleric, Rogue, Warrior, and Wizard.) \ No newline at end of file