forked from External/mage
introduced XorLessLifeCondition
This commit is contained in:
parent
e44b2fd673
commit
1f89b4eedf
8 changed files with 32 additions and 44 deletions
|
|
@ -31,7 +31,7 @@ import mage.MageInt;
|
|||
import mage.abilities.common.CantBlockAbility;
|
||||
import mage.abilities.common.LandfallAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.TenOrLessLifeCondition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect;
|
||||
|
|
@ -64,7 +64,7 @@ public class Bloodghast extends CardImpl {
|
|||
// Bloodghast has haste as long as an opponent has 10 or less life.
|
||||
ContinuousEffect effect = new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(effect,
|
||||
new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.AN_OPPONENT),
|
||||
new XorLessLifeCondition(XorLessLifeCondition.CheckType.AN_OPPONENT, 10),
|
||||
"Bloodghast has haste as long as an opponent has 10 or less life")));
|
||||
// Landfall — Whenever a land enters the battlefield under your control, you may return Bloodghast from your graveyard to the battlefield.
|
||||
this.addAbility(new LandfallAbility(Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(), true));
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@
|
|||
*/
|
||||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
|
|
@ -39,7 +38,6 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -56,7 +54,7 @@ public class ConvalescentCare extends CardImpl {
|
|||
Effect effect = new DrawCardSourceControllerEffect(1);
|
||||
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(3), TargetController.YOU, false);
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(new ConditionalTriggeredAbility(ability, new FiveOrLessLifeCondition(), "At the beginning of your upkeep, if you have 5 or less life, you gain 3 life and draw a card."));
|
||||
this.addAbility(new ConditionalTriggeredAbility(ability, new XorLessLifeCondition(XorLessLifeCondition.CheckType.CONTROLLER, 5), "At the beginning of your upkeep, if you have 5 or less life, you gain 3 life and draw a card."));
|
||||
}
|
||||
|
||||
public ConvalescentCare(final ConvalescentCare card) {
|
||||
|
|
@ -68,11 +66,5 @@ public class ConvalescentCare extends CardImpl {
|
|||
return new ConvalescentCare(this);
|
||||
}
|
||||
|
||||
static class FiveOrLessLifeCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getPlayer(source.getControllerId()).getLife() <= 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package mage.cards.c;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTappedAbility;
|
||||
import mage.abilities.condition.common.TenOrLessLifeCondition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.common.LoseLifeAllPlayersEffect;
|
||||
import mage.abilities.effects.common.TransformSourceEffect;
|
||||
|
|
@ -68,7 +68,7 @@ public class CryptolithFragment extends CardImpl {
|
|||
this.addAbility(new TransformAbility());
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
new BeginningOfUpkeepTriggeredAbility(new TransformSourceEffect(true), TargetController.YOU, false),
|
||||
new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.EACH_PLAYER),
|
||||
new XorLessLifeCondition(XorLessLifeCondition.CheckType.EACH_PLAYER, 10),
|
||||
"At the beginning of your upkeep, if each player has 10 or less life, transform Cryptolith Fragment."));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.TenOrLessLifeCondition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
|
|
@ -63,7 +63,7 @@ public class GuulDrazVampire extends CardImpl {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// As long as an opponent has 10 or less life, Guul Draz Vampire gets +2/+1 and has intimidate. (It can't be blocked except by artifact creatures and/or creatures that share a color with it.)
|
||||
Condition condition = new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.AN_OPPONENT);
|
||||
Condition condition = new XorLessLifeCondition(XorLessLifeCondition.CheckType.AN_OPPONENT, 10);
|
||||
ConditionalContinuousEffect effect1 = new ConditionalContinuousEffect(new BoostSourceEffect(2, 1, Duration.WhileOnBattlefield), condition, rule1);
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect1);
|
||||
ability.addEffect(new ConditionalContinuousEffect(new GainAbilitySourceEffect(IntimidateAbility.getInstance()), condition, rule2));
|
||||
|
|
|
|||
|
|
@ -27,17 +27,18 @@
|
|||
*/
|
||||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.TenOrLessLifeCondition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -56,7 +57,7 @@ public class RuthlessCullblade extends CardImpl {
|
|||
// Ruthless Cullblade gets +2/+1 as long as an opponent has 10 or less life.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||
new ConditionalContinuousEffect(new BoostSourceEffect(2, 1, Duration.WhileOnBattlefield),
|
||||
new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.AN_OPPONENT),
|
||||
new XorLessLifeCondition(XorLessLifeCondition.CheckType.AN_OPPONENT, 10),
|
||||
"{this} gets +2/+1 as long as an opponent has 10 or less life.")));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,9 @@
|
|||
*/
|
||||
package mage.cards.s;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect;
|
||||
|
|
@ -39,7 +38,6 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -56,7 +54,7 @@ public class SecondChance extends CardImpl {
|
|||
// At the beginning of your upkeep, if you have 5 or less life, sacrifice Second Chance and take an extra turn after this one.
|
||||
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new SacrificeSourceEffect(), TargetController.YOU, false);
|
||||
ability.addEffect(new AddExtraTurnControllerEffect());
|
||||
this.addAbility(new ConditionalTriggeredAbility(ability, new FiveOrLessLifeCondition(), "At the beginning of your upkeep, if you have 5 or less life, sacrifice {this} and take an extra turn after this one"));
|
||||
this.addAbility(new ConditionalTriggeredAbility(ability, new XorLessLifeCondition(XorLessLifeCondition.CheckType.CONTROLLER, 5), "At the beginning of your upkeep, if you have 5 or less life, sacrifice {this} and take an extra turn after this one"));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -69,11 +67,5 @@ public class SecondChance extends CardImpl {
|
|||
return new SecondChance(this);
|
||||
}
|
||||
|
||||
static class FiveOrLessLifeCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getPlayer(source.getControllerId()).getLife() <= 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,19 +27,19 @@
|
|||
*/
|
||||
package mage.cards.v;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.condition.common.TenOrLessLifeCondition;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.condition.common.XorLessLifeCondition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.TargetController;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
|
|
@ -57,7 +57,7 @@ public class VampireLacerator extends CardImpl {
|
|||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new ConditionalOneShotEffect(
|
||||
new LoseLifeSourceControllerEffect(1),
|
||||
new InvertCondition( new TenOrLessLifeCondition(TenOrLessLifeCondition.CheckType.AN_OPPONENT) ),
|
||||
new InvertCondition( new XorLessLifeCondition(XorLessLifeCondition.CheckType.AN_OPPONENT, 10) ),
|
||||
"you lose 1 life unless an opponent has 10 or less life"), TargetController.YOU, false));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,25 +27,28 @@
|
|||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class TenOrLessLifeCondition implements Condition {
|
||||
public class XorLessLifeCondition implements Condition {
|
||||
|
||||
public enum CheckType { AN_OPPONENT, CONTROLLER, TARGET_OPPONENT, EACH_PLAYER }
|
||||
|
||||
private final CheckType type;
|
||||
private final int amount;
|
||||
|
||||
public TenOrLessLifeCondition ( CheckType type ) {
|
||||
public XorLessLifeCondition ( CheckType type , int amount) {
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -55,11 +58,11 @@ public class TenOrLessLifeCondition implements Condition {
|
|||
switch ( this.type ) {
|
||||
case AN_OPPONENT:
|
||||
for ( UUID opponentUUID : game.getOpponents(source.getControllerId()) ) {
|
||||
conditionApplies |= game.getPlayer(opponentUUID).getLife() <= 10;
|
||||
conditionApplies |= game.getPlayer(opponentUUID).getLife() <= amount;
|
||||
}
|
||||
break;
|
||||
case CONTROLLER:
|
||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= 10;
|
||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= amount;
|
||||
break;
|
||||
case TARGET_OPPONENT:
|
||||
//TODO: Implement this.
|
||||
|
|
@ -71,11 +74,11 @@ public class TenOrLessLifeCondition implements Condition {
|
|||
Player p = game.getPlayer(pid);
|
||||
if (p != null) {
|
||||
if (maxLife < p.getLife()) {
|
||||
maxLife = p.getLife();
|
||||
maxLife = p.getLife();
|
||||
}
|
||||
}
|
||||
}
|
||||
conditionApplies |= maxLife <= 10;
|
||||
conditionApplies |= maxLife <= amount;
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue