Added message to log if player shuffles his library. Fixed wrong calls to shuffle.

This commit is contained in:
LevelX2 2014-01-24 00:53:40 +01:00
parent c2d923bac9
commit 5096d8b943
17 changed files with 23 additions and 15 deletions

View file

@ -105,7 +105,7 @@ class StreamOfConsciousnessEffect extends OneShotEffect<StreamOfConsciousnessEff
} }
} }
if (shuffle) { if (shuffle) {
player.getLibrary().shuffle(); player.shuffleLibrary(game);
} }
return true; return true;
} }

View file

@ -107,7 +107,7 @@ class VeteranExplorerEffect extends OneShotEffect<VeteranExplorerEffect> {
} }
} }
for (Player player: usingPlayers) { for (Player player: usingPlayers) {
player.getLibrary().shuffle(); player.shuffleLibrary(game);
} }
return true; return true;
} }

View file

@ -111,7 +111,7 @@ class LimDulsVaultEffect extends OneShotEffect<LimDulsVaultEffect> {
if (doAgain) { if (doAgain) {
player.loseLife(1, game); player.loseLife(1, game);
} else { } else {
player.getLibrary().shuffle(); player.shuffleLibrary(game);
} }
TargetCard target = new TargetCard(Zone.PICK, new FilterCard(doAgain ? textBottom : textTop)); TargetCard target = new TargetCard(Zone.PICK, new FilterCard(doAgain ? textBottom : textTop));

View file

@ -103,7 +103,7 @@ class LoamingShamanEffect extends OneShotEffect<LoamingShamanEffect> {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
} }
} }
targetPlayer.getLibrary().shuffle(); targetPlayer.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -113,7 +113,7 @@ class UnexpectedResultEffect extends OneShotEffect<UnexpectedResultEffect> {
return false; return false;
} }
if (controller.getLibrary().size() > 0) { if (controller.getLibrary().size() > 0) {
controller.getLibrary().shuffle(); controller.shuffleLibrary(game);
Card card = controller.getLibrary().getFromTop(game); Card card = controller.getLibrary().getFromTop(game);
if (card == null) { if (card == null) {
return false; return false;

View file

@ -109,7 +109,7 @@ class MemorysJourneyEffect extends OneShotEffect<MemorysJourneyEffect> {
} }
} }
if (shuffle) { if (shuffle) {
player.getLibrary().shuffle(); player.shuffleLibrary(game);
} }
return true; return true;
} }

View file

@ -123,7 +123,7 @@ class PrimalCommandShuffleGraveyardEffect extends OneShotEffect<PrimalCommandShu
if (player != null) { if (player != null) {
player.getLibrary().addAll(player.getGraveyard().getCards(game), game); player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
player.getGraveyard().clear(); player.getGraveyard().clear();
player.getLibrary().shuffle(); player.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -119,7 +119,7 @@ class WarpWorldEffect extends OneShotEffect<WarpWorldEffect> {
} }
if (count > 0) { if (count > 0) {
player.getLibrary().shuffle(); player.shuffleLibrary(game);
} }
permanentsCount.put(player.getId(), count); permanentsCount.put(player.getId(), count);

View file

@ -106,7 +106,7 @@ class RiftsweeperEffect extends OneShotEffect<RiftsweeperEffect> {
card.getCounters().clear(); card.getCounters().clear();
// move to exile // move to exile
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
game.getPlayer(card.getOwnerId()).getLibrary().shuffle(); game.getPlayer(card.getOwnerId()).shuffleLibrary(game);
game.informPlayers(new StringBuilder("Riftsweeper: Choosen card was ").append(card.getName()).toString()); game.informPlayers(new StringBuilder("Riftsweeper: Choosen card was ").append(card.getName()).toString());
return true; return true;
} }

View file

@ -99,7 +99,7 @@ class DeglamerShuffleIntoLibraryEffect extends OneShotEffect<DeglamerShuffleInto
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) { if (permanent != null) {
if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true) ) { if (permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true) ) {
game.getPlayer(permanent.getOwnerId()).getLibrary().shuffle(); game.getPlayer(permanent.getOwnerId()).shuffleLibrary(game);
return true; return true;
} }
} }

View file

@ -97,7 +97,7 @@ class WorldspineWurmEffect extends OneShotEffect<WorldspineWurmEffect> {
if (c != null) { if (c != null) {
player.getGraveyard().remove(c); player.getGraveyard().remove(c);
player.getLibrary().putOnTop(c, game); player.getLibrary().putOnTop(c, game);
player.getLibrary().shuffle(); player.shuffleLibrary(game);
return true; return true;
} }

View file

@ -91,7 +91,7 @@ class SerraAvatarEffect extends OneShotEffect<SerraAvatarEffect> {
if (c != null) { if (c != null) {
player.getGraveyard().remove(c); player.getGraveyard().remove(c);
player.getLibrary().putOnTop(c, game); player.getLibrary().putOnTop(c, game);
player.getLibrary().shuffle(); player.shuffleLibrary(game);
return true; return true;
} }

View file

@ -96,7 +96,7 @@ class SelectiveMemoryEffect extends OneShotEffect<SelectiveMemoryEffect> {
} }
} }
player.getLibrary().shuffle(); player.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -135,7 +135,7 @@ class QuestForAncientSecretsEffect extends OneShotEffect<QuestForAncientSecretsE
if (player != null) { if (player != null) {
player.getLibrary().addAll(player.getGraveyard().getCards(game), game); player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
player.getGraveyard().clear(); player.getGraveyard().clear();
player.getLibrary().shuffle(); player.shuffleLibrary(game);
return true; return true;
} }
return false; return false;

View file

@ -32,6 +32,7 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
@ -118,9 +119,11 @@ class TributeEffect extends OneShotEffect<TributeEffect> {
sb.append(" (add ").append(CardUtil.numberToText(tributeValue)).append(" +1/+1 counter"); sb.append(" (add ").append(CardUtil.numberToText(tributeValue)).append(" +1/+1 counter");
sb.append(tributeValue > 1 ? "s":"").append("to it)?"); sb.append(tributeValue > 1 ? "s":"").append("to it)?");
if (opponent.chooseUse(outcome, sb.toString(), game)) { if (opponent.chooseUse(outcome, sb.toString(), game)) {
sourcePermanent.addCounters(CounterType.P1P1.createInstance(tributeValue), game); 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.getState().setValue(new StringBuilder("tributeValue").append(source.getSourceId()).toString(), "yes");
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(tributeValue), true).apply(game, source);
} else { } else {
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.getState().setValue(new StringBuilder("tributeValue").append(source.getSourceId()).toString(), "no");
} }
return true; return true;

View file

@ -60,6 +60,10 @@ public class Library implements Serializable {
} }
} }
/**
* Don't use this directly.
* Use <player.shuffleLibrary(game)> instead.
*/
public void shuffle() { public void shuffle() {
UUID[] shuffled = library.toArray(new UUID[0]); UUID[] shuffled = library.toArray(new UUID[0]);
for (int n = shuffled.length - 1; n > 0; n--) { for (int n = shuffled.length - 1; n > 0; n--) {

View file

@ -1004,6 +1004,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
public void shuffleLibrary(Game game) { public void shuffleLibrary(Game game) {
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.SHUFFLE_LIBRARY, playerId, playerId))) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.SHUFFLE_LIBRARY, playerId, playerId))) {
this.library.shuffle(); this.library.shuffle();
game.informPlayers(new StringBuilder(this.name).append(" shuffels his or her library.").toString());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SHUFFLED, playerId, playerId)); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SHUFFLED, playerId, playerId));
} }
} }