mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
* Spirit of the Labyrinth - Fixed that the draw restriction did not qork for opponents.
This commit is contained in:
parent
aad8ad0871
commit
135288ec02
2 changed files with 28 additions and 14 deletions
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.sets.bornofthegods;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -76,12 +77,17 @@ public class SpiritOfTheLabyrinth extends CardImpl {
|
|||
|
||||
class SpiritOfTheLabyrinthWatcher extends Watcher {
|
||||
|
||||
private final HashSet<UUID> playersThatDrewCard;
|
||||
|
||||
public SpiritOfTheLabyrinthWatcher() {
|
||||
super("DrewCard", WatcherScope.PLAYER);
|
||||
super("DrewCard", WatcherScope.GAME);
|
||||
this.playersThatDrewCard = new HashSet<>();
|
||||
}
|
||||
|
||||
public SpiritOfTheLabyrinthWatcher(final SpiritOfTheLabyrinthWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playersThatDrewCard = new HashSet<>();
|
||||
playersThatDrewCard.addAll(watcher.playersThatDrewCard);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -91,16 +97,23 @@ class SpiritOfTheLabyrinthWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition == true) {//no need to check - condition has already occured
|
||||
return;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.DREW_CARD ) {
|
||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
condition = true;
|
||||
if (!playersThatDrewCard.contains(event.getPlayerId())) {
|
||||
playersThatDrewCard.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playersThatDrewCard.clear();
|
||||
}
|
||||
|
||||
public boolean hasPlayerDrewCardThisTurn(UUID playerId) {
|
||||
return playersThatDrewCard.contains(playerId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl {
|
||||
|
|
@ -132,8 +145,8 @@ class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DRAW_CARD) {
|
||||
Watcher watcher = game.getState().getWatchers().get("DrewCard", event.getPlayerId());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get("DrewCard");
|
||||
if (watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,12 +96,13 @@ class BrainstormEffect extends OneShotEffect {
|
|||
|
||||
private boolean putOnLibrary(Player player, Ability source, Game game) {
|
||||
TargetCardInHand target = new TargetCardInHand();
|
||||
player.chooseTarget(Outcome.ReturnToHand, target, source, game);
|
||||
Card card = player.getHand().get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.getHand().remove(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
player.chooseTarget(Outcome.ReturnToHand, target, source, game);
|
||||
Card card = player.getHand().get(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
return player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue