I’m trying to build a board game and I’m not sure how to model some basic things like the players state.
I want to have a variable number of players, so I’m using a list (even though there can be only 2, 3 or 4; is that already a bad idea?).
Where should I store the information of the “current player”?
- If I have an Integer
currentPlayerfield in my model, it might be out of bounds, and I have to do a bunch of
Array.setto make it work with the
- If I have a Bool (or some kind of state) in each Player, there might be several players “currently playing”.
Any input appreciated!
It’s really a fascinating language and paradigm to use, as difficult as it can be sometimes, it’s a great feeling to wrap my head around some new concepts!
PS: Also using Arrays force me to use a bunch of
Maybe.withDefault emptyPlayer (
emptyCell in the board view). It doesn’t seem like the best option, but should I really use an 225 lines long union type for modeling a 15×15 grid?