Fix certain planes by triggering once for each plane left when planeswalking.

This commit is contained in:
elcnesh
2014-12-14 13:08:26 +00:00
parent 50db5c165b
commit 6fb1fd3058
3 changed files with 20 additions and 27 deletions

View File

@@ -20,6 +20,7 @@ package forge.game.player;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -2291,19 +2292,18 @@ public class Player extends GameEntity implements Comparable<Player> {
* Puts my currently active planes, if any, at the bottom of my planar deck.
*/
public void leaveCurrentPlane() {
if (!currentPlanes.isEmpty()) {
for (final Card plane : currentPlanes) {
//Run PlaneswalkedFrom triggers here.
HashMap<String,Object> runParams = new HashMap<String,Object>();
runParams.put("Card", new CardCollection(currentPlanes));
final Map<String, Object> runParams = new ImmutableMap.Builder<String, Object>().put("Card", plane).build();
game.getTriggerHandler().runTrigger(TriggerType.PlaneswalkedFrom, runParams,false);
}
for (Card c : currentPlanes) {
game.getZoneOf(c).remove(c);
c.clearControllers();
getZone(ZoneType.PlanarDeck).add(c);
for (final Card plane : currentPlanes) {
game.getZoneOf(plane).remove(plane);
plane.clearControllers();
getZone(ZoneType.PlanarDeck).add(plane);
}
currentPlanes.clear();
}
//DBG
//System.out.println("CurrentPlanes: " + currentPlanes);

View File

@@ -30,33 +30,26 @@ public class TriggerPlaneswalkedFrom extends Trigger {
/* (non-Javadoc)
* @see forge.card.trigger.Trigger#performTest(java.util.Map)
*/
@SuppressWarnings("unchecked")
@Override
public boolean performTest(Map<String, Object> runParams2) {
public boolean performTest(final Map<String, Object> runParams2) {
if (this.mapParams.containsKey("ValidCard")) {
for(Card moved : (Iterable<Card>)runParams2.get("Card"))
{
if (moved.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(),
this.getHostCard())) {
final Card moved = (Card) runParams2.get("Card");
if (moved.isValid(this.mapParams.get("ValidCard").split(","), this
.getHostCard().getController(), this.getHostCard())) {
return true;
}
}
return false;
}
return true;
}
/* (non-Javadoc)
* @see forge.card.trigger.Trigger#setTriggeringObjects(forge.card.spellability.SpellAbility)
*/
@Override
public void setTriggeringObjects(SpellAbility sa) {
sa.setTriggeringObject("Cards", this.getRunParams().get("Card"));
// The 'Card' triggered object above is actually an array list of the current planes being left,
// so the actual source has to be determined differently than usual
sa.setTriggeringObject("Source", this.hostCard);
public void setTriggeringObjects(final SpellAbility sa) {
sa.setTriggeringObject("Card", this.getRunParams().get("Card"));
}
}

View File

@@ -8,7 +8,7 @@ SVar:Eruption:AB$ DamageAll | Cost$ 0 | ValidCards$ Creature,Planeswalker | Vali
T:Mode$ PlanarDice | Result$ Chaos | TriggerZones$ Command | Execute$ RolledChaos | TriggerDescription$ Whenever you roll {C}, prevent all damage that planes named CARDNAME would deal this game to permanents you control.
SVar:RolledChaos:AB$ Effect | Cost$ 0 | Name$ Mount Keralia Effect | StaticAbilities$ KeraliaProtection | EffectOwner$ You | Duration$ Permanent | SpellDescription$ Prevent all damage that planes named CARDNAME would deal this game to permanents you control.
SVar:KeraliaProtection:Mode$ PreventDamage | EffectZone$ Command | Target$ Permanent.YouCtrl | Source$ Plane.namedMount Keralia | Description$ Prevent all damage that planes named Mount Keralia would deal this game to permanents you control.
SVar:KeraliaX:TriggeredSource$CardCounters.PRESSURE
SVar:KeraliaX:TriggeredCard$CardCounters.PRESSURE
SVar:AIRollPlanarDieParams:Mode$ Always | LowPriority$ True
SVar:Picture:http://www.wizards.com/global/images/magic/general/mount_keralia.jpg
Oracle:At the beginning of your end step, put a pressure counter on Mount Keralia.\nWhen you planeswalk away from Mount Keralia, it deals damage equal to the number of pressure counters on it to each creature and each planeswalker.\nWhenever you roll {C}, prevent all damage that planes named Mount Keralia would deal this game to permanents you control.