mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
CostAdjustment: add ChangesZoneAll trigger
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
@@ -27,6 +30,7 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.game.spellability.TargetChoices;
|
import forge.game.spellability.TargetChoices;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
import forge.game.staticability.StaticAbility;
|
import forge.game.staticability.StaticAbility;
|
||||||
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
|
||||||
public class CostAdjustment {
|
public class CostAdjustment {
|
||||||
@@ -150,9 +154,9 @@ public class CostAdjustment {
|
|||||||
boolean isStateChangeToFaceDown = false;
|
boolean isStateChangeToFaceDown = false;
|
||||||
if (sa.isSpell()) {
|
if (sa.isSpell()) {
|
||||||
if (((Spell) sa).isCastFaceDown()) {
|
if (((Spell) sa).isCastFaceDown()) {
|
||||||
// Turn face down to apply cost modifiers correctly
|
// Turn face down to apply cost modifiers correctly
|
||||||
originalCard.setState(CardStateName.FaceDown, false);
|
originalCard.setState(CardStateName.FaceDown, false);
|
||||||
isStateChangeToFaceDown = true;
|
isStateChangeToFaceDown = true;
|
||||||
}
|
}
|
||||||
} // isSpell
|
} // isSpell
|
||||||
|
|
||||||
@@ -179,7 +183,7 @@ public class CostAdjustment {
|
|||||||
|
|
||||||
// Reduce cost
|
// Reduce cost
|
||||||
for (final StaticAbility stAb : reduceAbilities) {
|
for (final StaticAbility stAb : reduceAbilities) {
|
||||||
applyReduceCostAbility(stAb, sa, cost);
|
applyReduceCostAbility(stAb, sa, cost);
|
||||||
}
|
}
|
||||||
if (sa.isSpell() && sa.isOffering()) { // cost reduction from offerings
|
if (sa.isSpell() && sa.isOffering()) { // cost reduction from offerings
|
||||||
adjustCostByOffering(cost, sa);
|
adjustCostByOffering(cost, sa);
|
||||||
@@ -195,6 +199,8 @@ public class CostAdjustment {
|
|||||||
if (sa.isSpell()) {
|
if (sa.isSpell()) {
|
||||||
if (sa.isDelve()) {
|
if (sa.isDelve()) {
|
||||||
sa.getHostCard().clearDelved();
|
sa.getHostCard().clearDelved();
|
||||||
|
|
||||||
|
final CardCollection delved = new CardCollection();
|
||||||
final Player pc = sa.getActivatingPlayer();
|
final Player pc = sa.getActivatingPlayer();
|
||||||
final CardCollection mutableGrave = new CardCollection(pc.getCardsIn(ZoneType.Graveyard));
|
final CardCollection mutableGrave = new CardCollection(pc.getCardsIn(ZoneType.Graveyard));
|
||||||
final CardCollectionView toExile = pc.getController().chooseCardsToDelve(cost.getUnpaidShards(ManaCostShard.GENERIC), mutableGrave);
|
final CardCollectionView toExile = pc.getController().chooseCardsToDelve(cost.getUnpaidShards(ManaCostShard.GENERIC), mutableGrave);
|
||||||
@@ -204,9 +210,17 @@ public class CostAdjustment {
|
|||||||
cardsToDelveOut.add(c);
|
cardsToDelveOut.add(c);
|
||||||
} else if (!test) {
|
} else if (!test) {
|
||||||
sa.getHostCard().addDelved(c);
|
sa.getHostCard().addDelved(c);
|
||||||
pc.getGame().getAction().exile(c);
|
delved.add(game.getAction().exile(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!delved.isEmpty()) {
|
||||||
|
final Map<ZoneType, CardCollection> triggerList = Maps.newEnumMap(ZoneType.class);
|
||||||
|
triggerList.put(ZoneType.Graveyard, delved);
|
||||||
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
|
runParams.put("Cards", triggerList);
|
||||||
|
runParams.put("Destination", ZoneType.Exile);
|
||||||
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sa.getHostCard().hasKeyword("Convoke")) {
|
else if (sa.getHostCard().hasKeyword("Convoke")) {
|
||||||
adjustCostByConvoke(cost, sa, test);
|
adjustCostByConvoke(cost, sa, test);
|
||||||
@@ -215,7 +229,7 @@ public class CostAdjustment {
|
|||||||
|
|
||||||
// Reset card state (if changed)
|
// Reset card state (if changed)
|
||||||
if (isStateChangeToFaceDown) {
|
if (isStateChangeToFaceDown) {
|
||||||
originalCard.setState(CardStateName.Original, false);
|
originalCard.setState(CardStateName.Original, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// GetSpellCostChange
|
// GetSpellCostChange
|
||||||
@@ -394,7 +408,7 @@ public class CostAdjustment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("Type")) {
|
if (params.containsKey("Type")) {
|
||||||
final String type = params.get("Type");
|
final String type = params.get("Type");
|
||||||
if (type.equals("Spell")) {
|
if (type.equals("Spell")) {
|
||||||
if (!sa.isSpell()) {
|
if (!sa.isSpell()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user