mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
GameAction: fixed StaticAbility for Card changes Zone
This commit is contained in:
@@ -22,6 +22,8 @@ import com.google.common.collect.Iterables;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
@@ -65,14 +67,10 @@ import forge.util.Visitor;
|
|||||||
import forge.util.maps.HashMapOfLists;
|
import forge.util.maps.HashMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
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;
|
||||||
@@ -211,6 +209,9 @@ public class GameAction {
|
|||||||
for (final ReplacementEffect repl : copied.getReplacementEffects()) {
|
for (final ReplacementEffect repl : copied.getReplacementEffects()) {
|
||||||
repl.setHostCard(copied);
|
repl.setHostCard(copied);
|
||||||
}
|
}
|
||||||
|
for (final StaticAbility sa : copied.getStaticAbilities()) {
|
||||||
|
sa.setHostCard(copied);
|
||||||
|
}
|
||||||
if (c.getName().equals("Skullbriar, the Walking Grave")) {
|
if (c.getName().equals("Skullbriar, the Walking Grave")) {
|
||||||
copied.setCounters(c.getCounters());
|
copied.setCounters(c.getCounters());
|
||||||
}
|
}
|
||||||
@@ -309,7 +310,7 @@ public class GameAction {
|
|||||||
// play the change zone sound
|
// play the change zone sound
|
||||||
game.fireEvent(new GameEventCardChangeZone(c, zoneFrom, zoneTo));
|
game.fireEvent(new GameEventCardChangeZone(c, zoneFrom, zoneTo));
|
||||||
|
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
runParams.put("Card", lastKnownInfo);
|
runParams.put("Card", lastKnownInfo);
|
||||||
runParams.put("Origin", zoneFrom != null ? zoneFrom.getZoneType().name() : null);
|
runParams.put("Origin", zoneFrom != null ? zoneFrom.getZoneType().name() : null);
|
||||||
runParams.put("Destination", zoneTo.getZoneType().name());
|
runParams.put("Destination", zoneTo.getZoneType().name());
|
||||||
@@ -317,7 +318,7 @@ public class GameAction {
|
|||||||
runParams.put("IndividualCostPaymentInstance", game.costPaymentStack.peek());
|
runParams.put("IndividualCostPaymentInstance", game.costPaymentStack.peek());
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams, false);
|
||||||
if (zoneFrom != null && zoneFrom.is(ZoneType.Battlefield)) {
|
if (zoneFrom != null && zoneFrom.is(ZoneType.Battlefield)) {
|
||||||
final HashMap<String, Object> runParams2 = new HashMap<String, Object>();
|
final Map<String, Object> runParams2 = Maps.newHashMap();
|
||||||
runParams2.put("Card", lastKnownInfo);
|
runParams2.put("Card", lastKnownInfo);
|
||||||
runParams2.put("OriginalController", zoneFrom.getPlayer());
|
runParams2.put("OriginalController", zoneFrom.getPlayer());
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams2, false);
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams2, false);
|
||||||
@@ -527,7 +528,7 @@ public class GameAction {
|
|||||||
c.setTurnInZone(tiz);
|
c.setTurnInZone(tiz);
|
||||||
c.setCameUnderControlSinceLastUpkeep(true);
|
c.setCameUnderControlSinceLastUpkeep(true);
|
||||||
|
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
runParams.put("Card", c);
|
runParams.put("Card", c);
|
||||||
runParams.put("OriginalController", original);
|
runParams.put("OriginalController", original);
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams, false);
|
||||||
@@ -758,7 +759,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||||
|
|
||||||
if (runEvents && !affectedCards.isEmpty()) {
|
if (runEvents && !affectedCards.isEmpty()) {
|
||||||
@@ -767,7 +768,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void checkStateEffects(final boolean runEvents) {
|
public final void checkStateEffects(final boolean runEvents) {
|
||||||
checkStateEffects(runEvents, new HashSet<Card>());
|
checkStateEffects(runEvents, Sets.<Card>newHashSet());
|
||||||
}
|
}
|
||||||
public final void checkStateEffects(final boolean runEvents, final Set<Card> affectedCards) {
|
public final void checkStateEffects(final boolean runEvents, final Set<Card> affectedCards) {
|
||||||
// sol(10/29) added for Phase updates, state effects shouldn't be
|
// sol(10/29) added for Phase updates, state effects shouldn't be
|
||||||
@@ -817,7 +818,7 @@ public class GameAction {
|
|||||||
// Rule 704.5f - Put into grave (no regeneration) for toughness <= 0
|
// Rule 704.5f - Put into grave (no regeneration) for toughness <= 0
|
||||||
if (c.getNetToughness() <= 0) {
|
if (c.getNetToughness() <= 0) {
|
||||||
if (noRegCreats == null) {
|
if (noRegCreats == null) {
|
||||||
noRegCreats = new LinkedList<Card>();
|
noRegCreats = Lists.newLinkedList();
|
||||||
}
|
}
|
||||||
noRegCreats.add(c);
|
noRegCreats.add(c);
|
||||||
checkAgain = true;
|
checkAgain = true;
|
||||||
@@ -825,7 +826,7 @@ public class GameAction {
|
|||||||
for (final Integer dmg : c.getReceivedDamageFromThisTurn().values()) {
|
for (final Integer dmg : c.getReceivedDamageFromThisTurn().values()) {
|
||||||
if (c.getNetToughness() <= dmg.intValue()) {
|
if (c.getNetToughness() <= dmg.intValue()) {
|
||||||
if (desCreats == null) {
|
if (desCreats == null) {
|
||||||
desCreats = new LinkedList<Card>();
|
desCreats = Lists.newLinkedList();
|
||||||
}
|
}
|
||||||
desCreats.add(c);
|
desCreats.add(c);
|
||||||
checkAgain = true;
|
checkAgain = true;
|
||||||
@@ -837,7 +838,7 @@ public class GameAction {
|
|||||||
// Rule 704.5h - Destroy due to deathtouch
|
// Rule 704.5h - Destroy due to deathtouch
|
||||||
else if (c.getNetToughness() <= c.getDamage() || c.hasBeenDealtDeathtouchDamage()) {
|
else if (c.getNetToughness() <= c.getDamage() || c.hasBeenDealtDeathtouchDamage()) {
|
||||||
if (desCreats == null) {
|
if (desCreats == null) {
|
||||||
desCreats = new LinkedList<Card>();
|
desCreats = Lists.newLinkedList();
|
||||||
}
|
}
|
||||||
desCreats.add(c);
|
desCreats.add(c);
|
||||||
c.setHasBeenDealtDeathtouchDamage(false);
|
c.setHasBeenDealtDeathtouchDamage(false);
|
||||||
@@ -1068,7 +1069,7 @@ public class GameAction {
|
|||||||
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
if (p.checkLoseCondition()) { // this will set appropriate outcomes
|
||||||
// Run triggers
|
// Run triggers
|
||||||
if (losers == null) {
|
if (losers == null) {
|
||||||
losers = new ArrayList<Player>(3);
|
losers = Lists.newArrayListWithCapacity(3);
|
||||||
}
|
}
|
||||||
losers.add(p);
|
losers.add(p);
|
||||||
}
|
}
|
||||||
@@ -1092,7 +1093,7 @@ public class GameAction {
|
|||||||
reason = null; // they cannot lose!
|
reason = null; // they cannot lose!
|
||||||
} else {
|
} else {
|
||||||
if (losers == null) {
|
if (losers == null) {
|
||||||
losers = new ArrayList<Player>(3);
|
losers = Lists.newArrayListWithCapacity(3);
|
||||||
}
|
}
|
||||||
losers.add(p);
|
losers.add(p);
|
||||||
}
|
}
|
||||||
@@ -1108,8 +1109,8 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reason == null) {
|
if (reason == null) {
|
||||||
List<Player> notLost = new ArrayList<Player>();
|
List<Player> notLost = Lists.newArrayList();
|
||||||
Set<Integer> teams = new HashSet<Integer>();
|
Set<Integer> teams = Sets.newHashSet();
|
||||||
for (Player p : allPlayers) {
|
for (Player p : allPlayers) {
|
||||||
if (p.getOutcome() == null || p.getOutcome().hasWon()) {
|
if (p.getOutcome() == null || p.getOutcome().hasWon()) {
|
||||||
notLost.add(p);
|
notLost.add(p);
|
||||||
@@ -1219,7 +1220,7 @@ public class GameAction {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Card> toKeep = new ArrayList<Card>();
|
List<Card> toKeep = Lists.newArrayList();
|
||||||
long ts = 0;
|
long ts = 0;
|
||||||
|
|
||||||
for (final Card crd : worlds) {
|
for (final Card crd : worlds) {
|
||||||
@@ -1292,7 +1293,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replacement effects
|
// Replacement effects
|
||||||
final HashMap<String, Object> repRunParams = new HashMap<String, Object>();
|
final Map<String, Object> repRunParams = Maps.newHashMap();
|
||||||
repRunParams.put("Event", "Destroy");
|
repRunParams.put("Event", "Destroy");
|
||||||
repRunParams.put("Source", sa);
|
repRunParams.put("Source", sa);
|
||||||
repRunParams.put("Card", c);
|
repRunParams.put("Card", c);
|
||||||
@@ -1311,7 +1312,7 @@ public class GameAction {
|
|||||||
game.fireEvent(new GameEventCardDestroyed());
|
game.fireEvent(new GameEventCardDestroyed());
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
runParams.put("Card", c);
|
runParams.put("Card", c);
|
||||||
runParams.put("Causer", activator);
|
runParams.put("Causer", activator);
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.Destroyed, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.Destroyed, runParams, false);
|
||||||
@@ -1465,7 +1466,7 @@ public class GameAction {
|
|||||||
checkStateEffects(true); // why?
|
checkStateEffects(true); // why?
|
||||||
|
|
||||||
// Run Trigger beginning of the game
|
// Run Trigger beginning of the game
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.NewGame, runParams, true);
|
game.getTriggerHandler().runTrigger(TriggerType.NewGame, runParams, true);
|
||||||
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
//</THIS CODE WILL WORK WITH PHASE = NULL>
|
||||||
|
|
||||||
@@ -1494,7 +1495,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Power Play - Each player with a Power Play in the CommandZone becomes the Starting Player
|
// Power Play - Each player with a Power Play in the CommandZone becomes the Starting Player
|
||||||
Set<Player> powerPlayers = new HashSet<>();
|
Set<Player> powerPlayers = Sets.newHashSet();
|
||||||
for (Card c : game.getCardsIn(ZoneType.Command)) {
|
for (Card c : game.getCardsIn(ZoneType.Command)) {
|
||||||
if (c.getName().equals("Power Play")) {
|
if (c.getName().equals("Power Play")) {
|
||||||
powerPlayers.add(c.getOwner());
|
powerPlayers.add(c.getOwner());
|
||||||
@@ -1630,7 +1631,7 @@ public class GameAction {
|
|||||||
private void runOpeningHandActions(final Player first) {
|
private void runOpeningHandActions(final Player first) {
|
||||||
Player takesAction = first;
|
Player takesAction = first;
|
||||||
do {
|
do {
|
||||||
List<SpellAbility> usableFromOpeningHand = new ArrayList<SpellAbility>();
|
List<SpellAbility> usableFromOpeningHand = Lists.newArrayList();
|
||||||
|
|
||||||
// Select what can be activated from a given hand
|
// Select what can be activated from a given hand
|
||||||
for (final Card c : takesAction.getCardsIn(ZoneType.Hand)) {
|
for (final Card c : takesAction.getCardsIn(ZoneType.Hand)) {
|
||||||
@@ -1689,7 +1690,7 @@ public class GameAction {
|
|||||||
game.setMonarch(p);
|
game.setMonarch(p);
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
runParams.put("Player", p);
|
runParams.put("Player", p);
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.BecomeMonarch, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.BecomeMonarch, runParams, false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user