Prevent graveyard opening after resolving a removal spell with another spell targeting that creature below it that will now be countered

This commit is contained in:
drdev
2014-07-21 04:49:56 +00:00
parent 21d223908a
commit 7e4057b492
2 changed files with 37 additions and 14 deletions

View File

@@ -20,11 +20,13 @@ package forge.game.spellability;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.trigger.TriggerType; import forge.game.trigger.TriggerType;
import forge.game.zone.ZoneType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
@@ -76,6 +78,9 @@ public class SpellAbilityStackInstance {
private final HashMap<String, String> storedSVars = new HashMap<String, String>(); private final HashMap<String, String> storedSVars = new HashMap<String, String>();
private final List<ZoneType> zonesToOpen;
private final Map<Player, Object> playersWithValidTargets;
/** /**
* <p> * <p>
* Constructor for SpellAbility_StackInstance. * Constructor for SpellAbility_StackInstance.
@@ -125,6 +130,25 @@ public class SpellAbilityStackInstance {
source.setSVar(store, ""); source.setSVar(store, "");
} }
} }
//store zones to open and players to open them for at the time the SpellAbility first goes on the stack based on the selected targets
if (tc == null) {
zonesToOpen = null;
playersWithValidTargets = null;
}
else {
zonesToOpen = new ArrayList<ZoneType>();
playersWithValidTargets = new HashMap<Player, Object>();
for (Card card : tc.getTargetCards()) {
ZoneType zoneType = card.getZone() != null ? card.getZone().getZoneType() : null;
if (zoneType != ZoneType.Battlefield) { //don't need to worry about targets on battlefield
if (zoneType != null && !zonesToOpen.contains(zoneType)) {
zonesToOpen.add(zoneType);
}
playersWithValidTargets.put(card.getController(), null);
}
}
}
} }
/** /**
@@ -252,6 +276,14 @@ public class SpellAbilityStackInstance {
return this.tc; return this.tc;
} }
public final List<ZoneType> getZonesToOpen() {
return this.zonesToOpen;
}
public final Map<Player, Object> getPlayersWithValidTargets() {
return this.playersWithValidTargets;
}
public void updateTarget(TargetChoices target) { public void updateTarget(TargetChoices target) {
if (target != null) { if (target != null) {
this.tc = target; this.tc = target;

View File

@@ -1,10 +1,9 @@
package forge.screens.match.views; package forge.screens.match.views;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
@@ -68,19 +67,11 @@ public class VStack extends FDropDown {
//temporarily reveal zones targeted by active stack instance //temporarily reveal zones targeted by active stack instance
private void revealTargetZones() { private void revealTargetZones() {
if (activeStackInstance == null || activeStackInstance.getTargetChoices() == null) { return; } if (activeStackInstance == null) { return; }
final List<ZoneType> zones = new ArrayList<ZoneType>(); final List<ZoneType> zones = activeStackInstance.getZonesToOpen();
playersWithValidTargets = new HashMap<Player, Object>(); playersWithValidTargets = activeStackInstance.getPlayersWithValidTargets();
for (Card card : activeStackInstance.getTargetChoices().getTargetCards()) { if (zones != null && zones.size() > 0 && playersWithValidTargets != null && playersWithValidTargets.size() > 0) {
ZoneType zoneType = card.getZone() != null ? card.getZone().getZoneType() : null;
if (zoneType != null && !zones.contains(zoneType)) {
zones.add(zoneType);
}
playersWithValidTargets.put(card.getController(), null);
}
if (zones.size() > 0 && playersWithValidTargets.size() > 0) {
GuiBase.getInterface().openZones(zones, playersWithValidTargets); GuiBase.getInterface().openZones(zones, playersWithValidTargets);
} }
} }