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
RoundEndReasonHuleRoundEndReason0Round ended by win (hule)
RoundEndReasonRyuukyokuRoundEndReason1Round ended by draw (ryuukyoku)

Types

RoundEndReason

NameTypeNotes
RoundEndReasonint aliasRound end reason enum

RoundEnd

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

Hules

NameTypeNotes
SeatintSeat number, [0] is self
TsumoboolSelf-draw win
PointintPoints earned

Tsumogiri

NameTypeNotes
TilestringTile name
TsumogiriboolWhether discard is tsumogiri

Package Functions

NameParametersReturn ValueNotes
InstNone*gamestate.GameStateGameState singleton instance

Instance Methods

All methods below are from *gamestate.GameState.

Common Getters

NameParametersReturn ValueNotes
GetChangNoneintCurrent chang (round wind index)
GetJuNoneintCurrent ju
GetLeftTileCountNoneintRemaining tile count
GetLatestGlobalDiscardAtNone[]intLatest global discard index per seat
GetEarlyOutsideNone[][]stringEarly outside tiles per seat
GetRankingNoneintCurrent rank, zero-based

Hand

NameParametersReturn ValueNotes
GetHandTileNone[]stringHand tiles
AddHandTileinit bool, v ...stringNoneAppend tiles; sort always, and re-sort when init=true
RemoveHandTilev stringNoneRemove one matching tile
RemoveHandTilesv ...stringNoneRemove each tile once
RemoveHandTiles4v stringNoneRemove up to 4 copies across normal/aka/deaka
ResetHandTileNoneNoneClear hand tiles
SortHandTileNoneNoneSort tiles by internal tile order

Discards

NameParametersReturn ValueNotes
GetDiscardTileNone[][]stringDiscard tiles for 4 seats
AddDiscardTileindex int, v ...stringNoneAppend discard(s) to seat index
RemoveDiscardTileindex int, v stringNoneRemove one matching discard from seat index
RemoveDiscardTilesindex int, v ...stringNoneRemove each discard once
RemoveDiscardTiles4index int, v stringNoneRemove up to 4 copies across normal/aka/deaka
ResetDiscardTileNoneNoneClear all discard piles

Left Tile Streams

NameParametersReturn ValueNotes
GetLeftTileNone[]stringCurrent round left-tile stream
GetGlobalLeftTileNone[]stringGlobal left-tile stream
AddLeftTilev ...stringNoneAppend to both LeftTile and GlobalLeftTile
ResetLeftTileNoneNoneClear both streams
UndoLeftTileNoneNoneRemove latest tile from LeftTile only
ResetLeftTileCountleft intNoneReset remaining tile count
UpdateLeftTileCountNoneNoneLeftTileCount--

Dora

NameParametersReturn ValueNotes
GetDoraNone[]stringDora indicators
AddDorav ...stringNoneAppend dora indicator(s)
SetDorav ...stringNoneReplace dora indicators
RemoveDorav stringNoneRemove one matching dora indicator
RemoveDorasv ...stringNoneRemove each indicator once
RemoveDoras4v stringNoneRemove up to 4 copies across normal/aka/deaka
ResetDoraNoneNoneClear dora indicators
CalcDoraCountNoneintCount dora in hand and open melds

Meld

NameParametersReturn ValueNotes
GetMeldNone[][]*model.MeldRaw meld data (4 seats)
MeldsNone[][][]stringMeld tiles converted to string format
AddMeldindex int, v ...*model.MeldNoneAppend meld(s) for seat index
AddMinkanindex int, tiles []string, redFive bool, resetRedFive boolNoneUpgrade matching pon to minkan
ResetMeldNoneNoneReset meld container

Meld Discard Position

NameParametersReturn ValueNotes
GetMeldDiscardAtNone[][]stringDiscards related to chi/pon timing
AddMeldDiscardAtindex int, v ...stringNoneAppend record(s)
RemoveMeldDiscardAtindex int, v stringNoneRemove one matching record
RemoveMeldDiscardAtsindex int, v ...stringNoneRemove each record once
RemoveMeldDiscardAts4index int, v stringNoneRemove up to 4 copies across normal/aka/deaka
ResetMeldDiscardAtNoneNoneClear records for all seats

Riichi And Ippatsu

NameParametersReturn ValueNotes
SetRiichiindex int, v bool, t boolNoneSet riichi and riichi-tsumogiri state
SetRiichiAcceptindex int, v boolNoneSet riichi accept flag
ResetRiichiNoneNoneReset riichi-related arrays
GetRiichiNone[]boolRiichi flags (4 seats)
GetRiichiAtNone[]intRiichi position in global discard stream
GetRiichiTsumogiriNone[]boolWhether riichi discard was tsumogiri
GetCanIppatsuNone[]boolIppatsu availability flags
ResetRiichiAtNoneNoneReset RiichiAt to [-1,-1,-1,-1]
ResetCanIppatsuNoneNoneReset ippatsu flags
ResetTenhouFlagsNoneNoneReset Tenhou ippatsu helper flags
ResetCanIppatsuIndexi intNoneClear one seat's ippatsu + Tenhou flag
ResetLatestGlobalDiscardAtNoneNoneReset latest global discard indexes

