mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fixed issue #58 (ability from night and day side of "Screeching Bat" triggered simultaneously)
This commit is contained in:
parent
5507ba19b0
commit
b9d98eb564
4 changed files with 39 additions and 5 deletions
|
@ -44,6 +44,8 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.condition.common.TransformedCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -66,7 +68,7 @@ public class ScreechingBat extends CardImpl<ScreechingBat> {
|
|||
|
||||
// At the beginning of your upkeep, you may pay {2}{B}{B}. If you do, transform Screeching Bat.
|
||||
this.addAbility(new TransformAbility());
|
||||
this.addAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility());
|
||||
this.addAbility(new ConditionalTriggeredAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility(), new TransformedCondition(true), "", true));
|
||||
}
|
||||
|
||||
public ScreechingBat(final ScreechingBat card) {
|
||||
|
@ -82,7 +84,7 @@ public class ScreechingBat extends CardImpl<ScreechingBat> {
|
|||
class ScreechingBatBeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<ScreechingBatBeginningOfUpkeepTriggeredAbility> {
|
||||
|
||||
public ScreechingBatBeginningOfUpkeepTriggeredAbility() {
|
||||
super(Constants.Zone.BATTLEFIELD, new ScreechingBatTransformSourceEffect(), true);
|
||||
super(Constants.Zone.BATTLEFIELD, new ScreechingBatTransformSourceEffect());
|
||||
}
|
||||
|
||||
public ScreechingBatBeginningOfUpkeepTriggeredAbility(final ScreechingBatBeginningOfUpkeepTriggeredAbility ability) {
|
||||
|
|
|
@ -33,6 +33,8 @@ import mage.MageInt;
|
|||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.condition.common.TransformedCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -52,7 +54,7 @@ public class StalkingVampire extends CardImpl<StalkingVampire> {
|
|||
this.toughness = new MageInt(5);
|
||||
|
||||
// At the beginning of your upkeep, you may pay {2}{B}{B}. If you do, transform Stalking Vampire.
|
||||
this.addAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility());
|
||||
this.addAbility(new ConditionalTriggeredAbility(new ScreechingBatBeginningOfUpkeepTriggeredAbility(), new TransformedCondition(), "", true));
|
||||
}
|
||||
|
||||
public StalkingVampire(final StalkingVampire card) {
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.abilities.condition.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -37,11 +38,32 @@ import mage.game.Game;
|
|||
*/
|
||||
public class TransformedCondition implements Condition {
|
||||
|
||||
protected Boolean notCondition;
|
||||
|
||||
public TransformedCondition() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The condition checks wether a permanent is transformed or not.
|
||||
*
|
||||
* @param notCondition if true the condition is true when the permanent is not transformed
|
||||
* @return true if the condition is true, false if the condition is false
|
||||
*/
|
||||
public TransformedCondition(Boolean notCondition) {
|
||||
this.notCondition = notCondition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getPermanent(source.getSourceId()).isTransformed();
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (notCondition) {
|
||||
return !permanent.isTransformed();
|
||||
} else {
|
||||
return permanent.isTransformed();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,16 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl<Conditiona
|
|||
protected Condition condition;
|
||||
protected String text;
|
||||
|
||||
public ConditionalTriggeredAbility(TriggeredAbility ability, Condition condition, String text) {
|
||||
public ConditionalTriggeredAbility(TriggeredAbility ability, Condition condition, String text) {
|
||||
this(ability, condition, text, false);
|
||||
}
|
||||
|
||||
public ConditionalTriggeredAbility(TriggeredAbility ability, Condition condition, String text, Boolean optional) {
|
||||
super(ability.getZone(), null);
|
||||
this.ability = ability;
|
||||
this.modes = ability.getModes();
|
||||
this.condition = condition;
|
||||
this.optional = optional;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
@ -51,6 +56,9 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl<Conditiona
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
if (text != null && text.isEmpty()) {
|
||||
return ability.getRule();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue