Guess a Coordinate
Understand the functionality of guessing a coordinate.
We'll cover the following
Allow the players to guess coordinates
Guessing coordinates is the most important action in the game. In order to process a guess, we need to know which player is guessing. We also need to know the row and column values the player is guessing.
We start with a client function, guess_coordinate/4
, that takes those values. This wraps a GenServer.call/2
with a tuple representing the four arguments and the action. We can see this here:
def guess_coordinate(game, player, row, col) when player in @players, do:
GenServer.call(game, {:guess_coordinate, player, row, col})
Get hands-on with 1400+ tech skills courses.