MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / _trick_winner

Function _trick_winner

codeclash/arenas/bridge/replay.py:95–104  ·  view source on GitHub ↗
(trick: list[dict], trump: str | None)

Source from the content-addressed store, hash-verified

93
94
95def _trick_winner(trick: list[dict], trump: str | None) -> int:
96 led = trick[0]["card"][1]
97 best_pos, best_key = None, None
98 for play in trick:
99 suit = play["card"][1]
100 tier = 2 if (trump and suit == trump) else (1 if suit == led else 0)
101 key = (tier, _rank(play["card"]))
102 if best_key is None or key > best_key:
103 best_key, best_pos = key, play["position"]
104 return best_pos
105
106
107class BridgeReplayer(ReplayRenderer):

Callers 1

parseMethod · 0.85

Calls 1

_rankFunction · 0.85

Tested by

no test coverage detected