mirror of
https://github.com/correl/mage.git
synced 2025-03-16 17:00:13 -09:00
Using common CanBlockAdditionalCreatureEffect.
This commit is contained in:
parent
a0bed272db
commit
43dcbbeda6
3 changed files with 31 additions and 107 deletions
|
@ -30,19 +30,12 @@ package mage.sets.magic2010;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
|
||||||
import mage.Constants.Layer;
|
|
||||||
import mage.Constants.Outcome;
|
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.SubLayer;
|
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -59,7 +52,8 @@ public class PalaceGuard extends CardImpl<PalaceGuard> {
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(4);
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PalaceGuardEffect()));
|
// Palace Guard can block any number of creatures.
|
||||||
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAdditionalCreatureEffect(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PalaceGuard(final PalaceGuard card) {
|
public PalaceGuard(final PalaceGuard card) {
|
||||||
|
@ -70,47 +64,4 @@ public class PalaceGuard extends CardImpl<PalaceGuard> {
|
||||||
public PalaceGuard copy() {
|
public PalaceGuard copy() {
|
||||||
return new PalaceGuard(this);
|
return new PalaceGuard(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PalaceGuardEffect extends ContinuousEffectImpl<PalaceGuardEffect> {
|
|
||||||
|
|
||||||
public PalaceGuardEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
|
||||||
staticText = "{this} can block any number of creatures";
|
|
||||||
}
|
|
||||||
|
|
||||||
public PalaceGuardEffect(final PalaceGuardEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PalaceGuardEffect copy() {
|
|
||||||
return new PalaceGuardEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
|
||||||
Permanent perm = game.getPermanent(source.getSourceId());
|
|
||||||
if (perm != null) {
|
|
||||||
switch (layer) {
|
|
||||||
case RulesEffects:
|
|
||||||
perm.setMaxBlocks(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasLayer(Layer layer) {
|
|
||||||
return layer == Layer.RulesEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,7 @@ package mage.sets.prophecy;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
|
||||||
import mage.Constants.Layer;
|
|
||||||
import mage.Constants.Outcome;
|
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.SubLayer;
|
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -42,12 +38,11 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.AdjustingSourceCosts;
|
import mage.abilities.costs.AdjustingSourceCosts;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
@ -71,7 +66,7 @@ public class AvatarOfHope extends CardImpl<AvatarOfHope> {
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
// Avatar of Hope can block any number of creatures.
|
// Avatar of Hope can block any number of creatures.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AvatarOfHopeEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAdditionalCreatureEffect(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvatarOfHope(final AvatarOfHope card) {
|
public AvatarOfHope(final AvatarOfHope card) {
|
||||||
|
@ -84,11 +79,8 @@ public class AvatarOfHope extends CardImpl<AvatarOfHope> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSourceCosts {
|
class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSourceCosts {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AdjustingCostsAbility() {
|
public AdjustingCostsAbility() {
|
||||||
super(Constants.Zone.OUTSIDE, new AdjustingCostsEffect());
|
super(Constants.Zone.OUTSIDE, new AdjustingCostsEffect());
|
||||||
}
|
}
|
||||||
|
@ -134,7 +126,9 @@ class AdjustingCostsEffect extends CostModificationEffectImpl<AdjustingCostsEffe
|
||||||
|
|
||||||
if (mana.getColorless() > 0 && player != null && player.getLife() < 4) {
|
if (mana.getColorless() > 0 && player != null && player.getLife() < 4) {
|
||||||
int newCount = mana.getColorless() - 6;
|
int newCount = mana.getColorless() - 6;
|
||||||
if (newCount < 0) newCount = 0;
|
if (newCount < 0) {
|
||||||
|
newCount = 0;
|
||||||
|
}
|
||||||
mana.setColorless(newCount);
|
mana.setColorless(newCount);
|
||||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||||
return true;
|
return true;
|
||||||
|
@ -155,45 +149,3 @@ class AdjustingCostsEffect extends CostModificationEffectImpl<AdjustingCostsEffe
|
||||||
return new AdjustingCostsEffect(this);
|
return new AdjustingCostsEffect(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AvatarOfHopeEffect extends ContinuousEffectImpl<AvatarOfHopeEffect> {
|
|
||||||
|
|
||||||
public AvatarOfHopeEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
|
||||||
staticText = "{this} can block any number of creatures";
|
|
||||||
}
|
|
||||||
|
|
||||||
public AvatarOfHopeEffect(final AvatarOfHopeEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AvatarOfHopeEffect copy() {
|
|
||||||
return new AvatarOfHopeEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
|
||||||
Permanent perm = game.getPermanent(source.getSourceId());
|
|
||||||
if (perm != null) {
|
|
||||||
switch (layer) {
|
|
||||||
case RulesEffects:
|
|
||||||
perm.setMaxBlocks(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasLayer(Layer layer) {
|
|
||||||
return layer == Layer.RulesEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -49,6 +49,11 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl<CanBl
|
||||||
this(1);
|
this(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the number of creatures source creature can block
|
||||||
|
*
|
||||||
|
* @param amount - 0 = any number, 1-x = n additional blocks
|
||||||
|
*/
|
||||||
public CanBlockAdditionalCreatureEffect(int amount) {
|
public CanBlockAdditionalCreatureEffect(int amount) {
|
||||||
this(Duration.WhileOnBattlefield, amount);
|
this(Duration.WhileOnBattlefield, amount);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +61,7 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl<CanBl
|
||||||
public CanBlockAdditionalCreatureEffect(Duration duration, int amount) {
|
public CanBlockAdditionalCreatureEffect(Duration duration, int amount) {
|
||||||
super(duration, Outcome.Benefit);
|
super(duration, Outcome.Benefit);
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
staticText = "{this} can block " + (amount == 1 ? "an": amount) + " additional creature";
|
staticText = setText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CanBlockAdditionalCreatureEffect(final CanBlockAdditionalCreatureEffect effect) {
|
public CanBlockAdditionalCreatureEffect(final CanBlockAdditionalCreatureEffect effect) {
|
||||||
|
@ -78,12 +83,13 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl<CanBl
|
||||||
// maxBlocks = 0 equals to "can block any number of creatures"
|
// maxBlocks = 0 equals to "can block any number of creatures"
|
||||||
if (perm.getMaxBlocks() > 0) {
|
if (perm.getMaxBlocks() > 0) {
|
||||||
perm.setMaxBlocks(perm.getMaxBlocks() + 1);
|
perm.setMaxBlocks(perm.getMaxBlocks() + 1);
|
||||||
|
} else {
|
||||||
|
perm.setMaxBlocks(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +98,21 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl<CanBl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String setText() {
|
||||||
|
StringBuilder sb = new StringBuilder("{this} can block ");
|
||||||
|
switch(amount) {
|
||||||
|
case 0:
|
||||||
|
sb.append("any number of creatures");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sb.append("an additional creature");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sb.append(amount).append(" additional creatures");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasLayer(Layer layer) {
|
public boolean hasLayer(Layer layer) {
|
||||||
return layer == Layer.RulesEffects;
|
return layer == Layer.RulesEffects;
|
||||||
|
|
Loading…
Add table
Reference in a new issue