Skip to content

Commit

Permalink
g
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-gai committed Aug 18, 2023
1 parent 9229bc0 commit a7a36fa
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions contracts/Battleship.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ contract Battleship {
if (targetBoard[_x][_y] == CellState.Ship) {
targetBoard[_x][_y] = CellState.Hit;
if (msg.sender == player1) {
player1ShipsHit++;
} else {
player2ShipsHit++;
} else {
player1ShipsHit++;
}
if (checkWin()) {
if (player1ShipsHit == 17 || player2ShipsHit == 17) {
gameEnded = true;
winner = msg.sender;
}
Expand All @@ -111,8 +111,4 @@ contract Battleship {
currentPlayer = player1;
}
}

function checkWin() internal view returns (bool) {
return player1ShipsHit == 17 || player2ShipsHit == 17;
}
}

0 comments on commit a7a36fa

Please sign in to comment.