Added some font color to object and player names output to game logging and feedback area.

This commit is contained in:
LevelX2 2015-05-09 21:18:00 +02:00
parent c3ea08b59c
commit 9c97953b6b
384 changed files with 745 additions and 636 deletions

View file

@ -40,6 +40,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.GameLog;
public abstract class MageObjectImpl implements MageObject {
@ -97,7 +98,7 @@ public abstract class MageObjectImpl implements MageObject {
@Override
public String getLogName() {
return name;
return GameLog.getColoredObjectName(this);
}
@Override

View file

@ -74,6 +74,7 @@ import mage.game.stack.StackAbility;
import mage.players.Player;
import mage.target.Target;
import mage.target.Targets;
import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
import mage.watchers.Watcher;
import org.apache.log4j.Logger;
@ -396,7 +397,7 @@ public abstract class AbilityImpl implements Ability {
}
if (variableManaCost != null) {
int xValue = getManaCostsToPay().getX();
game.informPlayers(new StringBuilder(controller.getName()).append(" announces a value of ").append(xValue).append(" for ").append(variableManaCost.getText()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" announces a value of ").append(xValue).append(" for ").append(variableManaCost.getText()).toString());
}
}
activated = true;
@ -483,7 +484,7 @@ public abstract class AbilityImpl implements Ability {
// set the xcosts to paid
variableCost.setAmount(xValue);
((Cost) variableCost).setPaid();
String message = new StringBuilder(controller.getName())
String message = new StringBuilder(controller.getLogName())
.append(" announces a value of ").append(xValue).append(" (").append(variableCost.getActionText()).append(")").toString();
if (announceString == null) {
announceString = message;
@ -997,9 +998,9 @@ public abstract class AbilityImpl implements Ability {
if (object instanceof StackAbility) {
Card card = game.getCard(((StackAbility) object).getSourceId());
if (card != null) {
sb.append(card.getLogName());
sb.append(GameLog.getColoredObjectName(card));
} else {
sb.append(object.getName());
sb.append(GameLog.getColoredObjectName(object));
}
} else {
if (object instanceof Spell) {
@ -1011,7 +1012,7 @@ public abstract class AbilityImpl implements Ability {
}
sb.append(getOptionalTextSuffix(game, spell));
} else {
sb.append(object.getLogName());
sb.append(GameLog.getColoredObjectName(object));
}
}
} else {
@ -1074,7 +1075,7 @@ public abstract class AbilityImpl implements Ability {
}
protected String getTargetDescriptionForLog(Targets targets, Game game) {
StringBuilder sb = threadLocalBuilder.get();
StringBuilder sb = new StringBuilder(); // threadLocal StringBuilder can't be used because calling method already uses it
if (targets.size() > 0) {
String usedVerb = null;
for (Target target : targets) {
@ -1099,7 +1100,7 @@ public abstract class AbilityImpl implements Ability {
}
private String getOptionalTextSuffix(Game game, Spell spell) {
StringBuilder sb = threadLocalBuilder.get();
StringBuilder sb = new StringBuilder();
for (Ability ability : spell.getAbilities()) {
if (ability instanceof OptionalAdditionalSourceCosts) {
sb.append(((OptionalAdditionalSourceCosts) ability).getCastMessageSuffix());

View file

@ -125,10 +125,10 @@ class KinshipBaseEffect extends OneShotEffect {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controller.lookAtCards(sourcePermanent.getLogName(), cards, game);
controller.lookAtCards(sourcePermanent.getName(), cards, game);
if (CardUtil.shareSubtypes(sourcePermanent, card)) {
if (controller.chooseUse(outcome,new StringBuilder("Kinship - Reveal ").append(card.getLogName()).append("?").toString(), game)) {
controller.revealCards(sourcePermanent.getLogName(), cards, game);
controller.revealCards(sourcePermanent.getName(), cards, game);
for (Effect effect: kinshipEffects) {
effect.setTargetPointer(new FixedTarget(card.getId()));
if (effect.getEffectType().equals(EffectType.ONESHOT)) {

View file

@ -42,7 +42,7 @@ import mage.game.Game;
public class CastCommanderAbility extends SpellAbility {
public CastCommanderAbility(Card card) {
super(card.getManaCost(), card.getLogName(), Zone.COMMAND, SpellAbilityType.BASE);
super(card.getManaCost(), card.getName(), Zone.COMMAND, SpellAbilityType.BASE);
this.timing = TimingRule.SORCERY;
this.usesStack = true;
this.controllerId = card.getOwnerId();

View file

@ -64,7 +64,7 @@ public class ExileFromStackCost extends CostImpl {
}
paid |= spellToExile.moveToExile(null, "", ability.getSourceId(), game);
if (paid && !game.isSimulation()) {
game.informPlayers(player.getName() + " exiles " + spellToExile.getName() +" (as costs)");
game.informPlayers(player.getLogName() + " exiles " + spellToExile.getName() +" (as costs)");
}
}
}

View file

@ -73,7 +73,7 @@ public class ExileSourceCost extends CostImpl {
String exileZoneName = "";
if (toUniqueExileZone) {
exileZoneId = CardUtil.getExileZoneId(game, ability.getSourceId(), ability.getSourceObjectZoneChangeCounter());
exileZoneName = sourceObject.getLogName();
exileZoneName = sourceObject.getName();
}
paid = controller.moveCardToExileWithInfo((Card) sourceObject, exileZoneId, exileZoneName, sourceId, game, game.getState().getZone(sourceObject.getId()), true);
}

View file

@ -131,7 +131,7 @@ public class RemoveCounterCost extends CostImpl {
}
countersRemoved += numberOfCountersSelected;
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName())
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" removes ").append(numberOfCountersSelected == 1 ? "a":numberOfCountersSelected).append(" ")
.append(counterName).append(numberOfCountersSelected == 1 ? " counter from ":" counters from ")
.append(permanent.getName()).toString());

View file

@ -54,7 +54,7 @@ public class RevealHandSourceControllerCost extends CostImpl {
Player controller = game.getPlayer(controllerId);
MageObject sourceObject = game.getObject(sourceId);
if (controller != null && sourceObject != null) {
controller.revealCards(sourceObject.getLogName(), controller.getHand(), game);
controller.revealCards(sourceObject.getName(), controller.getHand(), game);
paid = true;
}
return paid;

View file

@ -1084,7 +1084,7 @@ public class ContinuousEffects implements Serializable {
for (Ability ability :entry.getValue()) {
MageObject object = game.getObject(ability.getSourceId());
if (object != null) {
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), object.getLogName() +": " + ability.getRule(object.getLogName()));
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), object.getName() +": " + ability.getRule(object.getName()));
} else {
texts.put(ability.getId().toString() + "_" + entry.getKey().getId().toString(), entry.getKey().getText(null));
}

View file

@ -83,7 +83,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
player.choose(Outcome.Damage, redirectTarget, null, game);
}
if (!game.isSimulation())
game.informPlayers(new StringBuilder(player.getName()).append(" redirects ")
game.informPlayers(new StringBuilder(player.getLogName()).append(" redirects ")
.append(event.getAmount())
.append(" damage to ")
.append(game.getPermanent(redirectTarget.getFirstTarget()).getLogName()).toString());

View file

@ -116,7 +116,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
cards.addAll(target.getTargets());
int amountCounters = cards.size() * amplifyFactor.getFactor();
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), game);
controller.revealCards(sourceCreature.getLogName(), cards, game);
controller.revealCards(sourceCreature.getName(), cards, game);
}
}
}

View file

@ -64,7 +64,7 @@ public class ChooseColorEffect extends OneShotEffect {
}
}
if (!game.isSimulation())
game.informPlayers(new StringBuilder(permanent.getLogName()).append(": ").append(controller.getName()).append(" has chosen ").append(choice.getChoice()).toString());
game.informPlayers(new StringBuilder(permanent.getLogName()).append(": ").append(controller.getLogName()).append(" has chosen ").append(choice.getChoice()).toString());
game.getState().setValue(source.getSourceId() + "_color", choice.getColor());
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + choice.getColor().getDescription() + "</font>", game);
return true;

View file

@ -68,7 +68,7 @@ public class ChooseCreatureTypeEffect extends OneShotEffect {
}
}
if (!game.isSimulation())
game.informPlayers(permanent.getName() + ": " + controller.getName() + " has chosen " + typeChoice.getChoice());
game.informPlayers(permanent.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
permanent.addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
}

View file

@ -81,7 +81,7 @@ public class ChooseModeEffect extends OneShotEffect {
}
if (choice.isChosen()) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(sourcePermanent.getLogName()).append(": ").append(controller.getName()).append(" has chosen ").append(choice.getChoice()).toString());
game.informPlayers(new StringBuilder(sourcePermanent.getLogName()).append(": ").append(controller.getLogName()).append(" has chosen ").append(choice.getChoice()).toString());
game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice());
sourcePermanent.addInfo("_modeChoice", "<font color = 'blue'>Chosen mode: " + choice.getChoice() + "</font>", game);
}

