Skip to main content

Crate ceelo_core

Crate ceelo_core 

Source
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
PlayerData
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.
WagerConsole
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:
WagerData
Stand in for the information known at the time the player or bank will make a bet.
WinOrLose
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 wager function. The other players will then in order choose some portion of the bank’s bet to “cover”. We accomplish this by calling the players’ wager functions. 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.

Type Aliases§

Bet
History
Simple Alias for the history of the game.