-2

These are my class designs: enter image description here

I also have Controllers where I can create table, create users add users to table, deal hands simulate user bets using PostMan (Above classes are game engine classes, I did not share controllers in spring boot. It is all API)

Somehow, I am not able to stitch them all together as a complete game.

Here is what I tried:

Finite State Machine: I think possible states in the game is: Collect Blinds, Deal Hands, GamePlay (where fold, bet and raise takes place), ShowDown. Then I tried to understand what would happen in states and got confused.

Then I tried to implement the logic with chain of responsibility, it looks like we have a chain of activities: collect blinds, deal hands, gameplay (itself is also chain of actions like folds, bets, raises) and updates inside them.

In practice, I was not able to achieve this. Does anyone has an idea how to put them together using design patterns?

Sunuba
  • 21

1 Answers1

1

State is about data, not discrete state machines. State Machines help you understand the emergent states.

If you consider state as all of data overall, you just need to be able to query different views of the data.

Relational Data doesn't have to be SQL, but it's easier to think that way. Your implementation could easily model "record" vectors in memory and implement JOINs using for-loops and lookups.

Entities and Lookups

  • Tables: ID, TableNumber
  • Holders: ID, Name, CashBalance
  • Games: ID, TableID, StartingHoldersJSON

Current Game

  • Cards: Suit, Value, HolderID, (GameID)
  • Bets: ..., (GameID)
  • GameHolders: IsInGame, HolderID, IsDealer, (GameID)

Game Events

  • CardPlayed
  • BetPlayed
  • ....
  • WinEarned
  • LossIncurred

Game Processes

  • When CardPlayed, update Card in [Current Game]
  • When all Game Events are processed, Query [Current Game] for Outcomes or Next Dealer move, and add corresponding Game Event.
  • And more...

Hopefully you see how a working system emerges.