1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-12 01:01:04 -09:00

modifed revealed cards

This commit is contained in:
BetaSteward 2011-01-24 22:51:45 -05:00
parent 55feb4a320
commit 360bbc86b5
20 changed files with 237 additions and 25 deletions

View file

@ -58,6 +58,8 @@ import mage.view.CardsView;
*/
public class ShowCardsDialog extends MageDialog implements MouseListener {
private boolean reloaded = false;
/** Creates new form ShowCardsDialog */
public ShowCardsDialog() {
initComponents();
@ -65,6 +67,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
}
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
this.reloaded = true;
this.title = name;
cardArea.removeAll();
if (showCards != null && showCards.size() < 10)
@ -129,6 +132,14 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * columns, Config.dimensions.frameHeight + 400));
}
public boolean isReloaded() {
return this.reloaded;
}
public void clearReloaded() {
this.reloaded = false;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is

View file

@ -38,7 +38,9 @@ import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
@ -51,6 +53,7 @@ import javax.swing.border.LineBorder;
import mage.client.MageFrame;
import mage.client.cards.Cards;
import mage.client.deckeditor.collection.viewer.MageBook;
import mage.client.dialog.ExileZoneDialog;
import mage.client.dialog.PickChoiceDialog;
import mage.client.dialog.ShowCardsDialog;
@ -60,12 +63,14 @@ import mage.client.remote.Session;
import mage.client.util.Config;
import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
import mage.client.util.gui.ArrowBuilder;
import mage.util.Logging;
import mage.view.AbilityPickerView;
import mage.view.CardsView;
import mage.view.ExileView;
import mage.view.GameView;
import mage.view.PlayerView;
import mage.view.RevealedView;
/**
*
@ -77,6 +82,7 @@ public class GamePanel extends javax.swing.JPanel {
private Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
private Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
private Map<String, ShowCardsDialog> revealed = new HashMap<String, ShowCardsDialog>();
private UUID gameId;
private UUID playerId;
private Session session;
@ -136,6 +142,9 @@ public class GamePanel extends javax.swing.JPanel {
for (ExileZoneDialog exile: exiles.values()) {
exile.hide();
}
for (ShowCardsDialog reveal: revealed.values()) {
reveal.hide();
}
}
public synchronized void showGame(UUID gameId, UUID playerId) {
@ -321,6 +330,7 @@ public class GamePanel extends javax.swing.JPanel {
}
exiles.get(exile.getId()).loadCards(exile, bigCard, gameId);
}
showRevealed(game);
if (game.getCombat().size() > 0) {
MageFrame.getCombatDialog().showDialog(game.getCombat());
}
@ -331,6 +341,19 @@ public class GamePanel extends javax.swing.JPanel {
this.repaint();
}
private void showRevealed(GameView game) {
for (ShowCardsDialog reveal: revealed.values()) {
reveal.clearReloaded();
}
for (RevealedView reveal: game.getRevealed()) {
if (!revealed.containsKey(reveal.getName())) {
ShowCardsDialog newReveal = new ShowCardsDialog();
revealed.put(reveal.getName(), newReveal);
}
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), reveal.getCards(), bigCard, Config.dimensions, gameId, false);
}
}
public void ask(String question, GameView gameView) {
updateGame(gameView);
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, true, false);
@ -387,11 +410,11 @@ public class GamePanel extends javax.swing.JPanel {
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
}
public void revealCards(String name, CardsView cards) {
ShowCardsDialog showCards = new ShowCardsDialog();
showCards.loadCards(name, cards, bigCard, Config.dimensions, gameId, false);
}
// public void revealCards(String name, CardsView cards) {
// ShowCardsDialog showCards = new ShowCardsDialog();
// showCards.loadCards(name, cards, bigCard, Config.dimensions, gameId, false);
// }
//
private void showCards(String title, CardsView cards, boolean required) {
ShowCardsDialog showCards = new ShowCardsDialog();
showCards.loadCards(title, cards, bigCard, Config.dimensions, gameId, required);

View file

@ -36,6 +36,7 @@ import mage.MageObject;
import mage.Constants.PhaseStep;
import mage.Constants.TurnPhase;
import mage.cards.Card;
import mage.cards.Cards;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.GameState;
@ -56,6 +57,7 @@ public class GameView implements Serializable {
private CardsView hand;
private CardsView stack = new CardsView();
private List<ExileView> exiles = new ArrayList<ExileView>();
private List<RevealedView> revealed = new ArrayList<RevealedView>();
private List<CombatGroupView> combat = new ArrayList<CombatGroupView>();
private TurnPhase phase;
private PhaseStep step;
@ -84,6 +86,9 @@ public class GameView implements Serializable {
for (ExileZone exileZone: state.getExile().getExileZones()) {
exiles.add(new ExileView(exileZone, game));
}
for (String name: state.getRevealed().keySet()) {
revealed.add(new RevealedView(name, state.getRevealed().get(name), game));
}
this.phase = state.getTurn().getPhaseType();
this.step = state.getTurn().getStepType();
this.turn = state.getTurnNum();
@ -129,6 +134,10 @@ public class GameView implements Serializable {
return exiles;
}
public List<RevealedView> getRevealed() {
return revealed;
}
public List<CombatGroupView> getCombat() {
return combat;
}

View file

@ -0,0 +1,59 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.view;
import java.io.Serializable;
import mage.cards.Card;
import mage.cards.Cards;
import mage.game.Game;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class RevealedView implements Serializable {
private String name;
private CardsView cards = new CardsView();
public RevealedView(String name, Cards cards, Game game) {
this.name = name;
for (Card card: cards.getCards(game)) {
this.cards.put(card.getId(), new CardView(card));
}
}
public String getName() {
return name;
}
public CardsView getCards() {
return cards;
}
}

View file

@ -96,7 +96,7 @@ class DuressEffect extends OneShotEffect<DuressEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
player.revealCards(player.getHand(), game);
player.revealCards("Duress", player.getHand(), game);
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
TargetCard target = new TargetCard(Zone.PICK, filter);

View file

@ -104,7 +104,7 @@ class ConundrumSphinxEffect extends OneShotEffect<ConundrumSphinxEffect> {
Card card = player.getLibrary().removeFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(cards, game);
player.revealCards("Conundrum Sphinx", cards, game);
if (card.getName().equals(cardChoice.getChoice())) {
card.moveToZone(Zone.HAND, source.getId(), game, true);
}

View file

@ -106,7 +106,7 @@ class CultivateEffect extends OneShotEffect<CultivateEffect> {
Card card = player.getLibrary().remove(cardId, game);
revealed.add(card);
}
player.revealCards(revealed, game);
player.revealCards("Cultivate", revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.PICK, filter);
target2.setRequired(true);

View file

@ -92,7 +92,7 @@ class DarkTutelageEffect extends OneShotEffect<DarkTutelageEffect> {
player.loseLife(card.getManaCost().convertedManaCost(), game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(cards, game);
player.revealCards("Dark Tutelage", cards, game);
return true;
}
return false;

View file

@ -103,7 +103,7 @@ class MassPolymorphEffect extends OneShotEffect<MassPolymorphEffect> {
else
nonCreatureCards.add(card);
}
player.revealCards(revealed, game);
player.revealCards("Mass Polymorph", revealed, game);
for (Card creatureCard: creatureCards.getCards(game)) {
creatureCard.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
}

View file

@ -94,7 +94,7 @@ class MerfolkSpyEffect extends OneShotEffect<MerfolkSpyEffect> {
if (player != null && player.getHand().size() > 0) {
Cards revealed = new CardsImpl();
revealed.add(player.getHand().getRandom(game));
player.revealCards(revealed, game);
player.revealCards("Merfolk Spy", revealed, game);
return true;
}
return false;

View file

@ -124,7 +124,7 @@ class WildEvocationEffect extends OneShotEffect<WildEvocationEffect> {
Card card = player.getHand().getRandom(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(cards, game);
player.revealCards("Wild Evocation", cards, game);
if (card.getCardType().contains(CardType.LAND)) {
card.putOntoBattlefield(game, Zone.HAND, source.getId(), player.getId());
}

View file

@ -107,7 +107,7 @@ class SarkhantheMadRevealAndDrawEffect extends OneShotEffect<SarkhantheMadReveal
permanent.damage(card.getManaCost().convertedManaCost(), this.getId(), game, false, false);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(cards, game);
player.revealCards("Sarkhan the Mad", cards, game);
return true;
}
return false;

View file

@ -104,7 +104,7 @@ class GoblinGuideEffect extends OneShotEffect<GoblinGuideEffect> {
Card card = defender.getLibrary().getFromTop(game);
if (card != null) {
cards.add(card);
defender.revealCards(cards, game);
defender.revealCards("Goblin Guide", cards, game);
if (card.getCardType().contains(CardType.LAND)) {
defender.getLibrary().removeFromTop(game);
card.moveToZone(Zone.HAND, source.getId(), game, true);

View file

@ -74,7 +74,7 @@ public class SearchLibraryRevealPutInHandEffect extends SearchEffect<SearchLibra
}
}
player.shuffleLibrary(game);
player.revealCards(revealed, game);
player.revealCards("Search", revealed, game);
}
return true;
}

View file

@ -118,7 +118,7 @@ public interface Game extends MageItem, Serializable {
public void fireSelectTargetEvent(UUID playerId, String message, Set<UUID> targets, boolean required);
public void fireSelectTargetEvent(UUID playerId, String message, Cards cards, boolean required);
public void fireSelectTargetEvent(UUID playerId, String message, TriggeredAbilities abilities, boolean required);
public void fireRevealCardsEvent(String message, Cards cards);
// public void fireRevealCardsEvent(String message, Cards cards);
public void fireSelectEvent(UUID playerId, String message);
public void fireLookAtCardsEvent(UUID playerId, String message, Cards cards);
public void firePriorityEvent(UUID playerId);

View file

@ -497,6 +497,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
applyEffects();
state.getPlayers().resetPassed();
fireUpdatePlayersEvent();
state.getRevealed().reset();
break;
} else
return;
@ -772,10 +773,10 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
playerQueryEventSource.target(playerId, message, abilities, required);
}
@Override
public void fireRevealCardsEvent(String message, Cards cards) {
tableEventSource.fireTableEvent(EventType.REVEAL, message, cards, this);
}
// @Override
// public void fireRevealCardsEvent(String message, Cards cards) {
// tableEventSource.fireTableEvent(EventType.REVEAL, message, cards, this);
// }
@Override
public void fireLookAtCardsEvent(UUID playerId, String message, Cards cards) {

View file

@ -77,6 +77,7 @@ public class GameState implements Serializable, Copyable<GameState> {
private Turn turn;
private SpellStack stack;
private Exile exile;
private Revealed revealed;
private Battlefield battlefield;
private int turnNum;
private boolean gameOver;
@ -97,6 +98,7 @@ public class GameState implements Serializable, Copyable<GameState> {
turn = new Turn();
stack = new SpellStack();
exile = new Exile();
revealed = new Revealed();
battlefield = new Battlefield();
effects = new ContinuousEffects();
triggers = new TriggeredAbilities();
@ -200,6 +202,10 @@ public class GameState implements Serializable, Copyable<GameState> {
return exile;
}
public Revealed getRevealed() {
return revealed;
}
public Turn getTurn() {
return turn;
}

View file

@ -0,0 +1,92 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.util.Copyable;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Revealed extends HashMap<String, Cards> implements Serializable, Copyable<Revealed> {
public Revealed() { }
public Revealed(final Revealed revealed) {
for (String key: revealed.keySet()) {
this.put(key, revealed.get(key).copy());
}
}
public void add(String name, Card card) {
this.get(name).add(card);
}
public void add(String name, Cards cards) {
if (!this.containsKey(name))
createRevealed(name);
this.put(name, cards.copy());
}
public Cards createRevealed(String name) {
if (!this.containsKey(name)) {
this.put(name, new CardsImpl());
}
return this.get(name);
}
public Cards getRevealed(String name) {
return this.get(name);
}
public void reset() {
this.clear();
}
public Card getCard(UUID cardId, Game game) {
for (Cards cards: this.values()) {
if (cards.contains(cardId))
return game.getCard(cardId);
}
return null;
}
@Override
public Revealed copy() {
return new Revealed(this);
}
}

View file

@ -80,6 +80,8 @@ public interface Player extends MageItem, Copyable<Player> {
public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
public Cards getHand();
public int getLandsPlayed();
public int getLandsPerTurn();
public void setLandsPerTurn(int landsPerTurn);
public boolean isPassed();
public boolean isEmptyDraw();
public void pass();
@ -119,7 +121,7 @@ public interface Player extends MageItem, Copyable<Player> {
public void concede(Game game);
public void abort();
public void revealCards(Cards cards, Game game);
public void revealCards(String name, Cards cards, Game game);
public void lookAtCards(Cards cards, Game game);
@Override

View file

@ -98,7 +98,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
protected boolean left;
protected RangeOfInfluence range;
protected Set<UUID> inRange = new HashSet<UUID>();
// protected Deck deck;
@Override
public abstract T copy();
@ -107,7 +106,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this(UUID.randomUUID());
this.name = name;
this.range = range;
// this.deck = deck;
hand = new CardsImpl(Zone.HAND);
graveyard = new CardsImpl(Zone.GRAVEYARD);
abilities = new AbilitiesImpl<Ability>();
@ -529,8 +527,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
}
@Override
public void revealCards(Cards cards, Game game) {
game.fireRevealCardsEvent(this.name + " revealed", cards);
public void revealCards(String name, Cards cards, Game game) {
game.getState().getRevealed().add(name, cards);
// game.fireRevealCardsEvent(this.name + " revealed", cards);
}
@Override
@ -665,6 +664,16 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return this.abilities;
}
@Override
public int getLandsPerTurn() {
return this.landsPerTurn;
}
@Override
public void setLandsPerTurn(int landsPerTurn) {
this.landsPerTurn = landsPerTurn;
}
@Override
public void setResponseString(String responseString) {}