The problem I needed to solve
Finishing one four-card trick does not finish a Hokm hand. I needed to separate each team’s trick count from the hands scored toward the match.
Implementation in this snapshot
HokmHandTrickScoringService applies a trick result to hand state. HokmMatchScoringService.ApplyHandEnded receives a completed hand and checks the match target.
The design decision and its cost
Hand completion has a specific event and can also carry a Kot outcome. The separation prevents an interface from swapping two numbers that represent different cycles.
Current boundaries
The match service rejects missing input, an unstarted match and an already-ended match. Those checks are not guarantees of network transactions or server persistence; the model is local.
Hand completion and match scoring
A common HUD pitfall is incrementing the number beside a team after one trick while confusing trick count with match score. ApplyTrickWinner first calls HokmHandState.AddTrickPoint and publishes TrickScoreChanged with both teams’ counts. Reaching HandTargetTricks additionally marks the hand ended and publishes HandEnded. A hand ends at its target rather than after every won trick, and the interface must obtain each number through the appropriate contract.
Match scoring exposes two ApplyHandEnded paths. The overload receiving hakemTeamId obtains a Kot result from HokmKotRuleResolver; the simpler overload constructs a normal outcome. WithWinType prepares the effective hand result, and AddHandPoints applies MatchPointsToAdd. Correct overload selection matters: the simpler call cannot infer a Hakem team it never received. The method signature chosen by the caller is part of scoring correctness.
Both services check started and ended state, but this is not general duplicate protection. While a match remains active, match scoring has no record of previously scored hand IDs. Its coordinator must apply each hand completion through a controlled path. MatchScoreChanged is published before checking MatchTargetHands; reaching the target additionally publishes MatchEnded. Listeners must distinguish a numerical update from completion of the entire match.
What this stage taught me
For me, scoring was more than one numeric variable. Every number belonged to a cycle, and each change needed to make clear whether it described a card, trick, hand or complete match.




