Merge branch 'master' into master2

This commit is contained in:
Anthony Calosa
2024-09-09 14:39:30 +08:00
7 changed files with 41 additions and 71 deletions

View File

@@ -33,6 +33,9 @@ public class SurveilEffect extends SpellAbilityEffect {
if (sa.hasParam("Amount")) { if (sa.hasParam("Amount")) {
num = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa); num = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
} }
if (num == 0) {
return;
}
boolean isOptional = sa.hasParam("Optional"); boolean isOptional = sa.hasParam("Optional");

View File

@@ -1119,23 +1119,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
public void surveil(int num, SpellAbility cause, Map<AbilityKey, Object> params) { public void surveil(int num, SpellAbility cause, Map<AbilityKey, Object> params) {
final Map<AbilityKey, Object> repParams = AbilityKey.mapFromAffected(this); num += StaticAbilitySurveilNum.surveilNumMod(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;
}
final CardCollection topN = getTopXCardsFromLibrary(num); final CardCollection topN = getTopXCardsFromLibrary(num);

View File

@@ -97,5 +97,4 @@ public final class PlayerPredicates {
} }
public static final Predicate<Player> NOT_LOST = p -> p.getOutcome() == null || p.getOutcome().hasWon(); public static final Predicate<Player> NOT_LOST = p -> p.getOutcome() == null || p.getOutcome().hasWon();
public static final Predicate<Player> CANT_WIN = p -> p.hasKeyword("You can't win the game.");
} }

View File

@@ -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 &emsp; HashMap<String, String>
* @param host &emsp; 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));
}
}

View File

@@ -44,7 +44,6 @@ public enum ReplacementType {
RollPlanarDice(ReplaceRollPlanarDice.class), RollPlanarDice(ReplaceRollPlanarDice.class),
Scry(ReplaceScry.class), Scry(ReplaceScry.class),
SetInMotion(ReplaceSetInMotion.class), SetInMotion(ReplaceSetInMotion.class),
Surveil(ReplaceSurveil.class),
Tap(ReplaceTap.class), Tap(ReplaceTap.class),
Transform(ReplaceTransform.class), Transform(ReplaceTransform.class),
TurnFaceUp(ReplaceTurnFaceUp.class), TurnFaceUp(ReplaceTurnFaceUp.class),

View File

@@ -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"));
}
}

View File

@@ -1,9 +1,7 @@
Name:Enhanced Surveillance Name:Enhanced Surveillance
ManaCost:1 U ManaCost:1 U
Types:Enchantment Types:Enchantment
R:Event$ Surveil | ActiveZones$ Battlefield | ValidPlayer$ You | ReplaceWith$ AddTwoMore | Description$ You may look at an additional two cards each time you surveil. S:Mode$ SurveilNum | Num$ 2 | ValidPlayer$ You | Optional$ True | 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
A:AB$ ChangeZoneAll | Cost$ Exile<1/CARDNAME> | ChangeType$ Card.YouOwn | Origin$ Graveyard | Destination$ Library | Shuffle$ True | SpellDescription$ Shuffle your graveyard into your library. 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 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. Oracle:You may look at an additional two cards each time you surveil.\nExile Enhanced Surveillance: Shuffle your graveyard into your library.