tile

package
v0.0.0-...-70723b6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 3 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// InstanceCount is a number of tiles. Results to 136.
	InstanceCount = TileCount * 4
	// InstanceBegin is a first valid tile.
	InstanceBegin Instance = 1
	// InstanceEnd is a tile after the last valid tile.
	// Use for iteration `for i:= InstanceBegin; i < InstanceEnd; i++`
	// or for validating valid ranges.
	InstanceEnd Instance = InstanceBegin + Instance(InstanceCount)
	// InstanceNull is a special value for indicating empty (no instance).
	InstanceNull Instance = 0
	NullCopy     CopyID   = -1
	AnyCopy      CopyID   = 0
)
View Source
const (
	TileCount     = int(TileEnd - TileBegin)
	SequenceBegin = TileBegin
	SequenceEnd   = East
	TileBegin     = Man1
)

Variables

This section is empty.

Functions

func TenhoTypeToString

func TenhoTypeToString(t Type) (ret string)

func TilesToTenhouString

func TilesToTenhouString(tiles Tiles) string

func TypeRune

func TypeRune(t Type) rune

TypeRune used for stringifying tiles

Types

type CopyID

type CopyID int

CopyID is a number of tile inside a group. Values are [0-3]. For example there are 4 tiles of 1 Man.

type Instance

type Instance int

Instance is a representation of one of 136 tiles in mahjong, including their copies. Instance values starts from value of `1` and ends with value of `136`. Value `0` (InstanceNull) used for `undefined` (not set). Four sequenced numbers indicates same tile. Ex. 1,2,3,4 is for 1 Man, 5,6,7,8 is for 2 Man, etc. Tiles order is the following: - `123456789` `Man` (numbers 1-36) - `123456789` `Pin` (numbers 37-72) - `123456789` `Sou` (numbers 73-108) - `East`, `South`, `West`, `East` (numbers 109-124) - `White`, `Green`, `Red` (numbers 125-136). Take note, that for the last group values starts from `White` (not `Red`, as stated in some manuals) See also Tile.

func (Instance) CopyID

func (i Instance) CopyID() CopyID

func (Instance) Tile

func (i Instance) Tile() Tile

type Instances

type Instances []Instance

func (Instances) Clone

func (i Instances) Clone() Instances

Clone clones the instances avoiding grow.

func (Instances) Len

func (i Instances) Len() int

func (Instances) Less

func (i Instances) Less(lhs, rhs int) bool

func (Instances) String

func (i Instances) String() string

String is for debugging purposes and for using in tests.

func (Instances) Swap

func (i Instances) Swap(lhs, rhs int)

func (Instances) Tiles

func (i Instances) Tiles() Tiles

type Tile

type Tile int

Tile is a representation of an uniqe tile. THere are 34 unique tiles. Tile values starts from value of `1` and ends with value of `34`. Value `0` (TileNull) used for `undefined` (not set). Tiles order is the following: - `123456789` `Man` (numbers 1-9) - `123456789` `Pin` (numbers 10-18) - `123456789` `Sou` (numbers 19-27) - `East`, `South`, `West`, `East` (numbers 28-31) - `White`, `Green`, `Red` (numbers 32-34) Take note, that for the last group values starts from `White` (not `Red`, as stated in some manuals) See also Instance.

const (
	TileNull Tile = iota
	Man1
	Man2
	Man3
	Man4
	Man5
	Man6
	Man7
	Man8
	Man9

	Pin1
	Pin2
	Pin3
	Pin4
	Pin5
	Pin6
	Pin7
	Pin8
	Pin9

	Sou1
	Sou2
	Sou3
	Sou4
	Sou5
	Sou6
	Sou7
	Sou8
	Sou9

	East
	South
	West
	North

	White
	Green
	Red

	TileEnd
)

Tile numberation starts from 1

func (Tile) Indicates

func (t Tile) Indicates() Tile

Indicates used for dora indicators to choose dora tile

func (Tile) Instance

func (t Tile) Instance(c CopyID) Instance

func (Tile) Number

func (t Tile) Number() int

func (Tile) String

func (t Tile) String() string

func (Tile) Type

func (t Tile) Type() Type

type Tiles

type Tiles []Tile

func NewTilesFromString

func NewTilesFromString(str string) (Tiles, error)

func (Tiles) Clone

func (t Tiles) Clone() Tiles

func (Tiles) Contains

func (t Tiles) Contains(x Tile) bool

func (Tiles) Len

func (t Tiles) Len() int

func (Tiles) Less

func (t Tiles) Less(i, j int) bool

func (Tiles) String

func (t Tiles) String() string

func (Tiles) Swap

func (t Tiles) Swap(i, j int)

type Type

type Type int
const (
	TypeMan    Type = Type(Man1)
	TypePin    Type = Type(Pin1)
	TypeSou    Type = Type(Sou1)
	TypeWind   Type = Type(East)
	TypeDragon Type = Type(White)
	TypeNull   Type = Type(TileNull)
)

func (Type) Tile

func (t Type) Tile(num int) Tile

Jump to

Keyboard shortcuts

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