tbase

package
v0.0.0-...-bd21981 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaskDanAll     LobbyRules = FlagDan1 | FlagDan2
	MaskDanKu      LobbyRules = 0
	MaskDan1                  = FlagDan1
	MaskDan2                  = FlagDan2
	MaskDanPhoenix            = MaskDan1 | MaskDan2

	RulesDzjanso LobbyRules = 0x0841
)

Variables

View Source
var DrawMap = map[string]DrawType{
	"":       DrawEnd,
	"yao9":   Draw9,
	"reach4": DrawReach4,
	"ron3":   DrawRon3,
	"kan4":   DrawKan4,
	"kaze4":  DrawWind4,
	"nm":     DrawNagashi,
}
View Source
var ReverseDrawMap = func() map[DrawType]string {
	ret := make(map[DrawType]string, len(DrawMap))
	for k, v := range DrawMap {
		ret[v] = k
	}
	return ret
}()
View Source
var ReverseYakuMap = func() map[yaku.Yaku]Yaku {
	ret := make(map[yaku.Yaku]Yaku, len(YakuMap))
	for k, v := range YakuMap {
		ret[v] = k
	}
	return ret
}()
View Source
var ReverseYakumanMap = func() map[yaku.Yakuman]Yakuman {
	ret := make(map[yaku.Yakuman]Yakuman, len(YakumanMap))
	for k, v := range YakumanMap {
		ret[v] = k
	}
	return ret
}()

Functions

func IntList

func IntList(val string) []int

func MoneyToInt

func MoneyToInt(in score.Money) int

func StringList

func StringList(val string) []string

Types

type Agari

type Agari struct {
	Who            Opponent
	From           Opponent
	Pao            *Opponent
	Status         TableStatus
	Score          Score
	FinalScores    FinalScoreChanges
	Changes        ScoreChanges
	Hand           tile.Instances
	DoraIndicators tile.Instances
	UraIndicators  tile.Instances
	WinTile        tile.Instance
	Yakus          Yakus
	Yakumans       Yakumans
	Melds          Melds
	// TODO: research
	Ratio string
	Chips []int
}

type CallType

type CallType int
const (
	Chi CallType = iota + 1
	Pon
	Kan
	ClosedKan
	UpgrdedKan
)

type Called

type Called struct {
	Type     CallType
	Opponent Opponent
	Tiles    tile.Instances
	Called   tile.Instance
	Upgraded tile.Instance
	// Core representation of meld for tempai calculator
	Core calc.Meld
}

func DecodeCalled

func DecodeCalled(in Meld) *Called

func (*Called) Add

func (c *Called) Add(x compact.Instances)

func (*Called) Encode

func (c *Called) Encode() Meld

func (*Called) IsKan

func (c *Called) IsKan() bool

type CalledList

type CalledList []*Called

func (CalledList) Add

func (cl CalledList) Add(x compact.Instances)

func (CalledList) Core

func (cl CalledList) Core() calc.Melds

type DrawType

type DrawType int
const (
	DrawUnknown DrawType = iota
	DrawEnd
	Draw9
	DrawReach4
	DrawRon3
	DrawKan4
	DrawWind4
	DrawNagashi
)

type FinalScoreChange

type FinalScoreChange struct {
	Score int
	Diff  Float
}

func (*FinalScoreChange) DiffMoney

func (sc *FinalScoreChange) DiffMoney() score.Money

func (*FinalScoreChange) ScoreMoney

func (sc *FinalScoreChange) ScoreMoney() score.Money

type FinalScoreChanges

type FinalScoreChanges []FinalScoreChange

type Float

type Float struct {
	Value float64
	IsInt bool
}

type Hands

type Hands []tile.Instances

type Init

type Init struct {
	Seed
	Scores Scores
	Dealer Opponent
	Chip   []int
}

type LobbyRules

type LobbyRules int
const (
	FlagOnline LobbyRules = 1 << iota
	FlagNoAkkas
	FlagNoKuitan
	FlagHanchan
	Flag3Man
	FlagDan1
	FlagFast
	FlagDan2
	FlagEnd
)

func (LobbyRules) Check

func (r LobbyRules) Check(f LobbyRules) bool

func (LobbyRules) DebugString

func (r LobbyRules) DebugString() string

func (LobbyRules) Extract

func (r LobbyRules) Extract(mask LobbyRules) LobbyRules

func (LobbyRules) String

func (r LobbyRules) String() string

type Meld

type Meld int

func EncodeCalled

func EncodeCalled(in *Called) Meld

func (Meld) Decode

