* 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

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game;
import mage.game.match.MatchImpl;
@ -43,7 +42,7 @@ public class TwoPlayerMatch extends MatchImpl {
@Override
public void startGame() throws GameException {
TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(),20);
TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans(), 20);
// Sets a start message about the match score
game.setStartMessage(this.createGameStartMessage());
initGame(game);

View file

@ -158,7 +158,7 @@ public final class CombatUtil {
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();
if (attackerId == null || defenderId == null) {
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) {
UUID attackerId = game.getCombat().getAttackerId();
UUID attackerId = game.getCombat().getAttackingPlayerId();
UUID defenderId = game.getCombat().getDefenders().iterator().next();
if (attackerId == null || defenderId == null) {
log.warn("Couldn't find attacker or defender: " + attackerId + ' ' + defenderId);

View file

@ -108,7 +108,7 @@ class AdmiralAckbarTriggeredAbility extends TriggeredAbilityImpl {
@Override
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

View file

@ -84,7 +84,7 @@ public class CitadelSiege extends CardImpl {
public void adjustTargets(Ability ability, Game game) {
if (this.getAbilities().contains(ability) && ability.getRule().startsWith("&bull Dragons")) {
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.addTarget(new TargetCreaturePermanent(filter));
}

View file

@ -49,6 +49,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.filter.StaticFilters;
import mage.filter.common.FilterNonlandPermanent;
import mage.game.combat.CombatGroup;
import mage.players.Player;
/**
@ -58,7 +59,7 @@ import mage.players.Player;
public class CurseOfBounty extends CardImpl {
public CurseOfBounty(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
this.subtype.add(SubType.AURA, SubType.CURSE);
// Enchant player
@ -67,11 +68,9 @@ public class CurseOfBounty extends CardImpl {
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// 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.
Ability ability = new CurseOfBountyTriggeredAbility();
ability.addEffect(new UntapAllControllerEffect(new FilterNonlandPermanent()));
this.addAbility(ability);
this.addAbility(new CurseOfBountyTriggeredAbility());
}
public CurseOfBounty(final CurseOfBounty card) {
@ -87,7 +86,7 @@ public class CurseOfBounty extends CardImpl {
class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfBountyTriggeredAbility() {
super(Zone.BATTLEFIELD, new UntapAllNonlandsTargetEffect(), false);
super(Zone.BATTLEFIELD, new UntapAllControllerEffect(new FilterNonlandPermanent()), false);
}
public CurseOfBountyTriggeredAbility(final CurseOfBountyTriggeredAbility ability) {
@ -101,17 +100,21 @@ class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
UUID controller = this.getControllerId();
if (enchantment != null
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) {
for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId()));
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
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;
}
@ -129,7 +132,7 @@ class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
}
class UntapAllNonlandsTargetEffect extends OneShotEffect {
public UntapAllNonlandsTargetEffect() {
super(Outcome.Untap);
}
@ -142,7 +145,7 @@ class UntapAllNonlandsTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
for (Permanent nonland: game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, player.getId(), game)) {
for (Permanent nonland : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, player.getId(), game)) {
nonland.untap(game);
}
return true;

View file

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

View file

@ -27,10 +27,12 @@
*/
package mage.cards.c;
import mage.abilities.Ability;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
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.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -39,15 +41,14 @@ import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.TargetPlayer;
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;
/**
*
@ -56,7 +57,7 @@ import mage.game.permanent.token.ZombieToken;
public class CurseOfDisturbance extends CardImpl {
public CurseOfDisturbance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
this.subtype.add(SubType.AURA, SubType.CURSE);
// Enchant player
@ -66,9 +67,7 @@ public class CurseOfDisturbance extends CardImpl {
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.
Ability ability = new CurseOfDisturbanceTriggeredAbility();
ability.addEffect(new CreateTokenEffect(new ZombieToken()));
this.addAbility(ability);
this.addAbility(new CurseOfDisturbanceTriggeredAbility());
}
public CurseOfDisturbance(final CurseOfDisturbance card) {
@ -84,7 +83,7 @@ public class CurseOfDisturbance extends CardImpl {
class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfDisturbanceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenTargetEffect(new ZombieToken()), false);
super(Zone.BATTLEFIELD, new CreateTokenEffect(new ZombieToken()), false);
}
public CurseOfDisturbanceTriggeredAbility(final CurseOfDisturbanceTriggeredAbility ability) {
@ -98,17 +97,21 @@ class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
UUID controller = this.getControllerId();
if (enchantment != null
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) {
for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId()));
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
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;
}
@ -122,5 +125,5 @@ class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfDisturbanceTriggeredAbility copy() {
return new CurseOfDisturbanceTriggeredAbility(this);
}
}

View file

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

View file

@ -28,8 +28,8 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
@ -46,6 +46,7 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.GoldToken;
import mage.players.Player;
import mage.target.TargetPlayer;
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.
// 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();
ability.addEffect(new CreateTokenEffect(new GoldToken()));
this.addAbility(ability);
this.addAbility(new CurseOfOpulenceTriggeredAbility());
}
public CurseOfOpulence(final CurseOfOpulence card) {
@ -85,7 +84,7 @@ public class CurseOfOpulence extends CardImpl {
class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfOpulenceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenTargetEffect(new GoldToken()), false);
super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoldToken()), false);
}
public CurseOfOpulenceTriggeredAbility(final CurseOfOpulenceTriggeredAbility ability) {
@ -99,13 +98,18 @@ class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (enchantment != null
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
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;
}
}

View file

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

View file

@ -27,10 +27,12 @@
*/
package mage.cards.c;
import mage.abilities.Ability;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
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.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -39,14 +41,13 @@ import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
/**
*
@ -55,7 +56,7 @@ import mage.abilities.effects.common.DrawCardTargetEffect;
public class CurseOfVerbosity extends CardImpl {
public CurseOfVerbosity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
this.subtype.add(SubType.AURA, SubType.CURSE);
// Enchant player
@ -65,9 +66,7 @@ public class CurseOfVerbosity extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, draw a card. Each opponent attacking that player does the same.
Ability ability = new CurseOfVerbosityTriggeredAbility();
ability.addEffect(new DrawCardSourceControllerEffect(1));
this.addAbility(ability);
this.addAbility(new CurseOfVerbosityTriggeredAbility());
}
public CurseOfVerbosity(final CurseOfVerbosity card) {
@ -83,7 +82,7 @@ public class CurseOfVerbosity extends CardImpl {
class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfVerbosityTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardTargetEffect(1), false);
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
}
public CurseOfVerbosityTriggeredAbility(final CurseOfVerbosityTriggeredAbility ability) {
@ -97,17 +96,21 @@ class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
UUID controller = this.getControllerId();
if (enchantment != null
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) {
for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId()));
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
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;
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
@ -47,6 +46,8 @@ import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.GainLifeTargetEffect;
import mage.game.combat.CombatGroup;
import mage.players.Player;
/**
*
@ -55,7 +56,7 @@ import mage.abilities.effects.common.GainLifeTargetEffect;
public class CurseOfVitality extends CardImpl {
public CurseOfVitality(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
this.subtype.add(SubType.AURA, SubType.CURSE);
// Enchant player
@ -65,9 +66,7 @@ public class CurseOfVitality extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, you gain 2 life. Each opponent attacking that player does the same.
Ability ability = new CurseOfVitalityTriggeredAbility();
ability.addEffect(new GainLifeEffect(2));
this.addAbility(ability);
this.addAbility(new CurseOfVitalityTriggeredAbility());
}
public CurseOfVitality(final CurseOfVitality card) {
@ -83,7 +82,7 @@ public class CurseOfVitality extends CardImpl {
class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl {
public CurseOfVitalityTriggeredAbility() {
super(Zone.BATTLEFIELD, new GainLifeTargetEffect(2), false);
super(Zone.BATTLEFIELD, new GainLifeEffect(2), false);
}
public CurseOfVitalityTriggeredAbility(final CurseOfVitalityTriggeredAbility ability) {
@ -97,17 +96,21 @@ class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
UUID controller = this.getControllerId();
if (enchantment != null
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
if (!game.getCombat().getAttackerId().equals(controller)) {
for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackerId()));
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
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;
}

View file

@ -83,7 +83,7 @@ class OverwhelmingInstinctTriggeredAbility extends TriggeredAbilityImpl {
@Override
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

View file

@ -1,71 +1,71 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author Styxo
*/
public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
private FilterCreaturePermanent filter;
private int minAttackers;
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
this(effect, minAttackers, new FilterCreaturePermanent("creatures"));
}
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers, FilterCreaturePermanent filter) {
super(Zone.BATTLEFIELD, effect);
this.filter = filter;
this.minAttackers = minAttackers;
}
public AttacksWithCreaturesTriggeredAbility(final AttacksWithCreaturesTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.minAttackers = ability.minAttackers;
}
@Override
public AttacksWithCreaturesTriggeredAbility copy() {
return new AttacksWithCreaturesTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int attackerCount = 0;
for (UUID attacker : game.getCombat().getAttackers()) {
if (filter.match(game.getPermanent(attacker), game)) {
attackerCount++;
}
}
return attackerCount >= minAttackers && game.getCombat().getAttackerId().equals(getControllerId());
}
@Override
public String getRule() {
StringBuilder sb = new StringBuilder("Whenever you attack with " + minAttackers + " or more ");
sb.append(filter.getMessage());
sb.append(", ");
sb.append(super.getRule());
return sb.toString();
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author Styxo
*/
public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
private FilterCreaturePermanent filter;
private int minAttackers;
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
this(effect, minAttackers, new FilterCreaturePermanent("creatures"));
}
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers, FilterCreaturePermanent filter) {
super(Zone.BATTLEFIELD, effect);
this.filter = filter;
this.minAttackers = minAttackers;
}
public AttacksWithCreaturesTriggeredAbility(final AttacksWithCreaturesTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
this.minAttackers = ability.minAttackers;
}
@Override
public AttacksWithCreaturesTriggeredAbility copy() {
return new AttacksWithCreaturesTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int attackerCount = 0;
for (UUID attacker : game.getCombat().getAttackers()) {
if (filter.match(game.getPermanent(attacker), game)) {
attackerCount++;
}
}
return attackerCount >= minAttackers && game.getCombat().getAttackingPlayerId().equals(getControllerId());
}
@Override
public String getRule() {
StringBuilder sb = new StringBuilder("Whenever you attack with " + minAttackers + " or more ");
sb.append(filter.getMessage());
sb.append(", ");
sb.append(super.getRule());
return sb.toString();
}
}

View file

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

View file

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