Merge branch 'abandoned_sarcophagus' into 'master'

Cycling: add Flag if card is discarded for cost with cycling

See merge request core-developers/forge!3770
This commit is contained in:
Michael Kamensky
2021-02-06 11:03:29 +00:00
6 changed files with 31 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ public enum AbilityKey {
CumulativeUpkeepPaid("CumulativeUpkeepPaid"), CumulativeUpkeepPaid("CumulativeUpkeepPaid"),
CurrentCastSpells("CurrentCastSpells"), CurrentCastSpells("CurrentCastSpells"),
CurrentStormCount("CurrentStormCount"), CurrentStormCount("CurrentStormCount"),
Cycling("Cycling"),
DamageAmount("DamageAmount"), DamageAmount("DamageAmount"),
DamageMap("DamageMap"), DamageMap("DamageMap"),
DamageSource("DamageSource"), DamageSource("DamageSource"),

View File

@@ -192,7 +192,12 @@ public class CostDiscard extends CostPartWithList {
*/ */
@Override @Override
protected Card doPayment(SpellAbility ability, Card targetCard) { protected Card doPayment(SpellAbility ability, Card targetCard) {
return targetCard.getController().discard(targetCard, null, null); final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
if (ability.isCycling() && targetCard.equals(ability.getHostCard())) {
// discard itself for cycling cost
runParams.put(AbilityKey.Cycling, true);
}
return targetCard.getController().discard(targetCard, null, null, runParams);
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@@ -1583,6 +1583,9 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
public final Card discard(final Card c, final SpellAbility sa, CardZoneTable table) { public final Card discard(final Card c, final SpellAbility sa, CardZoneTable table) {
return discard(c, sa , table, null);
}
public final Card discard(final Card c, final SpellAbility sa, CardZoneTable table, Map<AbilityKey, Object> params) {
if (!c.canBeDiscardedBy(sa)) { if (!c.canBeDiscardedBy(sa)) {
return null; return null;
} }
@@ -1604,6 +1607,9 @@ public class Player extends GameEntity implements Comparable<Player> {
final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromCard(c); final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromCard(c);
repRunParams.put(AbilityKey.Source, source); repRunParams.put(AbilityKey.Source, source);
repRunParams.put(AbilityKey.Affected, this); repRunParams.put(AbilityKey.Affected, this);
if (params != null) {
repRunParams.putAll(params);
}
if (game.getReplacementHandler().run(ReplacementType.Discard, repRunParams) != ReplacementResult.NotReplaced) { if (game.getReplacementHandler().run(ReplacementType.Discard, repRunParams) != ReplacementResult.NotReplaced) {
return null; return null;
@@ -1614,16 +1620,16 @@ public class Player extends GameEntity implements Comparable<Player> {
sb.append(this).append(" discards ").append(c); sb.append(this).append(" discards ").append(c);
final Card newCard; final Card newCard;
if (discardToTopOfLibrary) { if (discardToTopOfLibrary) {
newCard = game.getAction().moveToLibrary(c, 0, sa); newCard = game.getAction().moveToLibrary(c, 0, sa, params);
sb.append(" to the library"); sb.append(" to the library");
// Play the Discard sound // Play the Discard sound
} }
else if (discardMadness) { else if (discardMadness) {
newCard = game.getAction().exile(c, sa); newCard = game.getAction().exile(c, sa, params);
sb.append(" with Madness"); sb.append(" with Madness");
} }
else { else {
newCard = game.getAction().moveToGraveyard(c, sa); newCard = game.getAction().moveToGraveyard(c, sa, params);
// Play the Discard sound // Play the Discard sound
} }
if (table != null) { if (table != null) {
@@ -1648,6 +1654,9 @@ public class Player extends GameEntity implements Comparable<Player> {
runParams.put(AbilityKey.Card, c); runParams.put(AbilityKey.Card, c);
runParams.put(AbilityKey.Cause, cause); runParams.put(AbilityKey.Cause, cause);
runParams.put(AbilityKey.IsMadness, discardMadness); runParams.put(AbilityKey.IsMadness, discardMadness);
if (params != null) {
runParams.putAll(params);
}
game.getTriggerHandler().runTrigger(TriggerType.Discarded, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.Discarded, runParams, false);
game.getGameLog().add(GameLogEntryType.DISCARD, sb.toString()); game.getGameLog().add(GameLogEntryType.DISCARD, sb.toString());
return newCard; return newCard;

View File

@@ -59,6 +59,11 @@ public class ReplaceDiscard extends ReplacementEffect {
return false; return false;
} }
} }
if (hasParam("Cycling")) {
if (getParam("Cycling").equalsIgnoreCase("True") != runParams.containsKey(AbilityKey.Cycling)) {
return false;
}
}
if (hasParam("DiscardFromEffect")) { if (hasParam("DiscardFromEffect")) {
if (null == runParams.get(AbilityKey.Source)) { if (null == runParams.get(AbilityKey.Source)) {
return false; return false;

View File

@@ -92,6 +92,12 @@ public class ReplaceMoved extends ReplacementEffect {
} }
} }
if (hasParam("Cycling")) { // Cycling is by cost, not by effect so cause is null
if (getParam("Cycling").equalsIgnoreCase("True") != runParams.containsKey(AbilityKey.Cycling)) {
return false;
}
}
if (hasParam("FoundSearchingLibrary")) { if (hasParam("FoundSearchingLibrary")) {
if (!runParams.containsKey(AbilityKey.FoundSearchingLibrary)) { if (!runParams.containsKey(AbilityKey.FoundSearchingLibrary)) {
return false; return false;

View File

@@ -2,7 +2,7 @@ Name:Abandoned Sarcophagus
ManaCost:3 ManaCost:3
Types:Artifact Types:Artifact
S:Mode$ Continuous | Affected$ Card.nonLand+YouOwn+withCycling,Card.nonLand+YouOwn+withTypeCycling | MayPlay$ True | AffectedZone$ Graveyard | Description$ You may cast nonland cards with cycling from your graveyard. S:Mode$ Continuous | Affected$ Card.nonLand+YouOwn+withCycling,Card.nonLand+YouOwn+withTypeCycling | MayPlay$ True | AffectedZone$ Graveyard | Description$ You may cast nonland cards with cycling from your graveyard.
R:Event$ Moved | ValidCard$ Card.YouOwn+withCycling,Card.YouOwn+withTypeCycling | Destination$ Graveyard | NotCause$ Activated.Cycling | ReplaceWith$ Exile | ActiveZones$ Battlefield | Description$ If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead. R:Event$ Moved | ValidCard$ Card.YouOwn+withCycling,Card.YouOwn+withTypeCycling | Destination$ Graveyard | Cycling$ False | ReplaceWith$ Exile | ActiveZones$ Battlefield | Description$ If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead.
SVar:Exile:DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Exile | Defined$ ReplacedCard SVar:Exile:DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Exile | Defined$ ReplacedCard
#TODO: Add Ability$Cycling to Cycling cards for the purpose of this and other similar cards for deck hints #TODO: Add Ability$Cycling to Cycling cards for the purpose of this and other similar cards for deck hints
AI:RemoveDeck:Random AI:RemoveDeck:Random