room

package
v0.0.0-...-f84f93e Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(key string, rdata interfacer.IDesk)

添加一个私人局房间

func Close

func Close()

关闭列表

func Del

func Del(key string)

删除一个牌桌

func Exist

func Exist(key string) bool

是否存在

func GenInvitecode

func GenInvitecode(count int) (s string)

生成一个牌桌邀请码,全列表中唯一

func Get

func Get(key string) interfacer.IDesk

获取牌桌接口

func Len

func Len() int

func NewDesk

func NewDesk(data *DeskData) interfacer.IDesk

新建一张牌桌

Types

type Desk

type Desk struct {
	sync.RWMutex //房间锁
	// contains filtered or unexported fields
}

房间牌桌数据结构

func (*Desk) Broadcasts

func (t *Desk) Broadcasts(msg interfacer.IProto)

房间消息广播,聊天

func (*Desk) Closed

func (t *Desk) Closed(ok bool)

关闭房间,停服or过期清除等等.TODO:玩牌中是否关闭?

func (*Desk) Diceing

func (t *Desk) Diceing() bool

玩家打骰子切牌,发牌

func (*Desk) Discard

func (t *Desk) Discard(seat uint32, card byte, ok bool) int32

出牌,加锁,托管自摸自动胡牌

func (*Desk) DiscardHu

func (t *Desk) DiscardHu(card byte, cs []byte, ch, ps, ks []uint32, wildcard byte, seat uint32) int64

打牌检测,胡牌, 接炮胡检测

func (*Desk) DrawDetect

func (t *Desk) DrawDetect(card byte, cs []byte, ch, ps, ks []uint32, wildcard byte, seat uint32) int64

摸牌检测,胡牌/暗杠/补杠

func (*Desk) Enter

func (t *Desk) Enter(p interfacer.IPlayer) int32

进入

func (*Desk) MaiZi

func (t *Desk) MaiZi(seat, count uint32) int32

func (*Desk) Offline

func (t *Desk) Offline(seat uint32, status bool)

func (*Desk) Operate

func (t *Desk) Operate(card uint32, value int64, seat uint32) int32

玩家进行吃/碰/杠/胡操作

func (*Desk) Readying

func (t *Desk) Readying(seat uint32, ready bool) int32

玩家准备

func (*Desk) SetCheat

func (t *Desk) SetCheat(handcards [][]byte, leftcards []byte, wildcard byte)

func (*Desk) ToString

func (t *Desk) ToString() string

func (*Desk) Vote

func (t *Desk) Vote(ok bool, seat, vote uint32) int32

投票解散,ok=true发起,=false投票

type DeskData

type DeskData struct {
	Rid    uint32           //房间ID
	Cid    string           //房间创建人
	Expire uint32           //牌局设定的过期时间
	Code   string           //房间邀请码
	Round  uint32           // 总牌局数
	Ante   uint32           //私人房底分
	Cost   uint32           //创建消耗
	CTime  uint32           //创建时间
	Score  map[string]int32 //私人局用户战绩积分
	MaiZi  bool             // 是否买子
}

func NewDeskData

func NewDeskData(rid, round, expire, ante, cost uint32, creator, invitecode string, maizi bool) *DeskData

func (*DeskData) Convert

func (this *DeskData) Convert() *data.CreateRoomRecord

type Player

type Player struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

用户的全部数据,服务器存取专用

func NewPlayer

func NewPlayer(data *data.User) *Player

func (*Player) ClearRoom

func (this *Player) ClearRoom()

---------------------------房间属性---------------------------------

func (*Player) ConverDataUser

func (this *Player) ConverDataUser() *protocol.UserData

func (*Player) ConverProtoUser

func (this *Player) ConverProtoUser() *protocol.ProtoUser

func (*Player) GetConn

func (this *Player) GetConn() interfacer.IConn

func (*Player) GetInviteCode

func (this *Player) GetInviteCode() string

func (*Player) GetPlatform

func (this *Player) GetPlatform() uint32

func (*Player) GetRoomCard

func (this *Player) GetRoomCard() uint32

func (*Player) GetRoomID

func (this *Player) GetRoomID() uint32

func (*Player) GetRoomType

func (this *Player) GetRoomType() uint32

func (*Player) GetSeat

func (this *Player) GetSeat() uint32

func (*Player) GetUserid

func (this *Player) GetUserid() string

func (*Player) Send

func (this *Player) Send(value interfacer.IProto)

func (*Player) SetAuth

func (this *Player) SetAuth(auth string)

func (*Player) SetConn

func (this *Player) SetConn(value interfacer.IConn)

func (*Player) SetEmail

func (this *Player) SetEmail(email string)

func (*Player) SetIP

func (this *Player) SetIP(ip uint32)

func (*Player) SetLongitudeLatitude

func (this *Player) SetLongitudeLatitude(longitude, latitude string)

func (*Player) SetPwd

func (this *Player) SetPwd(pwd string)

func (*Player) SetRoom

func (this *Player) SetRoom(rid uint32, seat uint32, invitecode string)

分别为:房间类型ID,房间号,房间邀请码

func (*Player) SetRoomCard

func (this *Player) SetRoomCard(value uint32)

func (*Player) SetStatus

func (this *Player) SetStatus(status uint32)

func (*Player) SetUserid

func (this *Player) SetUserid(id string)

type RoomInfoResp

type RoomInfoResp struct {
	RoomId    string              `json:"roomid"`    // 房间号(邀请码)
	Ids       map[uint32]string   `json:"ids"`       // 玩家的id
	Roomcards map[uint32]uint32   `json:"roomcards"` // 玩家的房卡
	OutCards  map[uint32][]uint32 `json:"outCards"`  //海底牌
	PongCards map[uint32][]uint32 `json:"pongCards"` //碰牌
	KongCards map[uint32][]uint32 `json:"kongCards"` //杠牌
	ChowCards map[uint32][]uint32 `json:"chowCards"` //吃牌(8bit-8-8)
	HandCards map[uint32][]uint32 `json:"handCards"` //手牌
	Maizi     map[uint32]uint32   `json:"maizi"`     //买子
	Offline   map[uint32]bool     `json:"offline"`   // true:离线,false:上线

	Data      *DeskData        `json:"data"`      //房间类型基础数据
	Dealer    uint32           `json:"dealer"`    //庄家的座位
	Dice      uint32           `json:"dice"`      //骰子
	Cards     []uint32         `json:"cards"`     //没摸起的海底牌
	LianCount uint32           `json:"lianCount"` // 连庄数
	Round     uint32           `json:"round"`     // 打牌局数
	Opt       map[uint32]int64 `json:"opt"`       // 玩家吃碰杠胡掩码
	LuckyCard uint32           `json:"luckyCard"` //本局的财神牌值
	Discard   uint32           `json:"discard"`   //出牌
	Draw      uint32           `json:"draw"`      //摸牌
	Seat      uint32           `json:"seat"`      //当前摸牌|出牌位置
	Operate   int              `json:"operate"`   //操作状态
}

type SocialRooms

type SocialRooms struct {
	sync.RWMutex //读写锁
	// contains filtered or unexported fields
}

牌桌列表结构

Jump to

Keyboard shortcuts

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