mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
latest
This commit is contained in:
parent
d151f99f4f
commit
e1190077a2
11 changed files with 167 additions and 23 deletions
|
@ -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<String> 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<String> 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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<UUID, String> choices = new HashMap<UUID, String>();
|
||||
|
||||
public AbilityPickerView(Collection<? extends ActivatedAbility> abilities) {
|
||||
for (ActivatedAbility ability: abilities) {
|
||||
public AbilityPickerView(Collection<? extends Ability> abilities) {
|
||||
for (Ability ability: abilities) {
|
||||
choices.put(ability.getId(), ability.getRule());
|
||||
}
|
||||
}
|
||||
|
|
69
Mage.Common/src/mage/view/AbilityView.java
Normal file
69
Mage.Common/src/mage/view/AbilityView.java
Normal file
|
@ -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<String>();
|
||||
rules.add(formatRule(ability.getRule()));
|
||||
this.power = "";
|
||||
this.toughness = "";
|
||||
this.loyalty = "";
|
||||
this.cardTypes = new ArrayList<CardType>();
|
||||
this.subTypes = new ArrayList<String>();
|
||||
this.superTypes = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<CardView> {
|
|||
}
|
||||
|
||||
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<? extends Ability> abilities, Game game) {
|
||||
for (Ability ability: abilities) {
|
||||
String sourceName = game.getPermanent(ability.getSourceId()).getName();
|
||||
this.add(new AbilityView(ability, sourceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
54
Mage.Common/src/mage/view/CounterView.java
Normal file
54
Mage.Common/src/mage/view/CounterView.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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<UUID> attachments;
|
||||
private List<CounterView> counters;
|
||||
|
||||
public PermanentView(Permanent permanent) {
|
||||
super(permanent);
|
||||
|
@ -58,6 +59,12 @@ public class PermanentView extends CardView {
|
|||
attachments = new ArrayList<UUID>();
|
||||
attachments.addAll(permanent.getAttachments());
|
||||
}
|
||||
if (permanent.getCounters().size() > 0) {
|
||||
counters = new ArrayList<CounterView>();
|
||||
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<UUID> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public List<CounterView> getCounters() {
|
||||
return counters;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<SeatView> seats = new ArrayList<SeatView>();
|
||||
|
||||
|
@ -67,7 +66,7 @@ public class TableView implements Serializable {
|
|||
return gameType;
|
||||
}
|
||||
|
||||
public DeckType getDeckType() {
|
||||
public String getDeckType() {
|
||||
return deckType;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue