|
| 1 | +""" |
| 2 | +Yaku configuration and ID mappings. |
| 3 | +
|
| 4 | +.. rubric:: Data |
| 5 | +
|
| 6 | +* :data:`YAKU_ID_TO_TENHOU_ID` - mapping from library yaku IDs to Tenhou yaku IDs |
| 7 | +
|
| 8 | +.. rubric:: Classes |
| 9 | +
|
| 10 | +* :class:`YakuConfig` - pre-instantiated collection of all yaku for condition checking |
| 11 | +
|
| 12 | +Look up a Tenhou yaku ID: |
| 13 | +
|
| 14 | +>>> from mahjong.hand_calculating.yaku_config import YAKU_ID_TO_TENHOU_ID |
| 15 | +>>> from mahjong.hand_calculating.yaku_list import Riichi |
| 16 | +>>> YAKU_ID_TO_TENHOU_ID[Riichi.yaku_id] |
| 17 | +1 |
| 18 | +""" |
| 19 | + |
1 | 20 | from mahjong.hand_calculating.yaku_list import ( |
2 | 21 | AkaDora, |
3 | 22 | Chankan, |
|
123 | 142 | UraDora.yaku_id: 53, |
124 | 143 | AkaDora.yaku_id: 54, |
125 | 144 | } |
| 145 | +""" |
| 146 | +Mapping from library :attr:`~mahjong.hand_calculating.yaku.Yaku.yaku_id` values |
| 147 | +to `Tenhou <https://tenhou.net/>`_ yaku IDs. |
| 148 | +
|
| 149 | +Useful for integrating with Tenhou log formats or displaying results |
| 150 | +in Tenhou-compatible order. |
| 151 | +""" |
126 | 152 |
|
127 | 153 |
|
128 | 154 | class YakuConfig: |
| 155 | + """ |
| 156 | + Pre-instantiated collection of all yaku (winning patterns) for condition checking. |
| 157 | +
|
| 158 | + Each attribute is a :class:`~mahjong.hand_calculating.yaku.Yaku` instance that can |
| 159 | + check whether its condition is met for a given hand decomposition. Yaku are grouped |
| 160 | + by han value: situational yaku, 1-han, 2-han, 3-han, 6-han, yakuman, |
| 161 | + double yakuman, yakuman situations, and bonus dora. |
| 162 | +
|
| 163 | + A ``YakuConfig`` is automatically created as part of |
| 164 | + :class:`~mahjong.hand_calculating.hand_config.HandConfig`, so most users do not need |
| 165 | + to instantiate it directly. Direct instantiation is useful for checking individual |
| 166 | + yaku conditions outside the full hand evaluation pipeline. |
| 167 | +
|
| 168 | + Access yaku metadata: |
| 169 | +
|
| 170 | + >>> from mahjong.hand_calculating.yaku_config import YakuConfig |
| 171 | + >>> config = YakuConfig() |
| 172 | + >>> config.riichi.name |
| 173 | + 'Riichi' |
| 174 | + >>> config.riichi.han_closed |
| 175 | + 1 |
| 176 | + """ |
| 177 | + |
129 | 178 | def __init__(self) -> None: |
130 | 179 | # Yaku situations |
131 | 180 | self.tsumo = Tsumo() |
|
0 commit comments