Skip to content
New issue

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

Frontend blockchain integration tasks assignment #12

Open
Ching367436 opened this issue Mar 23, 2024 · 0 comments
Open

Frontend blockchain integration tasks assignment #12

Ching367436 opened this issue Mar 23, 2024 · 0 comments
Assignees

Comments

@Ching367436
Copy link
Collaborator

Ching367436 commented Mar 23, 2024

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 yet

function hasReportedShots() public view returns (bool)

End turn:

Someone needs to call function endTurn() public returns (bool) to end turn after everyone calls reportHits.

Check if the game is over

Whenever receive event PlayerLost(address player), check if the game is over.
If so, call submitKey then getWinner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants