robinzig wrote: ↑06 May 2021, 16:57
EDIT: went on my control panel and I appear to have access (read-only, of course) to the CoB source code! I don't remember requesting access but perhaps I did - thank you if you spontaneously gave it to me
I didn't do it myself, you may have asked it some time ago.
Here are a few things about CoB implementation:
- I didn't implement Undo on client side, it would have been a nightmare, and very risky regarding potential bugs (well at least if you want to display possible / legal moves, and tell players that a move is forbidden when they do it, and not later when they confirm their whole turn, which would be a terrible user experience). I wanted to allow players to undo a whole turn, and that can be a lot of actions, each of them having a lot of consequences on what's possible or not for subsequent actions.
I only used client states for a few simple cases. The least simple case is when choosing a tile to place, because it involves some server-side computing of possible moves (and number of workers needed for each move) for each die / tile couple, that will be passed to the client so that it can display proper informations upon die / tile player selection. But I wouldn't have used this approach for a more complex sequence of actions.
- I don't use BGA's undo feature because I don't want to reload the whole page on each Undo. So I have backup (snapshot) tables that record almost everything at the beginning of a turn, and for the UI undo, a `moved_pieces` table to keep track of the pieces that have moved during the turn (not of the moves themselves, upon Undo I just move them back to the place recorded in the backup table). There are a few tricky things, like for the turn order discs. Each game will have different tricky things to undo, and if it gets too complicated, the page reload of BGA's built-in Undo feature may be a good choice.
- But I thought that it would be confusing for players (especially new players) to see game tiles moving all over the board when a turn with several actions is cancelled. (They may not notice that these moves are caused by an "undo turn"). So I don't send notifications to other players and spectators when the moves are done, I store them in a DB table, then send them when the turn is confirmed (maybe not the best choice, see later). This is possible thanks to the new "Ignoring notifications" feature (see "Game interface logic" Studio doc page), that allows the player that just confirmed their turn to ignore these end-of-turn notifications, to avoid duplicate log messages. But at the moment there's a problem: these duplicate log messages are not ignored on the "game review" page, in the list of moves (hence the "maybe not the best choice", but maybe this could be fixed).
- Regarding the choice to show moves to opponents / spectators in real-time or only when they are confirmed, I think the feeling can be very different for different games (risk of confusion or not, pace of the game, ...). But even for a given game, the feeling can be different for different players: some castles of burgundy players would prefer to see the moves during their opponent's turn, but I'm pretty sure that some players play a lot with the undo feature, and that seeing all these moves and cancelations could be confusing or just plain annoying for a lot of other players. The ideal thing for me would be to have a user preference for this, but I'm not sure that with the framework as it is today it would be possible / doable without a lot of efforts and potential bugs (we don't have much control on log messages, even if the idea to strike cancelled move messages is good). But I really think that it would be great to improve the framework regarding undoing and notification management.