diff --git a/forge-game/src/main/java/forge/game/ability/effects/SurveilEffect.java b/forge-game/src/main/java/forge/game/ability/effects/SurveilEffect.java index e692e7f54a8..dde3c4f3912 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/SurveilEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/SurveilEffect.java @@ -33,6 +33,9 @@ public class SurveilEffect extends SpellAbilityEffect { if (sa.hasParam("Amount")) { num = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa); } + if (num == 0) { + return; + } boolean isOptional = sa.hasParam("Optional"); 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 ec72e3c81d6..e5431b25a7f 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -1119,23 +1119,7 @@ public class Player extends GameEntity implements Comparable { } public void surveil(int num, SpellAbility cause, Map params) { - final Map repParams = AbilityKey.mapFromAffected(this); - repParams.put(AbilityKey.Source, cause); - repParams.put(AbilityKey.SurveilNum, num); - if (params != null) { - repParams.putAll(params); - } - - switch (getGame().getReplacementHandler().run(ReplacementType.Surveil, repParams)) { - case NotReplaced: - break; - case Updated: { - num = (int) repParams.get(AbilityKey.SurveilNum); - break; - } - default: - return; - } + num += StaticAbilitySurveilNum.surveilNumMod(this); final CardCollection topN = getTopXCardsFromLibrary(num); diff --git a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java b/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java deleted file mode 100644 index 7f804f91c84..00000000000 --- a/forge-game/src/main/java/forge/game/replacement/ReplaceSurveil.java +++ /dev/null @@ -1,49 +0,0 @@ -package forge.game.replacement; - -import java.util.Map; - -import forge.game.ability.AbilityKey; -import forge.game.card.Card; -import forge.game.spellability.SpellAbility; - -/** - * TODO: Write javadoc for this type. - * - */ -public class ReplaceSurveil extends ReplacementEffect { - - /** - * - * ReplaceProduceMana. - * @param mapParams   HashMap - * @param host   Card - */ - public ReplaceSurveil(final Map mapParams, final Card host, final boolean intrinsic) { - super(mapParams, host, intrinsic); - } - - /* (non-Javadoc) - * @see forge.card.replacement.ReplacementEffect#canReplace(java.util.Map) - */ - @Override - public boolean canReplace(Map runParams) { - if (((int) runParams.get(AbilityKey.SurveilNum)) <= 0) { - return false; - } - if (!matchesValidParam("ValidPlayer", runParams.get(AbilityKey.Affected))) { - return false; - } - - return true; - } - - /* (non-Javadoc) - * @see forge.card.replacement.ReplacementEffect#setReplacingObjects(java.util.Map, forge.card.spellability.SpellAbility) - */ - @Override - public void setReplacingObjects(Map runParams, SpellAbility sa) { - sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected)); - sa.setReplacingObject(AbilityKey.SurveilNum, runParams.get(AbilityKey.SurveilNum)); - } - -} 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 f569f01fc8d..6e82f21b81d 100644 --- a/forge-game/src/main/java/forge/game/replacement/ReplacementType.java +++ b/forge-game/src/main/java/forge/game/replacement/ReplacementType.java @@ -44,7 +44,6 @@ public enum ReplacementType { RollPlanarDice(ReplaceRollPlanarDice.class), Scry(ReplaceScry.class), SetInMotion(ReplaceSetInMotion.class), - Surveil(ReplaceSurveil.class), Tap(ReplaceTap.class), Transform(ReplaceTransform.class), TurnFaceUp(ReplaceTurnFaceUp.class), diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilitySurveilNum.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilitySurveilNum.java new file mode 100644 index 00000000000..a39c9391d3a --- /dev/null +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilitySurveilNum.java @@ -0,0 +1,36 @@ +package forge.game.staticability; + +import forge.game.Game; +import forge.game.card.Card; +import forge.game.player.Player; +import forge.game.zone.ZoneType; + +public class StaticAbilitySurveilNum { + + static String MODE = "SurveilNum"; + + public static int surveilNumMod(Player p) { + final Game game = p.getGame(); + int mod = 0; + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.checkConditions(MODE)) { + continue; + } + mod += getSurveilMod(stAb, p); + } + } + return mod; + } + + public static int getSurveilMod(final StaticAbility stAb, final Player p) { + if (!stAb.matchesValidParam("ValidPlayer", p)) { + return 0; + } + if (stAb.hasParam("Optional") && !p.getController().confirmStaticApplication(stAb.getHostCard(), null, stAb.toString() + "?", null)) { + return 0; + } + return Integer.parseInt(stAb.getParam("Num")); + } + +} diff --git a/forge-gui/res/cardsfolder/e/enhanced_surveillance.txt b/forge-gui/res/cardsfolder/e/enhanced_surveillance.txt index c8d187a9692..67f47a7892a 100644 --- a/forge-gui/res/cardsfolder/e/enhanced_surveillance.txt +++ b/forge-gui/res/cardsfolder/e/enhanced_surveillance.txt @@ -1,9 +1,7 @@ Name:Enhanced Surveillance ManaCost:1 U Types:Enchantment -R:Event$ Surveil | ActiveZones$ Battlefield | ValidPlayer$ You | ReplaceWith$ AddTwoMore | Description$ You may look at an additional two cards each time you surveil. -SVar:AddTwoMore:DB$ ReplaceEffect | VarName$ SurveilNum | VarValue$ X -SVar:X:ReplaceCount$SurveilNum/Plus.2 +S:Mode$ SurveilNum | Num$ 2 | ValidPlayer$ You | Optional$ True | Description$ You may look at an additional two cards each time you surveil. A:AB$ ChangeZoneAll | Cost$ Exile<1/CARDNAME> | ChangeType$ Card.YouOwn | Origin$ Graveyard | Destination$ Library | Shuffle$ True | SpellDescription$ Shuffle your graveyard into your library. DeckNeeds:Ability$Surveil Oracle:You may look at an additional two cards each time you surveil.\nExile Enhanced Surveillance: Shuffle your graveyard into your library.