Added some methods to write card move infos more easy to game log.

This commit is contained in:
LevelX2 2014-01-26 16:41:17 +01:00
parent 778a3ce688
commit d07c7b490b
4 changed files with 68 additions and 5 deletions

View file

@ -113,18 +113,20 @@ class PeregrinationEffect extends OneShotEffect<PeregrinationEffect> {
target2.setRequired(true); target2.setRequired(true);
player.choose(Outcome.Benefit, revealed, target2, game); player.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game); Card card = revealed.get(target2.getFirstTarget(), game);
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
revealed.remove(card); revealed.remove(card);
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) { if (permanent != null) {
permanent.setTapped(true); permanent.setTapped(true);
} }
card = revealed.getCards(game).iterator().next(); card = revealed.getCards(game).iterator().next();
card.moveToZone(Zone.HAND, source.getId(), game, false); player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
} }
else if (target.getTargets().size() == 1) { else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next(); Card card = revealed.getCards(game).iterator().next();
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId()); player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) { if (permanent != null) {
permanent.setTapped(true); permanent.setTapped(true);

View file

@ -72,9 +72,11 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect<ReturnF
if (card != null && game.getState().getZone(cardId).equals(Zone.GRAVEYARD)) { if (card != null && game.getState().getZone(cardId).equals(Zone.GRAVEYARD)) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
if (informPlayers) { if (informPlayers) {
game.informPlayers(new StringBuilder(player.getName()).append(" returned ").append(card.getName()).append(" from graveyard to hand").toString()); player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
} else {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
} }
} }
} }

View file

@ -50,6 +50,7 @@ import mage.cards.decks.Deck;
import mage.choices.Choice; import mage.choices.Choice;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.RangeOfInfluence; import mage.constants.RangeOfInfluence;
import mage.constants.Zone;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.Counters; import mage.counters.Counters;
import mage.game.Game; import mage.game.Game;
@ -353,4 +354,29 @@ public interface Player extends MageItem, Copyable<Player> {
* @param card * @param card
*/ */
UUID getCommanderId(); UUID getCommanderId();
/**
* Uses card.moveToZone and posts a inform message about moving the card
* into the game log
*
* @param card
* @param sourceId
* @param game
* @param fromZone if null, this info isn't postet
* @return
*/
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
/**
* Uses putOntoBattlefield and posts also a info message about in the game log
*
* @param card
* @param game
* @param fromZone
* @param sourceId
* @param game
* @return
*/
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId);
} }

View file

@ -35,6 +35,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random; import java.util.Random;
@ -2091,4 +2092,36 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
public UUID getCommanderId() { public UUID getCommanderId() {
return this.commanderId; return this.commanderId;
} }
/**
* {@inheritDoc}
*/
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
boolean result = false;
if (card.moveToZone(Zone.HAND, sourceId, game, false)) {
game.informPlayers(new StringBuilder(this.getName())
.append(" puts ").append(card.getName()).append(" ")
.append(fromZone != null ? new StringBuilder("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" "):"")
.append("onto his or her hand").toString());
}
return result;
}
/**
* {@inheritDoc}
*/
@Override
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) {
boolean result = false;
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId())) {
game.informPlayers(new StringBuilder(this.getName())
.append(" puts ").append(card.getName())
.append("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")
.append("onto the Battlefield").toString());
}
return result;
}
} }