Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateShantenNum(handTiles Tiles, melds Calls) int
- func CallEqual(call1 *Call, call2 *Call) bool
- func CallToMeld(call *Call) calc.Meld
- func CallsToMelds(melds Calls) calc.Melds
- func DefaultDoubleYakumans() map[yaku.Yakuman]bool
- func GetRemainTileClassNumFromPlayerPerspective(game *Game, player *Player, tileClass TileClass) int
- func GetScoreResult(scoreRule *score.RulesStruct, yakuResult *yaku.Result, honba int) score.Score
- func GetYakuResult(handTiles Tiles, melds Calls, ctx *yaku.Context) *yaku.Result
- func IntToInstance(t int) tile.Instance
- func IntsToInstances(tiles Tiles) tile.Instances
- func IntsToTiles(tiles Tiles) tile.Tiles
- func TilesCallsToCalc(tiles Tiles, calls Calls) (compact.Instances, calc.Option)
- func TilesEqual(tiles1 Tiles, tiles2 Tiles) bool
- type BoardState
- type Call
- type CallType
- type Calls
- type ChiPonState
- type DealState
- type DiscardState
- type EndState
- type EndType
- type Event
- type EventAnKan
- type EventChanKan
- type EventChi
- type EventDaiMinKan
- type EventDiscard
- type EventEnd
- type EventFuriten
- type EventGet
- type EventGlobalInit
- type EventNagashiMangan
- type EventNewIndicator
- type EventPon
- type EventRiichi
- type EventRon
- type EventRyuuKyoku
- type EventShouMinKan
- type EventStart
- type EventTenpaiEnd
- type EventTsumo
- type EventTsumoGiri
- type EventType
- type Events
- type Fu
- type FuInfo
- type FuritenReason
- type Fus
- type Game
- func (game *Game) CheckGameEnd() bool
- func (game *Game) GetAllGlobalEvents() Events
- func (game *Game) GetGlobalEvents() Events
- func (game *Game) GetNumRemainTiles() int
- func (game *Game) GetPosBoardState(pos Wind, validActions Calls) (r *BoardState)
- func (game *Game) GetPosEvents(pos Wind, startIndex int) Events
- func (game *Game) JudgeDiscardCall(pMain *Player) Calls
- func (game *Game) JudgeOtherCalls(pMain *Player, tileID Tile) Calls
- func (game *Game) JudgeSelfCalls(pMain *Player) Calls
- func (game *Game) Reset(playerSlice []*Player, tiles Tiles) map[Wind]Calls
- func (game *Game) Step(posCall map[Wind]*Call) (map[Wind]Calls, EndType)
- type InitState
- type KanState
- type Limit
- type MahjongTiles
- func (tiles *MahjongTiles) DealTile(isRinshan bool) Tile
- func (tiles *MahjongTiles) DoraIndicators() Tiles
- func (tiles *MahjongTiles) GetCurrentIndicator() Tile
- func (tiles *MahjongTiles) Reset()
- func (tiles *MahjongTiles) Setup(ts Tiles) map[Wind]Tiles
- func (tiles *MahjongTiles) UraDoraIndicators() Tiles
- type Player
- func (player *Player) Copy() *Player
- func (player *Player) GetHandTilesClass() TileClasses
- func (player *Player) GetPossibleTenpaiTiles() Tiles
- func (player *Player) GetShantenNum() int
- func (player *Player) GetTenpaiSlice() []TileClass
- func (player *Player) InitTilesWind(tiles Tiles, wind Wind)
- func (player *Player) IsFuriten() bool
- func (player *Player) IsNagashiMangan() bool
- func (player *Player) ResetForGame()
- func (player *Player) ResetForRound()
- type PlayerState
- type Result
- type Rule
- type RyuuKyokuReason
- type ScoreChanges
- type ScoreResult
- type TenpaiInfo
- type TenpaiInfos
- type TenpaiResult
- type Tile
- type TileClass
- type TileClasses
- func (tileClasses *TileClasses) Append(tileClass TileClass)
- func (tileClasses *TileClasses) Copy() TileClasses
- func (tileClasses *TileClasses) Count(tileClass TileClass) int
- func (tileClasses *TileClasses) Index(tileClass TileClass, startIdx int) int
- func (tileClasses *TileClasses) MarshalJSON() ([]byte, error)
- func (tileClasses *TileClasses) Remove(tileClass TileClass)
- func (tileClasses *TileClasses) String() string
- func (tileClasses *TileClasses) UnmarshalJSON(data []byte) error
- type TileT
- type Tiles
- func (tiles *Tiles) Append(tile Tile)
- func (tiles *Tiles) Classes() *TileClasses
- func (tiles *Tiles) Copy() Tiles
- func (tiles *Tiles) Count(tileId Tile) int
- func (tiles *Tiles) Index(tileId Tile, startIdx int) int
- func (tiles *Tiles) Len() int
- func (tiles *Tiles) Less(i, j int) bool
- func (tiles *Tiles) MarshalJSON() ([]byte, error)
- func (tiles *Tiles) Remove(tile Tile)
- func (tiles *Tiles) String() string
- func (tiles *Tiles) Swap(i, j int)
- func (tiles *Tiles) UTF8() string
- func (tiles *Tiles) UnmarshalJSON(data []byte) error
- type Wind
- type WindRound
- type Yaku
- type YakuResult
- type YakuSet
- type Yakuman
- type Yakumans
Constants ¶
View Source
const NumTiles int = 136
Variables ¶
View Source
var ErrGameEnd = errors.New("game is end")
View Source
var MapStringToCallType = func() map[string]CallType { m := make(map[string]CallType) for i := Get; i <= Next; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToEventType = func() map[string]EventType { m := make(map[string]EventType) for i := EventTypeGet; i <= EventTypeGlobalInit; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToFu = func() map[string]Fu { m := make(map[string]Fu) for i := FuNone; i <= FuPair; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToFuritenReason = func() map[string]FuritenReason { m := make(map[string]FuritenReason) for i := FuritenJun; i <= FuritenRiichi; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToLimit = func() map[string]Limit { m := make(map[string]Limit) for i := LimitNone; i <= LimitYakuman; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToRyuuKyokuReason = func() map[string]RyuuKyokuReason { m := make(map[string]RyuuKyokuReason) for i := RyuuKyokuNormal; i <= RyuuKyokuSanChaHou; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToTile = func() map[string]Tile { m := make(map[string]Tile) for i := Man1T1; i <= Chun4; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToTileClass = func() map[string]TileClass { m := make(map[string]TileClass) for i := Man1; i <= RedSou5; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToWind = func() map[string]Wind { m := make(map[string]Wind) for i := WindDummy; i <= North; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToWindRound = func() map[string]WindRound { m := make(map[string]WindRound) for i := WindRoundEast1; i <= WindRoundNorth4; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToYaku = func() map[string]Yaku { m := make(map[string]Yaku) for i := YakuNone; i <= YakuChankan; i++ { m[i.String()] = i } return m }()
View Source
var MapStringToYakuman = func() map[string]Yakuman { m := make(map[string]Yakuman) for i := YakumanNone; i <= YakumanRenhou; i++ { m[i.String()] = i } return m }()
View Source
var NextCall = NewCall(Next, nil, nil)
View Source
var SkipCall = NewCall(Skip, nil, nil)
View Source
var TileClassMap = map[Tile]TileClass{}/* 137 elements not displayed */
View Source
var TileClassUTF = map[TileClass]string{
0: "🀇", 1: "🀈", 2: "🀉", 3: "🀊", 4: "🀋", 5: "🀌", 6: "🀍", 7: "🀎", 8: "🀏",
9: "🀙", 10: "🀚", 11: "🀛", 12: "🀜", 13: "🀝", 14: "🀞", 15: "🀟", 16: "🀠", 17: "🀡",
18: "🀐", 19: "🀑", 20: "🀒", 21: "🀓", 22: "🀔", 23: "🀕", 24: "🀖", 25: "🀗", 26: "🀘",
27: "🀀", 28: "🀁", 29: "🀂", 30: "🀃", 31: "🀆", 32: "🀅", 33: "🀄",
34: "[🀋]", 35: "[🀝]", 36: "[🀔]",
}
View Source
var YaoKyuTileClasses = TileClasses{0, 8, 9, 17, 18, 26, 27, 28, 29, 30, 31, 32, 33}
Functions ¶
func CalculateShantenNum ¶
func CallToMeld ¶
func CallsToMelds ¶
func DefaultDoubleYakumans ¶
func GetScoreResult ¶
func GetYakuResult ¶
func IntToInstance ¶
func IntsToInstances ¶
func IntsToTiles ¶
func TilesCallsToCalc ¶
func TilesEqual ¶
Types ¶
type BoardState ¶
type BoardState struct { WindRound WindRound `json:"wind_round"` NumHonba int `json:"num_honba"` NumRiichi int `json:"num_riichi"` DoraIndicators Tiles `json:"dora_indicators"` PlayerWind Wind `json:"player_wind"` Position Wind `json:"position"` HandTiles Tiles `json:"hand_tiles"` ValidActions Calls `json:"valid_actions,omitempty"` NumRemainTiles int `json:"remain_tiles"` PlayerStates map[Wind]*PlayerState `json:"player_states"` }
func BoardStateCopy ¶
func BoardStateCopy(boardState *BoardState) *BoardState
func NewBoardState ¶
func NewBoardState() *BoardState
func (*BoardState) DecodeEvents ¶
func (b *BoardState) DecodeEvents(events Events)
func (*BoardState) Equal ¶
func (b *BoardState) Equal(bs *BoardState) bool
func (*BoardState) MarshalJSON ¶
func (b *BoardState) MarshalJSON() ([]byte, error)
func (*BoardState) Reset ¶
func (b *BoardState) Reset()
func (*BoardState) UTF8 ¶
func (b *BoardState) UTF8() string
func (*BoardState) UnmarshalJSON ¶
func (b *BoardState) UnmarshalJSON(data []byte) error
type Call ¶
type Call struct { CallType CallType `json:"type"` CallTiles Tiles `json:"tiles"` CallTilesFromWho []Wind `json:"who"` }
func (*Call) MarshalJSON ¶
func (*Call) UnmarshalJSON ¶
type ChiPonState ¶
type ChiPonState struct {
// contains filtered or unexported fields
}
func (*ChiPonState) String ¶
func (s *ChiPonState) String() string
type DiscardState ¶
type DiscardState struct {
// contains filtered or unexported fields
}
func (*DiscardState) String ¶
func (s *DiscardState) String() string
type EventAnKan ¶
func (*EventAnKan) GetType ¶
func (event *EventAnKan) GetType() EventType
func (*EventAnKan) MarshalJSON ¶
func (event *EventAnKan) MarshalJSON() ([]byte, error)
func (*EventAnKan) UnmarshalJSON ¶
func (event *EventAnKan) UnmarshalJSON(data []byte) error
type EventChanKan ¶
type EventChanKan struct { Who Wind `json:"who"` FromWho Wind `json:"from_who"` HandTiles Tiles `json:"hand_tiles"` WinTile Tile `json:"win_tile"` Result *Result `json:"result"` }
func (*EventChanKan) GetType ¶
func (event *EventChanKan) GetType() EventType
func (*EventChanKan) MarshalJSON ¶
func (event *EventChanKan) MarshalJSON() ([]byte, error)
func (*EventChanKan) UnmarshalJSON ¶
func (event *EventChanKan) UnmarshalJSON(data []byte) error
type EventChi ¶
type EventChi struct { Who Wind `json:"who"` Call *Call `json:"call"` TenpaiInfos TenpaiInfos `json:"tenpai_infos,omitempty"` }
func (*EventChi) MarshalJSON ¶
func (*EventChi) UnmarshalJSON ¶
type EventDaiMinKan ¶
func (*EventDaiMinKan) GetType ¶
func (event *EventDaiMinKan) GetType() EventType
func (*EventDaiMinKan) MarshalJSON ¶
func (event *EventDaiMinKan) MarshalJSON() ([]byte, error)
func (*EventDaiMinKan) UnmarshalJSON ¶
func (event *EventDaiMinKan) UnmarshalJSON(data []byte) error
type EventDiscard ¶
type EventDiscard struct { Who Wind `json:"who"` Tile Tile `json:"tile"` TenpaiInfo *TenpaiInfo `json:"tenpai_info,omitempty"` }
func (*EventDiscard) GetType ¶
func (event *EventDiscard) GetType() EventType
func (*EventDiscard) MarshalJSON ¶
func (event *EventDiscard) MarshalJSON() ([]byte, error)
func (*EventDiscard) UnmarshalJSON ¶
func (event *EventDiscard) UnmarshalJSON(data []byte) error
type EventFuriten ¶
type EventFuriten struct { Who Wind `json:"who"` FuritenReason FuritenReason `json:"furiten_reason"` }
func (*EventFuriten) GetType ¶
func (event *EventFuriten) GetType() EventType
func (*EventFuriten) MarshalJSON ¶
func (event *EventFuriten) MarshalJSON() ([]byte, error)
func (*EventFuriten) UnmarshalJSON ¶
func (event *EventFuriten) UnmarshalJSON(data []byte) error
type EventGet ¶
type EventGet struct { Who Wind `json:"who"` Tile Tile `json:"tile,omitempty"` TenpaiInfos TenpaiInfos `json:"tenpai_infos,omitempty"` }
func (*EventGet) MarshalJSON ¶
func (*EventGet) UnmarshalJSON ¶
type EventGlobalInit ¶
type EventGlobalInit struct { AllTiles Tiles `json:"all_tiles"` WindRound WindRound `json:"wind_round"` Seed int64 `json:"seed"` NumGame int `json:"num_game"` NumHonba int `json:"num_honba"` NumRiichi int `json:"num_riichi"` Rule *Rule `json:"rule"` InitPoints map[Wind]int `json:"init_points"` }
func (*EventGlobalInit) GetType ¶
func (event *EventGlobalInit) GetType() EventType
func (*EventGlobalInit) MarshalJSON ¶
func (event *EventGlobalInit) MarshalJSON() ([]byte, error)
func (*EventGlobalInit) UnmarshalJSON ¶
func (event *EventGlobalInit) UnmarshalJSON(data []byte) error
type EventNagashiMangan ¶
type EventNagashiMangan struct {
Who Wind `json:"who"`
}
func (*EventNagashiMangan) GetType ¶
func (event *EventNagashiMangan) GetType() EventType
func (*EventNagashiMangan) MarshalJSON ¶
func (event *EventNagashiMangan) MarshalJSON() ([]byte, error)
func (*EventNagashiMangan) UnmarshalJSON ¶
func (event *EventNagashiMangan) UnmarshalJSON(data []byte) error
type EventNewIndicator ¶
type EventNewIndicator struct {
Tile Tile `json:"tile"`
}
func (*EventNewIndicator) GetType ¶
func (event *EventNewIndicator) GetType() EventType
func (*EventNewIndicator) MarshalJSON ¶
func (event *EventNewIndicator) MarshalJSON() ([]byte, error)
func (*EventNewIndicator) UnmarshalJSON ¶
func (event *EventNewIndicator) UnmarshalJSON(data []byte) error
type EventPon ¶
type EventPon struct { Who Wind `json:"who"` Call *Call `json:"call"` TenpaiInfos TenpaiInfos `json:"tenpai_infos,omitempty"` }
func (*EventPon) MarshalJSON ¶
func (*EventPon) UnmarshalJSON ¶
type EventRiichi ¶
func (*EventRiichi) GetType ¶
func (event *EventRiichi) GetType() EventType
func (*EventRiichi) MarshalJSON ¶
func (event *EventRiichi) MarshalJSON() ([]byte, error)
func (*EventRiichi) UnmarshalJSON ¶
func (event *EventRiichi) UnmarshalJSON(data []byte) error
type EventRon ¶
type EventRon struct { Who Wind `json:"who"` FromWho Wind `json:"from_who"` HandTiles Tiles `json:"hand_tiles"` WinTile Tile `json:"win_tile"` Result *Result `json:"result"` }
func (*EventRon) MarshalJSON ¶
func (*EventRon) UnmarshalJSON ¶
type EventRyuuKyoku ¶
type EventRyuuKyoku struct { Who Wind `json:"who,omitempty"` HandTiles Tiles `json:"hand_tiles,omitempty"` Reason RyuuKyokuReason `json:"reason,int"` }
func (*EventRyuuKyoku) GetType ¶
func (event *EventRyuuKyoku) GetType() EventType
func (*EventRyuuKyoku) MarshalJSON ¶
func (event *EventRyuuKyoku) MarshalJSON() ([]byte, error)
func (*EventRyuuKyoku) UnmarshalJSON ¶
func (event *EventRyuuKyoku) UnmarshalJSON(data []byte) error
type EventShouMinKan ¶
func (*EventShouMinKan) GetType ¶
func (event *EventShouMinKan) GetType() EventType
func (*EventShouMinKan) MarshalJSON ¶
func (event *EventShouMinKan) MarshalJSON() ([]byte, error)
func (*EventShouMinKan) UnmarshalJSON ¶
func (event *EventShouMinKan) UnmarshalJSON(data []byte) error
type EventStart ¶
type EventStart struct { WindRound WindRound `json:"wind_round"` InitWind Wind `json:"init_wind"` Seed int64 `json:"seed"` NumGame int `json:"num_game"` NumHonba int `json:"num_honba"` NumRiichi int `json:"num_riichi"` InitDoraIndicator Tile `json:"init_dora_indicator"` InitTiles Tiles `json:"init_tiles"` PlayersPoints map[Wind]int `json:"players_points"` Rule *Rule `json:"rule"` }
func (*EventStart) GetType ¶
func (event *EventStart) GetType() EventType
func (*EventStart) MarshalJSON ¶
func (event *EventStart) MarshalJSON() ([]byte, error)
func (*EventStart) UnmarshalJSON ¶
func (event *EventStart) UnmarshalJSON(data []byte) error
type EventTenpaiEnd ¶
type EventTenpaiEnd struct { Who Wind `json:"who"` HandTiles Tiles `json:"hand_tiles"` TenpaiSlice TileClasses `json:"Tenpai_slice"` }
func (*EventTenpaiEnd) GetType ¶
func (event *EventTenpaiEnd) GetType() EventType
func (*EventTenpaiEnd) MarshalJSON ¶
func (event *EventTenpaiEnd) MarshalJSON() ([]byte, error)
func (*EventTenpaiEnd) UnmarshalJSON ¶
func (event *EventTenpaiEnd) UnmarshalJSON(data []byte) error
type EventTsumo ¶
type EventTsumo struct { Who Wind `json:"who"` HandTiles Tiles `json:"hand_tiles"` WinTile Tile `json:"win_tile"` Result *Result `json:"result"` }
func (*EventTsumo) GetType ¶
func (event *EventTsumo) GetType() EventType
func (*EventTsumo) MarshalJSON ¶
func (event *EventTsumo) MarshalJSON() ([]byte, error)
func (*EventTsumo) UnmarshalJSON ¶
func (event *EventTsumo) UnmarshalJSON(data []byte) error
type EventTsumoGiri ¶
type EventTsumoGiri struct { Who Wind `json:"who"` Tile Tile `json:"tile"` TenpaiInfo *TenpaiInfo `json:"tenpai_info,omitempty"` }
func (*EventTsumoGiri) GetType ¶
func (event *EventTsumoGiri) GetType() EventType
func (*EventTsumoGiri) MarshalJSON ¶
func (event *EventTsumoGiri) MarshalJSON() ([]byte, error)
func (*EventTsumoGiri) UnmarshalJSON ¶
func (event *EventTsumoGiri) UnmarshalJSON(data []byte) error
type EventType ¶
type EventType int
const ( EventTypeGet EventType = -1 + iota EventTypeTsumoGiri EventTypeDiscard EventTypeChi EventTypePon EventTypeDaiMinKan EventTypeShouMinKan EventTypeAnKan EventTypeRiichi EventTypeRon EventTypeTsumo EventTypeNewIndicator EventTypeChanKan EventTypeRyuuKyoku EventTypeStart EventTypeEnd EventTypeFuriten EventTypeNagashiMangan EventTypeTenpaiEnd EventTypeGlobalInit )
type FuritenReason ¶
type FuritenReason int
const ( FuritenNone FuritenReason = iota FuritenJun FuritenDiscard FuritenRiichi )
func (FuritenReason) String ¶
func (i FuritenReason) String() string
type Game ¶
type Game struct { Rule *Rule Seed int64 P0 *Player P1 *Player P2 *Player P3 *Player PosPlayer map[Wind]*Player Tiles *MahjongTiles WindRound WindRound // {1:东一, 2:东二, 3:东三, 4:东四, 5:南一, 6:南二, 7:南三, 8:南四(all last), 9:西一(西入条件)...} NumGame int NumRiichi int // riichi sticks num NumHonba int // honba num Position Wind State gameState // contains filtered or unexported fields }
func NewMahjongGame ¶
NewMahjongGame
@Description: create a new game @param Seed: random Seed @param Rule: game Rule, nil for default Rule @return *Game
func ReConstructGame ¶
ReConstructGame
@Description: reconstruct game from globalEvents @param playerSlice: player slice @param globalEvents: global events @return *Game
func (*Game) CheckGameEnd ¶
func (*Game) GetAllGlobalEvents ¶
func (*Game) GetGlobalEvents ¶
func (*Game) GetNumRemainTiles ¶
func (*Game) GetPosBoardState ¶
func (game *Game) GetPosBoardState(pos Wind, validActions Calls) (r *BoardState)
GetPosBoardState
@Description: get player's wind board state @receiver game @param pos: player wind @return r: board state
func (*Game) GetPosEvents ¶
GetPosEvents
@Description: get player events @receiver game @param pos: player wind @param startIndex: start index, 0 for all events @return Events: player events
func (*Game) JudgeDiscardCall ¶
func (*Game) JudgeSelfCalls ¶
func (*Game) Reset ¶
Reset
@Description: reset game for new game @param playerSlice: player slice, len must be 4, and the order is East, South, West, North @param tiles: tiles for game, if nil, will use default random tiles @return map[Wind]Calls: calls for East player
type MahjongTiles ¶
type MahjongTiles struct { NumRemainTiles int // contains filtered or unexported fields }
func NewMahjongTiles ¶
func NewMahjongTiles(randP *rand.Rand) *MahjongTiles
func (*MahjongTiles) DealTile ¶
func (tiles *MahjongTiles) DealTile(isRinshan bool) Tile
func (*MahjongTiles) DoraIndicators ¶
func (tiles *MahjongTiles) DoraIndicators() Tiles
func (*MahjongTiles) GetCurrentIndicator ¶
func (tiles *MahjongTiles) GetCurrentIndicator() Tile
func (*MahjongTiles) Reset ¶
func (tiles *MahjongTiles) Reset()
func (*MahjongTiles) Setup ¶
func (tiles *MahjongTiles) Setup(ts Tiles) map[Wind]Tiles
Setup
@Description: setup tiles for each player @receiver tiles @param ts: prepared tiles, len must be 136, nil for default random tiles @return map[Wind]Tiles
func (*MahjongTiles) UraDoraIndicators ¶
func (tiles *MahjongTiles) UraDoraIndicators() Tiles
type Player ¶
type Player struct { Points int Wind Wind JunNum int KanNum int HandTiles Tiles DiscardTiles Tiles TilesTsumoGiri []bool BoardTiles Tiles Melds Calls TenpaiTiles Tiles ShantenNum int TenpaiSlice TileClasses JunFuriten bool DiscardFuriten bool RiichiFuriten bool IppatsuStatus bool RyuukyokuStatus bool FuritenStatus bool IsTsumo bool IsRiichi bool IsIppatsu bool IsRinshan bool IsChankan bool IsHaitei bool IsHoutei bool IsDaburuRiichi bool IsTenhou bool IsChiihou bool RiichiStep int }
func NewMahjongPlayer ¶
func NewMahjongPlayer() *Player
func (*Player) GetHandTilesClass ¶
func (player *Player) GetHandTilesClass() TileClasses
func (*Player) GetPossibleTenpaiTiles ¶
GetPossibleTenpaiTiles
@Description: Get player's possible tenpai tiles after get a tile @receiver player @return Tiles
func (*Player) GetShantenNum ¶
func (*Player) GetTenpaiSlice ¶
GetTenpaiSlice
@Description: Get player's tenpai slice after discard a tile @receiver player @return []TileClass
func (*Player) InitTilesWind ¶
func (*Player) IsNagashiMangan ¶
func (*Player) ResetForGame ¶
func (player *Player) ResetForGame()
func (*Player) ResetForRound ¶
func (player *Player) ResetForRound()
type PlayerState ¶
type Result ¶
type Result struct { YakuResult *YakuResult `json:"yakuResult,omitempty"` ScoreResult *ScoreResult `json:"scoreResult,omitempty"` RonCall *Call RyuuKyokuReason RyuuKyokuReason }
type Rule ¶
type Rule struct { GameLength int `json:"game_length"` // game length 1 for 1 round only, 4 for tonpuusen, 8 for hanchan, etc. // Yaku Rule IsOpenTanyao bool `json:"is_open_tanyao"` // true for open tanyao, false for closed tanyao HasAkaDora bool `json:"has_aka_dora"` // true for aka dora, false for no aka dora RenhouLimit Limit `json:"renhou_limit"` // Limit None for no Limit, Mangan for mangan limit, Haneman for haneman limit, etc. IsHaiteiFromLiveOnly bool `json:"is_haitei_from_live_only"` // true for haitei from live only(means no rinshan and haitei both), false for can rinshan and haitei both IsUra bool `json:"is_ura"` // true for has ura dora, false for no ura dora IsIpatsu bool `json:"is_ipatsu"` // true for has ipatsu, false for no ipatsu IsGreenRequired bool `json:"is_green_required"` // true for Ryuuiisou(Yakuman) need green(hatsu) required, false for no green required IsRinshanFu bool `json:"is_rinshan_fu"` // true for has rinshan fu, false for no rinshan fu // Score Rule IsManganRound bool `json:"is_mangan_round"` // true for points round up to mangan, false for no round IsKazoeYakuman bool `json:"is_kazoe_yakuman"` // true for has kazoe yakuman(13 han), false for no kazoe yakuman IsDoubleYakumans bool `json:"has_double_yakumans"` // true for has double yakuman, false for no double yakuman IsYakumanSum bool `json:"is_yakuman_sum"` // true for yakuman, false for no sum yakuman HonbaValue int `json:"honba_value"` // HonbaValue represent the value of one honba in score calculation, default is 100 // Other Rule IsSanChaHou bool `json:"is_san_cha_hou"` // can san chan ron, true for can, false for can't -> ryuu kyoku IsNagashiMangan bool `json:"is_nagashi_mangan"` // can nagashi/ryuukyoku mangan, true for can, false for can't }
func GetDefaultRule ¶
func GetDefaultRule() *Rule
func (*Rule) MarshalJSON ¶
func (*Rule) ScoreRule ¶
func (r *Rule) ScoreRule() *score.RulesStruct
func (*Rule) UnmarshalJSON ¶
func (*Rule) YakuRule ¶
func (r *Rule) YakuRule() *yaku.RulesStruct
type RyuuKyokuReason ¶
type RyuuKyokuReason int
const ( NoRyuuKyoku RyuuKyokuReason = iota RyuuKyokuNormal RyuuKyokuKyuuShuKyuuHai RyuuKyokuSuuChaRiichi RyuuKyokuSuuKaiKan RyuuKyokuSuufonRenda RyuuKyokuSanChaHou )
func (RyuuKyokuReason) String ¶
func (i RyuuKyokuReason) String() string
type ScoreChanges ¶
func (ScoreChanges) TotalPayed ¶
func (sc ScoreChanges) TotalPayed() (total int)
func (ScoreChanges) TotalWin ¶
func (sc ScoreChanges) TotalWin() int
type ScoreResult ¶
type ScoreResult struct { PayRon int `json:"payRon,omitempty"` PayRonDealer int `json:"payRonDealer,omitempty"` PayTsumo int `json:"payTsumo,omitempty"` PayTsumoDealer int `json:"payTsumoDealer,omitempty"` Special Limit `json:"yaku_limit,omitempty"` Han int `json:"han,omitempty"` Fu int `json:"fu,omitempty"` }
func (*ScoreResult) GetChanges ¶
func (s *ScoreResult) GetChanges(selfWind, otherWind Wind, sticks int) ScoreChanges
type TenpaiInfo ¶
type TenpaiInfo struct { TileClassesTenpaiResult map[TileClass]*TenpaiResult `json:"tile_classes_tenpai_result"` Furiten bool `json:"furiten"` }
func GetTenpaiInfo ¶
func GetTenpaiInfo(game *Game, player *Player) *TenpaiInfo
GetTenpaiInfo
@Description: get the tenpai info of a player after discard a tile @param game @param player @return *TenpaiInfo
func NewTenpaiInfo ¶
func NewTenpaiInfo() *TenpaiInfo
func (*TenpaiInfo) MarshalJSON ¶
func (tenpaiInfo *TenpaiInfo) MarshalJSON() ([]byte, error)
func (*TenpaiInfo) UnmarshalJSON ¶
func (tenpaiInfo *TenpaiInfo) UnmarshalJSON(data []byte) error
type TenpaiInfos ¶
type TenpaiInfos map[Tile]*TenpaiInfo
func GetTenpaiInfos ¶
func GetTenpaiInfos(game *Game, player *Player) TenpaiInfos
GetTenpaiInfos
@Description: after one player get a tile, get the tenpai infos(such as how many tiles remaining to ron) @param game @param player @return *TenpaiInfos
func (*TenpaiInfos) MarshalJSON ¶
func (tenpaiInfos *TenpaiInfos) MarshalJSON() ([]byte, error)
func (*TenpaiInfos) UnmarshalJSON ¶
func (tenpaiInfos *TenpaiInfos) UnmarshalJSON(data []byte) error
type TenpaiResult ¶
func GetTenpaiResult ¶
func GetTenpaiResult(game *Game, player *Player, tileClass TileClass) *TenpaiResult
func NewTenpaiResult ¶
func NewTenpaiResult(remainNum int, result *Result) *TenpaiResult
type Tile ¶
type Tile int
const ( TileDummy Tile = -1 + iota Man1T1 Man1T2 Man1T3 Man1T4 Man2T1 Man2T2 Man2T3 Man2T4 Man3T1 Man3T2 Man3T3 Man3T4 Man4T1 Man4T2 Man4T3 Man4T4 Man5T1 Man5T2 Man5T3 Man5T4 Man6T1 Man6T2 Man6T3 Man6T4 Man7T1 Man7T2 Man7T3 Man7T4 Man8T1 Man8T2 Man8T3 Man8T4 Man9T1 Man9T2 Man9T3 Man9T4 Pin1T1 Pin1T2 Pin1T3 Pin1T4 Pin2T1 Pin2T2 Pin2T3 Pin2T4 Pin3T1 Pin3T2 Pin3T3 Pin3T4 Pin4T1 Pin4T2 Pin4T3 Pin4T4 Pin5T1 Pin5T2 Pin5T3 Pin5T4 Pin6T1 Pin6T2 Pin6T3 Pin6T4 Pin7T1 Pin7T2 Pin7T3 Pin7T4 Pin8T1 Pin8T2 Pin8T3 Pin8T4 Pin9T1 Pin9T2 Pin9T3 Pin9T4 Sou1T1 Sou1T2 Sou1T3 Sou1T4 Sou2T1 Sou2T2 Sou2T3 Sou2T4 Sou3T1 Sou3T2 Sou3T3 Sou3T4 Sou4T1 Sou4T2 Sou4T3 Sou4T4 Sou5T1 Sou5T2 Sou5T3 Sou5T4 Sou6T1 Sou6T2 Sou6T3 Sou6T4 Sou7T1 Sou7T2 Sou7T3 Sou7T4 Sou8T1 Sou8T2 Sou8T3 Sou8T4 Sou9T1 Sou9T2 Sou9T3 Sou9T4 Ton1 Ton2 Ton3 Ton4 Nan1 Nan2 Nan3 Nan4 Shaa1 Shaa2 Shaa3 Shaa4 Pei1 Pei2 Pei3 Pei4 Haku1 Haku2 Haku3 Haku4 Hatsu1 Hatsu2 Hatsu3 Hatsu4 Chun1 Chun2 Chun3 Chun4 )
func IndicatorToDora ¶
type TileClasses ¶
type TileClasses []TileClass
func GetTenpaiSlice ¶
func GetTenpaiSlice(handTiles Tiles, melds Calls) TileClasses
func (*TileClasses) Append ¶
func (tileClasses *TileClasses) Append(tileClass TileClass)
func (*TileClasses) Copy ¶
func (tileClasses *TileClasses) Copy() TileClasses
func (*TileClasses) Count ¶
func (tileClasses *TileClasses) Count(tileClass TileClass) int
func (*TileClasses) Index ¶
func (tileClasses *TileClasses) Index(tileClass TileClass, startIdx int) int
func (*TileClasses) MarshalJSON ¶
func (tileClasses *TileClasses) MarshalJSON() ([]byte, error)
func (*TileClasses) Remove ¶
func (tileClasses *TileClasses) Remove(tileClass TileClass)
func (*TileClasses) String ¶
func (tileClasses *TileClasses) String() string
func (*TileClasses) UnmarshalJSON ¶
func (tileClasses *TileClasses) UnmarshalJSON(data []byte) error
type Tiles ¶
type Tiles []Tile
func IndicatorsToDora ¶
func (*Tiles) Classes ¶
func (tiles *Tiles) Classes() *TileClasses
func (*Tiles) MarshalJSON ¶
func (*Tiles) UnmarshalJSON ¶
type Yaku ¶
type Yaku int
const ( YakuNone Yaku = 0 YakuRiichi Yaku = 1 YakuDaburi Yaku = 2 YakuIppatsu Yaku = 3 YakuTsumo Yaku = 4 YakuTanyao Yaku = 5 YakuChanta Yaku = 6 YakuJunchan Yaku = 7 YakuHonrouto Yaku = 8 YakuYakuhai Yaku = 9 YakuHaku Yaku = 10 YakuHatsu Yaku = 11 YakuChun Yaku = 12 YakuWindRound Yaku = 13 YakuWindSelf Yaku = 14 YakuTon Yaku = 15 YakuNan Yaku = 16 YakuSja Yaku = 17 YakuPei Yaku = 18 YakuTonSelf Yaku = 19 YakuNanSelf Yaku = 20 YakuSjaSelf Yaku = 21 YakuPeiSelf Yaku = 22 YakuTonRound Yaku = 23 YakuNanRound Yaku = 24 YakuSjaRound Yaku = 25 YakuPeiRound Yaku = 26 YakuChiitoi Yaku = 27 YakuToitoi Yaku = 28 YakuSanankou Yaku = 29 YakuSankantsu Yaku = 30 YakuSanshoku Yaku = 31 YakuShousangen Yaku = 32 YakuPinfu Yaku = 33 YakuIppeiko Yaku = 34 YakuRyanpeikou Yaku = 35 YakuItsuu Yaku = 36 YakuSanshokuDoukou Yaku = 37 YakuHonitsu Yaku = 38 YakuChinitsu Yaku = 39 YakuDora Yaku = 40 YakuUraDora Yaku = 41 YakuAkaDora Yaku = 42 YakuRenhou Yaku = 43 YakuHaitei Yaku = 44 YakuHoutei Yaku = 45 YakuRinshan Yaku = 46 YakuChankan Yaku = 47 )
Yaku numbers are now fixed and should not be changed
type YakuResult ¶
type Yakuman ¶
type Yakuman int
const ( YakumanNone Yakuman = 0 YakumanKokushi Yakuman = 1 YakumanKokushi13 Yakuman = 2 YakumanSuukantsu Yakuman = 3 YakumanSuuankou Yakuman = 4 YakumanSuuankouTanki Yakuman = 5 YakumanDaisangen Yakuman = 6 YakumanShousuushi Yakuman = 7 YakumanDaisuushi Yakuman = 8 YakumanRyuuiisou Yakuman = 9 YakumanTsuiisou Yakuman = 10 YakumanChinrouto Yakuman = 11 YakumanChuurenpooto Yakuman = 12 YakumanChuurenpooto9 Yakuman = 13 YakumanTenhou Yakuman = 14 YakumanChihou Yakuman = 15 YakumanRenhou Yakuman = 16 )
Yakuman numbers are now fixed and should not be changed
Source Files
¶
- board_state.go
- call.go
- calltype_string.go
- consts.go
- converter.go
- event.go
- eventtype_string.go
- fu_string.go
- furitenreason_string.go
- game.go
- limit_string.go
- player.go
- reconstruct.go
- result.go
- rule.go
- ryuukyokureason_string.go
- state.go
- tile.go
- tile_string.go
- tileclass_string.go
- utils.go
- wind_string.go
- windround_string.go
- yaku.go
- yaku_string.go
- yakuman_string.go
Click to show internal directories.
Click to hide internal directories.