forked from External/mage
Combat.getAttackers and Combat.getBlockers now return a Set instead of a List, so that two-headed blockers aren't included twice
This commit is contained in:
parent
efaccf8564
commit
a6c5209a2a
20 changed files with 192 additions and 354 deletions
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -21,7 +18,7 @@ public class AttacksAloneSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
setTriggerPhrase("Whenever {this} attacks alone, ");
|
||||
}
|
||||
|
||||
public AttacksAloneSourceTriggeredAbility(final AttacksAloneSourceTriggeredAbility ability) {
|
||||
protected AttacksAloneSourceTriggeredAbility(final AttacksAloneSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
|
@ -32,25 +29,15 @@ public class AttacksAloneSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if(game.isActivePlayer(this.controllerId) ) {
|
||||
UUID creatureId = this.getSourceId();
|
||||
if(creatureId != null) {
|
||||
if(game.getCombat().attacksAlone() && Objects.equals(creatureId, game.getCombat().getAttackers().get(0))) {
|
||||
UUID defender = game.getCombat().getDefenderId(creatureId);
|
||||
if(defender != null) {
|
||||
for(Effect effect: getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(defender));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!getSourceId().equals(event.getSourceId()) || !game.getCombat().attacksAlone()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
getEffects().setTargetPointer(new FixedTarget(game.getCombat().getDefendingPlayerId(getSourceId(), game)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue