We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/Otmeal/Web3-battle-ship/tree/home-page-api/battle-ship/src/util
Done.
function joinGame(bytes32[] memory _playerShips, bytes32 hashedSecretKey)
address[] public playersAddress;
event PlayerJoinedGame(address player, uint playerIndex)
To make sure everyone is in before starting.
The user needs to choose the coordinate to shoot. After hitting shoot, the frontend should call function takeAShot(Coordinate memory _coord).
function takeAShot(Coordinate memory _coord)
Use function isTurnOver() public view returns (bool) to check.
function isTurnOver() public view returns (bool)
Use mapping(address => Coordinate) public playerShots to get the coordinate. function reportHits(ShipShotProof[] memory _shotSignatures)
mapping(address => Coordinate) public playerShots
function reportHits(ShipShotProof[] memory _shotSignatures)
reportHits
function hasReportedShots() public view returns (bool)
Someone needs to call function endTurn() public returns (bool) to end turn after everyone calls reportHits.
function endTurn() public returns (bool)
Whenever receive event PlayerLost(address player), check if the game is over. If so, call submitKey then getWinner
event PlayerLost(address player)
submitKey
getWinner
The text was updated successfully, but these errors were encountered:
Ching367436
Otmeal
No branches or pull requests
https://github.com/Otmeal/Web3-battle-ship/tree/home-page-api/battle-ship/src/util
Tasks
Open a new game
Done.
Join game
function joinGame(bytes32[] memory _playerShips, bytes32 hashedSecretKey)
Get all the address
address[] public playersAddress;
Listening to
event PlayerJoinedGame(address player, uint playerIndex)
To make sure everyone is in before starting.
takeAShot
The user needs to choose the coordinate to shoot. After hitting shoot, the frontend should call
function takeAShot(Coordinate memory _coord)
.Wait for others to shoot
Use
function isTurnOver() public view returns (bool)
to check.reportHits
Use
mapping(address => Coordinate) public playerShots
to get the coordinate.function reportHits(ShipShotProof[] memory _shotSignatures)
Periodically check if everyone has called
reportHits
yetfunction hasReportedShots() public view returns (bool)
End turn:
Someone needs to call
function endTurn() public returns (bool)
to end turn after everyone callsreportHits
.Check if the game is over
Whenever receive
event PlayerLost(address player)
, check if the game is over.If so, call
submitKey
thengetWinner
The text was updated successfully, but these errors were encountered: