Fixed: Temporary fix Concurrent access disconnected player game (nextPlayerSetup)
This commit is contained in:
@@ -40,7 +40,7 @@ public class GameController {
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the operation fails.
|
||||
*/
|
||||
public boolean DisconnectedPlayer(String username)
|
||||
public synchronized boolean DisconnectedPlayer(String username)
|
||||
{
|
||||
Player player= model.getPlayerByUsername(username);
|
||||
if(player==null)
|
||||
@@ -56,7 +56,7 @@ public class GameController {
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the operation fails.
|
||||
*/
|
||||
public boolean ReconnectPlayer(String username)
|
||||
public synchronized boolean ReconnectPlayer(String username)
|
||||
{
|
||||
Player player= model.getPlayerByUsername(username);
|
||||
if(player==null)
|
||||
@@ -89,7 +89,7 @@ public class GameController {
|
||||
* @return {@code true} if the player is successfully added,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean addPlayer(String username) {
|
||||
public synchronized boolean addPlayer(String username) {
|
||||
return model.addPlayer(new Player(username));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GameController {
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public boolean drawUpperTribeCard(String playerUsername,int pos) {
|
||||
public synchronized boolean drawUpperTribeCard(String playerUsername,int pos) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -118,7 +118,7 @@ public class GameController {
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public boolean drawLowerTribeCard(String playerUsername,int pos) {
|
||||
public synchronized boolean drawLowerTribeCard(String playerUsername,int pos) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -134,7 +134,7 @@ public class GameController {
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public boolean drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
public synchronized boolean drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -150,7 +150,7 @@ public class GameController {
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the draw operation fails.
|
||||
*/
|
||||
public boolean drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
public synchronized boolean drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -165,7 +165,7 @@ public class GameController {
|
||||
* @return {@code true} if the skip action is valid and successfully performed,
|
||||
* {@code false} if the player does not exist or if the action is not valid.
|
||||
*/
|
||||
public boolean SkipTurn(String playerUsername) {
|
||||
public synchronized boolean SkipTurn(String playerUsername) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -183,7 +183,7 @@ public class GameController {
|
||||
* @return {@code true} if the action succeeds,
|
||||
* {@code false} if the player does not exist or if the slot choice operation fails.
|
||||
*/
|
||||
public boolean slotChoice(String playerUsername,int pos) {
|
||||
public synchronized boolean slotChoice(String playerUsername,int pos) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
@@ -199,10 +199,15 @@ public class GameController {
|
||||
* {@code false} if no player with the specified username exists
|
||||
* or if the choice operation fails.
|
||||
*/
|
||||
public boolean TotemChoice(String playerUsername,String totem) {
|
||||
public synchronized boolean TotemChoice(String playerUsername,String totem) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
return false;
|
||||
return model.TotemChoice(player, Totems.valueOf(totem));
|
||||
}
|
||||
|
||||
//TODO
|
||||
public synchronized void EndGameForFeit(){
|
||||
model.EndGameForFeit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user