mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Merge origin/master
This commit is contained in:
commit
82ca0266ba
18 changed files with 374 additions and 333 deletions
|
@ -29,17 +29,17 @@ package mage.sets.avacynrestored;
|
||||||
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author noxx
|
* @author noxx
|
||||||
|
@ -51,7 +51,6 @@ public class GuiseOfFire extends CardImpl {
|
||||||
this.expansionSetCode = "AVR";
|
this.expansionSetCode = "AVR";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -60,8 +59,12 @@ public class GuiseOfFire extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Enchanted creature gets +1/-1 and attacks each turn if able.
|
// Enchanted creature gets +1/-1 and attacks each turn if able.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, -1, Duration.WhileOnBattlefield)));
|
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, -1, Duration.WhileOnBattlefield));
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA)));
|
Effect effect = new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA);
|
||||||
|
effect.setText("and attacks each turn if able");
|
||||||
|
ability.addEffect(effect);
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiseOfFire(final GuiseOfFire card) {
|
public GuiseOfFire(final GuiseOfFire card) {
|
||||||
|
|
|
@ -25,20 +25,15 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.sets.championsofkamigawa;
|
package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.common.replacement.CantAttackYouUnlessPayManaAllEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,16 +41,16 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public class GhostlyPrison extends CardImpl {
|
public class GhostlyPrison extends CardImpl {
|
||||||
|
|
||||||
public GhostlyPrison (UUID ownerId) {
|
public GhostlyPrison(UUID ownerId) {
|
||||||
super(ownerId, 10, "Ghostly Prison", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
super(ownerId, 10, "Ghostly Prison", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
this.expansionSetCode = "CHK";
|
this.expansionSetCode = "CHK";
|
||||||
|
|
||||||
|
|
||||||
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you
|
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GhostlyPrisonReplacementEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayManaAllEffect(new ManaCostsImpl("{2}"))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GhostlyPrison (final GhostlyPrison card) {
|
public GhostlyPrison(final GhostlyPrison card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,58 +60,3 @@ public class GhostlyPrison extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GhostlyPrisonReplacementEffect extends ReplacementEffectImpl {
|
|
||||||
|
|
||||||
private static final String effectText = "Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you";
|
|
||||||
|
|
||||||
GhostlyPrisonReplacementEffect ( ) {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
|
||||||
staticText = effectText;
|
|
||||||
}
|
|
||||||
|
|
||||||
GhostlyPrisonReplacementEffect ( GhostlyPrisonReplacementEffect effect ) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
if (event.getTargetId().equals(source.getControllerId()) ) {
|
|
||||||
Player attackedPlayer = game.getPlayer(event.getTargetId());
|
|
||||||
if (attackedPlayer != null) {
|
|
||||||
// only if a player is attacked. Attacking a planeswalker is free
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
|
||||||
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
|
|
||||||
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
|
|
||||||
if (attackTax.canPay(source, source.getSourceId(), event.getPlayerId(), game) &&
|
|
||||||
player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", source, game) ) {
|
|
||||||
if (attackTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GhostlyPrisonReplacementEffect copy() {
|
|
||||||
return new GhostlyPrisonReplacementEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,24 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.sets.championsofkamigawa;
|
package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.abilities.keyword.FlashAbility;
|
import mage.abilities.keyword.FlashAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.AttachmentType;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
@ -49,22 +52,30 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
*/
|
*/
|
||||||
public class UncontrollableAnger extends CardImpl {
|
public class UncontrollableAnger extends CardImpl {
|
||||||
|
|
||||||
public UncontrollableAnger (UUID ownerId) {
|
public UncontrollableAnger(UUID ownerId) {
|
||||||
super(ownerId, 195, "Uncontrollable Anger", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}");
|
super(ownerId, 195, "Uncontrollable Anger", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}{R}");
|
||||||
this.expansionSetCode = "CHK";
|
this.expansionSetCode = "CHK";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
// Flash (You may cast this spell any time you could cast an instant.)
|
||||||
|
this.addAbility(FlashAbility.getInstance());
|
||||||
|
|
||||||
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
this.addAbility(FlashAbility.getInstance());
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2, Duration.WhileOnBattlefield)));
|
// Enchanted creature gets +2/+2 and attacks each turn if able.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA)));
|
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2, Duration.WhileOnBattlefield));
|
||||||
|
Effect effect = new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA);
|
||||||
|
effect.setText("and attacks each turn if able");
|
||||||
|
ability.addEffect(effect);
|
||||||
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UncontrollableAnger (final UncontrollableAnger card) {
|
public UncontrollableAnger(final UncontrollableAnger card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,8 @@ import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.ReturnToHandTargetPermanentCost;
|
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
@ -42,11 +41,8 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledLandPermanent;
|
import mage.filter.common.FilterControlledLandPermanent;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +62,7 @@ public class ExaltedDragon extends CardImpl {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// Exalted Dragon can't attack unless you sacrifice a land.
|
// Exalted Dragon can't attack unless you sacrifice a land.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ExaltedDragonReplacementEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ExaltedDragonCostToAttackBlockEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExaltedDragon(final ExaltedDragon card) {
|
public ExaltedDragon(final ExaltedDragon card) {
|
||||||
|
@ -79,55 +75,26 @@ public class ExaltedDragon extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExaltedDragonReplacementEffect extends ReplacementEffectImpl {
|
class ExaltedDragonCostToAttackBlockEffect extends PayCostToAttackBlockEffectImpl {
|
||||||
|
|
||||||
private static final FilterControlledPermanent filter = new FilterControlledLandPermanent();
|
ExaltedDragonCostToAttackBlockEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK,
|
||||||
ExaltedDragonReplacementEffect ( ) {
|
new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent("a land"))));
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
|
||||||
staticText = "{this} can't attack unless you sacrifice a land <i>(This cost is paid as attackers are declared.)</i>";
|
staticText = "{this} can't attack unless you sacrifice a land <i>(This cost is paid as attackers are declared.)</i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
ExaltedDragonReplacementEffect ( ExaltedDragonReplacementEffect effect ) {
|
ExaltedDragonCostToAttackBlockEffect(ExaltedDragonCostToAttackBlockEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
throw new UnsupportedOperationException("Not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
|
||||||
if ( player != null ) {
|
|
||||||
SacrificeTargetCost attackCost = new SacrificeTargetCost(new TargetControlledPermanent(filter));
|
|
||||||
if ( attackCost.canPay(source, source.getSourceId(), event.getPlayerId(), game) &&
|
|
||||||
player.chooseUse(Outcome.Neutral, "Sacrifice a land?", source, game) )
|
|
||||||
{
|
|
||||||
if (attackCost.pay(source, game, source.getSourceId(), event.getPlayerId(), false) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
return event.getSourceId().equals(source.getSourceId());
|
return source.getSourceId().equals(event.getSourceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExaltedDragonReplacementEffect copy() {
|
public ExaltedDragonCostToAttackBlockEffect copy() {
|
||||||
return new ExaltedDragonReplacementEffect(this);
|
return new ExaltedDragonCostToAttackBlockEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,20 @@
|
||||||
package mage.sets.innistrad;
|
package mage.sets.innistrad;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||||
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.AttachmentType;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
|
||||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
|
||||||
import mage.cards.CardImpl;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
@ -55,15 +56,17 @@ public class FurorOfTheBitten extends CardImpl {
|
||||||
this.expansionSetCode = "ISD";
|
this.expansionSetCode = "ISD";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||||
|
|
||||||
// Enchanted creature gets +2/+2 and attacks each turn if able.
|
// Enchanted creature gets +2/+2 and attacks each turn if able.
|
||||||
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2, Duration.WhileOnBattlefield));
|
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(2, 2, Duration.WhileOnBattlefield));
|
||||||
ability.addEffect(new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA));
|
Effect effect = new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA);
|
||||||
|
effect.setText("and attacks each turn if able");
|
||||||
|
ability.addEffect(effect);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
|
||||||
import mage.abilities.common.BecomesTappedTriggeredAbility;
|
import mage.abilities.common.BecomesTappedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.DamageControllerEffect;
|
import mage.abilities.effects.common.DamageControllerEffect;
|
||||||
|
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -53,7 +53,6 @@ public class LustForWar extends CardImpl {
|
||||||
this.expansionSetCode = "ROE";
|
this.expansionSetCode = "ROE";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -66,7 +65,8 @@ public class LustForWar extends CardImpl {
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(attachedAbility, AttachmentType.AURA)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(attachedAbility, AttachmentType.AURA)));
|
||||||
|
|
||||||
// Enchanted creature attacks each turn if able.
|
// Enchanted creature attacks each turn if able.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||||
|
new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LustForWar(final LustForWar card) {
|
public LustForWar(final LustForWar card) {
|
||||||
|
|
|
@ -30,8 +30,9 @@ package mage.sets.saviorsofkamigawa;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.Cost;
|
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
|
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
@ -83,7 +84,7 @@ public class CowedByWisdom extends CardImpl {
|
||||||
class CowedByWisdomayCostToAttackBlockEffect extends PayCostToAttackBlockEffectImpl {
|
class CowedByWisdomayCostToAttackBlockEffect extends PayCostToAttackBlockEffectImpl {
|
||||||
|
|
||||||
CowedByWisdomayCostToAttackBlockEffect() {
|
CowedByWisdomayCostToAttackBlockEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK, null);
|
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK_AND_BLOCK);
|
||||||
staticText = "Enchanted creature can't attack or block unless its controller pays {1} for each card in your hand";
|
staticText = "Enchanted creature can't attack or block unless its controller pays {1} for each card in your hand";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,10 +93,12 @@ class CowedByWisdomayCostToAttackBlockEffect extends PayCostToAttackBlockEffectI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cost getCostToPay(GameEvent event, Ability source, Game game) {
|
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null && !controller.getHand().isEmpty()) {
|
if (controller != null && !controller.getHand().isEmpty()) {
|
||||||
return new GenericManaCost(controller.getHand().size());
|
ManaCosts manaCosts = new ManaCostsImpl();
|
||||||
|
manaCosts.add(new GenericManaCost(controller.getHand().size()));
|
||||||
|
return manaCosts;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,9 @@ package mage.sets.shadowmoor;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEachTurnStaticAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.AttachmentType;
|
import mage.constants.AttachmentType;
|
||||||
|
@ -55,7 +54,6 @@ public class BloodshedFever extends CardImpl {
|
||||||
this.expansionSetCode = "SHM";
|
this.expansionSetCode = "SHM";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -64,7 +62,8 @@ public class BloodshedFever extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Enchanted creature attacks each turn if able.
|
// Enchanted creature attacks each turn if able.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.AURA, Duration.WhileOnBattlefield, "Enchanted creature attacks each turn if able")));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||||
|
new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.AURA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BloodshedFever(final BloodshedFever card) {
|
public BloodshedFever(final BloodshedFever card) {
|
||||||
|
|
|
@ -28,19 +28,13 @@
|
||||||
package mage.sets.tempest;
|
package mage.sets.tempest;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.common.replacement.CantAttackYouUnlessPayManaAllEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -52,7 +46,8 @@ public class Propaganda extends CardImpl {
|
||||||
super(ownerId, 80, "Propaganda", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
|
super(ownerId, 80, "Propaganda", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
|
||||||
this.expansionSetCode = "TMP";
|
this.expansionSetCode = "TMP";
|
||||||
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PropagandaReplacementEffect()));
|
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you.
|
||||||
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayManaAllEffect(new ManaCostsImpl("{2}"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Propaganda(final Propaganda card) {
|
public Propaganda(final Propaganda card) {
|
||||||
|
@ -64,56 +59,3 @@ public class Propaganda extends CardImpl {
|
||||||
return new Propaganda(this);
|
return new Propaganda(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropagandaReplacementEffect extends ReplacementEffectImpl {
|
|
||||||
|
|
||||||
private static final String effectText = "Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you";
|
|
||||||
|
|
||||||
PropagandaReplacementEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
|
||||||
staticText = effectText;
|
|
||||||
}
|
|
||||||
|
|
||||||
PropagandaReplacementEffect(PropagandaReplacementEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
if (event.getTargetId().equals(source.getControllerId())) {
|
|
||||||
Player attackedPlayer = game.getPlayer(event.getTargetId());
|
|
||||||
if (attackedPlayer != null) {
|
|
||||||
// only if a player is attacked. Attacking a planeswalker is free
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
|
||||||
if (player != null) {
|
|
||||||
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
|
|
||||||
if (attackTax.canPay(source, source.getSourceId(), event.getPlayerId(), game)
|
|
||||||
&& player.chooseUse(Outcome.Neutral, "Pay {2} to attack player?", source, game)) {
|
|
||||||
if (attackTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropagandaReplacementEffect copy() {
|
|
||||||
return new PropagandaReplacementEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,15 +28,19 @@
|
||||||
package mage.sets.tenthedition;
|
package mage.sets.tenthedition;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
|
import mage.abilities.effects.common.replacement.CantAttackYouUnlessPayManaAllEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -56,8 +60,9 @@ public class WindbornMuse extends CardImpl {
|
||||||
|
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you.
|
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindbornMuseReplacementEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackYouUnlessPayManaAllEffect(new ManaCostsImpl("{2}"))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +80,12 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
private static final String effectText = "Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you";
|
private static final String effectText = "Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you";
|
||||||
|
|
||||||
WindbornMuseReplacementEffect ( ) {
|
WindbornMuseReplacementEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||||
staticText = effectText;
|
staticText = effectText;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindbornMuseReplacementEffect ( WindbornMuseReplacementEffect effect ) {
|
WindbornMuseReplacementEffect(WindbornMuseReplacementEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +96,7 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getTargetId().equals(source.getControllerId()) ) {
|
if (event.getTargetId().equals(source.getControllerId())) {
|
||||||
Player attackedPlayer = game.getPlayer(event.getTargetId());
|
Player attackedPlayer = game.getPlayer(event.getTargetId());
|
||||||
if (attackedPlayer != null) {
|
if (attackedPlayer != null) {
|
||||||
// only if a player is attacked. Attacking a planeswalker is free
|
// only if a player is attacked. Attacking a planeswalker is free
|
||||||
|
@ -104,11 +109,10 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
Player player = game.getPlayer(event.getPlayerId());
|
||||||
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
|
if (player != null && event.getTargetId().equals(source.getControllerId())) {
|
||||||
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
|
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
|
||||||
if ( attackTax.canPay(source, source.getSourceId(), event.getPlayerId(), game) &&
|
if (attackTax.canPay(source, source.getSourceId(), event.getPlayerId(), game)
|
||||||
player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", source, game) )
|
&& player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", source, game)) {
|
||||||
{
|
|
||||||
if (attackTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
|
if (attackTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,4 +128,3 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,4 +118,26 @@ public class CantAttackTest extends CardTestPlayerBase {
|
||||||
assertCounterCount("Ajani Goldmane", CounterType.LOYALTY, 2);
|
assertCounterCount("Ajani Goldmane", CounterType.LOYALTY, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCowedByWisdom() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||||
|
// Enchant creature
|
||||||
|
// Enchanted creature can't attack or block unless its controller pays {1} for each card in your hand.
|
||||||
|
addCard(Zone.HAND, playerA, "Cowed by Wisdom"); // Planeswalker 4 loyality counter
|
||||||
|
|
||||||
|
// Bushido 2 (When this blocks or becomes blocked, it gets +2/+2 until end of turn.)
|
||||||
|
// Battle-Mad Ronin attacks each turn if able.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Battle-Mad Ronin");
|
||||||
|
addCard(Zone.HAND, playerA, "Mountain", 4);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cowed by Wisdom", "Battle-Mad Ronin");
|
||||||
|
|
||||||
|
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertLife(playerA, 20);
|
||||||
|
|
||||||
|
assertTapped("Battle-Mad Ronin", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,38 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.VariableCost;
|
import mage.abilities.costs.VariableCost;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -40,12 +42,18 @@ import mage.abilities.costs.VariableCost;
|
||||||
public interface ManaCosts<T extends ManaCost> extends List<T>, ManaCost {
|
public interface ManaCosts<T extends ManaCost> extends List<T>, ManaCost {
|
||||||
|
|
||||||
ManaCosts<T> getUnpaidVariableCosts();
|
ManaCosts<T> getUnpaidVariableCosts();
|
||||||
|
|
||||||
List<VariableCost> getVariableCosts();
|
List<VariableCost> getVariableCosts();
|
||||||
|
|
||||||
int getX();
|
int getX();
|
||||||
|
|
||||||
void setX(int x);
|
void setX(int x);
|
||||||
|
|
||||||
void load(String mana);
|
void load(String mana);
|
||||||
|
|
||||||
List<String> getSymbols();
|
List<String> getSymbols();
|
||||||
|
|
||||||
|
boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Mana getMana();
|
Mana getMana();
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.costs.mana;
|
package mage.abilities.costs.mana;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -134,7 +133,8 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bookmarks the current state and restores it if player doesn't pay the mana cost
|
* bookmarks the current state and restores it if player doesn't pay the
|
||||||
|
* mana cost
|
||||||
*
|
*
|
||||||
* @param ability
|
* @param ability
|
||||||
* @param game
|
* @param game
|
||||||
|
@ -142,6 +142,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
* @param payingPlayerId
|
* @param payingPlayerId
|
||||||
* @return true if the cost was paid
|
* @return true if the cost was paid
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId) {
|
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId) {
|
||||||
int bookmark = game.bookmarkState();
|
int bookmark = game.bookmarkState();
|
||||||
if (pay(ability, game, sourceId, payingPlayerId, false)) {
|
if (pay(ability, game, sourceId, payingPlayerId, false)) {
|
||||||
|
@ -174,7 +175,6 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
return unpaid;
|
return unpaid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VariableCost> getVariableCosts() {
|
public List<VariableCost> getVariableCosts() {
|
||||||
List<VariableCost> variableCosts = new ArrayList<>();
|
List<VariableCost> variableCosts = new ArrayList<>();
|
||||||
|
@ -216,7 +216,6 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
}
|
}
|
||||||
|
|
||||||
//attempt to pay colored costs first
|
//attempt to pay colored costs first
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof ColoredManaCost) {
|
if (!cost.isPaid() && cost instanceof ColoredManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
@ -235,14 +234,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof SnowManaCost) {
|
if (!cost.isPaid() && cost instanceof SnowManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (ManaCost cost : this) {
|
for (ManaCost cost : this) {
|
||||||
if (!cost.isPaid() && cost instanceof GenericManaCost) {
|
if (!cost.isPaid() && cost instanceof GenericManaCost) {
|
||||||
cost.assignPayment(game, ability, pool);
|
cost.assignPayment(game, ability, pool);
|
||||||
|
@ -280,8 +277,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
} else {
|
} else {
|
||||||
if (!symbol.equals("X")) {
|
if (!symbol.equals("X")) {
|
||||||
this.add((T) new ColoredManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
this.add((T) new ColoredManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// check X wasn't added before
|
// check X wasn't added before
|
||||||
if (modifierForX == 0) {
|
if (modifierForX == 0) {
|
||||||
// count X occurence
|
// count X occurence
|
||||||
|
@ -296,11 +292,9 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
//TODO: handle multiple {X} and/or {Y} symbols
|
//TODO: handle multiple {X} and/or {Y} symbols
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(symbol.equals("snow"))
|
if (symbol.equals("snow")) {
|
||||||
{
|
|
||||||
this.add((T) new SnowManaCost());
|
this.add((T) new SnowManaCost());
|
||||||
}
|
} else if (Character.isDigit(symbol.charAt(0))) {
|
||||||
else if (Character.isDigit(symbol.charAt(0))) {
|
|
||||||
this.add((T) new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2))));
|
this.add((T) new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2))));
|
||||||
} else if (symbol.contains("P")) {
|
} else if (symbol.contains("P")) {
|
||||||
this.add((T) new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
this.add((T) new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
||||||
|
@ -443,7 +437,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
|
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
|
||||||
for(ManaCost manaCost: this) {
|
for (ManaCost manaCost : this) {
|
||||||
if (manaCost.containsColor(coloredManaSymbol)) {
|
if (manaCost.containsColor(coloredManaSymbol)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,6 +324,30 @@ public class ContinuousEffects implements Serializable {
|
||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkIfThereArePayCostToAttackBlockEffects(GameEvent event, Game game) {
|
||||||
|
for (ReplacementEffect effect : replacementEffects) {
|
||||||
|
if (!effect.checksEventType(event, game)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (effect instanceof PayCostToAttackBlockEffect) {
|
||||||
|
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
||||||
|
for (Ability ability : abilities) {
|
||||||
|
// for replacment effects of static abilities do not use LKI to check if to apply
|
||||||
|
if (ability.getAbilityType() != AbilityType.STATIC || ability.isInUseableZone(game, null, event)) {
|
||||||
|
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||||
|
if (!game.getScopeRelevant() || effect.hasSelfScope() || !event.getTargetId().equals(ability.getSourceId())) {
|
||||||
|
if (effect.applies(event, ability, game)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
|
|
|
@ -29,6 +29,7 @@ package mage.abilities.effects;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
|
@ -38,5 +39,7 @@ import mage.game.events.GameEvent;
|
||||||
*/
|
*/
|
||||||
public interface PayCostToAttackBlockEffect extends ReplacementEffect {
|
public interface PayCostToAttackBlockEffect extends ReplacementEffect {
|
||||||
|
|
||||||
Cost getCostToPay(GameEvent event, Ability source, Game game);
|
ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game);
|
||||||
|
|
||||||
|
Cost getOtherCostToPay(GameEvent event, Ability source, Game game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,13 @@ package mage.abilities.effects;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.mana.ManaCostImpl;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,12 +50,29 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Cost cost;
|
private final Cost cost;
|
||||||
|
private final ManaCosts manaCosts;
|
||||||
|
|
||||||
private final RestrictType restrictType;
|
private final RestrictType restrictType;
|
||||||
|
|
||||||
|
public PayCostToAttackBlockEffectImpl(Duration duration, Outcome outcome, RestrictType restrictType) {
|
||||||
|
super(duration, outcome, false);
|
||||||
|
this.restrictType = restrictType;
|
||||||
|
this.cost = null;
|
||||||
|
this.manaCosts = null;
|
||||||
|
}
|
||||||
|
|
||||||
public PayCostToAttackBlockEffectImpl(Duration duration, Outcome outcome, RestrictType restrictType, Cost cost) {
|
public PayCostToAttackBlockEffectImpl(Duration duration, Outcome outcome, RestrictType restrictType, Cost cost) {
|
||||||
super(duration, outcome, false);
|
super(duration, outcome, false);
|
||||||
this.restrictType = restrictType;
|
this.restrictType = restrictType;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
|
this.manaCosts = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PayCostToAttackBlockEffectImpl(Duration duration, Outcome outcome, RestrictType restrictType, ManaCosts manaCosts) {
|
||||||
|
super(duration, outcome, false);
|
||||||
|
this.restrictType = restrictType;
|
||||||
|
this.cost = null;
|
||||||
|
this.manaCosts = manaCosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PayCostToAttackBlockEffectImpl(PayCostToAttackBlockEffectImpl effect) {
|
public PayCostToAttackBlockEffectImpl(PayCostToAttackBlockEffectImpl effect) {
|
||||||
|
@ -64,6 +82,11 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
|
||||||
} else {
|
} else {
|
||||||
this.cost = null;
|
this.cost = null;
|
||||||
}
|
}
|
||||||
|
if (effect.manaCosts != null) {
|
||||||
|
this.manaCosts = effect.manaCosts.copy();
|
||||||
|
} else {
|
||||||
|
this.manaCosts = null;
|
||||||
|
}
|
||||||
this.restrictType = effect.restrictType;
|
this.restrictType = effect.restrictType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,20 +105,31 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
|
ManaCosts attackBlockManaTax = getManaCostToPay(event, source, game);
|
||||||
|
if (attackBlockManaTax != null) {
|
||||||
|
return handleManaCosts(attackBlockManaTax, event, source, game);
|
||||||
|
}
|
||||||
|
Cost attackBlockOtherTax = getOtherCostToPay(event, source, game);
|
||||||
|
if (attackBlockOtherTax != null) {
|
||||||
|
return handleOtherCosts(attackBlockOtherTax, event, source, game);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean handleManaCosts(ManaCosts attackBlockManaTax, GameEvent event, Ability source, Game game) {
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
Player player = game.getPlayer(event.getPlayerId());
|
||||||
Cost attackBlockTax = getCostToPay(event, source, game);
|
if (player != null) {
|
||||||
if (player != null && attackBlockTax != null) {
|
|
||||||
String chooseText;
|
String chooseText;
|
||||||
if (event.getType().equals(GameEvent.EventType.DECLARE_ATTACKER)) {
|
if (event.getType().equals(GameEvent.EventType.DECLARE_ATTACKER)) {
|
||||||
chooseText = "Pay " + attackBlockTax.getText() + " to attack?";
|
chooseText = "Pay " + attackBlockManaTax.getText() + " to attack?";
|
||||||
} else {
|
} else {
|
||||||
chooseText = "Pay " + attackBlockTax.getText() + " to block?";
|
chooseText = "Pay " + attackBlockManaTax.getText() + " to block?";
|
||||||
}
|
}
|
||||||
if (attackBlockTax.canPay(source, source.getSourceId(), player.getId(), game)
|
attackBlockManaTax.clearPaid();
|
||||||
|
if (attackBlockManaTax.canPay(source, source.getSourceId(), player.getId(), game)
|
||||||
&& player.chooseUse(Outcome.Neutral, chooseText, source, game)) {
|
&& player.chooseUse(Outcome.Neutral, chooseText, source, game)) {
|
||||||
if (attackBlockTax instanceof ManaCostImpl) {
|
if (attackBlockManaTax instanceof ManaCostsImpl) {
|
||||||
ManaCostsImpl manaCosts = new ManaCostsImpl(attackBlockTax.getText());
|
if (attackBlockManaTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) {
|
||||||
if (manaCosts.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +139,30 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean handleOtherCosts(Cost attackBlockOtherTax, GameEvent event, Ability source, Game game) {
|
||||||
|
Player player = game.getPlayer(event.getPlayerId());
|
||||||
|
if (player != null) {
|
||||||
|
attackBlockOtherTax.clearPaid();
|
||||||
|
if (attackBlockOtherTax.canPay(source, source.getSourceId(), event.getPlayerId(), game)
|
||||||
|
&& player.chooseUse(Outcome.Neutral,
|
||||||
|
attackBlockOtherTax.getText() + " to " + (event.getType().equals(EventType.DECLARE_ATTACKER) ? "attack?" : "block?"), source, game)) {
|
||||||
|
if (attackBlockOtherTax.pay(source, game, source.getSourceId(), event.getPlayerId(), false)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cost getCostToPay(GameEvent event, Ability source, Game game) {
|
public Cost getOtherCostToPay(GameEvent event, Ability source, Game game) {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
|
||||||
|
return manaCosts;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package mage.abilities.effects.common.replacement;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
|
||||||
|
import mage.abilities.effects.PayCostToAttackBlockEffectImpl.RestrictType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class CantAttackYouUnlessPayManaAllEffect extends PayCostToAttackBlockEffectImpl {
|
||||||
|
|
||||||
|
public CantAttackYouUnlessPayManaAllEffect(ManaCosts manaCosts) {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Detriment, RestrictType.ATTACK, manaCosts);
|
||||||
|
staticText = "Creatures can't attack you unless their controller pays " + manaCosts.getText() + " for each creature he or she controls that's attacking you";
|
||||||
|
}
|
||||||
|
|
||||||
|
CantAttackYouUnlessPayManaAllEffect(CantAttackYouUnlessPayManaAllEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
return source.getControllerId().equals(event.getTargetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CantAttackYouUnlessPayManaAllEffect copy() {
|
||||||
|
return new CantAttackYouUnlessPayManaAllEffect(this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,15 @@
|
||||||
*/
|
*/
|
||||||
package mage.game.combat;
|
package mage.game.combat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.RequirementEffect;
|
import mage.abilities.effects.RequirementEffect;
|
||||||
import mage.abilities.effects.RestrictionEffect;
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
|
@ -37,6 +46,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.common.FilterCreatureForCombatBlock;
|
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||||
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
@ -48,10 +58,6 @@ import mage.util.CardUtil;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
import mage.util.trace.TraceUtil;
|
import mage.util.trace.TraceUtil;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +139,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
|
|
||||||
public boolean useToughnessForDamage(Permanent permanent, Game game) {
|
public boolean useToughnessForDamage(Permanent permanent, Game game) {
|
||||||
if (useToughnessForDamage) {
|
if (useToughnessForDamage) {
|
||||||
for(FilterCreaturePermanent filter: useToughnessForDamageFilters) {
|
for (FilterCreaturePermanent filter : useToughnessForDamageFilters) {
|
||||||
if (filter.match(permanent, game)) {
|
if (filter.match(permanent, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +237,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" attacks with ").append(groups.size()).append(groups.size() == 1 ? " creature":" creatures").toString());
|
game.informPlayers(new StringBuilder(player.getLogName()).append(" attacks with ").append(groups.size()).append(groups.size() == 1 ? " creature" : " creatures").toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,12 +262,28 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mustAttack) {
|
if (mustAttack) {
|
||||||
|
// check which defenders the forced to attck creature can attack without paying a cost
|
||||||
|
HashSet<UUID> defendersCostlessAttackable = new HashSet<>();
|
||||||
|
defendersCostlessAttackable.addAll(defenders);
|
||||||
|
for (UUID defenderId : defenders) {
|
||||||
|
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||||
|
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
|
||||||
|
defenderId, creature.getId(), creature.getControllerId()), game)) {
|
||||||
|
defendersCostlessAttackable.remove(defenderId);
|
||||||
|
defendersForcedToAttack.remove(defenderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// force attack only if a defender can be attacked without paying a cost
|
||||||
|
if (!defendersCostlessAttackable.isEmpty()) {
|
||||||
|
// No need to attack a special defender
|
||||||
|
if (defendersForcedToAttack.isEmpty()) {
|
||||||
creaturesForcedToAttack.put(creature.getId(), defendersForcedToAttack);
|
creaturesForcedToAttack.put(creature.getId(), defendersForcedToAttack);
|
||||||
if (defendersForcedToAttack.isEmpty()) {
|
if (defendersForcedToAttack.isEmpty()) {
|
||||||
if (defenders.size() == 1) {
|
if (defendersCostlessAttackable.size() == 1) {
|
||||||
player.declareAttacker(creature.getId(), defenders.iterator().next(), game, false);
|
player.declareAttacker(creature.getId(), defenders.iterator().next(), game, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TargetDefender target = new TargetDefender(defenders, creature.getId());
|
TargetDefender target = new TargetDefender(defendersCostlessAttackable, creature.getId());
|
||||||
target.setRequired(true);
|
target.setRequired(true);
|
||||||
if (player.chooseTarget(Outcome.Damage, target, null, game)) {
|
if (player.chooseTarget(Outcome.Damage, target, null, game)) {
|
||||||
player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
|
player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
|
||||||
|
@ -273,6 +295,8 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkAttackRestrictions(Player player, Game game) {
|
protected void checkAttackRestrictions(Player player, Game game) {
|
||||||
|
@ -457,9 +481,10 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all requirements that apply and creates a Map with blockers and attackers
|
* Retrieves all requirements that apply and creates a Map with blockers and
|
||||||
* it contains only records if attackers can be retrieved
|
* attackers it contains only records if attackers can be retrieved //
|
||||||
* // Map<creature that can block, Set< all attackers the creature can block and force it to block the attacker>>
|
* Map<creature that can block,
|
||||||
|
* Set< all attackers the creature can block and force it to block the attacker>>
|
||||||
*
|
*
|
||||||
* @param attackingPlayer - attacker
|
* @param attackingPlayer - attacker
|
||||||
* @param game
|
* @param game
|
||||||
|
@ -582,7 +607,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
// check if the attacker is already blocked by a max of blockers, so blocker can't block it also
|
// check if the attacker is already blocked by a max of blockers, so blocker can't block it also
|
||||||
if (attackingCreature.getMaxBlockedBy() != 0) { // 0 = no restriction about the number of possible blockers
|
if (attackingCreature.getMaxBlockedBy() != 0) { // 0 = no restriction about the number of possible blockers
|
||||||
int alreadyBlockingCreatures = 0;
|
int alreadyBlockingCreatures = 0;
|
||||||
for(CombatGroup group :getGroups()) {
|
for (CombatGroup group : getGroups()) {
|
||||||
if (group.getAttackers().contains(attackingCreatureId)) {
|
if (group.getAttackers().contains(attackingCreatureId)) {
|
||||||
alreadyBlockingCreatures = group.getBlockers().size();
|
alreadyBlockingCreatures = group.getBlockers().size();
|
||||||
break;
|
break;
|
||||||
|
@ -999,7 +1024,6 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
// }
|
// }
|
||||||
// return total;
|
// return total;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public boolean attacksAlone() {
|
public boolean attacksAlone() {
|
||||||
return (groups.size() == 1 && groups.get(0).getAttackers().size() == 1);
|
return (groups.size() == 1 && groups.get(0).getAttackers().size() == 1);
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1130,6 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void removeBlockerGromGroup(UUID blockerId, CombatGroup groupToUnblock, Game game) {
|
public void removeBlockerGromGroup(UUID blockerId, CombatGroup groupToUnblock, Game game) {
|
||||||
Permanent creature = game.getPermanent(blockerId);
|
Permanent creature = game.getPermanent(blockerId);
|
||||||
if (creature != null) {
|
if (creature != null) {
|
||||||
|
|
Loading…
Reference in a new issue