ArcherArcher
Home
Quick Start
Project Introduction
  • 简体中文
  • English
Home
Quick Start
Project Introduction
  • 简体中文
  • English
  • Home
  • Basic Configuration

    • Project Introduction
    • Quick Start
    • FAQ
    • Contact Us
  • Advanced Development

    • Basic Knowledge
    • Basic Framework
    • Majsoul Development

      • Tile Names

        • Basic
      • Manager

        • Lobby Manager
      • Game Interfaces

        • Basic
      • LQ

        • Basic
      • Action Types

        • Basic
      • Game State

        • Basic
      • Login Event

        • Login Event
        • Advanced - Mahjong Event Login
      • Discard Actions

        • Basics
        • Advanced
      • Chii (Eat)
      • Pon
      • Kong
      • Cancel, Skip
  • Plugin System

    • Basic Usage
    • Resource Plugin Development
  • Auto Review

    • Automatic Review
  • Tenhou Room

    • Playing in Tenhou Private Room with Mortal Bot

Package Name

  • gamestate

Import

  • import "github.com/moxcomic/Archer/gamestate"

Constants

NameTypeValueNotes
RoundEndReasonHuleint0Round ended by winning
RoundEndReasonRyuukyokuint1Round ended by draw

RoundEnd

NameTypeNotes
ReasonintReason for round end
Deltas[]intScore changes for players, [0] is self
Hules[]*HulesWin data

Hules

NameTypeNotes
SeatintSeat number, [0] is self
TsumoboolWhether it is a self-draw win
PointintPoints earned

Tsumogiri

NameTypeNotes
TilestringTile name
TsumogiriboolWhether it was tsumogiri

Interface Methods

NameParametersReturn ValueNotes
InstNone*gamestate.GameStateGameState singleton instance

Instance Methods

Game Info

NameParametersReturn ValueNotes
GetChangNoneintCurrent round wind: 0=East, 1=South, 2=West
GetJuNoneintCurrent hand number
IsOnChiPonNoneboolWhether it's in Chii/Pon/Kan phase
IsOnBabeiNoneboolWhether it's in Babei phase
IsLiqi3NoneboolWhether it is three-player mahjong
IsInSyncGameNoneboolWhether this game is a reconnection game
IsRoundWindstringboolWhether the tile is the round wind
IsSelfWindstringboolWhether the tile is the player's own wind
IsCanWinNoneboolWhether the player can win
GetRankingNoneintCurrent ranking (0-indexed)
GetLeftTileCountNoneintRemaining tile count

Hand Tiles

NameParametersReturn ValueNotes
GetHandTileNone[]stringGet hand tiles

Discards

NameParametersReturn ValueNotes
GetDiscardTileNone[][]stringGet discard piles for all four players

Tile Pool

NameParametersReturn ValueNotes
GetLeftTileNone[]stringGet own tile pool
GetGlobalLeftTileNone[]stringGet global tile pool

Melds

NameParametersReturn ValueNotes
GetMeldNone[][]*model.MeldGet melds for all four players (raw data)
MeldsNone[][][]stringGet melds for all four players (string format)
GetMeldDiscardAtNone[][]stringGet meld discard positions

Dora

NameParametersReturn ValueNotes
GetDoraNone[]stringGet dora indicators
CalcDoraCountNoneintCalculate current dora count

Riichi

NameParametersReturn ValueNotes
GetRiichiNone[]boolGet riichi status for all four players
GetRiichiAtNone[]intRiichi position in global tile pool, -1 if not declared
GetRiichiTsumogiriNone[]boolWhether each player's riichi was tsumogiri
GetCanIppatsuNone[]boolWhether each player can perform ippatsu

Operations

NameParametersReturn ValueNotes
IsCanOperationsNoneboolWhether any actions can be performed
IsCanintboolWhether action (x) can be performed
OperationCombinationuint32[]stringGet combination for operation

Score

NameParametersReturn ValueNotes
GetRoundEndNone*RoundEndGet round end information

Other

NameParametersReturn ValueNotes
GetLatestGlobalDiscardAtNone[]intLatest global discard position for each player
GetEarlyOutsideNone[][]stringEarly outside tiles for each player
RemainTileCountstringintGet remaining count of a specific tile
ToLocalSeatintintConvert absolute seat to relative seat
ToLocalSeat2int, intintConvert absolute seat to relative seat (with tw)
ToPositionSeatintintConvert relative seat to absolute seat
ToPositionSeat2int, intintConvert relative seat to absolute seat (with tw)

Direct Field Access

The following fields can be accessed directly via gamestate.Inst().XXX:

NameTypeNotes
ChangintCurrent round wind: 0=East, 1=South, 2=West
BenintCurrent honba count
JuintCurrent hand number
OyaintDealer seat number
Score[]int32Player scores
IsSelfChiPonboolWhether the player is in chii/pon
IsSelfDealboolWhether the player just drew a tile (used for last tile offset)
UserUseMouseboolWhether the user is using the mouse
LastLinkstringLast game replay link
UuidstringGame UUID
Modeint32Game mode
TwintTenhou seat number
LevelstringPlayer level
LevelScoreuint32Player level score
Level3stringThree-player level
Level3Scoreuint32Three-player level score
IsInSyncGameboolWhether this game is a reconnection game
IsChangeEngineboolWhether engine was switched
IsRiichiMomentboolWhether it's a riichi moment
UidstringLogged-in account UID
LastDealstringLast drawn tile
SeatList[]intSeat list