From d0466ff6f3dcf9b94ccb91a378aa426610d56680 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Mon, 1 Nov 2021 09:21:50 -0500 Subject: [PATCH] [VOW] Implemented Investigator's Journal --- .../mage/cards/i/InvestigatorsJournal.java | 105 ++++++++++++++++++ .../src/mage/sets/InnistradCrimsonVow.java | 1 + .../main/java/mage/counters/CounterType.java | 1 + 3 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java diff --git a/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java b/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java new file mode 100644 index 00000000000..3f1f730870e --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/InvestigatorsJournal.java @@ -0,0 +1,105 @@ +package mage.cards.i; + +import java.util.HashMap; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.constants.SubType; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author weirddan455 + */ +public final class InvestigatorsJournal extends CardImpl { + + public InvestigatorsJournal(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); + + this.subtype.add(SubType.CLUE); + + // Investigator's Journal enters the battlefield with a number of suspect counters on it equal to the greatest number of creatures a player controls. + this.addAbility(new EntersBattlefieldAbility( + new AddCountersSourceEffect(CounterType.SUSPECT.createInstance(), InvestigatorsJournalValue.instance, false), + "with a number of suspect counters on it equal to the greatest number of creatures a player controls" + )); + + // {2}, {T}, Remove a suspect counter from Investigator's Journal: Draw a card. + Ability ability = new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new GenericManaCost(2)); + ability.addCost(new TapSourceCost()); + ability.addCost(new RemoveCountersSourceCost(CounterType.SUSPECT.createInstance())); + this.addAbility(ability); + + // {2}, Sacrifice Investigator's Journal: Draw a card. + ability = new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new GenericManaCost(2)); + ability.addCost(new SacrificeSourceCost()); + this.addAbility(ability); + } + + private InvestigatorsJournal(final InvestigatorsJournal card) { + super(card); + } + + @Override + public InvestigatorsJournal copy() { + return new InvestigatorsJournal(this); + } +} + +enum InvestigatorsJournalValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + HashMap creatureCounts = new HashMap<>(); + for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { + creatureCounts.put(playerId, 0); + } + for (Permanent permanent : game.getBattlefield().getAllPermanents()) { + if (permanent.isPhasedIn() && permanent.isCreature(game)) { + UUID controllerId = permanent.getControllerId(); + Integer count = creatureCounts.get(controllerId); + if (count != null) { + creatureCounts.put(controllerId, count + 1); + } + } + } + int greatestCreatureCount = 0; + for (Integer count : creatureCounts.values()) { + if (count > greatestCreatureCount) { + greatestCreatureCount = count; + } + } + return greatestCreatureCount; + } + + @Override + public InvestigatorsJournalValue copy() { + return instance; + } + + @Override + public String toString() { + return "X"; + } + + @Override + public String getMessage() { + return "greatest number of creatures a player controls"; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java index 7c811f0bf03..a86f7d04d9a 100644 --- a/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java +++ b/Mage.Sets/src/mage/sets/InnistradCrimsonVow.java @@ -62,6 +62,7 @@ public final class InnistradCrimsonVow extends ExpansionSet { cards.add(new SetCardInfo("Gryff Rider", 15, Rarity.COMMON, mage.cards.g.GryffRider.class)); cards.add(new SetCardInfo("Halana and Alena, Partners", 239, Rarity.RARE, mage.cards.h.HalanaAndAlenaPartners.class)); cards.add(new SetCardInfo("Hallowed Haunting", 17, Rarity.MYTHIC, mage.cards.h.HallowedHaunting.class)); + cards.add(new SetCardInfo("Investigator's Journal", 258, Rarity.RARE, mage.cards.i.InvestigatorsJournal.class)); cards.add(new SetCardInfo("Island", 270, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Kessig Wolfrider", 165, Rarity.RARE, mage.cards.k.KessigWolfrider.class)); cards.add(new SetCardInfo("Kindly Ancestor", 22, Rarity.COMMON, mage.cards.k.KindlyAncestor.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index a45df4ff756..a764ba0ac38 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -162,6 +162,7 @@ public enum CounterType { STORAGE("storage"), STRIFE("strife"), STUDY("study"), + SUSPECT("suspect"), TASK("task"), THEFT("theft"), TIDE("tide"),