diff --git a/Mage.Common/src/mage/interfaces/Server.java b/Mage.Common/src/mage/interfaces/Server.java index a125fce69db..8c308605c90 100644 --- a/Mage.Common/src/mage/interfaces/Server.java +++ b/Mage.Common/src/mage/interfaces/Server.java @@ -33,8 +33,8 @@ import java.rmi.RemoteException; import java.util.Collection; import java.util.List; import java.util.UUID; -import mage.Constants.DeckType; import mage.cards.decks.DeckCardLists; +import mage.game.GameException; import mage.interfaces.callback.CallbackServer; import mage.view.TableView; @@ -50,10 +50,11 @@ public interface Server extends Remote, CallbackServer { public String[] getGameTypes() throws RemoteException, MageException; public String[] getPlayerTypes() throws RemoteException, MageException; + public String[] getDeckTypes() throws RemoteException, MageException; //table methods - public TableView createTable(UUID sessionId, UUID roomId, String gameType, DeckType deckType, List playerTypes) throws RemoteException, MageException; - public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, int seatNum, String name, DeckCardLists deckList) throws RemoteException, MageException; + public TableView createTable(UUID sessionId, UUID roomId, String gameType, String deckType, List playerTypes) throws RemoteException, MageException; + public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, int seatNum, String name, DeckCardLists deckList) throws RemoteException, MageException, GameException; public boolean watchTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; public boolean replayTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; public void leaveTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackServerSession.java b/Mage.Common/src/mage/interfaces/callback/CallbackServerSession.java index fac2be70aed..2dc91103188 100644 --- a/Mage.Common/src/mage/interfaces/callback/CallbackServerSession.java +++ b/Mage.Common/src/mage/interfaces/callback/CallbackServerSession.java @@ -111,11 +111,11 @@ public class CallbackServerSession { waitingForCallback = true; waiting.signal(); while (callback.getMethod() == null) { - logger.fine("waiting for callback"); + logger.finer("waiting for callback"); callbackCalled.await(); } waitingForCallback = false; - logger.fine("callback called:" + callback.getMethod()); + logger.finer("callback called:" + callback.getMethod()); return callback; } finally { @@ -133,7 +133,7 @@ public class CallbackServerSession { lock.lock(); try { while (!waitingForCallback) { - logger.fine("waiting for callback state to call:" + call.getMethod()); + logger.finer("waiting for callback state to call:" + call.getMethod()); waiting.await(); } callback.setMethod(call.getMethod()); diff --git a/Mage.Common/src/mage/view/AbilityPickerView.java b/Mage.Common/src/mage/view/AbilityPickerView.java index 353d5f4f4d9..2ba4644e468 100644 --- a/Mage.Common/src/mage/view/AbilityPickerView.java +++ b/Mage.Common/src/mage/view/AbilityPickerView.java @@ -33,7 +33,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import mage.abilities.ActivatedAbility; +import mage.abilities.Ability; /** * @@ -43,8 +43,8 @@ public class AbilityPickerView implements Serializable { private Map choices = new HashMap(); - public AbilityPickerView(Collection abilities) { - for (ActivatedAbility ability: abilities) { + public AbilityPickerView(Collection abilities) { + for (Ability ability: abilities) { choices.put(ability.getId(), ability.getRule()); } } diff --git a/Mage.Common/src/mage/view/AbilityView.java b/Mage.Common/src/mage/view/AbilityView.java new file mode 100644 index 00000000000..21e211650a2 --- /dev/null +++ b/Mage.Common/src/mage/view/AbilityView.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 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.util.ArrayList; +import mage.Constants.CardType; +import mage.ObjectColor; +import mage.abilities.Ability; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class AbilityView extends CardView { + + private String sourceName; + + public AbilityView(Ability ability, String sourceName) { + this.id = ability.getId(); + this.name = "Ability"; + this.sourceName = sourceName; + this.rules = new ArrayList(); + rules.add(formatRule(ability.getRule())); + this.power = ""; + this.toughness = ""; + this.loyalty = ""; + this.cardTypes = new ArrayList(); + this.subTypes = new ArrayList(); + this.superTypes = new ArrayList(); + this.color = new ObjectColor(); + this.manaCost = ability.getManaCosts().getSymbols(); + this.art = ""; + } + + @Override + protected String formatRule(String rule) { + String newRule = rule.replace("{this}", this.sourceName); + newRule.replace("{source}", this.sourceName); + return newRule; + } + + +} diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index a013dda9b7c..33608dee53d 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -34,7 +34,6 @@ import java.util.List; import java.util.UUID; import mage.Constants.CardType; import mage.ObjectColor; -import mage.abilities.costs.mana.ManaCosts; import mage.cards.Card; import mage.game.permanent.Permanent; diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java index 5d7d5d5f4d3..586e986a4d6 100644 --- a/Mage.Common/src/mage/view/CardsView.java +++ b/Mage.Common/src/mage/view/CardsView.java @@ -30,8 +30,11 @@ package mage.view; import java.util.ArrayList; import java.util.Collection; +import mage.MageObject; +import mage.abilities.Ability; import mage.cards.Card; import mage.cards.Cards; +import mage.game.Game; /** * @@ -49,8 +52,16 @@ public class CardsView extends ArrayList { } public CardsView(Cards cards) { - for (Card card: cards.values()) { - this.add(new CardView(card)); + if (cards != null) + for (Card card: cards.values()) { + this.add(new CardView(card)); + } + } + + public CardsView(Collection abilities, Game game) { + for (Ability ability: abilities) { + String sourceName = game.getPermanent(ability.getSourceId()).getName(); + this.add(new AbilityView(ability, sourceName)); } } diff --git a/Mage.Common/src/mage/view/CounterView.java b/Mage.Common/src/mage/view/CounterView.java new file mode 100644 index 00000000000..10d2674a34a --- /dev/null +++ b/Mage.Common/src/mage/view/CounterView.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 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.counters.Counter; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CounterView implements Serializable { + private String name; + private int count; + + public CounterView(Counter counter) { + this.name = counter.getName(); + this.count = counter.getCount(); + } + + public String getName() { + return name; + } + + public int getCount() { + return count; + } +} diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index f98ea7512a4..cee7d36010d 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -73,13 +73,13 @@ public class GameView implements Serializable { for (ExileZone exileZone: game.getExile().getExileZones()) { exiles.add(new ExileView(exileZone)); } - this.phase = game.getPhase(); - this.step = game.getStep(); + this.phase = game.getTurn().getPhase(); + this.step = game.getTurn().getStep(); this.turn = game.getTurnNum(); - if (game.getTurn().getActivePlayerId() != null) - this.activePlayerName = game.getPlayer(game.getTurn().getActivePlayerId()).getName(); - if (game.getTurn().getPriorityPlayerId() != null) - this.priorityPlayerName = game.getPlayer(game.getTurn().getPriorityPlayerId()).getName(); + if (game.getActivePlayerId() != null) + this.activePlayerName = game.getPlayer(game.getActivePlayerId()).getName(); + if (game.getPriorityPlayerId() != null) + this.priorityPlayerName = game.getPlayer(game.getPriorityPlayerId()).getName(); for (CombatGroup combatGroup: game.getCombat().getGroups()) { combat.add(new CombatGroupView(combatGroup, game)); } diff --git a/Mage.Common/src/mage/view/PermanentView.java b/Mage.Common/src/mage/view/PermanentView.java index 9cf715ccd29..17ba9ca950a 100644 --- a/Mage.Common/src/mage/view/PermanentView.java +++ b/Mage.Common/src/mage/view/PermanentView.java @@ -31,7 +31,7 @@ package mage.view; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.game.GameState; +import mage.counters.Counter; import mage.game.permanent.Permanent; /** @@ -46,6 +46,7 @@ public class PermanentView extends CardView { private boolean faceUp; private int damage; private List attachments; + private List counters; public PermanentView(Permanent permanent) { super(permanent); @@ -58,6 +59,12 @@ public class PermanentView extends CardView { attachments = new ArrayList(); attachments.addAll(permanent.getAttachments()); } + if (permanent.getCounters().size() > 0) { + counters = new ArrayList(); + for (Counter counter: permanent.getCounters().values()) { + counters.add(new CounterView(counter)); + } + } } public boolean isTapped() { @@ -83,4 +90,8 @@ public class PermanentView extends CardView { public List getAttachments() { return attachments; } + + public List getCounters() { + return counters; + } } diff --git a/Mage.Common/src/mage/view/StackAbilityView.java b/Mage.Common/src/mage/view/StackAbilityView.java index f273e4c9048..a824f5fd98f 100644 --- a/Mage.Common/src/mage/view/StackAbilityView.java +++ b/Mage.Common/src/mage/view/StackAbilityView.java @@ -58,7 +58,7 @@ public class StackAbilityView extends CardView { @Override protected String formatRule(String rule) { - String newRule = rule.replace("{this}", this.name); + String newRule = rule.replace("{this}", this.sourceName); newRule.replace("{source}", this.sourceName); return newRule; } diff --git a/Mage.Common/src/mage/view/TableView.java b/Mage.Common/src/mage/view/TableView.java index 596e927f569..8d95df3ae5a 100644 --- a/Mage.Common/src/mage/view/TableView.java +++ b/Mage.Common/src/mage/view/TableView.java @@ -32,7 +32,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import mage.Constants.DeckType; import mage.Constants.TableState; import mage.game.Seat; import mage.game.Table; @@ -45,7 +44,7 @@ public class TableView implements Serializable { private UUID tableId; private String gameType; - private DeckType deckType; + private String deckType; private TableState tableState; private List seats = new ArrayList(); @@ -67,7 +66,7 @@ public class TableView implements Serializable { return gameType; } - public DeckType getDeckType() { + public String getDeckType() { return deckType; }