func (m Meld) Decode() *Called

func (Meld) Extract

func (m Meld) Extract(first, last int) int

func (Meld) Instance

func (m Meld) Instance(f, l int) tile.Instance

func (Meld) Type

func (m Meld) Type() MeldType

func (Meld) Who

func (m Meld) Who() Opponent

type MeldChi

type MeldChi Meld

type MeldKan

type MeldKan Meld

type MeldPon

type MeldPon Meld

type MeldType

type MeldType int
const (
	MeldTypeBad MeldType = iota
	MeldTypeChi
	MeldTypePon
	MeldTypeKan
)

type Melds

type Melds []Meld

func EncodeCalledList

func EncodeCalledList(in CalledList) Melds

func (Melds) Decode

func (m Melds) Decode() CalledList

type Opponent

type Opponent int
const (
	Self Opponent = iota
	Right
	Front
	Left
)

func (Opponent) String

func (o Opponent) String() string

type Ryuukyoku

type Ryuukyoku struct {
	DrawType     DrawType
	TableStatus  TableStatus
	ScoreChanges ScoreChanges
	Finals       FinalScoreChanges
	Hands        Hands
	Ratio        []int
}

type Score

type Score struct {
	Fu     yaku.FuPoints
	Total  score.Money
	Riichi score.RiichiSticks
}

type ScoreChange

type ScoreChange struct {
	Score int
	Diff  int
}

func (*ScoreChange) DiffMoney

func (sc *ScoreChange) DiffMoney() score.Money

func (*ScoreChange) ScoreMoney

func (sc *ScoreChange) ScoreMoney() score.Money

type ScoreChanges

type ScoreChanges []ScoreChange

func (ScoreChanges) ToFinal

func (sc ScoreChanges) ToFinal(isInt bool) FinalScoreChanges

type Scores

type Scores []score.Money

type Seed

type Seed struct {
	RoundNumber int
	Honba       score.Honba
	Sticks      score.RiichiSticks
	Dice        [2]int
	Indicator   tile.Instance
}

type Sex

type Sex int
const (
	SexUnknown Sex = iota
	SexMale
	SexFemale
	SexComputer
)

func ParseSexLetter

func ParseSexLetter(in string) Sex

func (Sex) Letter

func (sx Sex) Letter() string

type TableStatus

type TableStatus struct {
	Honba  score.Honba
	Sticks score.RiichiSticks
}

type UserList

type UserList struct {
	Names []string
	Dan   []int
	Rate  []Float
	Sex   []Sex
	RC    []int
	Gold  []int
	Count int
}

func (*UserList) GetDan

func (ul *UserList) GetDan() []int

func (*UserList) GetNames

func (ul *UserList) GetNames() []string

func (*UserList) GetRate

func (ul *UserList) GetRate() []Float

type Yaku

type Yaku int

type YakuRecord

type YakuRecord struct {
	Yaku  Yaku
	Value yaku.HanPoints
}

type Yakuman

type Yakuman int

type Yakumans

type Yakumans []Yakuman

func YakumansFromCore

func YakumansFromCore(in yaku.Yakumans) (ret Yakumans, err error)

func YakumansFromInts

func YakumansFromInts(in []int) Yakumans

func (Yakumans) Check

func (y Yakumans) Check(x Yakuman) bool

func (Yakumans) CheckCore

func (ys Yakumans) CheckCore(x yaku.Yakuman) bool

func (Yakumans) Ints

func (y Yakumans) Ints() []int

func (Yakumans) Len

func (a Yakumans) Len() int

func (Yakumans) Less

func (a Yakumans) Less(i, j int) bool

func (Yakumans) Swap

func (a Yakumans) Swap(i, j int)

func (Yakumans) ToCore

func (y Yakumans) ToCore() (ret yaku.Yakumans, err error)

type Yakus

type Yakus []YakuRecord

func YakusFromCore

func YakusFromCore(in yaku.YakuSet) (ret Yakus, err error)

func YakusFromInts

func YakusFromInts(in []int) Yakus

func (Yakus) Check

func (ys Yakus) Check(x Yaku) bool

func (Yakus) CheckCore

func (ys Yakus) CheckCore(x yaku.Yaku) bool

func (Yakus) Ints

func (ys Yakus) Ints() []int

func (Yakus) Len

func (a Yakus) Len() int

func (Yakus) Less

func (a Yakus) Less(i, j int) bool

func (Yakus) Swap

func (a Yakus) Swap(i, j int)

func (Yakus) ToCore

func (y Yakus) ToCore() (ret yaku.YakuSet, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL