* Gomazoa - Fixed that library of Gomazoa's owner was not shuffled.

This commit is contained in:
LevelX2 2014-05-28 00:35:19 +02:00
parent ee272aa960
commit 03d2aa3630

View file

@ -27,10 +27,9 @@
*/ */
package mage.sets.zendikar; package mage.sets.zendikar;
import mage.constants.CardType; import java.util.ArrayList;
import mage.constants.Outcome; import java.util.List;
import mage.constants.Rarity; import java.util.UUID;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -39,17 +38,17 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.DefenderAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.watchers.WatcherImpl; import mage.watchers.WatcherImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
@ -91,7 +90,7 @@ class GomazoaEffect extends OneShotEffect<GomazoaEffect> {
public GomazoaEffect() { public GomazoaEffect() {
super(Outcome.Neutral); super(Outcome.Neutral);
this.staticText = "Put Gomazoa and each creature it's blocking on top of their owners' libraries, then those players shuffle their libraries"; this.staticText = "Put {this} and each creature it's blocking on top of their owners' libraries, then those players shuffle their libraries";
} }
public GomazoaEffect(final GomazoaEffect effect) { public GomazoaEffect(final GomazoaEffect effect) {
@ -105,37 +104,45 @@ class GomazoaEffect extends OneShotEffect<GomazoaEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
List<UUID> creaturesBlocked = new ArrayList<UUID>(); Player controller = game.getPlayer(source.getControllerId());
List<UUID> players = new ArrayList<UUID>(); if (controller != null) {
Permanent gomazoa = game.getPermanent(source.getSourceId()); List<UUID> creaturesBlocked;
if (gomazoa != null) { List<UUID> players = new ArrayList<>();
gomazoa.moveToZone(Zone.LIBRARY, id, game, true); Permanent gomazoa = game.getPermanent(source.getSourceId());
} if (gomazoa != null) {
controller.moveCardToLibraryWithInfo(gomazoa, source.getSourceId(), game, Zone.BATTLEFIELD, true);
BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatchers().get("BlockedByWatcher", source.getSourceId()); players.add(gomazoa.getOwnerId());
creaturesBlocked = watcher.blockedByWatcher;
for (UUID blockedById : creaturesBlocked) {
Permanent blockedByGomazoa = game.getPermanent(blockedById);
if (blockedByGomazoa != null && blockedByGomazoa.isAttacking()) {
players.add(blockedByGomazoa.getOwnerId());
blockedByGomazoa.moveToZone(Zone.LIBRARY, id, game, true);
} }
}
for (UUID player : players) { BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatchers().get("BlockedByWatcher", source.getSourceId());
Player owner = game.getPlayer(player); creaturesBlocked = watcher.blockedByWatcher;
if (owner != null) {
owner.shuffleLibrary(game); for (UUID blockedById : creaturesBlocked) {
Permanent blockedByGomazoa = game.getPermanent(blockedById);
if (blockedByGomazoa != null && blockedByGomazoa.isAttacking()) {
players.add(blockedByGomazoa.getOwnerId());
Player owner = game.getPlayer(blockedByGomazoa.getOwnerId());
if (owner != null) {
owner.moveCardToLibraryWithInfo(blockedByGomazoa, source.getSourceId(), game, Zone.BATTLEFIELD, true);
}
}
} }
for (UUID player : players) {
Player owner = game.getPlayer(player);
if (owner != null) {
owner.shuffleLibrary(game);
}
}
return true;
} }
return true; return false;
} }
} }
class BlockedByWatcher extends WatcherImpl<BlockedByWatcher> { class BlockedByWatcher extends WatcherImpl<BlockedByWatcher> {
public List<UUID> blockedByWatcher = new ArrayList<UUID>(); public List<UUID> blockedByWatcher = new ArrayList<>();
public BlockedByWatcher() { public BlockedByWatcher() {
super("BlockedByWatcher", WatcherScope.CARD); super("BlockedByWatcher", WatcherScope.CARD);
@ -165,4 +172,4 @@ class BlockedByWatcher extends WatcherImpl<BlockedByWatcher> {
super.reset(); super.reset();
blockedByWatcher.clear(); blockedByWatcher.clear();
} }
} }