added tournaments - drafts are now a variant of tournament

This commit is contained in:
BetaSteward 2011-02-06 11:09:25 -05:00
parent 78e60ce457
commit ffc7b5bfd8
88 changed files with 3768 additions and 311 deletions

View file

@ -35,10 +35,11 @@ import java.util.List;
import java.util.UUID;
import mage.cards.decks.DeckCardLists;
import mage.game.GameException;
import mage.game.draft.DraftOptions;
import mage.game.tournament.TournamentOptions;
import mage.interfaces.callback.CallbackServer;
import mage.view.TableView;
import mage.view.GameView;
import mage.view.TournamentView;
/**
*
@ -54,9 +55,9 @@ public interface Server extends Remote, CallbackServer {
//table methods
public TableView createTable(UUID sessionId, UUID roomId, MatchOptions matchOptions) throws RemoteException, MageException;
public TableView createDraftTable(UUID sessionId, UUID roomId, DraftOptions draftOptions) throws RemoteException, MageException;
public TableView createTournamentTable(UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) throws RemoteException, MageException;
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, DeckCardLists deckList) throws RemoteException, MageException, GameException;
public boolean joinDraftTable(UUID sessionId, UUID roomId, UUID tableId, String name) throws RemoteException, MageException, GameException;
public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name) throws RemoteException, MageException, GameException;
public boolean submitDeck(UUID sessionId, UUID tableId, 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;
@ -74,6 +75,7 @@ public interface Server extends Remote, CallbackServer {
public UUID getTableChatId(UUID tableId) throws RemoteException, MageException;
public UUID getGameChatId(UUID gameId) throws RemoteException, MageException;
public UUID getRoomChatId(UUID roomId) throws RemoteException, MageException;
public UUID getTournamentChatId(UUID tournamentId) throws RemoteException, MageException;
//room methods
public UUID getMainRoomId() throws RemoteException, MageException;
@ -89,8 +91,12 @@ public interface Server extends Remote, CallbackServer {
public void sendPlayerInteger(UUID gameId, UUID sessionId, Integer data) throws RemoteException, MageException;
public void concedeGame(UUID gameId, UUID sessionId) throws RemoteException, MageException;
//tournament methods
public void startTournament(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
public void joinTournament(UUID draftId, UUID sessionId) throws RemoteException, MageException;
public TournamentView getTournament(UUID tournamentId) throws RemoteException, MageException;
//draft methods
public void startDraft(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
public void joinDraft(UUID draftId, UUID sessionId) throws RemoteException, MageException;
public void sendCardPick(UUID draftId, UUID sessionId, UUID cardId) throws RemoteException, MageException;

View file

@ -31,6 +31,7 @@ package mage.interfaces;
import java.io.Serializable;
import java.util.List;
import mage.view.GameTypeView;
import mage.view.TournamentTypeView;
/**
*
@ -39,12 +40,14 @@ import mage.view.GameTypeView;
public class ServerState implements Serializable {
private List<GameTypeView> gameTypes;
private List<TournamentTypeView> tournamentTypes;
private String[] playerTypes;
private String[] deckTypes;
private boolean testMode;
public ServerState(List<GameTypeView> gameTypes, String[] playerTypes, String[] deckTypes, boolean testMode) {
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes, String[] playerTypes, String[] deckTypes, boolean testMode) {
this.gameTypes = gameTypes;
this.tournamentTypes = tournamentTypes;
this.playerTypes = playerTypes;
this.deckTypes = deckTypes;
this.testMode = testMode;
@ -54,6 +57,10 @@ public class ServerState implements Serializable {
return gameTypes;
}
public List<TournamentTypeView> getTournamentTypes() {
return tournamentTypes;
}
public String[] getPlayerTypes() {
return playerTypes;
}

View file

@ -47,6 +47,10 @@ public class ClientCallback implements Serializable {
this.data = data;
}
public ClientCallback(String method) {
this(method, null);
}
public void clear() {
method = null;
data = null;

View file

@ -29,7 +29,11 @@
package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.game.Game;
import mage.game.tournament.Round;
import mage.game.tournament.TournamentPairing;
/**
*
@ -38,8 +42,20 @@ import mage.game.tournament.Round;
public class RoundView implements Serializable {
private static final long serialVersionUID = 1L;
public RoundView(Round round) {
List<TournamentGameView> games = new ArrayList<TournamentGameView>();
public RoundView(Round round) {
for (TournamentPairing pair: round.getPairs()) {
if (pair.getMatch() != null) {
for (Game game: pair.getMatch().getGames()) {
games.add(new TournamentGameView(round.getRoundNumber(), pair, game));
}
}
}
}
public List<TournamentGameView> getGames() {
return games;
}
}

View file

@ -0,0 +1,89 @@
/*
* 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 java.util.UUID;
import mage.game.Game;
import mage.game.tournament.TournamentPairing;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TournamentGameView implements Serializable {
private static final long serialVersionUID = 1L;
private int roundNum;
private UUID matchId;
private UUID gameId;
private String state;
private String result;
private String players;
TournamentGameView(int roundNum, TournamentPairing pair, Game game) {
this.roundNum = roundNum;
this.matchId = pair.getMatch().getId();
this.gameId = game.getId();
this.players = pair.getPlayer1().getPlayer().getName() + " " + pair.getPlayer2().getPlayer().getName();
if (game.isGameOver()) {
this.state = "Finished";
this.result = game.getWinner();
}
else {
this.state = "Dueling";
this.result = "";
}
}
public int getRoundNum() {
return roundNum;
}
public UUID getMatchId() {
return this.matchId;
}
public UUID getGameId() {
return this.gameId;
}
public String getState() {
return this.state;
}
public String getResult() {
return this.result;
}
public String getPlayers() {
return this.players;
}
}

View file

@ -29,6 +29,10 @@
package mage.view;
import java.io.Serializable;
import mage.game.tournament.Round;
import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentPairing;
import mage.game.tournament.TournamentPlayer;
/**
*
@ -37,4 +41,25 @@ import java.io.Serializable;
public class TournamentPlayerView implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String results;
private int points;
TournamentPlayerView(TournamentPlayer player) {
this.name = player.getPlayer().getName();
this.points = player.getPoints();
this.results = player.getResults();
}
public String getName() {
return this.name;
}
public int getPoints() {
return this.points;
}
public String getResults() {
return results;
}
}

View file

@ -0,0 +1,79 @@
/*
* 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.game.tournament.TournamentType;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TournamentTypeView implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private int minPlayers;
private int maxPlayers;
private int numBoosters;
private boolean draft;
public TournamentTypeView(TournamentType tournamentType) {
this.name = tournamentType.getName();
this.minPlayers = tournamentType.getMinPlayers();
this.maxPlayers = tournamentType.getMaxPlayers();
this.numBoosters = tournamentType.getNumBoosters();
this.draft = tournamentType.isDraft();
}
@Override
public String toString() {
return name;
}
public String getName() {
return name;
}
public int getMinPlayers() {
return minPlayers;
}
public int getMaxPlayers() {
return maxPlayers;
}
public int getNumBoosters() {
return numBoosters;
}
public boolean isDraft() {
return draft;
}
}

View file

@ -31,7 +31,9 @@ package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.game.tournament.Round;
import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentPlayer;
/**
*
@ -41,8 +43,22 @@ public class TournamentView implements Serializable {
private static final long serialVersionUID = 1L;
List<RoundView> rounds = new ArrayList<RoundView>();
List<TournamentPlayerView> players = new ArrayList<TournamentPlayerView>();
public TournamentView(Tournament tournament) {
for (TournamentPlayer player: tournament.getPlayers()) {
players.add(new TournamentPlayerView(player));
}
for (Round round: tournament.getRounds()) {
rounds.add(new RoundView(round));
}
}
public List<TournamentPlayerView> getPlayers() {
return players;
}
public List<RoundView> getRounds() {
return rounds;
}
}