Closed Starlight-30036225 closed 7 months ago
I made a whole new packet sent every time the turn changes.
But I can see a very easy simplification here.
Am i stupid?
`` CH.sendMessage(PacketHeader.BOARD_STATE, room.LoadNotationFromMap()); CH.sendMessage((PacketHeader.MOVE, "WHITE");
``
Why don't I just add the player colour as the first 5 characters of the board state?
Lets do that instead so i dont have to always send these two packets at once.
String Notation = ColourAndNotation.substring(5); String Colour = ColourAndNotation.substring(0,5); Board.turn = (Board.White == (Objects.equals(Colour, "WHITE")));
That was simple. I should have done this ages ago
Now all players assume it is not their turn at the start of the game. Just makes this easier.
Now that spectators have been added, I need to recreate how players are told whos turn it is.
If i create a packet that sends a colour string of whos turn it is to all connected players, it allows spectators to know whos turn it is. This does mean the client needs to check the incoming string against their own colour, but that is minimal. The current automatic flip-flop I have built inside the display is a terrible system as it lets the spectator think it can be their turn.
Lets rebuild it