Editorial illustration: Who advances the turn?

Who advances the turn?

The problem I needed to solve

A card can be legally played before it is time to move to the next player. Collection, resolving a winner or finishing an animation may sit between those moments.

Implementation in this snapshot

TurnManager.MoveNext advances the index and turn number. SetCurrentPlayer assigns a leader directly, ReverseDirection changes direction, and Reset restarts the counter.

The design decision and its cost

The core’s human controller does not own turn advancement. That separation matters in Hokm, where the winner of four played cards must lead the next trick.

Current boundaries

TurnManager knows a generic order and does not automatically exclude empty-handed players. Reset also retains the existing direction; callers need to understand those details.

The trick leader is not simply the next player

After Hokm’s fourth card, advancing normally through the list is not necessarily correct. The trick winner must lead next, even if another player follows the last actor in ordinary order. TurnManager.SetCurrentPlayer supports direct assignment and verifies membership in TurnOrder. A coordinator can connect the winner result to the next turn without teaching the generic core about Hokm. The turn manager does not derive a winner from table cards.

MoveNext increments turnNumber, whereas SetCurrentPlayer only changes currentIndex. The counter should therefore not be assumed to count every leader assignment or four-card trick. TurnResult packages the previous player, current player, index and counter so consumers can understand the transition. A UI needing a trick number must obtain that concept from game state; the name TurnNumber alone does not define Hokm’s cycles.

ReverseDirection changes direction without moving the current player. Reset restores the starting index and counter but retains direction. If a previous flow reversed direction, Reset alone will not undo that choice. CalculateNextIndex also wraps around the list without knowing about eliminated players or empty hands. Games where players leave the flow need an additional policy; applying that policy to every generic movement would introduce unnecessary coupling.

What this stage taught me

I kept turn movement explicit. It makes the sequence of decisions, presentation and continuation easier to follow, and avoids assuming every tap necessarily completes a turn.

Explore Dalo

Latest devlogs

Editorial illustration: Pasur launch and telemetry in the shared structure

Pasur launch and telemetry in the shared structure

Adding Pasur needs both a correct mode handoff and valid public telemetry.

Read article
Editorial illustration: Presenting selection and captures in Pasur

Presenting selection and captures in Pasur

Pasur motion should explain which hand card was played and which table cards were captured.

Read article
Editorial illustration: Pasur bot decisions from capture options

Pasur bot decisions from capture options

My teammate’s Pasur bot chooses among legal options without inspecting hidden opposing cards.

Read article
Dalo