mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
* C17 Enchantment Curses - Fixed a bug that could create game errors (index out of bounds).
This commit is contained in:
parent
0affb45264
commit
db93e3f672
16 changed files with 179 additions and 159 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1414,7 +1414,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
}
|
||||
|
||||
public UUID getAttackerId() {
|
||||
public UUID getAttackingPlayerId() {
|
||||
return attackingPlayerId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue