ritchie/engine/error

Errors produced by the engine.

Types

Reasons an action could be rejected.

pub type ActionError {
  TsumogiriMismatch(tile.Tile, option.Option(tile.Tile))
  DiscardClosedHandUnderRiichi
  NoSwapCalling(tile.Tile, meld.Meld)
  TileNotExist(tile.Tile)
  DeclareRiichiAgain
  DeclareRiichiWithoutPoints
  DeclareRiichiWithOpenMeld
  DeclareRiichiWhileNotReady
  DiscardOnlyAfterChiiPon
  CannotKanOnLastDraw
  InvalidAnkanUnderRiichi(tile.Tile)
  NotEnoughForAnkan(tile.Tile)
  NoPonForKakan(tile.Tile)
  NotEnoughKindsForNineKinds(Int)
  NotInitAbortable
  MustDeclareTsumoAgariOnDraw
  CannotTsumoAgari
}

Constructors

  • TsumogiriMismatch(tile.Tile, option.Option(tile.Tile))

    Tsumogiri discard doesn’t match drawn tile

  • DiscardClosedHandUnderRiichi

    Discard from closed hand while under riichi

  • NoSwapCalling(tile.Tile, meld.Meld)

    Discard considered swap-calling

  • TileNotExist(tile.Tile)

    Tile doesn’t exist

  • DeclareRiichiAgain

    Redeclaring riichi when it’s already declared

  • DeclareRiichiWithoutPoints

    Declaring riichi without the requisite amount of points

  • DeclareRiichiWithOpenMeld

    Declaring riichi with an open hand

  • DeclareRiichiWhileNotReady

    Declaring riichi with a hand not ready after discarding

  • DiscardOnlyAfterChiiPon

    Discard not after chii/pon

  • CannotKanOnLastDraw

    Attempting to call ankan/kakan on last draw

  • InvalidAnkanUnderRiichi(tile.Tile)

    Attempting invalid ankan under riichi

  • NotEnoughForAnkan(tile.Tile)

    Attempting ankan without enough tiles in hand

  • NoPonForKakan(tile.Tile)

    Attempting kakan without matching pon

  • NotEnoughKindsForNineKinds(Int)

    Declaring nine kinds of terminals/honors without enough of them in hand

  • NotInitAbortable

    Aborting after first go-around

  • MustDeclareTsumoAgariOnDraw

    Declaring tsumo-agari not on drawn tile

  • CannotTsumoAgari

    Declaring tsumo-agari without ready hand/without yaku

Errors from the engine.

pub type EngineError {
  RoundNotStarted
  RoundEnded
  NoActionRegistered
  InvalidAction(ActionError)
  InvalidReaction(ReactionError)
}

Constructors

  • RoundNotStarted

    No round has been started yet

  • RoundEnded

    The round has already ended

  • NoActionRegistered

    No action has been registered for the current turn

  • InvalidAction(ActionError)

    The action was rejected by validation

  • InvalidReaction(ReactionError)

    The reaction was rejected by validation

Reasons a reaction could be rejected.

pub type ReactionError {
  TerminalAction
  CannotReactToSelf
  OpenMeldUnderRiichi
  MeldOnLastDraw
  NotDiscard(action.Action)
  CanOnlyChiiPrevPlayer
  InvalidChii(tile.Tile, tile.Tile, tile.Tile)
  InvalidPon(tile.Tile, tile.Tile, tile.Tile)
  InvalidDaiminkan
  Furiten
  CannotRonAgari
  CannotRonAgariOverAnkan
}

Constructors

  • TerminalAction

    Action is terminal and no reactions are possible

  • CannotReactToSelf

    Acting player cannot react to their own action

  • OpenMeldUnderRiichi

    Cannot declare an open meld under riichi

  • MeldOnLastDraw

    Cannot declare an open meld on the last draw

  • NotDiscard(action.Action)

    Can only call a discarded tile

  • CanOnlyChiiPrevPlayer

    Chii can only be called on the previous player’s discard

  • InvalidChii(tile.Tile, tile.Tile, tile.Tile)

    Invalid chii with the given own tiles and called tile

  • InvalidPon(tile.Tile, tile.Tile, tile.Tile)

    Invalid pon with the given own tiles and called tile

  • InvalidDaiminkan

    Invalid daiminkan

  • Furiten

    Cannot ron while under furiten

  • CannotRonAgari

    Cannot ron, either not waiting, or no yaku

  • CannotRonAgariOverAnkan

    Cannot ron over an ankan (with the exception of kokushi)

✨ Search Document