Commit d38bb6cb authored by Anders H. Rebner's avatar Anders H. Rebner
Browse files

Fixed did not finish bug

parent 44b76b29
......@@ -7,6 +7,7 @@ import com.mygdx.game.model.Player;
import com.mygdx.game.views.PlayView;
import com.mygdx.game.views.tokens.StarPiece;
import java.util.ArrayList;
import java.util.List;
public class GameController {
......@@ -103,17 +104,9 @@ public class GameController {
}
public void setPlayerFinished(int playerId, int place) {
int playerIndex;
List<Player> players = playerController.getLobby().getPlayers();
for (Player player: players) {
if (player.getID() == playerId) {
playerIndex = players.indexOf(player);
this.view.setPlayerFinished(playerIndex, place);
break;
}
}
List<Integer> playerIds = new ArrayList(model.getPlayerIds());
int playerIndex = playerIds.indexOf(playerId);
this.view.setPlayerFinished(playerIndex, place);
}
public void setGameFinished() {
......
......@@ -23,7 +23,7 @@ public class NetworkController {
this.client = new Client();
client.start();
try {
String IP4_LAN_ADDRESS = "192.168.1.167"; //"192.168.0.136";
String IP4_LAN_ADDRESS = "192.168.0.136";
client.connect(10000, IP4_LAN_ADDRESS, 54555);
} catch (IOException e) {
e.printStackTrace();
......
......@@ -136,4 +136,8 @@ class Game(gameState: GameState, playerIds: LinkedHashSet<Int>) {
private fun thereArePlayersLeft(): Boolean {
return playerFinishedIds.size < playerIds.size - playerLeftIds.size
}
fun getPlayerIds(): LinkedHashSet<Int> {
return playerIds
}
}
......@@ -26,8 +26,7 @@ public class cLobbyLeave extends Command{
Lobby lobby = net.getLobby(lobbyId);
System.out.printf("Request from Player w. ID: %d to leave Lobby w. ID: %d. Returning Lobby w. ID: %d \n",
playerId, lobbyId, lobbyId);
System.out.printf("Request from Player w. ID: %d to leave Lobby w. ID: %d \n", playerId, lobbyId);
for (Connection c : net.getConnections(lobby)) {
c.sendTCP(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment