some small fixes

This commit is contained in:
Hanmac
2018-09-18 23:34:13 +02:00
parent b50f44d10c
commit 643dfc5092
3 changed files with 25 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import forge.game.Game;
import forge.game.ability.SpellAbilityEffect; import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
@@ -8,10 +9,14 @@ public class HauntEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card card = sa.getHostCard(); Card card = sa.getHostCard();
if (sa.usesTargeting() && !card.isToken()) { final Game game = card.getGame();
card = game.getCardState(card, null);
if (card == null) {
return;
} else if (sa.usesTargeting() && !card.isToken()) {
// haunt target but only if card is no token // haunt target but only if card is no token
final Card copy = card.getGame().getAction().exile(card, sa); final Card copy = game.getAction().exile(card, sa);
sa.getTargets().getFirstTargetedCard().addHauntedBy(copy); sa.getTargets().getFirstTargetedCard().addHauntedBy(copy);
} else if (!sa.usesTargeting() && card.getHaunting() != null) { } else if (!sa.usesTargeting() && card.getHaunting() != null) {
// unhaunt // unhaunt

View File

@@ -118,6 +118,9 @@ public class TriggerChangesZone extends Trigger {
return false; return false;
} }
SpellAbility cause = (SpellAbility) runParams2.get("Cause"); SpellAbility cause = (SpellAbility) runParams2.get("Cause");
if (cause == null) {
return false;
}
if (!cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(), if (!cause.getHostCard().isValid(getParam("ValidCause").split(","), getHostCard().getController(),
getHostCard(), null)) { getHostCard(), null)) {
return false; return false;

View File

@@ -18,9 +18,9 @@ public class TriggerChangesZoneAll extends Trigger {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final Map<ZoneType, CardCollection> moved = (Map<ZoneType, CardCollection>) runParams2.get("Cards"); final Map<ZoneType, CardCollection> moved = (Map<ZoneType, CardCollection>) runParams2.get("Cards");
if (this.mapParams.containsKey("Destination")) { if (hasParam("Destination")) {
if (!this.mapParams.get("Destination").equals("Any")) { if (!getParam("Destination").equals("Any")) {
if (!runParams2.get("Destination").equals(ZoneType.valueOf(this.mapParams.get("Destination")))) { if (!runParams2.get("Destination").equals(ZoneType.valueOf(getParam("Destination")))) {
return false; return false;
} }
} }
@@ -28,12 +28,12 @@ public class TriggerChangesZoneAll extends Trigger {
final CardCollection allCards = new CardCollection(); final CardCollection allCards = new CardCollection();
if (this.mapParams.containsKey("Origin")) { if (hasParam("Origin")) {
if (!this.mapParams.get("Origin").equals("Any")) { if (!getParam("Origin").equals("Any")) {
if (this.mapParams.get("Origin") == null) { if (getParam("Origin") == null) {
return false; return false;
} }
final List<ZoneType> origin = ZoneType.listValueOf((String)this.mapParams.get("Origin")); final List<ZoneType> origin = ZoneType.listValueOf((String)getParam("Origin"));
for (ZoneType z : origin) { for (ZoneType z : origin) {
if (moved.containsKey(z)) { if (moved.containsKey(z)) {
allCards.addAll(moved.get(z)); allCards.addAll(moved.get(z));
@@ -46,9 +46,9 @@ public class TriggerChangesZoneAll extends Trigger {
} }
} }
if (this.mapParams.containsKey("ValidCards")) { if (hasParam("ValidCards")) {
int count = CardLists.getValidCardCount(allCards, this.mapParams.get("ValidCards").split(","),this.getHostCard().getController(), int count = CardLists.getValidCardCount(allCards, getParam("ValidCards").split(","),this.getHostCard().getController(),
this.getHostCard()); this.getHostCard());
if (count == 0) { if (count == 0) {
return false; return false;
@@ -65,9 +65,9 @@ public class TriggerChangesZoneAll extends Trigger {
CardCollection allCards = new CardCollection(); CardCollection allCards = new CardCollection();
if (this.mapParams.containsKey("Origin")) { if (hasParam("Origin")) {
if (!this.mapParams.get("Origin").equals("Any") && this.mapParams.get("Origin") != null) { if (!getParam("Origin").equals("Any") && getParam("Origin") != null) {
final List<ZoneType> origin = ZoneType.listValueOf((String)this.mapParams.get("Origin")); final List<ZoneType> origin = ZoneType.listValueOf((String)getParam("Origin"));
for (ZoneType z : origin) { for (ZoneType z : origin) {
if (moved.containsKey(z)) { if (moved.containsKey(z)) {
allCards.addAll(moved.get(z)); allCards.addAll(moved.get(z));
@@ -80,8 +80,8 @@ public class TriggerChangesZoneAll extends Trigger {
} }
} }
if (this.mapParams.containsKey("ValidCards")) { if (hasParam("ValidCards")) {
allCards = CardLists.getValidCards(allCards, this.mapParams.get("ValidCards").split(","),this.getHostCard().getController(), allCards = CardLists.getValidCards(allCards, getParam("ValidCards").split(","),this.getHostCard().getController(),
this.getHostCard(), sa); this.getHostCard(), sa);
} }