Commit Graph

3 Commits

Author SHA1 Message Date
Aryadev Chavali
dc94a396ec Clean up player-{pay,receive}
Clean up the implementation of player-pay and player-receive by:

- Single-clause early-error `if` for errors
- use `incf`/`decf` instead of `setf`.
2025-02-15 16:20:14 +00:00
Aryadev Chavali
24b07f9166 Introduce custom errors for player handling
Custom errors for malformed/nonexistent player IDs as well as a player
not having a high enough balance for the money requested.

This will allow me to encode more information in the errors, for
callers to use.  I'm generally of the opinion that callers should be
checking error conditions before calling these functions, but per
Murphy's law it would be nice to have more information in the error
message.
2025-02-15 15:40:56 +00:00
Aryadev Chavali
4ded442dd4 Player handler package
This package defines a player data structure, collections of players,
and different interactions you can have with them:
- Extracting attributes (destructors)
- Checking if they're bankrupt or can bet
- Modifying a collection to adjust the balance of any one
  player (including errors in case that isn't possible)
2025-02-15 15:37:16 +00:00