Open Sandyman opened 4 years ago
For this issue I tried to define ShipSunk(): checking if battleship.hit() and if so asking the player if the battleship was sunk, to respond if the battleship was sunk, if so which one and printing "You sunk my ____"
In the original game, a player must indicate to the other players that a ship has sunk. For instance, "you sunk my aircraft carrier."
The current implementation doesn't have any way to convey this information, but it would be a nice addition.
The gRPC protocol will probably have to be updated for this to work, as there is no provision to send this information in any way.
Is possible for the game server to keep track of player's move? if that is possible then having a hit() function that return nothing to returning a string value for the location that is a hit, for example hit("ac") which would represent Aircraft carrier then from there the game server would increment the count value for the Aircraft carrier count. if Aircraft carrier count equal to Aircraft carrier predefine length (for example 5) then game server would send a ShipSunk().
The game server could potentially keep track of player's moves. It would then need to have more knowledge about (at the very least) the ships, as you suggest @j222144.
It is an interesting addition, though, and while it would require a change to the protocol (and to the game server), it's quite doable.
Ultimately, the game server might keep track of the boards, which reduces (pretty much to nil) the chance of cheating. :)
Probably adding arrays for every single ship. For example (aircraft = [ A, A, A, A, A]) and every time the ship gets hit the user will enter the letter in this case (A) and then with a for loop eliminates the (A) from the array until the array is empty and then automatically send a message to the opponent "Aircraft sunk!"
First of all the server would have to be updated to incorporate a response to a ship being sunk by the opponent from the player. With which the player would send the name of the ship that was sunk to the server and then the server would send that to the opponent.
In the original game, a player must indicate to the other players that a ship has sunk. For instance, "you sunk my aircraft carrier."
The current implementation doesn't have any way to convey this information, but it would be a nice addition.
The gRPC protocol will probably have to be updated for this to work, as there is no provision to send this information in any way.