mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Merge
This commit is contained in:
commit
fa7468df5a
14 changed files with 138 additions and 137 deletions
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
|
|
@ -61,7 +62,7 @@ public class DragonskullSummit extends CardImpl<DragonskullSummit> {
|
|||
super(ownerId, 223, "Dragonskull Summit", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.MORE_THAN, 0);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.MORE_THAN, 0));
|
||||
String abilityText = "tap it unless you control a " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new BlackManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
|
|
@ -61,7 +62,7 @@ public class DrownedCatacomb extends CardImpl<DrownedCatacomb> {
|
|||
super(ownerId, 224, "Drowned Catacomb", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.MORE_THAN, 0);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.MORE_THAN, 0));
|
||||
String abilityText = "tap it unless you control a " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new BlackManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlueManaAbility;
|
||||
|
|
@ -61,7 +62,7 @@ public class GlacialFortress extends CardImpl<GlacialFortress> {
|
|||
super(ownerId, 226, "Glacial Fortress", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.MORE_THAN, 0);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.MORE_THAN, 0));
|
||||
String abilityText = "tap it unless you control a " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new BlueManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.GreenManaAbility;
|
||||
|
|
@ -61,7 +62,7 @@ public class RootboundCrag extends CardImpl<RootboundCrag> {
|
|||
super(ownerId, 227, "Rootbound Crag", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.MORE_THAN, 0);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.MORE_THAN, 0));
|
||||
String abilityText = "tap it unless you control a " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new RedManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.GreenManaAbility;
|
||||
|
|
@ -61,7 +62,7 @@ public class SunpetalGrove extends CardImpl<SunpetalGrove> {
|
|||
super(ownerId, 228, "Sunpetal Grove", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "M10";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.MORE_THAN, 0);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.MORE_THAN, 0));
|
||||
String abilityText = "tap it unless you control a " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new GreenManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
|
|
@ -59,7 +60,7 @@ public class BlackcleaveCliffs extends CardImpl<BlackcleaveCliffs> {
|
|||
super(ownerId, 224, "Blackcleave Cliffs", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "SOM";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.FEWER_THAN, 3);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.FEWER_THAN, 4));
|
||||
String abilityText = "tap it unless you control fewer than 3 " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new BlackManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.GreenManaAbility;
|
||||
|
|
@ -59,7 +60,7 @@ public class CopperlineGorge extends CardImpl<CopperlineGorge> {
|
|||
super(ownerId, 225, "Copperline Gorge", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "SOM";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.FEWER_THAN, 3);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.FEWER_THAN, 4));
|
||||
String abilityText = "tap it unless you control fewer than 3 " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new RedManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
|
|
@ -59,7 +60,7 @@ public class DarkslickShores extends CardImpl<DarkslickShores> {
|
|||
super(ownerId, 226, "Darkslick Shores", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "SOM";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.FEWER_THAN, 3);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.FEWER_THAN, 4));
|
||||
String abilityText = "tap it unless you control fewer than 3 " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new BlueManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.GreenManaAbility;
|
||||
|
|
@ -59,7 +60,7 @@ public class RazorvergeThicket extends CardImpl<RazorvergeThicket> {
|
|||
super(ownerId, 228, "Razorverge Thicket", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "SOM";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.FEWER_THAN, 3);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.FEWER_THAN, 4));
|
||||
String abilityText = "tap it unless you control fewer than 3 " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new GreenManaAbility());
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ import mage.Constants.CardType;
|
|||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.Controls;
|
||||
import mage.abilities.condition.common.ControlsPermanent;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.TapSourceEffect;
|
||||
import mage.abilities.mana.BlueManaAbility;
|
||||
|
|
@ -59,7 +60,7 @@ public class SeachromeCoast extends CardImpl<SeachromeCoast> {
|
|||
super(ownerId, 229, "Seachrome Coast", Rarity.RARE, new CardType[]{CardType.LAND}, null);
|
||||
this.expansionSetCode = "SOM";
|
||||
|
||||
Condition controls = new Controls(filter, Controls.CountType.FEWER_THAN, 3);
|
||||
Condition controls = new Unless(new ControlsPermanent(filter, ControlsPermanent.CountType.FEWER_THAN, 4));
|
||||
String abilityText = "tap it unless you control fewer than 3 " + filter.getMessage();
|
||||
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new TapSourceEffect(), controls, abilityText), abilityText));
|
||||
this.addAbility(new WhiteManaAbility());
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import mage.Constants.Rarity;
|
|||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.SimpleTriggeredAbility;
|
||||
import mage.abilities.condition.common.Not;
|
||||
import mage.abilities.condition.common.Unless;
|
||||
import mage.abilities.condition.common.TenOrLessLife;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.LoseLifeSourceEffect;
|
||||
|
|
@ -79,7 +79,7 @@ class VampireLaceratorTriggeredAbility extends SimpleTriggeredAbility {
|
|||
super(Zone.BATTLEFIELD, EventType.UPKEEP_STEP_PRE,
|
||||
new ConditionalOneShotEffect(
|
||||
new LoseLifeSourceEffect(1),
|
||||
new Not( new TenOrLessLife(AN_OPPONENT)),
|
||||
new Unless( new TenOrLessLife(AN_OPPONENT)),
|
||||
"At the beginning of your upkeep, you lose 1 "
|
||||
+ "life unless an opponent has 10 or less life."));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Battlefield checking condition. This condition can decorate other conditions
|
||||
* as well as be used standalone.
|
||||
*
|
||||
* @see #Controls(mage.filter.Filter)
|
||||
* @see #Controls(mage.filter.Filter, mage.abilities.condition.Condition)
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class Controls implements Condition {
|
||||
|
||||
public static enum CountType { MORE_THAN, FEWER_THAN, EQUAL_TO };
|
||||
private FilterPermanent filter;
|
||||
private Condition condition;
|
||||
private CountType type;
|
||||
private int count;
|
||||
|
||||
/**
|
||||
* Applies a filter, a {@link CountType}, and count to permanents on the
|
||||
* battlefield when checking the condition during the
|
||||
* {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation.
|
||||
*
|
||||
* @param filter
|
||||
*/
|
||||
public Controls ( FilterPermanent filter, CountType type, int count ) {
|
||||
this.filter = filter;
|
||||
this.type = type;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a filter, a {@link CountType}, and count to permanents on the
|
||||
* battlefield and calls the decorated condition to see if it
|
||||
* {@link #apply(mage.game.Game, mage.abilities.Ability) applies}
|
||||
* as well. This will force both conditions to apply for this to be true.
|
||||
*
|
||||
* @param filter
|
||||
* @param conditionToDecorate
|
||||
*/
|
||||
public Controls ( FilterPermanent filter, CountType type, int count, Condition conditionToDecorate ) {
|
||||
this(filter, type, count);
|
||||
this.condition = conditionToDecorate;
|
||||
}
|
||||
|
||||
/*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean conditionApplies = false;
|
||||
|
||||
switch ( this.type ) {
|
||||
case FEWER_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) > this.count;
|
||||
break;
|
||||
case MORE_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) < this.count;
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) == this.count;
|
||||
break;
|
||||
}
|
||||
|
||||
//If a decorated condition exists, check it as well and apply them together.
|
||||
if ( this.condition != null ) {
|
||||
conditionApplies = conditionApplies && this.condition.apply(game, source);
|
||||
}
|
||||
|
||||
return conditionApplies;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,3 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -5,15 +32,86 @@ import mage.abilities.condition.Condition;
|
|||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Battlefield checking condition. This condition can decorate other conditions
|
||||
* as well as be used standalone.
|
||||
*
|
||||
* @see #Controls(mage.filter.Filter)
|
||||
* @see #Controls(mage.filter.Filter, mage.abilities.condition.Condition)
|
||||
*
|
||||
* @author nantuko
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class ControlsPermanent implements Condition {
|
||||
private FilterPermanent filter;
|
||||
|
||||
public static enum CountType { MORE_THAN, FEWER_THAN, EQUAL_TO };
|
||||
private FilterPermanent filter;
|
||||
private Condition condition;
|
||||
private CountType type;
|
||||
private int count;
|
||||
|
||||
/**
|
||||
* Applies a filter and delegates creation to
|
||||
* {@link #ControlsPermanent(mage.filter.FilterPermanent, mage.abilities.condition.common.ControlsPermanent.CountType, int)}
|
||||
* with {@link CountType#MORE_THAN}, and 0.
|
||||
*
|
||||
* @param filter
|
||||
*/
|
||||
public ControlsPermanent(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
this(filter, CountType.MORE_THAN, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getBattlefield().countAll(filter, source.getControllerId()) > 0;
|
||||
}
|
||||
/**
|
||||
* Applies a filter, a {@link CountType}, and count to permanents on the
|
||||
* battlefield when checking the condition during the
|
||||
* {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation.
|
||||
*
|
||||
* @param filter
|
||||
*/
|
||||
public ControlsPermanent ( FilterPermanent filter, CountType type, int count ) {
|
||||
this.filter = filter;
|
||||
this.type = type;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a filter, a {@link CountType}, and count to permanents on the
|
||||
* battlefield and calls the decorated condition to see if it
|
||||
* {@link #apply(mage.game.Game, mage.abilities.Ability) applies}
|
||||
* as well. This will force both conditions to apply for this to be true.
|
||||
*
|
||||
* @param filter
|
||||
* @param conditionToDecorate
|
||||
*/
|
||||
public ControlsPermanent ( FilterPermanent filter, CountType type, int count, Condition conditionToDecorate ) {
|
||||
this(filter, type, count);
|
||||
this.condition = conditionToDecorate;
|
||||
}
|
||||
|
||||
/*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean conditionApplies = false;
|
||||
|
||||
switch ( this.type ) {
|
||||
case FEWER_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) < this.count;
|
||||
break;
|
||||
case MORE_THAN:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) > this.count;
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
conditionApplies = game.getBattlefield().countAll(filter, source.getControllerId()) == this.count;
|
||||
break;
|
||||
}
|
||||
|
||||
//If a decorated condition exists, check it as well and apply them together.
|
||||
if ( this.condition != null ) {
|
||||
conditionApplies = conditionApplies && this.condition.apply(game, source);
|
||||
}
|
||||
|
||||
return conditionApplies;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ import mage.game.Game;
|
|||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class Not implements Condition {
|
||||
public class Unless implements Condition {
|
||||
|
||||
private Condition condition;
|
||||
|
||||
public Not ( Condition condition ) {
|
||||
public Unless ( Condition condition ) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue