* C17 Enchantment Curses - Fixed a bug that could create game errors (index out of bounds).

This commit is contained in:
LevelX2 2017-08-17 21:36:55 +02:00
parent 0affb45264
commit db93e3f672
16 changed files with 179 additions and 159 deletions

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.game; package mage.game;
import mage.game.match.MatchImpl; import mage.game.match.MatchImpl;

View file

@ -158,7 +158,7 @@ public final class CombatUtil {
public static CombatInfo blockWithGoodTrade(Game game, List<Permanent> attackers, List<Permanent> blockers) { public static CombatInfo blockWithGoodTrade(Game game, List<Permanent> attackers, List<Permanent> blockers) {
UUID attackerId = game.getCombat().getAttackerId(); UUID attackerId = game.getCombat().getAttackingPlayerId();
UUID defenderId = game.getCombat().getDefenders().iterator().next(); UUID defenderId = game.getCombat().getDefenders().iterator().next();
if (attackerId == null || defenderId == null) { if (attackerId == null || defenderId == null) {
log.warn("Couldn't find attacker or defender: " + attackerId + ' ' + defenderId); log.warn("Couldn't find attacker or defender: " + attackerId + ' ' + defenderId);
@ -295,7 +295,7 @@ public final class CombatUtil {
public static CombatInfo blockWithGoodTrade2(Game game, List<Permanent> attackers, List<Permanent> blockers) { public static CombatInfo blockWithGoodTrade2(Game game, List<Permanent> attackers, List<Permanent> blockers) {
UUID attackerId = game.getCombat().getAttackerId(); UUID attackerId = game.getCombat().getAttackingPlayerId();
UUID defenderId = game.getCombat().getDefenders().iterator().next(); UUID defenderId = game.getCombat().getDefenders().iterator().next();
if (attackerId == null || defenderId == null) { if (attackerId == null || defenderId == null) {
log.warn("Couldn't find attacker or defender: " + attackerId + ' ' + defenderId); log.warn("Couldn't find attacker or defender: " + attackerId + ' ' + defenderId);

View file

@ -108,7 +108,7 @@ class AdmiralAckbarTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
return game.getCombat().getAttackers().size() >= 2 && game.getCombat().getAttackerId().equals(getControllerId()); return game.getCombat().getAttackers().size() >= 2 && game.getCombat().getAttackingPlayerId().equals(getControllerId());
} }
@Override @Override

View file

@ -84,7 +84,7 @@ public class CitadelSiege extends CardImpl {
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (this.getAbilities().contains(ability) && ability.getRule().startsWith("&bull Dragons")) { if (this.getAbilities().contains(ability) && ability.getRule().startsWith("&bull Dragons")) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls"); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls");
filter.add(new ControllerIdPredicate(game.getCombat().getAttackerId())); filter.add(new ControllerIdPredicate(game.getCombat().getAttackingPlayerId()));
ability.getTargets().clear(); ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanent(filter)); ability.addTarget(new TargetCreaturePermanent(filter));
} }

View file

@ -49,6 +49,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.UntapAllControllerEffect; import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.filter.common.FilterNonlandPermanent; import mage.filter.common.FilterNonlandPermanent;
import mage.game.combat.CombatGroup;
import mage.players.Player; import mage.players.Player;
/** /**
@ -69,9 +70,7 @@ public class CurseOfBounty extends CardImpl {
// Whenever enchanted player is attacked, untap all nonland permanents you control. // Whenever enchanted player is attacked, untap all nonland permanents you control.
// Each opponent attacking that player untaps all nonland permanents he or she controls. // Each opponent attacking that player untaps all nonland permanents he or she controls.
Ability ability = new CurseOfBountyTriggeredAbility(); this.addAbility(new CurseOfBountyTriggeredAbility());
ability.addEffect(new UntapAllControllerEffect(new FilterNonlandPermanent()));
this.addAbility(ability);
} }
public CurseOfBounty(final CurseOfBounty card) { public CurseOfBounty(final CurseOfBounty card) {
@ -87,7 +86,7 @@ public class CurseOfBounty extends CardImpl {
class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl { class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfBountyTriggeredAbility() { public CurseOfBountyTriggeredAbility() {
super(Zone.BATTLEFIELD, new UntapAllNonlandsTargetEffect(), false); super(Zone.BATTLEFIELD, new UntapAllControllerEffect(new FilterNonlandPermanent()), false);
} }
public CurseOfBountyTriggeredAbility(final CurseOfBountyTriggeredAbility ability) { public CurseOfBountyTriggeredAbility(final CurseOfBountyTriggeredAbility ability) {
@ -101,18 +100,22 @@ class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
UUID controller = this.getControllerId(); Player controller = game.getPlayer(getControllerId());
if (enchantment != null if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) { for (CombatGroup group : game.getCombat().getBlockingGroups()) {
for (Effect effect: this.getEffects()) { if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
} Effect effect = new UntapAllNonlandsTargetEffect();
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
} }
return true; return true;
} }
}
}
return false; return false;
} }

View file

@ -102,7 +102,7 @@ class CurseOfChaosTriggeredAbility extends TriggeredAbilityImpl {
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (Effect effect: this.getEffects()) { for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
} }
return true; return true;
} }

View file

@ -27,10 +27,12 @@
*/ */
package mage.cards.c; package mage.cards.c;
import mage.abilities.Ability; import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -39,15 +41,14 @@ import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.game.permanent.token.ZombieToken;
/** /**
* *
@ -66,9 +67,7 @@ public class CurseOfDisturbance extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName())); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, create a 2/2 black Zombie creature token. Each opponent attacking that player does the same. // Whenever enchanted player is attacked, create a 2/2 black Zombie creature token. Each opponent attacking that player does the same.
Ability ability = new CurseOfDisturbanceTriggeredAbility(); this.addAbility(new CurseOfDisturbanceTriggeredAbility());
ability.addEffect(new CreateTokenEffect(new ZombieToken()));
this.addAbility(ability);
} }
public CurseOfDisturbance(final CurseOfDisturbance card) { public CurseOfDisturbance(final CurseOfDisturbance card) {
@ -84,7 +83,7 @@ public class CurseOfDisturbance extends CardImpl {
class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl { class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfDisturbanceTriggeredAbility() { public CurseOfDisturbanceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenTargetEffect(new ZombieToken()), false); super(Zone.BATTLEFIELD, new CreateTokenEffect(new ZombieToken()), false);
} }
public CurseOfDisturbanceTriggeredAbility(final CurseOfDisturbanceTriggeredAbility ability) { public CurseOfDisturbanceTriggeredAbility(final CurseOfDisturbanceTriggeredAbility ability) {
@ -98,18 +97,22 @@ class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
UUID controller = this.getControllerId(); Player controller = game.getPlayer(getControllerId());
if (enchantment != null if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) { for (CombatGroup group : game.getCombat().getBlockingGroups()) {
for (Effect effect: this.getEffects()) { if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
} Effect effect = new CreateTokenTargetEffect(new ZombieToken());
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
} }
return true; return true;
} }
}
}
return false; return false;
} }

View file

@ -102,7 +102,7 @@ class CurseOfInertiaTriggeredAbility extends TriggeredAbilityImpl {
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
TargetPermanent target = new TargetPermanent(); TargetPermanent target = new TargetPermanent();
target.setTargetController(game.getCombat().getAttackerId()); target.setTargetController(game.getCombat().getAttackingPlayerId());
addTarget(target); addTarget(target);
return true; return true;
} }

View file

@ -28,8 +28,8 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect; import mage.abilities.effects.common.CreateTokenTargetEffect;
@ -46,6 +46,7 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.token.GoldToken; import mage.game.permanent.token.GoldToken;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -67,9 +68,7 @@ public class CurseOfOpulence extends CardImpl {
// Whenever enchanted player is attacked, create a colorless artifact token named Gold. // Whenever enchanted player is attacked, create a colorless artifact token named Gold.
// It has "sacrifice this artifact: Add one mana of any color to your mana pool." Each opponent attacking that player does the same. // It has "sacrifice this artifact: Add one mana of any color to your mana pool." Each opponent attacking that player does the same.
Ability ability = new CurseOfOpulenceTriggeredAbility(); this.addAbility(new CurseOfOpulenceTriggeredAbility());
ability.addEffect(new CreateTokenEffect(new GoldToken()));
this.addAbility(ability);
} }
public CurseOfOpulence(final CurseOfOpulence card) { public CurseOfOpulence(final CurseOfOpulence card) {
@ -85,7 +84,7 @@ public class CurseOfOpulence extends CardImpl {
class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl { class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfOpulenceTriggeredAbility() { public CurseOfOpulenceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenTargetEffect(new GoldToken()), false); super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoldToken()), false);
} }
public CurseOfOpulenceTriggeredAbility(final CurseOfOpulenceTriggeredAbility ability) { public CurseOfOpulenceTriggeredAbility(final CurseOfOpulenceTriggeredAbility ability) {
@ -99,13 +98,18 @@ class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
if (enchantment != null Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) { for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) { if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo())); if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new CreateTokenTargetEffect(new GoldToken());
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
}
return true; return true;
} }
} }

View file

@ -108,7 +108,7 @@ class CurseOfShallowTriggeredAbility extends TriggeredAbilityImpl {
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
} }
return true; return true;
} }

View file

@ -27,10 +27,12 @@
*/ */
package mage.cards.c; package mage.cards.c;
import mage.abilities.Ability; import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -39,14 +41,13 @@ import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
/** /**
* *
@ -65,9 +66,7 @@ public class CurseOfVerbosity extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName())); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, draw a card. Each opponent attacking that player does the same. // Whenever enchanted player is attacked, draw a card. Each opponent attacking that player does the same.
Ability ability = new CurseOfVerbosityTriggeredAbility(); this.addAbility(new CurseOfVerbosityTriggeredAbility());
ability.addEffect(new DrawCardSourceControllerEffect(1));
this.addAbility(ability);
} }
public CurseOfVerbosity(final CurseOfVerbosity card) { public CurseOfVerbosity(final CurseOfVerbosity card) {
@ -83,7 +82,7 @@ public class CurseOfVerbosity extends CardImpl {
class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl { class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfVerbosityTriggeredAbility() { public CurseOfVerbosityTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1), false); super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
} }
public CurseOfVerbosityTriggeredAbility(final CurseOfVerbosityTriggeredAbility ability) { public CurseOfVerbosityTriggeredAbility(final CurseOfVerbosityTriggeredAbility ability) {
@ -97,18 +96,22 @@ class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
UUID controller = this.getControllerId(); Player controller = game.getPlayer(getControllerId());
if (enchantment != null if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) { for (CombatGroup group : game.getCombat().getBlockingGroups()) {
for (Effect effect: this.getEffects()) { if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
} Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
} }
return true; return true;
} }
}
}
return false; return false;
} }

View file

@ -27,7 +27,6 @@
*/ */
package mage.cards.c; package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
@ -47,6 +46,8 @@ import mage.target.targetpointer.FixedTarget;
import java.util.UUID; import java.util.UUID;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.GainLifeTargetEffect; import mage.abilities.effects.common.GainLifeTargetEffect;
import mage.game.combat.CombatGroup;
import mage.players.Player;
/** /**
* *
@ -65,9 +66,7 @@ public class CurseOfVitality extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName())); this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, you gain 2 life. Each opponent attacking that player does the same. // Whenever enchanted player is attacked, you gain 2 life. Each opponent attacking that player does the same.
Ability ability = new CurseOfVitalityTriggeredAbility(); this.addAbility(new CurseOfVitalityTriggeredAbility());
ability.addEffect(new GainLifeEffect(2));
this.addAbility(ability);
} }
public CurseOfVitality(final CurseOfVitality card) { public CurseOfVitality(final CurseOfVitality card) {
@ -83,7 +82,7 @@ public class CurseOfVitality extends CardImpl {
class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl { class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfVitalityTriggeredAbility() { public CurseOfVitalityTriggeredAbility() {
super(Zone.BATTLEFIELD, new GainLifeTargetEffect(2), false); super(Zone.BATTLEFIELD, new GainLifeEffect(2), false);
} }
public CurseOfVitalityTriggeredAbility(final CurseOfVitalityTriggeredAbility ability) { public CurseOfVitalityTriggeredAbility(final CurseOfVitalityTriggeredAbility ability) {
@ -97,18 +96,22 @@ class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
UUID controller = this.getControllerId(); Player controller = game.getPlayer(getControllerId());
if (enchantment != null if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null && enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) { && game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) { for (CombatGroup group : game.getCombat().getBlockingGroups()) {
for (Effect effect: this.getEffects()) { if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId())); if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
} Effect effect = new GainLifeTargetEffect(2);
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
} }
return true; return true;
} }
}
}
return false; return false;
} }

View file

@ -83,7 +83,7 @@ class OverwhelmingInstinctTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
return game.getCombat().getAttackers().size() >= 3 && game.getCombat().getAttackerId().equals(getControllerId()); return game.getCombat().getAttackers().size() >= 3 && game.getCombat().getAttackingPlayerId().equals(getControllerId());
} }
@Override @Override

View file

@ -56,7 +56,7 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
attackerCount++; attackerCount++;
} }
} }
return attackerCount >= minAttackers && game.getCombat().getAttackerId().equals(getControllerId()); return attackerCount >= minAttackers && game.getCombat().getAttackingPlayerId().equals(getControllerId());
} }
@Override @Override

View file

@ -1414,7 +1414,7 @@ public class Combat implements Serializable, Copyable<Combat> {
} }
} }
public UUID getAttackerId() { public UUID getAttackingPlayerId() {
return attackingPlayerId; return attackingPlayerId;
} }

View file

@ -168,9 +168,14 @@ public abstract class MatchImpl implements Match {
MatchPlayer matchWinner = null; MatchPlayer matchWinner = null;
for (MatchPlayer matchPlayer : players) { for (MatchPlayer matchPlayer : players) {
if (!matchPlayer.hasQuit()) { if (!matchPlayer.hasQuit()) {
if (matchPlayer.getDeck() == null) {
logger.error("MatchPlayer's deck was null - matchId " + this.getId() + " - " + matchPlayer.getName());
matchPlayer.setQuit(true);
} else {
activePlayers++; activePlayers++;
matchWinner = matchPlayer; matchWinner = matchPlayer;
} }
}
if (matchPlayer.getWins() >= options.getWinsNeeded()) { if (matchPlayer.getWins() >= options.getWinsNeeded()) {
matchPlayer.setMatchWinner(true); matchPlayer.setMatchWinner(true);
endTime = new Date(); endTime = new Date();