mahjong

package
v0.0.0-...-c5f9841 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 7 Imported by: 0

README

   条        筒
----------------------
0 1条    |   36 1筒   |
1 1条    |   37 1筒   |
2 1条    |   38 1筒   |
3 1条    |   39 1筒   |
4 2条    |   40 2筒   |
5 2条    |   41 2筒   |
6 2条    |   42 2筒   |
7 2条    |   43 2筒   |
8 3条    |   44 3筒   |
9 3条    |   45 3筒   |
10 3条   |   46 3筒   |
11 3条   |   47 3筒   |
12 4条   |   48 4筒   |   
13 4条   |   49 4筒   |   
14 4条   |   50 4筒   |   
15 4条   |   51 4筒   |   
16 5条   |   52 5筒   |   
17 5条   |   53 5筒   |   
18 5条   |   54 5筒   |   
19 5条   |   55 5筒   |   
20 6条   |   56 6筒   |   
21 6条   |   57 6筒   |   
22 6条   |   58 6筒   |   
23 6条   |   59 6筒   |   
24 7条   |   60 7筒   |   
25 7条   |   61 7筒   |   
26 7条   |   62 7筒   |   
27 7条   |   63 7筒   |   
28 8条   |   64 8筒   |   
29 8条   |   65 8筒   |   
30 8条   |   66 8筒   |   
31 8条   |   67 8筒   |   
32 9条   |   68 9筒   |   
33 9条   |   69 9筒   |   
34 9条   |   70 9筒   |   
35 9条   |   71 9筒   |   

Documentation

Index

Constants

View Source
const (
	MaxFan = -1 // 极品
	MeiHu  = -2 // 没胡牌
)
View Source
const (
	IllegalIndex = -1
)
View Source
const MaxTileIndex = 29

每种花色(条,筒)最多9种牌型,但牌是没有0点的共计 9+9 1-9: 条 11-19: 筒 21-29: 万

Variables

This section is empty.

Functions

func IndexFromID

func IndexFromID(id int) int

func RemoveId

func RemoveId(m *Mahjong, tid int)

Types

type Context

type Context struct {
	WinningID         int      //自己要和的牌
	PrevOp            int      //上一个操作
	NewDrawingID      int      //最新上手的牌
	NewOtherDiscardID int      //上家打出的最新一张牌
	LastDiscardId     int      // 最新打过的牌
	Desc              []string // 描述

	IsLastTile bool //自己上手的最新一张牌,是否是桌面上的最后一张

	LastHint *protocol.Hint //最后一次提示

	ResultType int

	Opts   *protocol.DeskOptions
	DeskNo string
	Uid    int64

	Fan int // 番数, -1表示极品
	Que int // 定缺,0表示未定缺,1表示缺条/2缺筒/3缺万

	IsGangShangHua bool // 是不是杠上花
	IsGangShangPao bool // 是不是杠上炮
	IsQiangGangHu  bool // 是不是抢杠胡
}

func (*Context) Reset

func (c *Context) Reset()

func (*Context) SetPrevOp

func (c *Context) SetPrevOp(op int)

func (*Context) String

func (c *Context) String() string

type Indexes

type Indexes []int //麻将的index

type Mahjong

type Mahjong []*Tile

func FromID

func FromID(ids []int) Mahjong

根据id索引创建

func (Mahjong) Ids

func (m Mahjong) Ids() []int

func (Mahjong) Indexes

func (m Mahjong) Indexes() []int

func (Mahjong) Len

func (m Mahjong) Len() int

func (Mahjong) Less

func (m Mahjong) Less(i, j int) bool

func (Mahjong) Shuffle

func (m Mahjong) Shuffle()

func (Mahjong) Sort

func (m Mahjong) Sort()

func (Mahjong) String

func (m Mahjong) String() string

func (Mahjong) Swap

func (m Mahjong) Swap(i, j int)

type ReadyTile

type ReadyTile struct {
	Index  int //和牌的index
	Points int //番数
}

func (*ReadyTile) Equals

func (rt *ReadyTile) Equals(t *ReadyTile) bool

func (*ReadyTile) String

func (rt *ReadyTile) String() string

type Result

type Result []int

func (Result) String

func (res Result) String() string

type ScoreChangeType

type ScoreChangeType byte

type Stats

type Stats [MaxTileIndex + 1]byte

func (*Stats) CountWithIndex

func (ms *Stats) CountWithIndex(idx int) int

func (*Stats) From

func (ms *Stats) From(mjs ...Mahjong)

func (*Stats) FromIndex

func (ms *Stats) FromIndex(tiles ...Indexes)

func (*Stats) String

func (ms *Stats) String() string

type Tile

type Tile struct {
	Id    int
	Suit  int //花色
	Rank  int //点数
	Index int //索引(1~9, 11~19)
}

func TileFromID

func TileFromID(id int) *Tile

id: 0~3 -> 1条 4~7 -> 2条 ... 0~35 =>条 36~71 =>筒

func TileFromIndex

func TileFromIndex(idx int) *Tile

21, 23, 25: 中、发、白 ps:此处返回的tile的id不正确

func (*Tile) Equals

func (t *Tile) Equals(other *Tile) bool

func (*Tile) String

func (t *Tile) String() string

type Tiles

type Tiles []int //麻将内部表示(即72张牌的id号列表)

func New

func New(count int) Tiles

func (Tiles) Shuffle

func (m Tiles) Shuffle()

Directories

Path Synopsis
https://www.xqbase.com/other/mahjongg_english.htm
https://www.xqbase.com/other/mahjongg_english.htm

Jump to

Keyboard shortcuts

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