[Cruce-commit] SF.net SVN: cruce:[100] Java/trunk
Status: Beta
Brought to you by:
caiusb
|
From: <ali...@us...> - 2010-04-07 15:15:00
|
Revision: 100
http://cruce.svn.sourceforge.net/cruce/?rev=100&view=rev
Author: alinposho
Date: 2010-04-07 15:14:54 +0000 (Wed, 07 Apr 2010)
Log Message:
-----------
Am modificat diagrama de secventa: GameLogicSequenceDiagram.
Modified Paths:
--------------
Java/trunk/Documentation/GameLogicSequenceDiagram.jpg
Java/trunk/src/prc/bubulina/cruce/server/PlayerMap.java
Java/trunk/src/prc/bubulina/cruce/server/RoundLogic.java
Java/trunk/src/prc/bubulina/cruce/server/ServerImplementation.java
Modified: Java/trunk/Documentation/GameLogicSequenceDiagram.jpg
===================================================================
(Binary files differ)
Modified: Java/trunk/src/prc/bubulina/cruce/server/PlayerMap.java
===================================================================
--- Java/trunk/src/prc/bubulina/cruce/server/PlayerMap.java 2010-04-07 14:12:12 UTC (rev 99)
+++ Java/trunk/src/prc/bubulina/cruce/server/PlayerMap.java 2010-04-07 15:14:54 UTC (rev 100)
@@ -11,31 +11,38 @@
private Map<Player, ServerSidePlayer> data;
private Map<Player, ClientInterface> clients;
private static PlayerMap instance;
+
private PlayerMap() {
data = new HashMap<Player, ServerSidePlayer>();
clients = new HashMap<Player, ClientInterface>();
}
+
public static PlayerMap getInstance() {
if (instance == null)
instance = new PlayerMap();
return instance;
}
+
public void put(ServerSidePlayer ssplayer, ClientInterface client) {
data.put(ssplayer.getInfo(), ssplayer);
clients.put(ssplayer.getInfo(), client);
}
+
public ServerSidePlayer getServerSidePlayer(Player player) {
return data.get(player);
}
+
public ClientInterface getClient(Player player) {
return clients.get(player);
}
+
public Player getPlayer(ClientInterface client) {
for (Entry<Player, ClientInterface> e : clients.entrySet())
if (e.getValue().equals(client))
return e.getKey();
return null;
}
+
public void reset() {
data.clear();
}
Modified: Java/trunk/src/prc/bubulina/cruce/server/RoundLogic.java
===================================================================
--- Java/trunk/src/prc/bubulina/cruce/server/RoundLogic.java 2010-04-07 14:12:12 UTC (rev 99)
+++ Java/trunk/src/prc/bubulina/cruce/server/RoundLogic.java 2010-04-07 15:14:54 UTC (rev 100)
@@ -9,6 +9,7 @@
public class RoundLogic {
private List<Team> teams;
private Map<Integer, ServerSidePlayer> playerOrder;
+
public RoundLogic(List<Team> teams) {
this.teams = teams;
int i = 0;
@@ -16,15 +17,18 @@
for (ServerSidePlayer p : t.getPlayers())
playerOrder.put(i++, p);
}
- private Team getTeam(ServerSidePlayer player) {
+
+ public Team getTeam(ServerSidePlayer player) {
for (Team t : teams)
if (t.getPlayers().contains(player))
return t;
return null;
}
+
public void startRound() {
sendCards();
}
+
private void sendCards() {
List<Card> givenCards = new LinkedList<Card>();
for (int i = 0; i < 4; i++) {
@@ -32,9 +36,12 @@
List<Card> cards = new LinkedList<Card>();
for (int j = 0; j < 6; j++) {
Card card;
+
do {
card = Card.getRandomCard();
- } while (givenCards.contains(card));
+ }
+ while (givenCards.contains(card));
+
givenCards.add(card);
cards.add(card);
}
Modified: Java/trunk/src/prc/bubulina/cruce/server/ServerImplementation.java
===================================================================
--- Java/trunk/src/prc/bubulina/cruce/server/ServerImplementation.java 2010-04-07 14:12:12 UTC (rev 99)
+++ Java/trunk/src/prc/bubulina/cruce/server/ServerImplementation.java 2010-04-07 15:14:54 UTC (rev 100)
@@ -12,17 +12,22 @@
public class ServerImplementation implements ServerInterface {
private static ServerImplementation instance;
+
private ServerImplementation() {}
- public static ServerImplementation getInstance() {
+
+ public synchronized static ServerImplementation getInstance() {
if (instance == null)
instance = new ServerImplementation();
return instance;
}
+
private List<Team> teams = new LinkedList<Team>();
private List<ClientInterface> clients = new LinkedList<ClientInterface>();
private StartGameLogic startGameLogic;
private GameLogic gameLogic;
- public boolean sendCards(List<Card> cards, ServerSidePlayer player) {
+
+
+ public synchronized boolean sendCards(List<Card> cards, ServerSidePlayer player) {
ClientInterface client = PlayerMap.getInstance().getClient(player.getInfo());
try {
if (client.receiveCards(cards) == false) {
@@ -39,28 +44,33 @@
}
return true;
}
- public boolean acceptCard(Player sender, Card card) throws RemoteException {
+
+ public synchronized boolean acceptCard(Player sender, Card card) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
- public boolean acceptCard(Player sender, Card card, int anunt) throws RemoteException {
+
+ public synchronized boolean acceptCard(Player sender, Card card, int anunt) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
- public Score getOverallScore() throws RemoteException {
+
+ public synchronized Score getOverallScore() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
- public Player joinGame(String name, ClientInterface client) throws RemoteException {
+ public synchronized Player joinGame(String name, ClientInterface client) throws RemoteException {
ServerSidePlayer ssplayer = startGameLogic.setupPlayer(name, client);
if (ssplayer != null)
return ssplayer.getInfo();
return null;
}
- public void registerForNotifications(ClientInterface callback) throws RemoteException {
+
+ public synchronized void registerForNotifications(ClientInterface callback) throws RemoteException {
clients.add(callback);
}
- public void startGame(Player sender) throws RemoteException {
+
+ public synchronized void startGame(Player sender) throws RemoteException {
startGameLogic.playerReady();
if (startGameLogic.gameReady()) {
for (ClientInterface client : clients)
@@ -68,4 +78,5 @@
gameLogic.startGame(teams);
}
}
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|