View file

@ -109,23 +109,23 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
boolean topOpponent = true;
// Reveal top cards of involved players
StringBuilder message = new StringBuilder("Clash: ");
message.append(controller.getName());
message.append(controller.getLogName());
if (controller.getLibrary().size() > 0) {
Cards cards = new CardsImpl();
cardController = controller.getLibrary().getFromTop(game);
cards.add(cardController);
controller.revealCards("for clash by " + controller.getName(), cards, game);
controller.revealCards("for clash by " + controller.getLogName(), cards, game);
cmcController = cardController.getManaCost().convertedManaCost();
message.append(" (").append(cmcController).append(")");
} else {
message.append(" no card");
}
message.append(" vs. ").append(opponent.getName());
message.append(" vs. ").append(opponent.getLogName());
if (opponent.getLibrary().size() > 0) {
Cards cards = new CardsImpl();
cardOpponent = opponent.getLibrary().getFromTop(game);
cards.add(cardOpponent);
opponent.revealCards("for clash by " + opponent.getName(), cards, game);
opponent.revealCards("for clash by " + opponent.getLogName(), cards, game);
cmcOpponent = cardOpponent.getManaCost().convertedManaCost();
message.append(" (").append(cmcOpponent).append(")");
} else {
@ -134,11 +134,11 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
message.append(" - ");
if (!game.isSimulation()) {
if (cmcController > cmcOpponent) {
message.append(controller.getName()).append(" won the clash");
message.append(controller.getLogName()).append(" won the clash");
game.informPlayer(controller, "You won the clash!");
} else if (cmcController < cmcOpponent) {
message.append(opponent.getName()).append(" won the clash");
game.informPlayer(controller, opponent.getName() + " won the clash!");
message.append(opponent.getLogName()).append(" won the clash");
game.informPlayer(controller, opponent.getLogName() + " won the clash!");
} else {
message.append(" no winner ");
}

View file

@ -465,7 +465,7 @@ class TargetWithAdditionalFilter<T extends MageItem> extends TargetImpl {
} else {
Player player = game.getPlayer(targetId);
if (player != null) {
sb.append(player.getName()).append(" ");
sb.append(player.getLogName()).append(" ");
}
}
}

View file

@ -70,7 +70,7 @@ public class CopyTargetSpellEffect extends OneShotEffect {
activateMessage = activateMessage.substring(6);
}
if (!game.isSimulation())
game.informPlayers(player.getName() + " copies " + activateMessage);
game.informPlayers(player.getLogName() + " copies " + activateMessage);
return true;
}
return false;

View file

@ -85,7 +85,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
} else {
message = chooseUseText;
}
message = CardUtil.replaceSourceName(message, sourceObject.getLogName());
message = CardUtil.replaceSourceName(message, sourceObject.getName());
boolean result = true;
boolean doEffect = true;
// check if any player is willing to pay
@ -95,7 +95,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (!game.isSimulation())
game.informPlayers(player.getName() + " pays the cost to prevent the effect");
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
doEffect = false;
break;
}

View file

@ -81,7 +81,7 @@ public class ExileSourceEffect extends OneShotEffect {
String exileZoneName = "";
if (toUniqueExileZone) {
exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
exileZoneName = sourceObject.getLogName();
exileZoneName = sourceObject.getName();
}
Card sourceCard = (Card) sourceObject;
return controller.moveCardToExileWithInfo(sourceCard, exileZoneId, exileZoneName, source.getSourceId(), game, game.getState().getZone(sourceCard.getId()), true);

View file

@ -71,11 +71,11 @@ public class ExileTargetForSourceEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (permanent != null) {
return controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getLogName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
return controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
} else {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
return controller.moveCardToExileWithInfo(card, exileId, sourceObject.getLogName(), source.getSourceId(), game, game.getState().getZone(card.getId()), true);
return controller.moveCardToExileWithInfo(card, exileId, sourceObject.getName(), source.getSourceId(), game, game.getState().getZone(card.getId()), true);
}
}
}

View file

@ -39,7 +39,7 @@ public class FlipSourceEffect extends OneShotEffect {
ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.getInstance(), "");
game.addEffect(effect, source);
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(" flips ").append(permanent.getName()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" flips ").append(permanent.getName()).toString());
return true;
}
}

View file

@ -142,7 +142,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
} else {
card.moveToZone(targetPickedCards, source.getSourceId(), game, false);
if (!game.isSimulation())
game.informPlayers(player.getName() + " moves a card to " + targetPickedCards.toString().toLowerCase());
game.informPlayers(player.getLogName() + " moves a card to " + targetPickedCards.toString().toLowerCase());
}
if (revealPickedCards) {
reveal.add(card);

View file

@ -44,7 +44,7 @@ public class LookLibraryMayPutToBottomEffect extends OneShotEffect {
if (card == null) {
return false;
}
controller.lookAtCards(sourceObject.getLogName(), new CardsImpl(card), game);
controller.lookAtCards(sourceObject.getName(), new CardsImpl(card), game);
boolean toBottom = controller.chooseUse(outcome, "Put card on the bottom of your library?", game);
return controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, !toBottom, false);
}

View file

@ -67,7 +67,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
player.lookAtCards(sourceObject.getLogName(), cards, game);
player.lookAtCards(sourceObject.getName(), cards, game);
}
return true;
}