Operations

NameParametersReturn ValueNotes
IsCanOperationsNoneboolWhether operation list is non-empty
IsOperationtarget uint32boolWhether target op exists
OperationCombinationtarget uint32[]stringReturn matched operation combinations
IsCantarget intboolWhether target op exists (int version)
SetOperationListv []*lq.OptionalOperationNoneSetter kept for yaegi compatibility

Rules And Win Utilities

NameParametersReturn ValueNotes
IsLiqi3NoneboolWhether it is three-player mahjong
IsRoundWindstringboolWhether the tile is the round wind
IsSelfWindstringboolWhether the tile is the player's own wind
IsCanWinNoneboolWhether the player can win

Assassin / Tile Remaining Helpers

NameParametersReturn ValueNotes
ResetAssassinNoneNoneReset internal tile-remaining counters
AssassinTileCountt stringNoneConsume one tile from counters
AssassinTileCountstiles []stringNoneConsume multiple tiles
RemainTileCounttile stringintRemaining copies for one tile

Seat Conversion

NameParametersReturn ValueNotes
ToLocalSeatseat intintAbsolute seat -> local seat
ToLocalSeat2seat int, tw intintAbsolute seat -> local seat with custom tw
ToPositionSeatseat intintLocal seat -> absolute seat
ToPositionSeat2seat int, tw intintLocal seat -> absolute seat with custom tw

Link / Account Helpers

NameParametersReturn ValueNotes
EncodeAccountIdNoneintEncode account id used in Majsoul paipu link
SetLastLinkNoneNoneBuild and set LastLink from current platform/uuid
SetUuidv stringNoneSetter kept for yaegi compatibility
AddEarlyOutsideindex int, tile stringNoneAdd one early outside tile
ResetEarlyOutsideNoneNoneReset early outside tile record
ResetScoreNoneNoneReset score to [25000,25000,25000,25000]

Direct Field Access

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

NameTypeNotes
HandLocksync.MutexHand tile mutex
HandTile[]stringPlayer hand tiles
LeftLocksync.MutexLeft-tile mutex
LeftTile[]stringLeft-tile stream
GlobalLeftTile[]stringGlobal left-tile stream
DiscardLocksync.MutexDiscard mutex
DiscardTile[][]stringDiscard tiles per seat
MeldLocksync.MutexMeld mutex
Meld[][]*model.MeldMelds per seat
MeldDiscardAtLocksync.MutexMeld-discard-at mutex
MeldDiscardAt[][]stringMeld discard records
DoraLocksync.MutexDora mutex
Dora[]stringDora indicators
Riichi[]boolRiichi flags
RiichiAccept[]boolRiichi accepted flags
RiichiTsumogiri[]boolRiichi tsumogiri flags
RiichiAt[]intRiichi positions in global stream
LatestDiscardintLatest discard seat
LatestGlobalDiscardAt[]intLatest global discard index per seat
CanIppatsu[]boolIppatsu flags
TenhouIppatsuFlag[]boolTenhou helper flags
EarlyOutside[][]stringEarly outside tiles per seat
IsOnChiPonboolCurrent state is chi/pon flow
IsOnBabeiboolCurrent state is babei flow
ChangintCurrent round wind: 0=East, 1=South, 2=West
BenintCurrent honba count
JuintCurrent hand number
OyaintDealer seat number
Score[]int32Player scores
LeftTileCountintRemaining tile count
IsSelfChiPonboolWhether the player is in chii/pon
IsSelfDealboolWhether the player just drew a tile (used for last tile offset)
OperationList[]*lq.OptionalOperationCurrent operation list
UserUseMouseboolWhether the user is using the mouse
LastLinkstringLast game replay link
UuidstringGame UUID
Modeint32Game mode
OnTenhouLobbyboolWhether on Tenhou lobby
OnTenhouGameboolWhether on Tenhou game
TwintTenhou seat number
LastLeveluint32Last known level id
LevelstringPlayer level
LevelScoreuint32Player level score
Level3stringThree-player level
Level3Scoreuint32Three-player level score
IsInSyncGameboolWhether this game is a reconnection game
ResAuthGame*lq.ResAuthGameAuth game payload
Round*lq.ActionNewRoundLatest new-round action payload
RoundEndData*RoundEndLast round-end snapshot
Tile37[]intTile remaining counter (37-index style)
TilesSeen[34]uint8Seen tile counter (34-index style)
Tsumogiri3[][]*TsumogiriTsumogiri log for 3p
IsChangeEngineboolWhether engine was switched
IsRiichiMomentboolWhether it's a riichi moment
TingPaiInfo[]*lq.TingPaiInfoTingpai info payload
TingPaiDiscardInfo[]*lq.TingPaiDiscardInfoTingpai-discard info payload
UidstringLogged-in account UID
LastDealstringLast drawn tile
SeatList[]intSeat list
Liqi3boolRiichiCity 3-player flag