⚙️Game Mechanics
Introduction
The Hot Potato Game is a smart contract-based game. Players mint non-fungible tokens (NFTs), and these tokens are used in our "Hot Potato" game where players pass the "potato" (a trait assigned to a token) between each other. If a player holds the potato when the "explosion timer" expires, their token is "exploded" and removed from the active game. The game continues until there is only one token left.
Game State
The GameState is an enumeration that represents the current state of the game. The possible states are: Queued, Minting, Playing, Paused, FinalRound (two tokens remaining), and Ended
Token Mechanics
The game revolves around the minting and passing of NFTs. Here are some key functions related to this:
mintHand(uint256 count): This function allows a user to mint a number of NFTs, and requires the game state to be in theMintingstate. The minted NFTs are added to theactiveTokensarray and initially do not possess the "Hot Potato" trait.passPotato(uint256 tokenIdTo): This function allows a user to pass the "Hot Potato" to another token. It requires the game to be in thePlayingstate and checks that the potato has not yet exploded.
Game Flow
Here are the key functions related to the flow of the game:
startGame(): This function starts the game, transitioning it into theMintingstate. It can only be called by the contract owner.endMinting(): This function ends the minting phase of the game, transitioning it into thePlayingstate. It randomizes the initial assignment of the "Hot Potato" (via ChainlinkVRF) and starts the explosion timer. It can only be called by the contract owner.pauseGame(): This function pauses the game. It can only be called by the contract owner and stores the remaining time if an explosion is in progress.resumeGame(): This function resumes the game after it has been paused. It can only be called by the contract owner and restores the explosion timer if it was running before the game was paused.restartGame(): This function restarts the game, clearing all current game data and returning it to theQueuedstate. It can only be called by the contract owner.
Potato Explosion
When the explosion timer expires, the token holding the "Hot Potato" is "exploded", i.e., removed from the game. The explosion timer starts at an initial duration and decreases each time the potato is passed, up to a minimum duration.
checkExplosion(): This function allows anyone to check if the potato has exploded. If the potato has exploded, it callsprocessExplosion().processExplosion(): This function processes the explosion of the potato. It removes the potato trait from the exploded token, removes the token from the activeTokens array, and checks if the game should transition to the final round or end.
Randomization
The game uses the Chainlink VRF (Verifiable Random Function) to randomize certain aspects of the game, such as the initial holder of the potato and the explosion timer. This ensures that these aspects of the game are fair and unpredictable.
randomize(uint256 userProvidedSeed): This function requests a random number from the Chainlink VRF. It can only be called by the contract owner during theQueuedandPlayingstates.
Statistics
The contract keeps track of various statistics related to the game, including the number of successful and failed passes per player and total wins. This provides a way for players to track their performance in the game.
Game Rounds
The game operates in rounds. Each round starts with the startGame function, which transitions the game into the Minting state and allows players to mint hands (tokens). When the minting phase ends, the endMinting function is called, which transitions the game into the Playing state and starts the potato passing and explosion mechanics. The round ends when there is only one token left, at which point the endGame function is called to transition the game into the Ended state. The game can then be restarted with the restartGame function. This function clears all current game data and returns the game to the Queued state, allowing a new round to begin.
Endgame
As the intense round of the HotPotato game reaches its finale, only a solitary token remains in play. The holder of this triumphant token, having navigated the unpredictable twists and turns of the game, is rewarded with a significant prize:
With the conclusion of the round, the game is reset and prepared for the next adrenaline-fueled round of play. All the elements return to their initial states, ready to commence a fresh, exciting cycle of the game from square one.
This concludes the overview of the game mechanics for the HotPotato game. Through every round, the game combines strategy, unpredictability, and the thrill of potential rewards, providing an engaging and dynamic player experience. Remember, this documentation serves as a high-level overview. For a deep-dive understanding, it's recommended to review the source code along with the accompanying comments.

Last updated