gamer

package
v0.0.0-...-9be9f3c Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRoomTableExceed = errors.New("tables of room exceed the limit")
	ErrorNotOnTable      = errors.New("not on table")
)

Functions

func NewRobotAirfone

func NewRobotAirfone(t *Table, logger log.Logger) *roboAirfone

Types

type Airfone

type Airfone interface {
	//请求返回
	ReplySendChat() (err error)
	//通知
	PlayerSendChat(sid Seat, mid int32, msg string) (err error)
}

type Card

type Card byte

type CardColor

type CardColor byte
const (
	Heart   CardColor = iota + 1 //红桃
	Spade                        //黑桃
	Club                         //梅花
	Diamond                      //方块
)

type CardDealer

type CardDealer struct {
	// contains filtered or unexported fields
}

func NewCardDealer

func NewCardDealer() *CardDealer

func (*CardDealer) NextSuit

func (de *CardDealer) NextSuit() (cards Cards)

NextSuit 获取下一组牌

func (*CardDealer) Shuffle

func (de *CardDealer) Shuffle()

Shuffle 洗牌

type CardValue

type CardValue byte

type Cards

type Cards []Card

func (Cards) BiggerThan

func (cds Cards) BiggerThan(cards Cards) bool

func (Cards) Equal

func (cds Cards) Equal(cards Cards) bool

func (Cards) GetType

func (cds Cards) GetType() CardsType

func (Cards) Len

func (cds Cards) Len() int

Len

func (Cards) Less

func (cds Cards) Less(i, j int) bool

Less

func (Cards) Swap

func (cds Cards) Swap(i, j int)

Swap

func (Cards) ToBytes

func (cds Cards) ToBytes() (cards []byte)

type CardsType

type CardsType byte
const (
	HighCard      CardsType = iota + 1 //高牌
	Pair                               //对子
	Flush                              //同花
	Straight                           //顺子
	StraightFlush                      //同花顺
	ThreeOfAKind                       //豹子
)

type Logger

type Logger interface {
	Log(keyvals ...interface{}) error
}

type Player

type Player struct {
	UserID  UserID //玩家个人唯一ID
	Cards   Cards  //玩家牌
	Seat    Seat   //玩家牌桌内的座位号
	IsRobot bool

	//状态
	Status int //玩家状态

	//玩家个人数据
	Info *PlayerInfo
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(id UserID, airfone Airfone, info *PlayerInfo, isRobot bool) (player *Player)

type PlayerInfo

type PlayerInfo struct {
	Token     string
	SeatCode  SeatCode //玩家世界坐标
	Coin      int64
	Gem       int32
	Nick      string
	Avatar    string
	Friends   []UserID
	Character int32
}

type Room

type Room struct {
	RoomOptions
	Tables map[TableId]*Table
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(op RoomOptions, logger Logger, userCenter UserCenter) (r *Room)

NewRoom 创建新房间

func (*Room) CountTable

func (r *Room) CountTable() int

CountTable 计算开桌局数

type RoomClass

type RoomClass int
const (
	FirstClassRoom RoomClass = iota + 1
	SecondClassRoom
	ThirdClassRoom
)

type RoomOptions

type RoomOptions struct {
	//牌桌配置
	RoomClass RoomClass
	BootBet   int64 //底注
}

type Seat

type Seat int //Seat 玩家在牌桌上的座位号
const (
	SeatVoid Seat = iota //空座号,进入牌座并站立的玩家都分配这个座位号
	Seat1
	Seat2
	Seat3
	Seat4
	Seat5
)

func (Seat) Next

func (s Seat) Next() (seat Seat)

type SeatCode

type SeatCode int //SeatCode 由游戏代码、房间代码、牌桌代码和座位号构成

type Table

type Table struct {

	//牌桌配置
	TableOptions

	//玩家管理
	Seats   map[Seat]UserID
	Players map[UserID]*Player
	//牌局状态
	Status int

	//外部依赖
	UCenter UserCenter
	// contains filtered or unexported fields
}

func NewTable

func NewTable(option TableOptions, logger Logger, userCenter UserCenter) (t *Table)

NewTable 新建牌桌

func (*Table) SendChat

func (t *Table) SendChat(id UserID, mid int32, msg string) (err error)

AddFriend 邀请加好友

type TableId

type TableId int //TableId 桌号

type TableOptions

type TableOptions struct {
	TableId   TableId   //桌号
	RoomClass RoomClass //所属房间等级
	BootBet   int64     //底注金币数
}

type UserCenter

type UserCenter interface {
	GetInfo(id UserID) (info *PlayerInfo, err error)
}

type UserID

type UserID int64

Jump to

Keyboard shortcuts

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