From 1053b3fdeafadb57e30954ff42e01ca76ae91a67 Mon Sep 17 00:00:00 2001 From: swordshine Date: Wed, 24 Jun 2020 22:08:15 +0800 Subject: [PATCH] JMP: Add Bruvac the Grandiloquent --- .../main/java/forge/game/player/Player.java | 22 +++++- .../forge/game/replacement/ReplaceMill.java | 71 +++++++++++++++++++ .../game/replacement/ReplacementType.java | 1 + .../upcoming/bruvac_the_grandiloquent.txt | 9 +++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 forge-game/src/main/java/forge/game/replacement/ReplaceMill.java create mode 100644 forge-gui/res/cardsfolder/upcoming/bruvac_the_grandiloquent.txt diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index fd2ac8a9e6b..80007185ec7 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1662,11 +1662,31 @@ public class Player extends GameEntity implements Comparable { return notes.get(notedFor); } - public final CardCollectionView mill(final int n, final ZoneType destination, + public final CardCollectionView mill(int n, final ZoneType destination, final boolean bottom, SpellAbility sa, CardZoneTable table) { final CardCollectionView lib = getCardsIn(ZoneType.Library); final CardCollection milled = new CardCollection(); + // Replacement effects + final Map repRunParams = AbilityKey.mapFromAffected(this); + repRunParams.put(AbilityKey.Number, n); + repRunParams.put(AbilityKey.Destination, destination); + + switch (getGame().getReplacementHandler().run(ReplacementType.Mill, repRunParams)) { + case NotReplaced: + break; + case Updated: + // check if this is still the affected player + if (this.equals(repRunParams.get(AbilityKey.Affected))) { + n = (int) repRunParams.get(AbilityKey.Number); + } else { + return milled; + } + break; + default: + return milled; + } + final int max = Math.min(n, lib.size()); for (int i = 0; i < max; i++) { diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceMill.java b/forge-game/src/main/java/forge/game/replacement/ReplaceMill.java new file mode 100644 index 00000000000..608081f6204 --- /dev/null +++ b/forge-game/src/main/java/forge/game/replacement/ReplaceMill.java @@ -0,0 +1,71 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package forge.game.replacement; + +import forge.game.ability.AbilityKey; +import forge.game.card.Card; +import forge.game.spellability.SpellAbility; +import forge.game.zone.ZoneType; + +import java.util.Map; + +/** + * TODO: Write javadoc for this type. + * + */ +public class ReplaceMill extends ReplacementEffect { + + /** + * Instantiates a new replace mill. + * + * @param params the params + * @param host the host + */ + public ReplaceMill(final Map params, final Card host, final boolean intrinsic) { + super(params, host, intrinsic); + } + + /* (non-Javadoc) + * @see forge.card.replacement.ReplacementEffect#canReplace(java.util.HashMap) + */ + @Override + public boolean canReplace(Map runParams) { + + if (ZoneType.Graveyard != ((ZoneType) runParams.get(AbilityKey.Destination))) { + return false; + } + if (hasParam("ValidPlayer")) { + if (!matchesValid(runParams.get(AbilityKey.Affected), getParam("ValidPlayer").split(","), getHostCard())) { + return false; + } + } + + return true; + } + + + + /* (non-Javadoc) + * @see forge.card.replacement.ReplacementEffect#setReplacingObjects(java.util.HashMap, forge.card.spellability.SpellAbility) + */ + @Override + public void setReplacingObjects(Map runParams, SpellAbility sa) { + sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected)); + sa.setReplacingObject(AbilityKey.Number, runParams.get(AbilityKey.Number)); + } +} diff --git a/forge-game/src/main/java/forge/game/replacement/ReplacementType.java b/forge-game/src/main/java/forge/game/replacement/ReplacementType.java index 9ddaa8dd6d7..5fbcce04d8a 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplacementType.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplacementType.java @@ -21,6 +21,7 @@ public enum ReplacementType { DrawCards(ReplaceDrawCards.class), GainLife(ReplaceGainLife.class), GameLoss(ReplaceGameLoss.class), + Mill(ReplaceMill.class), Moved(ReplaceMoved.class), ProduceMana(ReplaceProduceMana.class), SetInMotion(ReplaceSetInMotion.class), diff --git a/forge-gui/res/cardsfolder/upcoming/bruvac_the_grandiloquent.txt b/forge-gui/res/cardsfolder/upcoming/bruvac_the_grandiloquent.txt new file mode 100644 index 00000000000..3ff19e8fa9b --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/bruvac_the_grandiloquent.txt @@ -0,0 +1,9 @@ +Name:Bruvac the Grandiloquent +ManaCost:2 U +Types:Legendary Creature Human Advisor +PT:1/4 +R:Event$ Mill | ActiveZones$ Battlefield | ValidPlayer$ Player.Opponent | ReplaceWith$ MillTwice | Description$ If an opponent would mill one or more cards, they mill twice that many cards instead. (To mill a card, a player puts the top card of their library into their graveyard.) +SVar:MillTwice:DB$ ReplaceEffect | VarName$ Number | VarValue$ X | References$ X +SVar:X:ReplaceCount$Number/Twice +DeckHints:Ability$Mill +Oracle:If an opponent would mill one or more cards, they mill twice that many cards instead. (To mill a card, a player puts the top card of their library into their graveyard.)