Fixed: Temporary fix Concurrent access disconnected player game (nextPlayerSetup)
This commit is contained in:
@@ -83,7 +83,7 @@ public class Game implements Serializable {
|
||||
* @param totem the selected totem.
|
||||
* @return {@code true} if the choice is applied successfully, {@code false} otherwise.
|
||||
*/
|
||||
public boolean TotemChoice(Player player,Totems totem) {
|
||||
public synchronized boolean TotemChoice(Player player,Totems totem) {
|
||||
if(!currentState.getGameStage().equals(GameStages.TOTEM_CHOICE))
|
||||
return false;
|
||||
if(!getCurrentState().getCurrentPlayer().equals(player))
|
||||
@@ -135,7 +135,7 @@ public class Game implements Serializable {
|
||||
* @return {@code true} if the disconnection is handled successfully,
|
||||
* {@code false} if the player was already marked as disconnected.
|
||||
*/
|
||||
public boolean DisconnectedPlayer(Player player)
|
||||
public synchronized boolean DisconnectedPlayer(Player player)
|
||||
{
|
||||
if(disconnetedPlayers.containsKey(player) && disconnetedPlayers.get(player))
|
||||
{
|
||||
@@ -177,7 +177,7 @@ public class Game implements Serializable {
|
||||
* @return {@code true} if the reconnection is handled successfully,
|
||||
* {@code false} if the player was not previously marked as disconnected.
|
||||
*/
|
||||
public boolean ReconnectPlayer(Player player)
|
||||
public synchronized boolean ReconnectPlayer(Player player)
|
||||
{
|
||||
if(!disconnetedPlayers.containsKey(player))
|
||||
{
|
||||
@@ -198,7 +198,7 @@ public class Game implements Serializable {
|
||||
/**
|
||||
* Clears the collection of disconnected players.
|
||||
*/
|
||||
public void ClearDisconnected()
|
||||
public synchronized void ClearDisconnected()
|
||||
{
|
||||
disconnetedPlayers.clear();
|
||||
}
|
||||
@@ -689,7 +689,7 @@ public class Game implements Serializable {
|
||||
* If the current stage is {@code OPTIONAL_CARD_EFFECT}, the next player is taken from the optional card queue.
|
||||
* If no player is available, the game stage is updated to {@code RESOLVING_EVENT}.
|
||||
*/
|
||||
private void nextPlayerSetup() {
|
||||
private synchronized void nextPlayerSetup() {
|
||||
|
||||
if (GameStages.SLOT_CHOICE == currentState.getGameStage()) {
|
||||
Player tempPlayer = orderLogicCard.pull();
|
||||
@@ -796,7 +796,7 @@ public class Game implements Serializable {
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
private void transitionToOptionalOrNextRound() {
|
||||
private synchronized void transitionToOptionalOrNextRound() {
|
||||
currentState.GameStageUpdate(GameStages.OPT_CARD_E);
|
||||
|
||||
OptionalCardQueue = new LinkedList<>();
|
||||
@@ -986,7 +986,7 @@ public class Game implements Serializable {
|
||||
* in the first position of the final ranking. The remaining players are
|
||||
* ordered by prestige value and, in case of a tie, by food value.
|
||||
*/
|
||||
public void EndGameForFeit() {
|
||||
public synchronized void EndGameForFeit() {
|
||||
Player winner=playersList.stream().filter(x->!disconnetedPlayers.containsKey(x)||!disconnetedPlayers.get(x)).toList().get(0);
|
||||
currentState.GameStageUpdate(GameStages.ENDED);
|
||||
playerStanding=new ArrayList<>(playersList);
|
||||
|
||||
Reference in New Issue
Block a user