Added amount parameter to EnchantedCondition.

This commit is contained in:
LevelX2 2013-02-10 02:34:26 +01:00
parent b367717f76
commit 0fa76a9669
7 changed files with 27 additions and 16 deletions

View file

@ -35,6 +35,7 @@ import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.EnchantedCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinousEffect;
@ -67,11 +68,12 @@ public class FlaringFlameKin extends CardImpl<FlaringFlameKin> {
new BoostSourceEffect(1, 0, Duration.EndOfTurn),
new ManaCostsImpl("{R}"));
ConditionalContinousEffect effect1 = new ConditionalContinousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), EnchantedCondition.getInstance(), rule1);
Condition enchanted = new EnchantedCondition();
ConditionalContinousEffect effect1 = new ConditionalContinousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), enchanted, rule1);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect1));
ConditionalContinousEffect effect2 = new ConditionalContinousEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance()), EnchantedCondition.getInstance(), rule2);
ConditionalContinousEffect effect2 = new ConditionalContinousEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance()), enchanted, rule2);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect2));
ConditionalContinousEffect effect3 = new ConditionalContinousEffect(new GainAbilitySourceEffect(grantedAbility), EnchantedCondition.getInstance(), rule3);
ConditionalContinousEffect effect3 = new ConditionalContinousEffect(new GainAbilitySourceEffect(grantedAbility), enchanted, rule3);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect3));
}

View file

@ -69,7 +69,7 @@ public class FreewindEquenaut extends CardImpl<FreewindEquenaut> {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinousEffect(
new GainAbilitySourceEffect(ability, Duration.WhileOnBattlefield),
EnchantedCondition.getInstance(),
new EnchantedCondition(),
"As long as {this} is enchanted, it has \"{tap}: {this} deals 2 damage to target attacking or blocking creature\"")));
}

View file

@ -59,7 +59,7 @@ public class SkyriderTrainee extends CardImpl<SkyriderTrainee> {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinousEffect(
new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield),
EnchantedCondition.getInstance(),
new EnchantedCondition(),
"{this} has flying as long as it's enchanted")));
}

View file

@ -34,6 +34,7 @@ import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.EnchantedCondition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
@ -62,13 +63,14 @@ public class ThranGolem extends CardImpl<ThranGolem> {
this.power = new MageInt(3);
this.toughness = new MageInt(3);
ConditionalContinousEffect effect1 = new ConditionalContinousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), EnchantedCondition.getInstance(), rule1);
Condition enchanted = new EnchantedCondition();
ConditionalContinousEffect effect1 = new ConditionalContinousEffect(new BoostSourceEffect(2, 2, Duration.WhileOnBattlefield), enchanted, rule1);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect1));
ConditionalContinousEffect effect2 = new ConditionalContinousEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance()), EnchantedCondition.getInstance(), rule2);
ConditionalContinousEffect effect2 = new ConditionalContinousEffect(new GainAbilitySourceEffect(FlyingAbility.getInstance()), enchanted, rule2);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect2));
ConditionalContinousEffect effect3 = new ConditionalContinousEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance()), EnchantedCondition.getInstance(), rule3);
ConditionalContinousEffect effect3 = new ConditionalContinousEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance()), enchanted, rule3);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect3));
ConditionalContinousEffect effect4 = new ConditionalContinousEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance()), EnchantedCondition.getInstance(), rule4);
ConditionalContinousEffect effect4 = new ConditionalContinousEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance()), enchanted, rule4);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect4));
}

View file

@ -59,7 +59,7 @@ public class GateHound extends CardImpl<GateHound> {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinousEffect(
new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent()),
EnchantedCondition.getInstance(),
new EnchantedCondition(),
"Creatures you control have vigilance as long as {this} is enchanted")));
}

View file

@ -40,23 +40,30 @@ import mage.game.permanent.Permanent;
*/
public class EnchantedCondition implements Condition {
private static EnchantedCondition fInstance = new EnchantedCondition();
private int numberOfEnchantments;
public static Condition getInstance() {
return fInstance;
public EnchantedCondition() {
this(1);
}
public EnchantedCondition(int numberOfEnchantments) {
this.numberOfEnchantments = numberOfEnchantments;
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
int numberOfFoundEnchantments = 0;
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null && attached.getCardType().contains(CardType.ENCHANTMENT)) {
return true;
if (++numberOfFoundEnchantments >= numberOfEnchantments) {
return true;
}
}
}
}
return false;
return (numberOfFoundEnchantments >= numberOfEnchantments);
}
}

View file

@ -25,7 +25,7 @@ public class FlipSourceEffect extends OneShotEffect<FlipSourceEffect> {
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
p.flip(game);
return p.flip(game);
}
return false;
}