Shelem Scorekeeping

v0.1.0
io.github.khaleghika/shelem-scorekeeping Checked 10 hours ago Published 1 month ago

Scores Shelem (شلم) card game hands: bids, Mak, Shelem, the 1000-point rule and the 1165 win.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

calculate_shelem_score Calculate Shelem score

Score one completed Shelem hand and return both teams' new totals. Pass the cumulative scores from before the hand, the declaring team, the bid, and how many points were captured (defending_points, declarer_points, or outcome "mak"/"sweep"). The engine applies the doubled sweep award, failed and heavily failed bids, Shelem/sar-shelem (+330/-330/-660), the 1000-point rule for a defending team, and the 1165 winning threshold. All arithmetic is integer and deterministic. Invalid or contradictory input returns an error and no score.

ParameterTypeDescription
bid *integerThe winning bid: 100, 105, ..., 165. Expand spoken abbreviations first ("20" is 120).
team1_score *integerTeam 1 cumulative score before this hand. May be negative.
team2_score *integerTeam 2 cumulative score before this hand. May be negative.
bid_successfulOptional cross-check. The captured points decide success; if this flag disagrees the hand is rejected. Mak is successful.
bidding_teamTeam that won the bidding: 1 or 2. Must equal hakem_team when both are given. At least one of the two is required.
contractOmit below 165. Required when bid is 165: "shelem", "sare-shelem" or "normal" (scored differently on failure).
declarer_pointsPoints captured by the declaring team: 0-165, multiple of 5. Must sum to 165 with defending_points when both are given.
defending_pointsPoints captured by the defending team: 0-165, multiple of 5.
hakem_teamTeam of the Hakem (the declarer): 1 or 2.
outcome"mak": the declarer captured exactly the bid. "sweep": the defenders captured nothing. Use instead of, or consistently with, the point fields.