mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Some changes to Suspend (not finished) and AddCountersSourceEffect.
This commit is contained in:
parent
b6fddc301c
commit
beb3affa7c
2 changed files with 71 additions and 34 deletions
|
@ -33,6 +33,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -44,8 +45,9 @@ import mage.players.Player;
|
|||
public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffect> {
|
||||
|
||||
private Counter counter;
|
||||
protected boolean informPlayers;
|
||||
protected DynamicValue amount;
|
||||
private boolean informPlayers;
|
||||
private DynamicValue amount;
|
||||
private boolean putOnCard;
|
||||
|
||||
public AddCountersSourceEffect(Counter counter) {
|
||||
this(counter, false);
|
||||
|
@ -55,17 +57,23 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
this(counter, new StaticValue(0), informPlayers);
|
||||
}
|
||||
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers) {
|
||||
this(counter, amount, informPlayers, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param informPlayers
|
||||
* @param putOnCard - counters have to be put on a card instead of a permanent
|
||||
*/
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers) {
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers, boolean putOnCard) {
|
||||
super(Outcome.Benefit);
|
||||
this.counter = counter.copy();
|
||||
this.informPlayers = informPlayers;
|
||||
this.amount = amount;
|
||||
this.putOnCard = putOnCard;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -76,25 +84,45 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
}
|
||||
this.informPlayers = effect.informPlayers;
|
||||
this.amount = effect.amount;
|
||||
this.putOnCard = effect.putOnCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
newCounter.add(amount.calculate(game, source));
|
||||
permanent.addCounters(newCounter, game);
|
||||
if (informPlayers) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(new StringBuilder(player.getName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(permanent.getName()).toString());
|
||||
if (putOnCard) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
newCounter.add(amount.calculate(game, source));
|
||||
card.addCounters(newCounter, game);
|
||||
if (informPlayers) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(new StringBuilder(player.getName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(card.getName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
newCounter.add(amount.calculate(game, source));
|
||||
permanent.addCounters(newCounter, game);
|
||||
if (informPlayers) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(new StringBuilder(player.getName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(permanent.getName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
|
|
|
@ -47,7 +47,9 @@ import mage.abilities.condition.common.SuspendedCondition;
|
|||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
|
||||
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.CounterType;
|
||||
|
@ -143,20 +145,22 @@ public class SuspendAbility extends ActivatedAbilityImpl<SuspendAbility> {
|
|||
public SuspendAbility(int suspend, ManaCost cost, Card card) {
|
||||
super(Zone.HAND, new SuspendExileEffect(suspend), cost);
|
||||
this.usesStack = false;
|
||||
ruleText = new StringBuilder("Suspend ").append(suspend).append(" - ").append(cost.getText())
|
||||
.append(" <i>(Rather than cast this card from your hand, pay ")
|
||||
.append(cost.getText())
|
||||
.append(" and exile it with ")
|
||||
.append(suspend == 1 ? "a time counter":suspend + " time counters")
|
||||
.append(" on it.")
|
||||
.append(" At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.")
|
||||
.append(card.getCardType().contains(CardType.CREATURE)? " If you play it this way and it's a creature, it gains haste until you lose control of it.":"")
|
||||
.append(")</i>")
|
||||
.toString();
|
||||
StringBuilder sb = new StringBuilder("Suspend ");
|
||||
if (cost != null) {
|
||||
sb.append(suspend).append(" - ").append(cost.getText())
|
||||
.append(" <i>(Rather than cast this card from your hand, pay ")
|
||||
.append(cost.getText())
|
||||
.append(" and exile it with ")
|
||||
.append(suspend == 1 ? "a time counter":suspend + " time counters")
|
||||
.append(" on it.")
|
||||
.append(" At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.")
|
||||
.append(card.getCardType().contains(CardType.CREATURE)? " If you play it this way and it's a creature, it gains haste until you lose control of it.":"")
|
||||
.append(")</i>");
|
||||
}
|
||||
ruleText = sb.toString();
|
||||
if (card.getManaCost().isEmpty()) {
|
||||
setRuleAtTheTop(true);
|
||||
}
|
||||
|
||||
// add triggered ability to remove the counter from the card
|
||||
Ability ability = new ConditionalTriggeredAbility(
|
||||
new BeginningOfUpkeepTriggeredAbility(Zone.EXILED, new RemoveCounterSourceEffect(CounterType.TIME.createInstance()), TargetController.YOU, false),
|
||||
|
@ -167,11 +171,11 @@ public class SuspendAbility extends ActivatedAbilityImpl<SuspendAbility> {
|
|||
// add triggered ability that casts the suspended card, if all counters are removed
|
||||
card.addAbility(new SuspendPlayCardAbility(card.getCardType().contains(CardType.CREATURE)));
|
||||
// if it's a creature card, add Haste ability
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainHasteEffect(Duration.WhileOnBattlefield));
|
||||
ability.setRuleVisible(false);
|
||||
card.addAbility(ability);
|
||||
}
|
||||
// if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
// ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainHasteEffect(Duration.WhileOnBattlefield));
|
||||
// ability.setRuleVisible(false);
|
||||
// card.addAbility(ability);
|
||||
// }
|
||||
}
|
||||
|
||||
public SuspendAbility(SuspendAbility ability) {
|
||||
|
@ -252,6 +256,11 @@ class SuspendPlayCardAbility extends TriggeredAbilityImpl<SuspendPlayCardAbility
|
|||
|
||||
public SuspendPlayCardAbility(boolean isCreature) {
|
||||
super(Zone.EXILED, new SuspendPlayCardEffect(isCreature));
|
||||
if (isCreature) {
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainHasteEffect(Duration.WhileOnBattlefield));
|
||||
Effect effect = new GainAbilitySourceEffect(ability, Duration.WhileOnBattlefield);
|
||||
this.addEffect(effect);
|
||||
}
|
||||
setRuleVisible(false);
|
||||
}
|
||||
|
||||
|
@ -286,8 +295,8 @@ class SuspendPlayCardEffect extends OneShotEffect<SuspendPlayCardEffect> {
|
|||
|
||||
public SuspendPlayCardEffect(boolean isCreature) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = new StringBuilder("play it without paying its mana cost if able. If you can't, it remains removed from the game")
|
||||
.append(isCreature ? ". If you play it this way and it's a creature, it gains haste until you lose control of it":"").toString();
|
||||
this.staticText = "play it without paying its mana cost if able. If you can't, it remains removed from the game";
|
||||
|
||||
}
|
||||
|
||||
public SuspendPlayCardEffect(final SuspendPlayCardEffect effect) {
|
||||
|
|
Loading…
Reference in a new issue