Improved text generation.

This commit is contained in:
LevelX2 2012-11-18 14:07:49 +01:00
parent 1d46a90bbd
commit d065b95501
2 changed files with 26 additions and 2 deletions

View file

@ -35,6 +35,7 @@ import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
/**
* @author BetaSteward_at_googlemail.com
@ -59,6 +60,12 @@ public class CopyTargetSpellEffect extends OneShotEffect<CopyTargetSpellEffect>
copy.setCopiedSpell(true);
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
String activateMessage = copy.getSpellAbility().getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
}
game.informPlayers(player.getName() + " copies " + activateMessage);;
return true;
}
return false;

View file

@ -31,9 +31,11 @@ package mage.abilities.effects.common.counter;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.counters.Counter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author BetaSteward_at_googlemail.com
@ -41,17 +43,25 @@ import mage.game.permanent.Permanent;
public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffect> {
private Counter counter;
protected boolean informPlayers;
public AddCountersSourceEffect(Counter counter) {
this(counter, false);
}
public AddCountersSourceEffect(Counter counter, boolean informPlayers) {
super(Outcome.Benefit);
this.counter = counter.copy();
this.informPlayers = informPlayers;
setText();
}
public AddCountersSourceEffect(final AddCountersSourceEffect effect) {
super(effect);
if (effect.counter != null)
if (effect.counter != null) {
this.counter = effect.counter.copy();
}
this.informPlayers = effect.informPlayers;
}
@Override
@ -60,6 +70,12 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
if (permanent != null) {
if (counter != null) {
permanent.addCounters(counter.copy(), game);
if (informPlayers) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
}
}
}
}
return true;
@ -70,8 +86,9 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
StringBuilder sb = new StringBuilder();
sb.append("put ").append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters on {this}");
staticText = sb.toString();
} else
} else {
staticText = "put a " + counter.getName() + " counter on {this}";
}
}
@Override