View file

@ -83,7 +83,7 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl
StringBuilder sb = new StringBuilder(sourceObject.getName()).append(": Prevent the next ");
sb.append(multiTarget.getTargetAmount(targetId)).append(" damage to ");
if (player != null) {
sb.append(player.getName());
sb.append(player.getLogName());
} else if (permanent != null) {
sb.append(permanent.getName());
}

View file

@ -70,7 +70,7 @@ public class PutTokenOntoBattlefieldCopySource extends OneShotEffect {
CardUtil.copyTo(token).from((Permanent)thisCard);
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName())
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts a ").append(token.getName()).append(" token ").append("onto the Battlefield").toString());
return true;
}
@ -81,7 +81,7 @@ public class PutTokenOntoBattlefieldCopySource extends OneShotEffect {
CardUtil.copyTo(token).from(permanent);
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName())
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts a ").append(token.getName()).append(" token ").append("onto the Battlefield").toString());
return true;
}

View file

@ -93,7 +93,7 @@ public class ReturnFromExileEffect extends OneShotEffect {
case BATTLEFIELD:
card.moveToZone(zone, source.getSourceId(), game, tapped);
if (!game.isSimulation()) {
game.informPlayers(controller.getName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
}
break;
case HAND:
@ -108,7 +108,7 @@ public class ReturnFromExileEffect extends OneShotEffect {
default:
card.moveToZone(zone, source.getSourceId(), game, tapped);
if (!game.isSimulation()) {
game.informPlayers(controller.getName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
game.informPlayers(controller.getLogName() + " moves " + card.getName() + " to " + zone.toString().toLowerCase());
}
}
}

View file

@ -107,7 +107,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
return false;
}
if (!game.isSimulation()) {
game.informPlayers(controller.getName() + " moves " + card.getLogName() + " from exile to " + returnToZone.toString().toLowerCase());
game.informPlayers(controller.getLogName() + " moves " + card.getLogName() + " from exile to " + returnToZone.toString().toLowerCase());
}
card.moveToZone(returnToZone, source.getSourceId(), game, tapped);
}

View file

@ -82,7 +82,7 @@ public class RevealAndShuffleIntoLibrarySourceEffect extends OneShotEffect {
if (owner != null) {
Zone fromZone = game.getState().getZone(sourceObject.getId());
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getLogName(), cards, game);
controller.revealCards(sourceObject.getName(), cards, game);
}
if (permanent != null) {
controller.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, fromZone, true, true);

View file

@ -82,7 +82,7 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
return false;
}
if (!game.isSimulation())
game.informPlayers(target.getName() + ": " + controller.getName() + " has chosen " + choiceColor.getChoice());
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
if (choiceColor.getColor().isBlack()) {
sb.append("B");
} else if (choiceColor.getColor().isBlue()) {

View file

@ -97,7 +97,7 @@ public class BecomesColorTargetEffect extends ContinuousEffectImpl {
return false;
}
if (!game.isSimulation())
game.informPlayers(controller.getName() + " has chosen the color: " + objectColor.toString());
game.informPlayers(controller.getLogName() + " has chosen the color: " + objectColor.toString());
} else {
objectColor = this.setColor;
}

View file

@ -135,7 +135,7 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", game)){
boolean result = permanent.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
if (!game.isSimulation())
game.informPlayers(player.getName() + " has moved his or her commander to the command zone");
game.informPlayers(player.getLogName() + " has moved his or her commander to the command zone");
return result;
}
}
@ -155,7 +155,7 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl {
if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", game)){
boolean result = card.moveToZone(Zone.COMMAND, source.getSourceId(), game, false);
if (!game.isSimulation())
game.informPlayers(player.getName() + " has moved his or her commander to the command zone");
game.informPlayers(player.getLogName() + " has moved his or her commander to the command zone");
return result;
}
}

View file

@ -78,7 +78,7 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect
}
}
if (choice.isChosen() && !game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getName() + " has chosen protection from " + choice.getChoice());
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen protection from " + choice.getChoice());
}
}
}

View file

@ -74,7 +74,7 @@ public class AddCountersAllEffect extends OneShotEffect {
permanent.addCounters(counter.copy(), game);
if (!game.isSimulation())
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
.append(controller.getName()).append(" puts ")
.append(controller.getLogName()).append(" puts ")
.append(counter.getCount()).append(" ").append(counter.getName().toLowerCase())
.append(" counter on ").append(permanent.getName()).toString());
}

View file

@ -106,7 +106,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
if (informPlayers && !game.isSimulation()) {
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.getLogName()).toString());
game.informPlayers(new StringBuilder(player.getLogName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(card.getLogName()).toString());
}
}
}
@ -129,7 +129,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
int amountAdded = permanent.getCounters().getCount(newCounter.getName()) - before;
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getName()+" puts "+amountAdded+" "+newCounter.getName().toLowerCase()+" counter on "+permanent.getLogName());
game.informPlayers(player.getLogName()+" puts "+amountAdded+" "+newCounter.getName().toLowerCase()+" counter on "+permanent.getLogName());
}
}
}

View file

@ -96,7 +96,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
int numberAdded = permanent.getCounters().getCount(counter.getName()) - before;
affectedTargets ++;
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() +": "+ controller.getName()+ " puts " +
game.informPlayers(sourceObject.getLogName() +": "+ controller.getLogName()+ " puts " +
numberAdded + " " + counter.getName().toLowerCase() + " counter on " + permanent.getLogName());
}
}
@ -109,9 +109,9 @@ public class AddCountersTargetEffect extends OneShotEffect {
affectedTargets ++;
if (!game.isSimulation())
game.informPlayers(new StringBuilder(sourceObject.getLogName()).append(": ")
.append(controller.getName()).append(" puts ")
.append(controller.getLogName()).append(" puts ")
.append(counter.getCount()).append(" ").append(counter.getName().toLowerCase())
.append(" counter on ").append(player.getName()).toString());
.append(" counter on ").append(player.getLogName()).toString());
}
}
}

View file

