mirror of
https://github.com/correl/mage.git
synced 2025-01-13 03:00:10 +00:00
* Play with top card library - fixed that player can see next top card before casting current top card;
This commit is contained in:
parent
d3b1be2f75
commit
ca4a4528fb
3 changed files with 24 additions and 22 deletions
|
@ -14,6 +14,8 @@ import mage.filter.Filter;
|
|||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
|
||||
|
@ -395,4 +397,17 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
this.addDependedToType(DependencyType.AddingCreatureType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCanLookAtNextTopLibraryCard(Game game) {
|
||||
// If the top card of your library changes while you’re casting a spell, playing a land, or activating an ability,
|
||||
// you can’t look at the new top card until you finish doing so. This means that if you cast the top card of
|
||||
// your library, you can’t look at the next one until you’re done paying for that spell. (2019-05-03)
|
||||
if (!game.getStack().isEmpty()) {
|
||||
StackObject stackObject = game.getStack().getFirst();
|
||||
return !(stackObject instanceof Spell)
|
||||
|| !Zone.LIBRARY.equals(((Spell) stackObject).getFromZone())
|
||||
|| ((Spell) stackObject).isDoneActivatingManaAbilities();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,18 @@ public class LookAtTopCardOfLibraryAnyTimeEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
Card topCard = controller.getLibrary().getFromTop(game);
|
||||
if (topCard == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
MageObject obj = source.getSourceObject(game);
|
||||
if (obj == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (!game.getState().getStack().isEmpty()) { // if a card is on the stack, don't allow it
|
||||
return true;
|
||||
if (!isCanLookAtNextTopLibraryCard(game)) {
|
||||
return false;
|
||||
}
|
||||
controller.lookAtCards("Top card of " + obj.getIdName() + " controller's library", topCard, game);
|
||||
return true;
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
@ -47,11 +44,11 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl {
|
|||
if (allPlayers) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !isCastFromPlayersLibrary(game, playerId)) {
|
||||
if (player != null && isCanLookAtNextTopLibraryCard(game)) {
|
||||
player.setTopCardRevealed(true);
|
||||
}
|
||||
}
|
||||
} else if (!isCastFromPlayersLibrary(game, controller.getId())) {
|
||||
} else if (isCanLookAtNextTopLibraryCard(game)) {
|
||||
controller.setTopCardRevealed(true);
|
||||
}
|
||||
return true;
|
||||
|
@ -59,16 +56,6 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean isCastFromPlayersLibrary(Game game, UUID playerId) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
StackObject stackObject = game.getStack().getLast();
|
||||
return stackObject instanceof Spell
|
||||
&& !((Spell) stackObject).isDoneActivatingManaAbilities()
|
||||
&& Zone.LIBRARY.equals(((Spell) stackObject).getFromZone());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayWithTheTopCardRevealedEffect copy() {
|
||||
return new PlayWithTheTopCardRevealedEffect(this);
|
||||
|
|
Loading…
Reference in a new issue