Expand description
This library is meant to be an “engine” for simulating the Cee-Lo Game. The game’s mechanics aren’t very simple, so I wrote this library to make sure I got it right and not mix game logic with implementation details.
Structs§
- Player
- Player
Data - Stores the amount of money a player has in addition to their betting strategy.
- Reroll
- Type representing the need to Reroll the dice in hopes of a valid combination.
- Wager
Console - Basic implementation of players wagering at a console.
- WagerN
- Wager struct for betting arbitrary amounts of money.
Enums§
- Rolls
- This struct is necessary because whenever a valid roll occurs in Cee-Lo, we can evaluate it:
- Wager
Data - Stand in for the information known at the time the player or bank will make a bet.
- WinOr
Lose - Struct for storing if the Bank or Player had a higher quality dice roll than each other and how. In Cee-Lo, payouts can be up to 5 times the initial bet.
Traits§
- Wager
- Types implenting this Trait will be able to make an informed wager.
Functions§
- add
- always_
roll - Using recursion to our advantage to always get a valid roll. This will run forever if you are particularly unlucky.
- everyone_
roll - All players roll the dice in this phase. Both the raw dice result and “Quality” are stored for later.
- fade_
bet - This helper function helps to keep score of all of the bets.
- fade_
bets - In Cee-Lo, it is necessary for the bank to make an initial bet through the use of it’s
wagerfunction. The other players will then in order choose some portion of the bank’s bet to “cover”. We accomplish this by calling the players’wagerfunctions. Once the bank’s bet is completely “covered”, no more betting can occur until the round ends. - payout
- In this stage, players exchange money and a new bank is chosen if need be.
- play_
until_ winner - This is the game loop that decides the winner of the game. Returns the winning player and the game history.
- roll_
dice - Helper function that rolls 3d6 and gives the result.
- winner
- Returns the only player standing or multiple players.
- wins_
and_ losses - Helper function to determine how the players in the game won or lost
- wins_
and_ losses_ no_ bank - Seperates the bank from the players as they don’t work the same way as regular players when paying out bets, since it revolves around them.