Ensure cards hidden if you shouldn't be able to see them

This commit is contained in:
drdev
2014-03-13 22:32:58 +00:00
parent dc5be10721
commit 1bd2df2d28
2 changed files with 51 additions and 10 deletions

View File

@@ -8528,19 +8528,43 @@ public class Card extends GameEntity implements Comparable<Card> {
}
public boolean canBeShownTo(final Player viewer) {
if (!isFaceDown()) {
Zone zone = this.getZone();
if (zone == null) { return false; } //cards can't be shown if they're not in a zone
switch (zone.getZoneType()) {
case Ante:
case Command:
case Exile:
case Battlefield:
case Graveyard:
case Stack:
//cards in these zones are visible to all
if (isFaceDown() && getController().isOpponentOf(viewer) && !hasKeyword("Your opponent may look at this card.")) {
break; //exception is face down cards controlled by opponents
}
return true;
}
if (getController() == viewer && isInZone(ZoneType.Battlefield)) {
case Hand:
case Sideboard:
//face-up cards in these zones are hidden to opponents unless they specify otherwise
if (getController().isOpponentOf(viewer) && !hasKeyword("Your opponent may look at this card.")) {
break;
}
return true;
case Library:
case PlanarDeck:
case SchemeDeck:
//cards in these zones are hidden to all unless they specify otherwise
if (getController() == viewer && hasKeyword("You may look at this card.")) {
return true;
}
if (getController().isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
return true;
}
break;
}
//one last check to see if card can be shown
final Game game = this.getGame();
if (getController() == viewer && hasKeyword("You may look at this card.")) {
return true;
}
if (getController().isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
return true;
}
for (Card host : game.getCardsIn(ZoneType.Battlefield)) {
final ArrayList<StaticAbility> staticAbilities = host.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {

View File

@@ -223,8 +223,25 @@ public class FControl {
}
}
public static Player getCurrentPlayer() {
// try current priority
Player currentPriority = game.getPhaseHandler().getPriorityPlayer();
if (null != currentPriority && currentPriority.getLobbyPlayer() == FServer.getLobby().getGuiPlayer()) {
return currentPriority;
}
// otherwise find just any player, belonging to this lobbyplayer
for (Player p : game.getPlayers()) {
if (p.getLobbyPlayer() == FServer.getLobby().getGuiPlayer()) {
return p;
}
}
return null;
}
public static boolean mayShowCard(Card c) {
return true;// game == null || !gameHasHumanPlayer || c.canBeShownTo(getCurrentPlayer());
return game == null || !gameHasHumanPlayer || c.canBeShownTo(getCurrentPlayer());
}
public static void showCombat(Combat combat) {