mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Fix Enhanced Surveillance (#6104)
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -1119,23 +1119,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
public void surveil(int num, SpellAbility cause, Map<AbilityKey, Object> params) {
|
||||
final Map<AbilityKey, Object> 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);
|
||||
|
||||
|
||||
@@ -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<String, String>
|
||||
* @param host   Card
|
||||
*/
|
||||
public ReplaceSurveil(final Map<String, String> 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<AbilityKey, Object> 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<AbilityKey, Object> runParams, SpellAbility sa) {
|
||||
sa.setReplacingObject(AbilityKey.Player, runParams.get(AbilityKey.Affected));
|
||||
sa.setReplacingObject(AbilityKey.SurveilNum, runParams.get(AbilityKey.SurveilNum));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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),
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user