Skip to content

Commit

Permalink
* Enters battlefield, played land triggered abilities - fixed multipl…
Browse files Browse the repository at this point in the history
…e rollback errors on missing target;
  • Loading branch information
JayDi85 committed Dec 24, 2019
1 parent 9cf1ee2 commit 49ea020
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 104 deletions.
7 changes: 3 additions & 4 deletions Mage.Sets/src/mage/cards/a/AetherCharge.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
Expand All @@ -20,8 +18,9 @@
import mage.game.permanent.Permanent;
import mage.target.common.TargetOpponentOrPlaneswalker;

import java.util.UUID;

/**
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public final class AetherCharge extends CardImpl {
Expand Down Expand Up @@ -69,7 +68,7 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.isCreature() && permanent.hasSubtype(SubType.BEAST, game)
if (permanent != null && permanent.isCreature() && permanent.hasSubtype(SubType.BEAST, game)
&& permanent.isControlledBy(this.controllerId)) {
Effect effect = this.getEffects().get(0);
effect.setValue("damageSource", event.getTargetId());
Expand Down
10 changes: 5 additions & 5 deletions Mage.Sets/src/mage/cards/a/AngelicChorus.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
Expand All @@ -16,14 +14,15 @@
import mage.game.permanent.Permanent;
import mage.players.Player;

import java.util.UUID;

/**
*
* @author Backfir3
*/
public final class AngelicChorus extends CardImpl {

public AngelicChorus(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{W}");

// Whenever a creature enters the battlefield under your control, you gain life equal to its toughness.
this.addAbility(new AngelicChorusTriggeredAbility());
Expand Down Expand Up @@ -57,7 +56,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.isCreature()
if (permanent != null
&& permanent.isCreature()
&& permanent.isControlledBy(this.controllerId)) {
this.getEffects().get(0).setValue("lifeSource", event.getTargetId());
return true;
Expand Down
7 changes: 4 additions & 3 deletions Mage.Sets/src/mage/cards/a/ArchonOfRedemption.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.a;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.GainLifeEffect;
Expand All @@ -16,6 +14,8 @@
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;

import java.util.UUID;

/**
* @author Loki
*/
Expand Down Expand Up @@ -66,7 +66,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.isControlledBy(getControllerId())
if (permanent != null
&& permanent.isControlledBy(getControllerId())
&& permanent.isCreature()
&& (permanent.getId().equals(getSourceId())
|| (permanent.getAbilities().contains(FlyingAbility.getInstance())))) {
Expand Down
22 changes: 10 additions & 12 deletions Mage.Sets/src/mage/cards/a/AwesomePresence.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
package mage.cards.a;

import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
import mage.abilities.effects.PayCostToAttackBlockEffectImpl.RestrictType;
import mage.abilities.effects.common.AttachEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;

import java.util.UUID;

/**
*
* @author jeffwadsworth
*/
public final class AwesomePresence extends CardImpl {
Expand Down Expand Up @@ -63,7 +62,7 @@ public AwesomePresenceRestrictionEffect(ManaCosts manaCosts) {
+ " can't be blocked "
+ "unless defending player pays "
+ (manaCosts == null ? "" : manaCosts.getText()
+ " for each creature they control that's blocking it");
+ " for each creature they control that's blocking it");
}

public AwesomePresenceRestrictionEffect(AwesomePresenceRestrictionEffect effect) {
Expand All @@ -77,13 +76,12 @@ public boolean applies(GameEvent event, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (blockingCreature != null
&& enchantedAttackingCreature != null
&& enchantment != null
&& enchantment.isAttachedTo(enchantedAttackingCreature.getId())) {
Player defendingPlayer = game.getPlayer(blockingCreature.getControllerId());
if (defendingPlayer != null) {
if (manaCosts.canPay(source, source.getSourceId(), defendingPlayer.getId(), game)
&& manaCosts.pay(source, game, source.getSourceId(), defendingPlayer.getId(), false)) {
return false;
}
return !manaCosts.canPay(source, source.getSourceId(), defendingPlayer.getId(), game)
|| !manaCosts.pay(source, game, source.getSourceId(), defendingPlayer.getId(), false);
}
}
return true;
Expand Down
6 changes: 3 additions & 3 deletions Mage.Sets/src/mage/cards/b/Burgeoning.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.b;

import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
import mage.cards.CardImpl;
Expand All @@ -14,6 +12,8 @@
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;

import java.util.UUID;

/**
* @author duncant
*/
Expand Down Expand Up @@ -54,7 +54,7 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanent(event.getTargetId());
return game.getOpponents(controllerId).contains(land.getControllerId());
return land != null && game.getOpponents(controllerId).contains(land.getControllerId());
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions Mage.Sets/src/mage/cards/c/CityOfTraitors.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

package mage.cards.c;

import java.util.Objects;
import java.util.UUID;
import mage.Mana;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.common.TapSourceCost;
Expand All @@ -17,14 +14,16 @@
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;

import java.util.Objects;
import java.util.UUID;

/**
*
* @author jeffwadsworth
*/
public final class CityOfTraitors extends CardImpl {

public CityOfTraitors(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");

// When you play another land, sacrifice City of Traitors.
this.addAbility(new CityOfTraitorsTriggeredAbility());
Expand Down Expand Up @@ -61,7 +60,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanent(event.getTargetId());
return land.isLand()
return land != null
&& land.isLand()
&& land.isControlledBy(this.controllerId)
&& !Objects.equals(event.getTargetId(), this.getSourceId());
}
Expand Down
9 changes: 4 additions & 5 deletions Mage.Sets/src/mage/cards/d/DirtcowlWurm.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.d;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
Expand All @@ -16,14 +14,15 @@
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;

import java.util.UUID;

/**
*
* @author fireshoes
*/
public final class DirtcowlWurm extends CardImpl {

public DirtcowlWurm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}");
this.subtype.add(SubType.WURM);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
Expand Down Expand Up @@ -59,7 +58,7 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanent(event.getTargetId());
return game.getOpponents(controllerId).contains(land.getControllerId());
return land != null && game.getOpponents(controllerId).contains(land.getControllerId());
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions Mage.Sets/src/mage/cards/f/FlayerOfTheHatebound.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

package mage.cards.f;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
Expand All @@ -11,8 +9,8 @@
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
Expand All @@ -22,14 +20,15 @@
import mage.players.Player;
import mage.target.common.TargetAnyTarget;

import java.util.UUID;

/**
*
* @author BetaSteward
*/
public final class FlayerOfTheHatebound extends CardImpl {

public FlayerOfTheHatebound(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{R}");
this.subtype.add(SubType.DEVIL);

this.power = new MageInt(4);
Expand Down Expand Up @@ -71,7 +70,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (((EntersTheBattlefieldEvent) event).getFromZone() == Zone.GRAVEYARD
if (permanent != null
&& ((EntersTheBattlefieldEvent) event).getFromZone() == Zone.GRAVEYARD
&& permanent.isOwnedBy(controllerId)
&& permanent.isCreature()) {
Effect effect = this.getEffects().get(0);
Expand Down
17 changes: 8 additions & 9 deletions Mage.Sets/src/mage/cards/f/FreyalisesWinds.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mage.cards.f;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTappedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
Expand All @@ -9,19 +8,16 @@
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;

import java.util.UUID;

/**
*
* @author jeffwadsworth
*/
public final class FreyalisesWinds extends CardImpl {
Expand Down Expand Up @@ -73,8 +69,11 @@ public boolean apply(Game game, Ability source) {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanentUntapping = game.getPermanent(event.getTargetId());
permanentUntapping.removeCounters(CounterType.WIND.createInstance(), game);
return true;
if (permanentUntapping != null) {
permanentUntapping.removeCounters(CounterType.WIND.createInstance(), game);
return true;
}
return false;
}

@Override
Expand Down
5 changes: 2 additions & 3 deletions Mage.Sets/src/mage/cards/j/Jokulmorder.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package mage.cards.j;

import mage.MageInt;
Expand Down Expand Up @@ -27,7 +26,6 @@
import java.util.UUID;

/**
*
* @author fireshoes
*/
public final class Jokulmorder extends CardImpl {
Expand Down Expand Up @@ -85,7 +83,8 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent land = game.getPermanent(event.getTargetId());
return land.hasSubtype(SubType.ISLAND, game)
return land != null
&& land.hasSubtype(SubType.ISLAND, game)
&& land.isControlledBy(this.controllerId);
}

Expand Down
Loading

0 comments on commit 49ea020

Please sign in to comment.