feat!(lua.endpoints): add sort endpoint for hand sorting by rank/suit
- Dominant language
- Python
- Stars
- 72
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Add a new `sort` endpoint that exposes the in-game "Sort Hand" buttons (Sort by Rank / Sort by Suit) from the play/discard bar in `SELECTING_HAND`.
## Params
```
method: sort
params: { by: "rank" | "suit" }
returns: GameState
required state: SELECTING_HAND
```
Maps to the existing callbacks:
- `by: "rank"` → `G.FUNCS.sort_hand_value` → `G.hand:sort('desc')`
- `by: "suit"` → `G.FUNCS.sort_hand_suit` → `G.hand:sort('suit desc')`
## Why
The sort logic lives server-side in `Card:get_nominal` and reads `card.base.*` (ignores `facing`), so hidden cards land in their true sorted position among visible ones. This makes sorting a genuine **deduction oracle** for fair-play bots that intentionally hide face-down card values (e.g. from The Wheel, The House, The Mark, The Fish) and want to play as a human would — triangulating rank and suit by alternating rank/suit sorts and tracking cards across the reorder by their stable `id`.
This cannot be replicated with the existing `rearrange` endpoint, since `rearrange` requires the caller to already know the target permutation, which defeats the purpose when card values are hidden from the client.
## Scope
Hand-only, `SELECTING_HAND`-only — matches the game's own button bar exactly.
Contributor guide
Assessment
This issue has not been assessed yet.