From 97b6553a1c12418098f5b384c0f46352736be378 Mon Sep 17 00:00:00 2001 From: Lukas Heine Date: Sun, 17 Mar 2024 02:07:25 +0000 Subject: [PATCH] remove unused contract functions --- contracts/poker.sol | 62 ++++++++++----------------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/contracts/poker.sol b/contracts/poker.sol index bc81c7f..6359eda 100644 --- a/contracts/poker.sol +++ b/contracts/poker.sol @@ -41,6 +41,19 @@ contract Poker is Permissioned { stillPlaying[msg.sender] = true; } + function startGame() public { + require(isPlayer(msg.sender), "You are not in the game"); + require(players.length > 1, "Not enough players to start the game"); + require(cards.length == 0, "Game already started"); + require( + playerIndex(msg.sender) == 0, + "Only the first player can start the game" + ); + + deal(); + currentPlayer = players[0]; + } + function bet(uint256 amount) public { require(isPlayer(msg.sender), "You are not in the game"); require(stillPlaying[msg.sender], "You are not in the game"); @@ -100,57 +113,10 @@ contract Poker is Permissioned { currentPlayer = players[index]; } - /*function betRound() public return uint8 { - uint8 currentBet = 0; - - for (uint8 i = 0; i < players.length; i++) { - // check if player is still in the game - if (!stillPlaying[i]) continue ; - - // check if player has already bet - // check if player has enough money to bet - // check if player wants to bet - // update player bet - // update currentBet - } - - - uint currentBet - - pot += msg.value; - }*/ - - /*function mainLoop() public payable { // returns (gamestate?) - // main game loop - // check if all players have joined - require(isPlayer(msg.sender), "You are not in the game"); + function deal() internal { require(players.length > 1, "Not enough players to start the game"); require(cards.length == 0, "Game already started"); - // track next player to move - - // track current game phase and allowed actions - - // deal cards - deal() - - - // pre-flop bet round - // reveal flop - // bet round - // reveal turn - // bet round - // reveal river - // bet round - // check for winner - // showdon - // distribute pot - - }*/ - - function deal() public { - require(players.length > 1, "Not enough players to start the game"); - // create a new deck of cards cards = new euint8[](players.length * 2 + 5); for (uint8 i = 0; i < cards.length; ) {