mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 20:59:14 -08:00
refactoring and cleanup
This commit is contained in:
parent
9b19ce56c0
commit
77f19c157a
11 changed files with 40 additions and 65 deletions
|
|
@ -65,14 +65,11 @@ public class CreatureDiesTriggeredAbility extends TriggeredAbilityImpl<CreatureD
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)
|
||||
&& (!another || !permanent.getId().equals(this.getSourceId()))) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)
|
||||
&& (!another || !permanent.getId().equals(this.getSourceId()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -30,14 +30,11 @@ public class DiesAndDealtDamageThisTurnTriggeredAbility extends TriggeredAbility
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card instanceof Permanent && ((Permanent)card).getDealtDamageByThisTurn().contains(this.sourceId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Card card = game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (card instanceof Permanent && ((Permanent)card).getDealtDamageByThisTurn().contains(this.sourceId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public class DiesAnotherCreatureYouControlTriggeredAbility extends TriggeredAbil
|
|||
Permanent permanent = zEvent.getTarget();
|
||||
|
||||
if (permanent != null && permanent.getCardType().contains(Constants.CardType.CREATURE) &&
|
||||
zEvent.getToZone() == Constants.Zone.GRAVEYARD &&
|
||||
zEvent.getFromZone() == Constants.Zone.BATTLEFIELD &&
|
||||
zEvent.isDiesEvent() &&
|
||||
permanent.getControllerId().equals(this.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,10 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl<DiesAttac
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (p.getAttachments().contains(this.getSourceId()))
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (p.getAttachments().contains(this.getSourceId()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl<GainAbilityTar
|
|||
protected Ability ability;
|
||||
|
||||
public GainAbilityTargetEffect(Ability ability, Duration duration) {
|
||||
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA,
|
||||
ability.getEffects().size() > 0 ? ability.getEffects().get(0).getOutcome() : Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,13 +55,10 @@ public class MorbidWatcher extends WatcherImpl<MorbidWatcher> {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (condition == true) //no need to check - condition has already occured
|
||||
return;
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD) {
|
||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (p != null && p.getCardType().contains(CardType.CREATURE)) {
|
||||
condition = true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Constants.Zone.BATTLEFIELD);
|
||||
if (p != null && p.getCardType().contains(CardType.CREATURE)) {
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue