Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Fixed bug disconnecting players after first round
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl August Gjørsvik authored and Carl August Gjørsvik committed Apr 30, 2019
1 parent efa1c2e commit dfe4d38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/sky7/Client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ public void finishedProcessing(IBoard board) {

@Override
public void render(HashMap<Integer, ArrayList<ICard>> cards) {
game.process(cards);

new Thread(() -> {
game.process(cards);
}).start();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/sky7/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Game implements IGame {
private IBoard board;
private List<Integer> destroyedRobots = new ArrayList<>();
private boolean hosting;
private boolean disableDamage = true;

/**
* The construct for a game engine on host.
Expand Down Expand Up @@ -284,6 +285,7 @@ private void expressConveyor() {
}

private void applyDamage(int playerID, int damage) {
if (disableDamage) return;
if (hosting) {
host.applyDamage(playerID, damage);
} else if (client.getPlayer().getPlayerNumber() == playerID) client.applyDamage(playerID, damage);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/sky7/host/HostNetHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void connected (Connection connection) {
NumberOfPlayers nop = new NumberOfPlayers();
nop.nPlayers = server.getConnections().length+1;
server.sendToAllTCP(nop);
connection.setKeepAliveTCP(5000);
}

public void disconnected (Connection connection) {
Expand Down

0 comments on commit dfe4d38

Please sign in to comment.