mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Thraximundar - Fixed that the second ability to sacrifice a creature didn't trigger.
This commit is contained in:
parent
3592c3b06a
commit
d36a968579
19 changed files with 44 additions and 21 deletions
|
@ -94,7 +94,7 @@ class MageSlayerEffect extends OneShotEffect<MageSlayerEffect> {
|
||||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||||
int power = game.getPermanent(equipment.getAttachedTo()).getPower().getValue();
|
int power = game.getPermanent(equipment.getAttachedTo()).getPower().getValue();
|
||||||
UUID defendingPlayerId = game.getCombat().getDefendingPlayer(equipment.getAttachedTo());
|
UUID defendingPlayerId = game.getCombat().getDefenderId(equipment.getAttachedTo());
|
||||||
if (defendingPlayerId != null) {
|
if (defendingPlayerId != null) {
|
||||||
game.getPlayer(defendingPlayerId).damage(power, id, game, false, true);
|
game.getPlayer(defendingPlayerId).damage(power, id, game, false, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -110,10 +110,9 @@ class ThraximundarTriggeredAbility extends TriggeredAbilityImpl<ThraximundarTrig
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.DECLARED_ATTACKERS
|
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
||||||
&& game.getActivePlayerId().equals(this.controllerId)
|
|
||||||
&& event.getSourceId() == this.getSourceId()) {
|
&& event.getSourceId() == this.getSourceId()) {
|
||||||
UUID defender = game.getCombat().getDefendingPlayer(this.getSourceId());
|
UUID defender = game.getCombat().getDefendingPlayerId(this.getSourceId(), game);
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
|
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ class VedalkenGhoulTriggeredAbility extends TriggeredAbilityImpl<VedalkenGhoulTr
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.CREATURE_BLOCKED && event.getTargetId().equals(this.getSourceId())) {
|
if (event.getType() == GameEvent.EventType.CREATURE_BLOCKED && event.getTargetId().equals(this.getSourceId())) {
|
||||||
UUID defendingPlayer = game.getCombat().getDefendingPlayer(this.getSourceId());
|
UUID defendingPlayer = game.getCombat().getDefenderId(this.getSourceId());
|
||||||
if (defendingPlayer != null) {
|
if (defendingPlayer != null) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(defendingPlayer));
|
effect.setTargetPointer(new FixedTarget(defendingPlayer));
|
||||||
|
|
|
@ -147,7 +147,7 @@ class MasterOfCrueltiesEffect extends OneShotEffect<MasterOfCrueltiesEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player defendingPlayer = game.getPlayer(game.getCombat().getDefendingPlayer(source.getSourceId()));
|
Player defendingPlayer = game.getPlayer(game.getCombat().getDefenderId(source.getSourceId()));
|
||||||
if (defendingPlayer != null) {
|
if (defendingPlayer != null) {
|
||||||
defendingPlayer.setLife(1, game);
|
defendingPlayer.setLife(1, game);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -113,7 +113,7 @@ class GrimgrinCorpseBornAbility extends TriggeredAbilityImpl<GrimgrinCorpseBornA
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(sourceId);
|
UUID defenderId = game.getCombat().getDefenderId(sourceId);
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
|
|
||||||
this.getTargets().clear();
|
this.getTargets().clear();
|
||||||
|
|
|
@ -103,7 +103,7 @@ class TrepanationBladeDiscardEffect extends OneShotEffect<TrepanationBladeDiscar
|
||||||
if (creature == null) {
|
if (creature == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(creature.getId());
|
UUID defenderId = game.getCombat().getDefenderId(creature.getId());
|
||||||
Player player = game.getPlayer(defenderId);
|
Player player = game.getPlayer(defenderId);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -98,7 +98,7 @@ class AncientHellkiteAbility extends ActivatedAbilityImpl<AncientHellkiteAbility
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean activate(Game game, boolean noMana) {
|
public boolean activate(Game game, boolean noMana) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(sourceId);
|
UUID defenderId = game.getCombat().getDefenderId(sourceId);
|
||||||
if (defenderId != null) {
|
if (defenderId != null) {
|
||||||
FilterCreaturePermanent filter = filterTemplate.copy();
|
FilterCreaturePermanent filter = filterTemplate.copy();
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
|
|
|
@ -87,7 +87,7 @@ class CyclopsGladiatorEffect extends OneShotEffect<CyclopsGladiatorEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
if (defenderId != null) {
|
if (defenderId != null) {
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
|
|
|
@ -106,7 +106,7 @@ class NefaroxOverlordOfGrixisTriggeredAbility extends TriggeredAbilityImpl<Nefar
|
||||||
UUID nefarox = this.getSourceId();
|
UUID nefarox = this.getSourceId();
|
||||||
if (nefarox != null) {
|
if (nefarox != null) {
|
||||||
if (game.getCombat().attacksAlone() && nefarox == game.getCombat().getAttackers().get(0)) {
|
if (game.getCombat().attacksAlone() && nefarox == game.getCombat().getAttackers().get(0)) {
|
||||||
UUID defender = game.getCombat().getDefendingPlayer(nefarox);
|
UUID defender = game.getCombat().getDefenderId(nefarox);
|
||||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
|
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class ColossalWhaleAbility extends TriggeredAbilityImpl<ColossalWhaleAbility> {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(sourceId);
|
UUID defenderId = game.getCombat().getDefenderId(sourceId);
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
|
|
||||||
this.getTargets().clear();
|
this.getTargets().clear();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class MasterOfDiversion extends CardImpl<MasterOfDiversion> {
|
||||||
if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
||||||
ability.getTargets().clear();
|
ability.getTargets().clear();
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(ability.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId());
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
|
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
|
||||||
target.setRequired(true);
|
target.setRequired(true);
|
||||||
|
|
|
@ -93,7 +93,7 @@ class SkymarkRocAbility extends TriggeredAbilityImpl<SkymarkRocAbility> {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls with toughness 2 or less");
|
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls with toughness 2 or less");
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(sourceId);
|
UUID defenderId = game.getCombat().getDefenderId(sourceId);
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, 3));
|
filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, 3));
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ class LordOfShatterskullPassEffect extends OneShotEffect<LordOfShatterskullPassE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
if (defenderId != null) {
|
if (defenderId != null) {
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||||
filter.add(new ControllerIdPredicate(defenderId));
|
filter.add(new ControllerIdPredicate(defenderId));
|
||||||
|
|
|
@ -155,7 +155,7 @@ class MyrBattlesphereEffect extends OneShotEffect<MyrBattlesphereEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
Player defender = game.getPlayer(defenderId);
|
Player defender = game.getPlayer(defenderId);
|
||||||
if (defender != null) {
|
if (defender != null) {
|
||||||
defender.damage(amount.calculate(game, source), source.getSourceId(), game, false, false);
|
defender.damage(amount.calculate(game, source), source.getSourceId(), game, false, false);
|
||||||
|
|
|
@ -92,7 +92,7 @@ class GoblinGuideEffect extends OneShotEffect<GoblinGuideEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
Player defender = game.getPlayer(defenderId);
|
Player defender = game.getPlayer(defenderId);
|
||||||
if (defender != null) {
|
if (defender != null) {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class DefendingPlayerControlsCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defendingPlayer = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defendingPlayer = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
return defendingPlayer != null && game.getBattlefield().countAll(filter, defendingPlayer, game) > 0;
|
return defendingPlayer != null && game.getBattlefield().countAll(filter, defendingPlayer, game) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class AnnihilatorEffect extends OneShotEffect<AnnihilatorEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID defenderId = game.getCombat().getDefendingPlayer(source.getSourceId());
|
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
|
||||||
Player player = game.getPlayer(defenderId);
|
Player player = game.getPlayer(defenderId);
|
||||||
|
|
||||||
//Defender may be a planeswalker.
|
//Defender may be a planeswalker.
|
||||||
|
|
|
@ -161,7 +161,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl<ReturnAttackerToHandTarget
|
||||||
if (permanent == null) {
|
if (permanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
defendingPlayerId = game.getCombat().getDefendingPlayer(permanent.getId());
|
defendingPlayerId = game.getCombat().getDefenderId(permanent.getId());
|
||||||
paid |= permanent.moveToZone(Zone.HAND, sourceId, game, false);
|
paid |= permanent.moveToZone(Zone.HAND, sourceId, game, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,12 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDefendingPlayer(UUID attackerId) {
|
/**
|
||||||
|
*
|
||||||
|
* @param attackerId
|
||||||
|
* @return uuid of defending player or planeswalker
|
||||||
|
*/
|
||||||
|
public UUID getDefenderId(UUID attackerId) {
|
||||||
UUID defenderId = null;
|
UUID defenderId = null;
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (group.getAttackers().contains(attackerId)) {
|
if (group.getAttackers().contains(attackerId)) {
|
||||||
|
@ -537,6 +542,25 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
return defenderId;
|
return defenderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getDefendingPlayerId(UUID attackerId, Game game) {
|
||||||
|
UUID defenderId = null;
|
||||||
|
for (CombatGroup group : groups) {
|
||||||
|
if (group.getAttackers().contains(attackerId)) {
|
||||||
|
defenderId = group.getDefenderId();
|
||||||
|
if (group.defenderIsPlaneswalker) {
|
||||||
|
Permanent permanent = game.getPermanent(defenderId);
|
||||||
|
if (permanent != null) {
|
||||||
|
defenderId = permanent.getControllerId();
|
||||||
|
} else {
|
||||||
|
defenderId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defenderId;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<UUID> getPlayerDefenders(Game game) {
|
public Set<UUID> getPlayerDefenders(Game game) {
|
||||||
Set<UUID> playerDefenders = new HashSet<UUID>();
|
Set<UUID> playerDefenders = new HashSet<UUID>();
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
|
|
Loading…
Reference in a new issue