Skip to content

Commit

Permalink
Frontend and Contract improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Jan 13, 2024
1 parent 7ec7c31 commit dcc75d1
Show file tree
Hide file tree
Showing 9 changed files with 924 additions and 28 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

dApp for betting on the outcome of a Tic Tac Toe game.

- Frontend inspired by [Sportsbook](https://github.com/luloxi/sportsbook)
- Board (pending development by BuidlGuidl members)
- Game idea by [freeCodeCamp Frontend Web Development Tutorial](https://www.youtube.com/watch?v=MsnQ5uepIaE)

## How can I contribute to this build?

- 👷‍♀️ To view current development tasks, [join this Trello board](https://trello.com/invite/b/s0vot1BA/ATTI366c508087a404ccf9343def4d76d1ce6F7899AA/newbies-lounge) and check the list "TicTacToe".
Expand Down
34 changes: 17 additions & 17 deletions packages/hardhat/contracts/TicTacToe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,33 +164,33 @@ contract TicTacToe {
"Invalid game state for prize withdrawal"
);

// Ensure the caller is one of the players or has not withdrawn yet
require(
msg.sender == game.player1 || msg.sender == game.player2,
"Not a player"
);

// Ensure the player has not withdrawn yet
if (msg.sender == game.player1) {
require(
game.state == GameState.PLAYER1WON,
"You haven't won this game!"
);
// WITHDRAW RULES FOR PLAYER 1 VICTORY
if (game.state == GameState.PLAYER1WON && msg.sender == game.player1) {
require(
!game.player1Withdrawn,
"You have already withdrawn the prize!"
);
game.player1Withdrawn = true;
} else {
require(
game.state == GameState.PLAYER2WON,
"You haven't won this game!"
);
}

// WITHDRAW RULES FOR PLAYER 2 VICTORY
if (game.state == GameState.PLAYER2WON && msg.sender == game.player2) {
require(
!game.player2Withdrawn,
"You have already withdrawn the prize!"
);
game.player2Withdrawn = true;
}

// WITHDRAW RULES FOR TIE RESULT
if (game.state == GameState.TIE) {
if (msg.sender == game.player1) {
require(!game.player1Withdrawn,"You have already withdrawn the prize!");
game.player1Withdrawn = true;
} else if (msg.sender == game.player2) {
require(!game.player2Withdrawn, "You have already withdrawn the prize!");
game.player2Withdrawn = true;
}
}

// Calculate and transfer the prize based on the game state
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat/deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading

0 comments on commit dcc75d1

Please sign in to comment.