@ -113,7 +113,7 @@ public class ProliferateEffect extends OneShotEffect {
choices.add(counter.getName());
}
choice.setChoices(choices);
choice.setMessage("Choose a counter to proliferate (" + player.getName() + ")");
choice.setMessage("Choose a counter to proliferate (" + player.getLogName() + ")");
controller.choose(Outcome.Benefit, choice, game);
for (Counter counter : player.getCounters().values()) {
if (counter.getName().equals(choice.getChoice())) {

View file

@ -134,9 +134,9 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
Cards revealedCards = new CardsImpl(Zone.HAND);
numberToReveal = Math.min(player.getHand().size(), numberToReveal);
if (player.getHand().size() > numberToReveal) {
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in target player's hand"));
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in "+ player.getLogName() +"'s hand"));
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(player.getId(), game) && player.choose(Outcome.Discard, player.getHand(), chosenCards, game)) {
if (chosenCards.canChoose(player.getId(), game) && player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) {
if (!chosenCards.getTargets().isEmpty()) {
List<UUID> targets = chosenCards.getTargets();
for (UUID targetid : targets) {

View file

@ -93,13 +93,13 @@ public class SearchLibraryPutOnLibraryEffect extends SearchEffect {
Cards foundCards = new CardsImpl();
foundCards.addAll(cards);
if (reveal) {
controller.revealCards(sourceObject.getLogName(), foundCards, game);
controller.revealCards(sourceObject.getName(), foundCards, game);
}
if (forceShuffle) {
controller.shuffleLibrary(game);
}
if (cards.size() > 0 && !game.isSimulation()) {
game.informPlayers(controller.getName() + " moves " + cards.size() + " card" + (cards.size() == 1 ? " ":"s ") + "on top of his or her library");
game.informPlayers(controller.getLogName() + " moves " + cards.size() + " card" + (cards.size() == 1 ? " ":"s ") + "on top of his or her library");
}
for (Card card: cards) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);

View file

@ -96,7 +96,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
// cards in Graveyard
int cardsCount = (cardName.isEmpty() ? 0 :targetPlayer.getGraveyard().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getLogName());
TargetCard target = new TargetCard((graveyardExileOptional ? 0 :cardsCount), cardsCount,Zone.GRAVEYARD, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
List<UUID> targets = target.getTargets();
@ -113,7 +113,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
// cards in Hand
cardsCount = (cardName.isEmpty() ? 0 :targetPlayer.getHand().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getLogName());
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
List<UUID> targets = target.getTargets();
@ -127,7 +127,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
}
} else {
if (targetPlayer.getHand().size() > 0) {
controller.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game);
controller.lookAtCards(targetPlayer.getLogName() + " hand", targetPlayer.getHand(), game);
}
}
@ -136,7 +136,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getName());
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter);
if (controller.choose(Outcome.Exile, cardsInLibrary, target, game)) {
List<UUID> targets = target.getTargets();

View file

@ -246,7 +246,7 @@ class ConspireEffect extends OneShotEffect {
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(copy.getActivatedMessage(game)).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
return true;
}
}

View file

@ -252,7 +252,7 @@ class ConvokeEffect extends OneShotEffect {
manaName = "colorless";
}
if (!game.isSimulation())
game.informPlayers("Convoke: " + controller.getName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana");
game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana");
}
}

View file

@ -100,7 +100,7 @@ class DredgeEffect extends ReplacementEffectImpl {
&& player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getName()).
append("? (").append(amount).append(" cards go from top of library to graveyard)").toString(), game)) {
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(player.getName()).append(" dreges ").append(sourceCard.getName()).toString());
game.informPlayers(new StringBuilder(player.getLogName()).append(" dreges ").append(sourceCard.getName()).toString());
}
Cards cardsToGrave = new CardsImpl();
cardsToGrave.addAll(player.getLibrary().getTopCards(game, amount));

View file

@ -212,7 +212,7 @@ class FlashbackEffect extends OneShotEffect {
spellAbility.getManaCostsToPay().setX(amount);
}
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(" flashbacks ").append(card.getName()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" flashbacks ").append(card.getName()).toString());
spellAbility.setCostModificationActive(false); // prevents to apply cost modification twice for flashbacked spells
if (controller.cast(spellAbility, game, true)) {
game.addEffect(new FlashbackReplacementEffect(), source);

View file

@ -219,7 +219,7 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
xManaValue = game.getPlayer(this.controllerId).announceXMana(varCosts.get(0).getMinX(), Integer.MAX_VALUE, "Announce kicker value for " + varCosts.get(0).getText(), game, this);
// kicker variable X costs handled internally as multikicker with {1} cost (no multikicker on card)
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(game.getPlayer(this.controllerId).getName()).append(" announced a value of ").append(xManaValue).append(" for ").append(" kicker X ").toString());
game.informPlayers(game.getPlayer(this.controllerId).getLogName() + " announced a value of " + xManaValue +" for " + " kicker X ");
}
ability.getManaCostsToPay().add(new GenericManaCost(xManaValue));
} else {

View file

@ -255,7 +255,7 @@ class ReplicateCopyEffect extends OneShotEffect {
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(copy.getActivatedMessage(game)).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
}
return true;
}

View file

@ -109,7 +109,7 @@ class SunburstEffect extends OneShotEffect {
if (!game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
game.informPlayers(player.getLogName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
}
}
}

View file

@ -282,7 +282,7 @@ class SuspendExileEffect extends OneShotEffect {
}
card.addCounters(CounterType.TIME.createInstance(suspend), game);
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(" suspends (").append(suspend).append(") ").append(card.getName()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" suspends (").append(suspend).append(") ").append(card.getName()).toString());
return true;
}
}

View file

@ -120,13 +120,13 @@ class TributeEffect extends OneShotEffect {
sb.append(tributeValue > 1 ? "s":"").append(" to it)?");
if (opponent.chooseUse(outcome, sb.toString(), game)) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(opponent.getName()).append(" pays tribute to ").append(sourcePermanent.getName()).toString());
game.getState().setValue(new StringBuilder("tributeValue").append(source.getSourceId()).toString(), "yes");
game.informPlayers(opponent.getLogName() + " pays tribute to " + sourcePermanent.getLogName());
game.getState().setValue("tributeValue" + source.getSourceId(), "yes");
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(tributeValue), true).apply(game, source);
} else {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(opponent.getName()).append(" does not pay tribute to ").append(sourcePermanent.getName()).toString());
game.getState().setValue(new StringBuilder("tributeValue").append(source.getSourceId()).toString(), "no");
game.informPlayers(opponent.getLogName() + " does not pay tribute to " + sourcePermanent.getLogName());
game.getState().setValue("tributeValue"+ source.getSourceId(), "no");
}
return true;
}

View file

@ -113,7 +113,7 @@ class UnleashReplacementEffect extends ReplacementEffectImpl {
if (creature != null && controller != null) {
if (controller.chooseUse(outcome, "Unleash "+ creature.getName() +"?", game)) {
if (!game.isSimulation())
game.informPlayers(controller.getName() + " unleashes " + creature.getName());
game.informPlayers(controller.getLogName() + " unleashes " + creature.getName());
creature.addCounters(CounterType.P1P1.createInstance(), game);
}
}

View file

@ -54,7 +54,7 @@ public class MageDrawAction extends MageAction {
score += value;
}
if (!player.isTopCardRevealed() && numDrawn > 0) {
game.fireInformEvent(player.getName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : ""));
game.fireInformEvent(player.getLogName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : ""));
}
if (player.isEmptyDraw()) {
GameEvent event = GameEvent.getEvent(GameEvent.EventType.EMPTY_DRAW, player.getId(), player.getId());
@ -85,7 +85,7 @@ public class MageDrawAction extends MageAction {
drawnCards.add(card);
card.moveToZone(Zone.HAND, null, game, false);
if (player.isTopCardRevealed()) {
game.fireInformEvent(player.getName() + " draws a revealed card (" + card.getLogName() + ")");
game.fireInformEvent(player.getLogName() + " draws a revealed card (" + card.getLogName() + ")");
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DREW_CARD, card.getId(), player.getId()));

View file

@ -67,6 +67,7 @@ import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.PermanentCard;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.util.GameLog;
import mage.watchers.Watcher;
import org.apache.log4j.Logger;
@ -208,7 +209,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public List<String> getRules() {
try {
return abilities.getRules(this.getLogName());
return abilities.getRules(this.getName());
} catch (Exception e) {
logger.info("Exception in rules generation for card: " + this.getName(), e);
}
@ -741,10 +742,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public String getLogName() {
// if (this.isFaceDown()) {
// return "facedown card";
// }
return name;
if (name.isEmpty()) {
return GameLog.getNeutralColoredText("face down card");
} else {
return GameLog.getColoredObjectName(this);
}
}
@Override

View file

@ -51,12 +51,12 @@ public class NamePredicate implements Predicate<MageObject> {
// If a player names a card, the player may name either half of a split card, but not both.
// A split card has the chosen name if one of its two names matches the chosen name.
if (input instanceof SplitCard) {
return name.equals(((SplitCard)input).getLeftHalfCard().getName()) || name.equals(((SplitCard)input).getRightHalfCard().getLogName());
return name.equals(((SplitCard)input).getLeftHalfCard().getName()) || name.equals(((SplitCard)input).getRightHalfCard().getName());
} else if (input instanceof Spell && ((Spell)input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)){
SplitCard card = (SplitCard) ((Spell)input).getCard();
return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getLogName());
return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getName());
} else {
return name.equals(input.getLogName());
return name.equals(input.getName());
}
}

