package proto import ( db2 "bet24.com/servers/micros/privateroom/config" ) const ( RoomType_Normal = "PrivateRoom" RoomType_SimpleMatch = "Match" ) const ( PrivateRoomStatus_Invalid = iota PrivateRoomStatus_Free PrivateRoomStatus_Playing PrivateRoomStatus_Ended ) type GameRoom struct { Status int `xorm:"INT(11)" ` //1代表空闲 2代表使用中 Id int `xorm:"not null pk autoincr INT(11)" json:"id"` PlayerNum int `xorm:"INT(11)" ` //加入游戏房间人数 GameEnd int `xorm:"INT(11)" ` //0未开始,1进行中,2已结束 Mode int `xorm:"INT(11)" ` //游戏模式,1是经典,2是匹配 Logo string `xorm:"VARCHAR(255)"` //游戏logo Type int `xorm:"INT(11)" ` //1是lodo,2 baloot TableId int `xorm:"INT(11)" ` //1是lodo,2 baloot } const ( Method_Create = "privateroom.create" Method_Dismiss = "privateroom.onRoomDismiss" Method_StatucChanged = "privateroom.onRoomStatusChanged" Method_ForceEnter = "privateroom.forceEnter" ) type Request_Create struct { MethodName string Creator int // 创建者 GameRule string // 游戏规则 Target int // 局数或分数 UserCount int // 对局人数 //Fee int // 门票费用 PlayTimeout int } type Request_OnRoomDismiss struct { MethodName string RoomNo int } type Request_OnRoomStatusChanged struct { MethodName string RoomNo int OldStatus int NewStatus int } type Request_ForceEnter struct { MethodName string RoomNo int UserId int ChairId int } type RoomUser struct { UserId int NickName string ChairId int Score int // 可能还有其他信息 FaceId int FaceUrl string BaseScore int SetCount int YyfUid int } type RoomUserBrief struct { UserId int NickName string ChairId int Score int BaseScore int SetCount int `json:",omitempty"` } func (ru *RoomUser) ToBrief() *RoomUserBrief { return &RoomUserBrief{ UserId: ru.UserId, NickName: ru.NickName, ChairId: ru.ChairId, Score: ru.Score, BaseScore: ru.BaseScore, SetCount: ru.SetCount, } } type RoomInfo struct { RoomNo int GameId int ServerAddr string TableId int GameName string RuleName string UserCount int // 限制人数 Fee int Status int Target int Prize int // 奖金 IsPublic bool UserList []*RoomUser PlayTime int ExtraInfo string } type RoomInfoBrief struct { RoomNo int GameId int ServerAddr string TableId int RuleName string UserCount int // 限制人数 Fee int `json:",omitempty"` Target int Prize int // 奖金 IsPublic bool UserList []*RoomUserBrief } func (ru *RoomInfo) ToBrief() *RoomInfoBrief { ret := &RoomInfoBrief{ RoomNo: ru.RoomNo, GameId: ru.GameId, ServerAddr: ru.ServerAddr, TableId: ru.TableId, RuleName: ru.RuleName, UserCount: ru.UserCount, Target: ru.Target, Prize: ru.Prize, IsPublic: ru.IsPublic, Fee: ru.Fee, } for i := 0; i < len(ru.UserList); i++ { ret.UserList = append(ret.UserList, ru.UserList[i].ToBrief()) } return ret } func GetIdleRoom2(mode int,tableId int) *GameRoom { //lock5.Lock() //var idle = 0 var gameRoom GameRoom = GameRoom{Status: 1} //var gameRoom has, _ := db2.Engine.Get(&gameRoom) //if mode ==1{ if has { gameRoom.Status = 2 //gameRoom = gameRooms[i] //gameRoom.MinNum = 2 //gameRoom.AdmissionFee = adminfee //gameRoom.MaxNum = maxnum gameRoom.Mode = mode gameRoom.Type = 2 gameRoom.TableId=tableId //gameRooms[i].RoomType = true //gameRoom.DataList = DataList //初始化构建玩家 //var rankPlayer = map[int]*GamePlayer{} // var gzPlayer = []*GamePlayer{} // var player = map[int]*GamePlayer{} // var roomPlayer = map[string]*GamePlayer{} // gameRoom.RoomPlayers = roomPlayer // gameRoom.RankPlayers = rankPlayer // gameRoom.GzPlayers = gzPlayer // gameRoom.Players = player //gameRoom.PlayerNum = 0 //gameRoom.RunnerNum = 0 //gameRoom.ArrivalNum = 0 //gameRoom.GameEnd = GameNotStarted db2.Engine.ID(gameRoom.Id).Update(gameRoom) } else { // RoomInit(len(gameRooms), len(gameRooms)+100) // lock5.Unlock() //fmt.Printf("私人房建房") gameRoom.TableId=tableId gameRoom.Status = 2 gameRoom.Type = 2 //gameRoom = gameRooms[i] // gameRoom.MinNum = 2 // gameRoom.AdmissionFee = adminfee // gameRoom.MaxNum = maxnum gameRoom.Mode = mode //gameRooms[i].RoomType = true //gameRoom.DataList = DataList //初始化构建玩家 //var rankPlayer = map[int]*GamePlayer{} // var gzPlayer = []*GamePlayer{} // var player = map[int]*GamePlayer{} // var roomPlayer = map[string]*GamePlayer{} //gameRoom.RoomPlayers = roomPlayer // gameRoom.RankPlayers = rankPlayer //gameRoom.GzPlayers = gzPlayer //gameRoom.Players = player gameRoom.PlayerNum = 0 // gameRoom.RunnerNum = 0 // gameRoom.ArrivalNum = 0 // gameRoom.GameEnd = GameNotStarted db2.Engine.Insert(&gameRoom) } //} // lock5.Unlock() return &gameRoom /*if idle == 0 { } */ }