Перейти к содержанию

Семейство: DiceAndScore

Кости, таблица очков, треки прогресса.

Игры

kubiki, yatzy, chet_nechet, one_to_twelve, dice_board, shagay_naadan, sunduchki, naidi_chislo, belosnezhka

Use Cases

flowchart LR
    Player((Player)) --> UC_Roll[UC-RollDice]
    Player --> UC_Score[UC-RecordScore]
    Player --> UC_EndTurn[UC-EndTurn]
    System((System)) --> UC_Validate[UC-ValidateCombination]
    UC_Roll --> UC_Validate
    UC_Score --> UC_EndTurn
UC Описание FR ref
UC-RollDice Активный игрок бросает кости (сервер CSPRNG) FR-dice-01
UC-RecordScore Записать результат в scorecard / трек FR-dice-02
UC-EndTurn Передать ход следующему FR-dice-03
UC-ValidateCombination Проверить допустимость комбинации FR-dice-04

FSM (обобщённый)

stateDiagram-v2
    [*] --> AwaitRoll: turnStart
    AwaitRoll --> Rolling: rollDice
    Rolling --> AwaitChoice: diceShown
    AwaitChoice --> ScoreEntry: choiceMade
    AwaitChoice --> Reroll: keepDice
    Reroll --> AwaitChoice: rerollDone
    ScoreEntry --> CheckWin: scoreRecorded
    CheckWin --> GameOver: winner
    CheckWin --> NextTurn: continue
    NextTurn --> AwaitRoll: nextPlayer
    GameOver --> [*]

Sequence: типичный ход (Яцзы)

sequenceDiagram
    participant P as Player
    participant API as GameService
    participant D as DiceModule
    participant WS as Realtime

    P->>API: roll_dice
    API->>D: roll(5, d6)
    D-->>API: [3,3,5,2,1]
    API->>WS: state_changed
    P->>API: keep_dice {indices:[0,1]}
    P->>API: score_category {cat: FullHouse}
    API->>API: validate + apply
    API->>WS: state_changed

Shared module: dice.py

# Концепт (Phase 4)
def roll_dice(count: int, sides: int, rng) -> list[int]: ...
def is_valid_yatzy_combo(dice: list[int], category: str) -> bool: ...
def score_yatzy(dice: list[int], category: str) -> int: ...

Per-game вариации

Игра Кости Особенность
yatzy 5×d6, 3 reroll 13 категорий scorecard
kubiki 5×d6 Классические комбинации, очки за раунд
chet_nechet 1×d6 Ставка чёт/нечёт
one_to_twelve 2×d6 Трек 1–12, заполнение клеток
dice_board 2×d6 Поле 6×6, см. dice-board

NFR

  • NFR-G01: полная серверная валидация
  • NFR-G05: reproducible seed в тестах
  • FR-035: CSPRNG на сервере