View file

@ -150,7 +150,7 @@ public abstract class GameCommanderImpl extends GameImpl {
}
}
player.drawCards(numCards - deduction, this);
fireInformEvent(new StringBuilder(player.getName())
fireInformEvent(new StringBuilder(player.getLogName())
.append(" mulligans ")
.append(numCards)
.append(numCards == 1? " card":" cards")

View file

@ -538,7 +538,7 @@ public abstract class GameImpl implements Game, Serializable {
if (winnerId == null) {
return "Game is a draw";
}
return new StringBuilder("Player ").append(state.getPlayer(winnerId).getName()).append(" is the winner").toString();
return "Player "+ state.getPlayer(winnerId).getName() + " is the winner";
}
@Override
@ -699,7 +699,7 @@ public abstract class GameImpl implements Game, Serializable {
state.setExtraTurn(true);
state.setTurnId(extraTurn.getId());
if (!this.isSimulation()) {
informPlayers(extraPlayer.getName() + " takes an extra turn");
informPlayers(extraPlayer.getLogName() + " takes an extra turn");
}
playTurn(extraPlayer);
state.setTurnNum(state.getTurnNum() + 1);
@ -747,7 +747,7 @@ public abstract class GameImpl implements Game, Serializable {
private void logStartOfTurn(Player player) {
StringBuilder sb = new StringBuilder("Turn ").append(state.getTurnNum()).append(" ");
sb.append(player.getName());
sb.append(player.getLogName());
sb.append(" (");
int delimiter = this.getPlayers().size() - 1;
for (Player gamePlayer : this.getPlayers().values()) {
@ -817,11 +817,11 @@ public abstract class GameImpl implements Game, Serializable {
if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
startingPlayerId = targetPlayer.getTargets().get(0);
Player startingPlayer = state.getPlayer(startingPlayerId);
StringBuilder message = new StringBuilder(choosingPlayer.getName()).append(" chooses that ");
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
if (choosingPlayer.getId().equals(startingPlayerId)) {
message.append("he or she");
} else {
message.append(startingPlayer.getName());
message.append(startingPlayer.getLogName());
}
message.append(" takes the first turn");
@ -868,10 +868,10 @@ public abstract class GameImpl implements Game, Serializable {
if (keep) {
endMulligan(player.getId());
keepPlayers.add(playerId);
fireInformEvent(player.getName() + " keeps hand");
fireInformEvent(player.getLogName() + " keeps hand");
} else {
mulliganPlayers.add(playerId);
fireInformEvent(player.getName() + " decides to take mulligan");
fireInformEvent(player.getLogName() + " decides to take mulligan");
}
}
}
@ -959,7 +959,7 @@ public abstract class GameImpl implements Game, Serializable {
protected UUID pickChoosingPlayer() {
UUID[] players = getPlayers().keySet().toArray(new UUID[0]);
UUID playerId = players[rnd.nextInt(players.length)];
fireInformEvent(state.getPlayer(playerId).getName() + " won the toss");
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
return playerId;
}
@ -1031,7 +1031,7 @@ public abstract class GameImpl implements Game, Serializable {
usedFreeMulligans.put(player.getId(), 1);
}
}
fireInformEvent(new StringBuilder(player.getName())
fireInformEvent(new StringBuilder(player.getLogName())
.append(" mulligans")
.append(deduction == 0 ? " for free and draws ":" down to ")
.append(Integer.toString(numCards - deduction))
@ -1074,7 +1074,7 @@ public abstract class GameImpl implements Game, Serializable {
Player player = state.getPlayer(playerId);
if (player != null) {
logger.debug(new StringBuilder("Player ").append(player.getName()).append(" concedes game ").append(this.getId()));
fireInformEvent(player.getName() + " has conceded.");
fireInformEvent(player.getLogName() + " has conceded.");
player.concede(this);
}
}
@ -2142,7 +2142,7 @@ public abstract class GameImpl implements Game, Serializable {
if (targetObject == null) {
Player targetPlayer = game.getPlayer(event.getTargetId());
if (targetPlayer != null) {
targetName = targetPlayer.getName();
targetName = targetPlayer.getLogName();
}
} else {
targetName = targetObject.getLogName();

View file

@ -231,7 +231,7 @@ public class Combat implements Serializable, Copyable<Combat> {
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(player.getName()).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());
}
}
@ -382,7 +382,7 @@ public class Combat implements Serializable, Copyable<Combat> {
for (CombatGroup group : this.getGroups()) {
if (group.defendingPlayerId.equals(defender.getId())) {
if (!shownDefendingPlayer) {
game.informPlayers(new StringBuilder("Attacked player: ").append(defender.getName()).toString());
game.informPlayers("Attacked player: " + defender.getLogName());
shownDefendingPlayer = true;
}
StringBuilder sb = new StringBuilder();
@ -899,7 +899,7 @@ public class Combat implements Serializable, Copyable<Combat> {
game.informPlayer(attackingPlayer, new StringBuilder("No more than ")
.append(CardUtil.numberToText(defendingPlayer.getMaxAttackedBy()))
.append(" creatures can attack ")
.append(defendingPlayer.getName()).toString());
.append(defendingPlayer.getLogName()).toString());
}
return false;
}

View file

@ -42,6 +42,7 @@ import mage.game.Game;
import java.util.List;
import java.util.UUID;
import mage.util.GameLog;
/**
*
@ -100,7 +101,7 @@ public class Commander implements CommandObject{
@Override
public String getLogName() {
return card.getName();
return GameLog.getColoredObjectName(this);
}
@Override

View file

@ -40,6 +40,7 @@ import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.GameLog;
/**
* @author nantuko
@ -100,7 +101,7 @@ public class Emblem implements CommandObject {
@Override
public String getLogName() {
return name;
return GameLog.getColoredObjectName(this);
}
@Override

View file

@ -420,7 +420,7 @@ public abstract class MatchImpl implements Match {
StringBuilder sb = new StringBuilder();
sb.append("<br/><b>Match score:</b><br/>");
for (MatchPlayer mp :this.getPlayers()) {
sb.append(" ").append(mp.getName());
sb.append(" ").append(mp.getPlayer().getLogName());
sb.append(" - ").append(mp.getWins()).append(mp.getWins()==1?" win":" wins");
if (mp.hasQuit()) {
sb.append(" QUITTED");

View file

@ -76,6 +76,7 @@ import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.util.GameLog;
import mage.util.ThreadLocalStringBuilder;
/**
@ -996,7 +997,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
moveToZone(Zone.GRAVEYARD, sourceId, game, false);
Player player = game.getPlayer(getControllerId());
if (player != null && !game.isSimulation()) {
game.informPlayers(new StringBuilder(player.getName()).append(" sacrificed ").append(this.getLogName()).toString());
game.informPlayers(new StringBuilder(player.getLogName()).append(" sacrificed ").append(this.getLogName()).toString());
}
game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT, objectId, sourceId, controllerId));
return true;
@ -1280,12 +1281,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
public String getLogName() {
if (name.isEmpty()) {
if (faceDown) {
return "face down creature";
return GameLog.getNeutralColoredText("face down creature");
} else {
return "a creature without name";
return GameLog.getNeutralColoredText("a creature without name");
}
}
return name;
return GameLog.getColoredObjectName(this);
}
@Override

View file

@ -165,7 +165,7 @@ public class Token extends MageObjectImpl {
}
}
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(controller.getName()).append(" puts ")
game.informPlayers(new StringBuilder(controller.getLogName()).append(" puts ")
.append(CardUtil.numberToText(amount, "a")).append(" ").append(this.getName()).append(" token").append(amount==1?"":"s")
.append(" onto the battlefield").toString());
}

View file

@ -63,6 +63,7 @@ import mage.game.permanent.PermanentCard;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetAmount;
import mage.util.GameLog;
/**
*
@ -168,8 +169,7 @@ public class Spell implements StackObject, Card {
return "a card face down";
}
}
return getSpellAbility().toString();
return GameLog.replaceNameByColoredName(card, getSpellAbility().toString());
}
@Override
@ -512,7 +512,7 @@ public class Spell implements StackObject, Card {
if (object == null) {
Player targetPlayer = game.getPlayer(targetId);
if (targetPlayer != null) {
name = targetPlayer.getName();
name = targetPlayer.getLogName();
}
} else {
name = object.getName();
@ -545,7 +545,7 @@ public class Spell implements StackObject, Card {
@Override
public String getLogName() {
return card.getName();
return GameLog.getColoredObjectName(card);
}
@Override

View file

@ -63,6 +63,7 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetAmount;
import mage.util.GameLog;
import mage.watchers.Watcher;
/**
@ -131,7 +132,7 @@ public class StackAbility implements StackObject, Ability {
@Override
public String getLogName() {
return name;
return GameLog.getColoredObjectName(this);
}
@Override
@ -730,7 +731,7 @@ public class StackAbility implements StackObject, Ability {
if (object == null) {
Player targetPlayer = game.getPlayer(targetId);
if (targetPlayer != null) {
targetNames = targetPlayer.getName();
targetNames = targetPlayer.getLogName();
}
} else {
targetNames = object.getName();

View file

@ -82,6 +82,7 @@ public interface Player extends MageItem, Copyable<Player> {
boolean isHuman();
String getName();
String getLogName();
RangeOfInfluence getRange();
Library getLibrary();
Cards getSideboard();

View file

@ -127,6 +127,7 @@ import mage.target.TargetPermanent;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetDiscard;
import mage.util.CardUtil;
import mage.util.GameLog;
import mage.watchers.common.BloodthirstWatcher;
import org.apache.log4j.Logger;
@ -632,7 +633,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public void discardToMax(Game game) {
if (hand.size() > this.maxHandSize) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(getName()).append(" discards down to ").append(this.maxHandSize).append(this.maxHandSize == 1 ? " hand card" : " hand cards").toString());
game.informPlayers(getLogName() + " discards down to " + this.maxHandSize + (this.maxHandSize == 1 ? " hand card" : " hand cards"));
discard(hand.size() - this.maxHandSize, null, game);
}
}
@ -726,7 +727,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card != null) {
// write info to game log first so game log infos from triggered or replacement effects follow in the game log
if (!game.isSimulation())
game.informPlayers(new StringBuilder(name).append(" discards ").append(card.getName()).toString());
game.informPlayers(getLogName() + " discards " + card.getLogName());
/* If a card is discarded while Rest in Peace is on the battlefield, abilities that function
* when a card is discarded (such as madness) still work, even though that card never reaches
* a graveyard. In addition, spells or abilities that check the characteristics of a discarded
@ -917,11 +918,16 @@ public abstract class PlayerImpl implements Player, Serializable {
}
setCastSourceIdWithoutMana(null);
if (spell.activate(game, noMana)) {
// for (Ability spellAbility: spell.getSpellAbilities()) {
// for (Effect effect: spellAbility.getEffects()) {
// effect.getTargetPointer().init(game, ability);
// }
// }
GameEvent event = GameEvent.getEvent(GameEvent.EventType.SPELL_CAST, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId);
event.setZone(fromZone);
game.fireEvent(event);
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(name).append(spell.getActivatedMessage(game)).toString());
game.informPlayers(getLogName() + spell.getActivatedMessage(game));
}
game.removeBookmark(bookmark);
resetStoredBookmark(game);
@ -973,7 +979,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card.putOntoBattlefield(game, zone, null, playerId)) {
landsPlayed++;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LAND_PLAYED, card.getId(), card.getId(), playerId));
game.fireInformEvent(name + " plays " + card.getName());
game.fireInformEvent(getLogName() + " plays " + card.getLogName());
// game.removeBookmark(bookmark);
resetStoredBookmark(game);
return true;
@ -1012,7 +1018,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (ability.activate(game, false)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATED_ABILITY, ability.getId(), ability.getSourceId(), playerId));
if (!game.isSimulation())
game.informPlayers(new StringBuilder(name).append(ability.getGameLogMessage(game)).toString());
game.informPlayers(getLogName() + ability.getGameLogMessage(game));
game.removeBookmark(bookmark);
resetStoredBookmark(game);
return true;
@ -1039,7 +1045,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (action.activate(game, false)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATED_ABILITY, action.getSourceId(), action.getId(), playerId));
if (!game.isSimulation())
game.informPlayers(new StringBuilder(name).append(action.getGameLogMessage(game)).toString());
game.informPlayers(getLogName() + action.getGameLogMessage(game));
if (action.resolve(game)) {
game.removeBookmark(bookmark);
resetStoredBookmark(game);
@ -1265,7 +1271,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.SHUFFLE_LIBRARY, playerId, playerId))) {
this.library.shuffle();
if (!game.isSimulation())
game.informPlayers(new StringBuilder(this.name).append(" shuffles his or her library.").toString());
game.informPlayers(getLogName() + " shuffles his or her library.");
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SHUFFLED, playerId, playerId));
}
}
@ -1279,11 +1285,11 @@ public abstract class PlayerImpl implements Player, Serializable {
public void revealCards(String name, Cards cards, Game game, boolean postToLog) {
game.getState().getRevealed().add(name, cards);
if (postToLog && !game.isSimulation()) {
StringBuilder sb = new StringBuilder(this.getName()).append(" reveals ");
StringBuilder sb = new StringBuilder(getLogName()).append(" reveals ");
int current = 0, last = cards.size();
for (Card card : cards.getCards(game)) {
current++;
sb.append(card.getName());
sb.append(card.getLogName());
if (current < last) {
sb.append(", ");
}
@ -1359,7 +1365,7 @@ public abstract class PlayerImpl implements Player, Serializable {
StringBuilder sb = new StringBuilder(message).append(" to untap").append(" (").append(Math.min(leftForUntap.size(), numberToUntap)).append(" in total");
MageObject effectSource = game.getObject(ability.getSourceId());
if (effectSource != null) {
sb.append(" from ").append(effectSource.getName()).toString();
sb.append(" from ").append(effectSource.getLogName()).toString();
}
sb.append(")");
filter.setMessage(sb.toString());
@ -1407,7 +1413,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!game.isSimulation()) {
// show in log which permanents were selected to untap
for (Permanent permanent : selectedToUntap) {
game.informPlayers(new StringBuilder(this.getName()).append(" untapped ").append(permanent.getName()).toString());
game.informPlayers(this.getLogName() + " untapped " + permanent.getLogName());
}
}
// untap if permanent is not concerned by notMoreThan effects or is included in the selectedToUntapList
@ -1488,6 +1494,11 @@ public abstract class PlayerImpl implements Player, Serializable {
return name;
}
@Override
public String getLogName() {
return GameLog.getColoredPlayerName(name);
}
@Override
public boolean isHuman() {
return human;
@ -1558,7 +1569,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (!game.replaceEvent(event)) {
this.life -= event.getAmount();
if (!game.isSimulation())
game.informPlayers(new StringBuilder(this.getName()).append(" loses ").append(event.getAmount()).append(" life").toString());
game.informPlayers(this.getLogName() + " loses " + event.getAmount() + " life");
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount));
return amount;
}
@ -1583,8 +1594,9 @@ public abstract class PlayerImpl implements Player, Serializable {
GameEvent event = new GameEvent(GameEvent.EventType.GAIN_LIFE, playerId, playerId, playerId, amount, false);
if (!game.replaceEvent(event)) {
this.life += event.getAmount();
if (!game.isSimulation())
game.informPlayers(new StringBuilder(this.getName()).append(" gains ").append(event.getAmount()).append(" life").toString());
if (!game.isSimulation()) {
game.informPlayers(this.getLogName() + " gains " + event.getAmount() + " life");
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, playerId, playerId, event.getAmount()));
return event.getAmount();
}
@ -1774,7 +1786,7 @@ public abstract class PlayerImpl implements Player, Serializable {
quit = true;
this.concede(game);
logger.debug(getName() + " quits the match.");
game.informPlayers(getName() + " quits the match.");
game.informPlayers(getLogName() + " quits the match.");
}
@Override
@ -1782,7 +1794,7 @@ public abstract class PlayerImpl implements Player, Serializable {
quit = true;
timerTimeout = true;
this.concede(game);
game.informPlayers(getName() + " has run out of time. Loosing the Match.");
game.informPlayers(getLogName() + " has run out of time. Loosing the Match.");
}
@Override
@ -1790,7 +1802,7 @@ public abstract class PlayerImpl implements Player, Serializable {
quit = true;
idleTimeout = true;
this.concede(game);
game.informPlayers(new StringBuilder(getName()).append(" was idle for too long. Loosing the Match.").toString());
game.informPlayers(new StringBuilder(getLogName()).append(" was idle for too long. Loosing the Match.").toString());
}
@Override
@ -1889,14 +1901,14 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public void lostForced(Game game) {
logger.debug(this.getName() + " has lost gameId: " + game.getId());
logger.debug(this.getLogName() + " has lost gameId: " + game.getId());
//20100423 - 603.9
if (!this.wins) {
this.loses = true;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST, null, null, playerId));
game.informPlayers(this.getName() + " has lost the game.");
game.informPlayers(this.getLogName() + " has lost the game.");
} else {
logger.debug(this.getName() + " has already won - stop lost");
logger.debug(this.getLogName() + " has already won - stop lost");
}
// for draw - first all players that have lost have to be set to lost
if (!hasLeft()) {
@ -1945,7 +1957,7 @@ public abstract class PlayerImpl implements Player, Serializable {
}
if (opponentsAlive == 0 && !hasWon()) {
logger.debug("player won -> No more opponents alive game won: " + this.getName());
game.informPlayers(new StringBuilder(this.getName()).append(" has won the game").toString());
game.informPlayers(this.getLogName() + " has won the game");
this.wins = true;
game.end();
}
@ -2012,12 +2024,12 @@ public abstract class PlayerImpl implements Player, Serializable {
Library searchedLibrary = null;
String searchInfo = null;
if (targetPlayerId.equals(playerId)) {
searchInfo = getName() + " searches his or her library";
searchInfo = getLogName() + " searches his or her library";
searchedLibrary = library;
} else {
Player targetPlayer = game.getPlayer(targetPlayerId);
if (targetPlayer != null) {
searchInfo = getName() + " searches the library of " + targetPlayer.getName();
searchInfo = getLogName() + " searches the library of " + targetPlayer.getLogName();
searchedLibrary = targetPlayer.getLibrary();
}
}
@ -2068,7 +2080,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public boolean flipCoin(Game game, ArrayList<UUID> appliedEffects) {
boolean result = rnd.nextBoolean();
if (!game.isSimulation())
game.informPlayers("[Flip a coin] " + getName() + (result ? " won (head)." : " lost (tail)."));
game.informPlayers("[Flip a coin] " + getLogName() + (result ? " won (head)." : " lost (tail)."));
GameEvent event = new GameEvent(GameEvent.EventType.FLIP_COIN, playerId, null, playerId, 0, result);
event.setAppliedEffects(appliedEffects);
game.replaceEvent(event);
@ -2734,7 +2746,7 @@ public abstract class PlayerImpl implements Player, Serializable {
public void revealFaceDownCard(Card card, Game game) {
if (game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.REVEAL_FACE_DOWN, this.getId(), game)) {
Cards cards = new CardsImpl(card);
this.revealCards(name, cards, game);
this.revealCards(getName(), cards, game);
}
}
@ -2803,7 +2815,7 @@ public abstract class PlayerImpl implements Player, Serializable {
card = game.getCard(card.getId());
}
if (!game.isSimulation()) {
StringBuilder sb = new StringBuilder(this.getName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
switch(fromZone) {
case EXILED:
sb.append(" from exile zone ");
@ -2890,7 +2902,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card instanceof PermanentCard) {
card = game.getCard(card.getId());
}
StringBuilder sb = new StringBuilder(this.getName())
StringBuilder sb = new StringBuilder(this.getLogName())
.append(" puts ").append(card.getLogName()).append(" ")
.append(fromZone != null ? new StringBuilder("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") : "");
if (card.getOwnerId().equals(getId())) {
@ -2913,7 +2925,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card instanceof PermanentCard) {
card = game.getCard(card.getId());
}
StringBuilder sb = new StringBuilder(this.getName())
StringBuilder sb = new StringBuilder(this.getLogName())
.append(" puts ").append(withName ? card.getLogName() : "a card").append(" ");
if (fromZone != null) {
if (fromZone.equals(Zone.PICK)) {
@ -2928,7 +2940,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} else {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
sb.append(" of ").append(player.getName()).append("'s library");
sb.append(" of ").append(player.getLogName()).append("'s library");
}
}
game.informPlayers(sb.toString());
@ -2946,10 +2958,9 @@ public abstract class PlayerImpl implements Player, Serializable {
if (card instanceof PermanentCard) {
card = game.getCard(card.getId());
}
game.informPlayers(new StringBuilder(this.getName())
.append(" moves ").append(withName ? card.getLogName() : "a card face down").append(" ")
.append(fromZone != null ? new StringBuilder("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") : "")
.append("to the exile zone").toString());
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() : "a card face down") + " " +
(fromZone != null ? new StringBuilder("from ") + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "") +
"to the exile zone");
}
result = true;
}
@ -2971,7 +2982,7 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean result = false;
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) {
if (!game.isSimulation())
game.informPlayers(new StringBuilder(this.getName())
game.informPlayers(new StringBuilder(this.getLogName())
.append(" puts ").append(facedown ? "a card face down ":card.getLogName())
.append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")
.append("onto the Battlefield").toString());

View file

@ -198,7 +198,7 @@ public class TargetPlayer extends TargetImpl {
for (UUID targetId: getTargets()) {
Player player = game.getPlayer(targetId);
if (player != null) {
sb.append(player.getName()).append(" ");
sb.append(player.getLogName()).append(" ");
} else {
sb.append("[target missing]");
}

View file

@ -229,7 +229,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
else {
Player player = game.getPlayer(targetId);
if (player != null) {
sb.append(player.getName()).append(" ");
sb.append(player.getLogName()).append(" ");
}
}
}

View file

@ -212,7 +212,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
}
else {
Player player = game.getPlayer(targetId);
sb.append(player.getName()).append("(").append(getTargetAmount(targetId)).append(") ");
sb.append(player.getLogName()).append("(").append(getTargetAmount(targetId)).append(") ");
}
}
return sb.toString();

View file

@ -174,7 +174,7 @@ public class TargetDefender extends TargetImpl {
}
else {
Player player = game.getPlayer(targetId);
sb.append(player.getName()).append(" ");
sb.append(player.getLogName()).append(" ");
}
}
return sb.toString();

View file

@ -252,7 +252,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
}
else {
Player player = game.getPlayer(targetId);
sb.append(player.getName()).append(" ");
sb.append(player.getLogName()).append(" ");
}
}
return sb.toString();

View file

@ -0,0 +1,85 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 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
* provided with the distribution.
*
* 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
* 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
* 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
* 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
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.util;
import mage.MageObject;
import mage.ObjectColor;
/**
*
* @author LevelX2
*/
public class GameLog {
static final String LOG_COLOR_PLAYER = "#20B2AA"; // LightSeaGreen
static final String LOG_COLOR_GREEN = "#90EE90"; // LightGreen
static final String LOG_COLOR_RED = "#FF6347"; // Tomato
static final String LOG_COLOR_BLUE = "#87CEFA"; // LightSkyBlue
static final String LOG_COLOR_BLACK = "#696969"; // DimGray // "#5F9EA0"; // CadetBlue
static final String LOG_COLOR_WHITE = "#F0E68C"; // Khaki
static final String LOG_COLOR_MULTI = "#DAA520"; // GoldenRod
static final String LOG_COLOR_COLORLESS = "#B0C4DE"; // LightSteelBlue
static final String LOG_COLOR_NEUTRAL = "#F0F8FF"; // AliceBlue
public static String replaceNameByColoredName(MageObject mageObject, String text) {
return text.replaceAll(mageObject.getName(), getColoredObjectName(mageObject));
}
public static String getColoredObjectName(MageObject mageObject) {
return "<font color=\'" + getColorName(mageObject.getColor()) + "\'>" + mageObject.getName() + "</font>";
}
public static String getNeutralColoredText(String text) {
return "<font color=\'" + LOG_COLOR_NEUTRAL + "\'>" + text + "</font>";
}
public static String getColoredPlayerName(String name) {
return "<font color=\'" + LOG_COLOR_PLAYER + "\'>" + name + "</font>";
}
private static String getColorName(ObjectColor objectColor) {
if (objectColor.isMulticolored()) {
return LOG_COLOR_MULTI;
} else if (objectColor.isColorless()){
return LOG_COLOR_COLORLESS;
} else if (objectColor.isRed()){
return LOG_COLOR_RED;
} else if (objectColor.isGreen()){
return LOG_COLOR_GREEN;
} else if (objectColor.isBlue()){
return LOG_COLOR_BLUE;
} else if (objectColor.isWhite()){
return LOG_COLOR_WHITE;
} else {
return LOG_COLOR_BLACK;
}
}
}

View file

@ -89,7 +89,7 @@ public class CommanderInfoWatcher extends Watcher {
MageObject commander = game.getObject(sourceId);
if (player != null && commander != null){
if (!game.isSimulation())
game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getName() + " during the game.");
game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getLogName() + " during the game.");
this.addCardInfoToCommander(game);
}
}
@ -119,7 +119,7 @@ public class CommanderInfoWatcher extends Watcher {
for (Map.Entry<UUID, Integer> entry : damageToPlayer.entrySet()) {
Player damagedPlayer = game.getPlayer(entry.getKey());
sb.setLength(0);
sb.append("<b>Commander</b> did ").append(entry.getValue()).append(" combat damage to player ").append(damagedPlayer.getName()).append(".");
sb.append("<b>Commander</b> did ").append(entry.getValue()).append(" combat damage to player ").append(damagedPlayer.getLogName()).append(".");
this.addInfo(object, new StringBuilder("Commander").append(entry.getKey()).toString(),sb.toString(), game);
}
}

View file

@ -89,7 +89,7 @@ public class SoulbondWatcher extends Watcher {
chosen.setPairedCard(permanent.getId());
permanent.setPairedCard(chosen.getId());
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(" souldbonds ").append(permanent.getLogName()).append(" with ").append(chosen.getName()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" souldbonds ").append(permanent.getLogName()).append(" with ").append(chosen.getName()).toString());
}
}
}
@ -114,7 +114,7 @@ public class SoulbondWatcher extends Watcher {
chosen.setPairedCard(permanent.getId());
permanent.setPairedCard(chosen.getId());
if (!game.isSimulation())
game.informPlayers(new StringBuilder(controller.getName()).append(" souldbonds ").append(permanent.getLogName()).append(" with ").append(chosen.getName()).toString());
game.informPlayers(new StringBuilder(controller.getLogName()).append(" souldbonds ").append(permanent.getLogName()).append(" with ").append(chosen.getName()).toString());
break;
}
}