package belotetime.application.server;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import com.sun.swing.internal.plaf.synth.resources.synth;
import belotetime.application.game.Game;
public class GameServer
{
private ArrayList<GameClient> clients;
private boolean gameStarted;
private Game game;
public static int cnt;
public GameServer()
{
clients = new ArrayList<>();
gameStarted = false;
game = new Game();
cnt = 0;
}
public synchronized void addPlayer(GameClient client)
{
clients.add(client);
}
public synchronized ArrayList<GameClient> getClients()
{
return clients;
}
public void setClients(ArrayList<GameClient> clients)
{
this.clients = clients;
}
public synchronized void sendAll(String response) throws IOException
{
for(GameClient c : clients)
{
c.getResponse().writeUTF(response);
}
}
public synchronized boolean isGameStarted()
{
return gameStarted;
}
public synchronized void setGameStarted(boolean gameStarted)
{
this.gameStarted = gameStarted;
}
public Game getGame()
{
return game;
}
public void setGame(Game game)
{
this.game = game;
}
}