|
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
- local RoomCmd = MJFramework.MJImport("mj.luaScript.Protocol.MJCmd")
- local MJMessage = MJFramework.MJImport("mj.luaScript.Protocol.MJMessage")
-
- local Room = class("luzhouguiRoom_Coin" , require("mj_luzhougui.luaScript.Protocol.luzhouguiProtocol"))
-
- function Room:ctor(net)
- Room.super.ctor(self, net)
-
- -- 开局后后台推送的信息
- self:defPushMsg{cmd = 0x8301, reader = MJMessage.GameInfoChange, func = handler(self , self.onGameInfoChange)};
- end
-
- function Room:initRoomInfo()
- Room.super.initRoomInfo(self)
-
- --记录当前游戏serverLevel
- self.roomInfo.serverLevel = tonumber(app.user.serverLevel)
- end
-
- -- 开局后后台推送的信息
- function Room:onGameInfoChange(status, response)
- logD("Room:onGameInfoChange(), ", table.tostring(response))
-
- self:dispatchEvent({name = "onGameInfoChange", response = response});
- end
-
- -- 服务器下发玩家的准备状态
- function Room:onUserReadyResponse(status, response)
- Room.super.onUserReadyResponse(self, status, response)
-
- --游戏结束置为假
- if response.nUserId == self:getMyUserId() then
- self.roomInfo.isGameOver = false
- end
- end
-
- -- 自己退出房间
- function Room:onUserExitResponse(status, response)
- if self.roomInfo and self.roomInfo.isGameOver == true then
- return
- end
- if self.roomInfo and self.roomInfo.changeTable == true then
- self.roomInfo.changeTable = nil
- return
- end
-
- Room.super.onUserExitResponse(self, status, response)
- end
-
- -- 其他玩家退出房间
- function Room:onOtherLogoutResponse(status, response)
- if self.roomInfo and self.roomInfo.isGameOver == true then
- return
- end
-
- Room.super.onOtherLogoutResponse(self, status, response)
- end
-
- function Room:addExtendData(response)
- Room.super.addExtendData(self, response)
-
- self.roomInfo.extJson = response.extJson
- self.roomInfo.extJsonData = json.decode(response.extJson)
- for k,v in pairs(app.room.roomInfo.memberList) do
- local extJsonData = app.room.roomInfo.extJsonData["" .. k]
- if extJsonData then
- if tonumber(k) == self:getMyUserId() then
- self.roomInfo.hosting = extJsonData.hosted
- end
- v.hosted = extJsonData.hosted
- end
- end
- end
-
- function Room:onGameXiaoJuResponse(status, response)
- --刷新金币
- for k,v in pairs(response.allPlayerInfo) do --response.allPlayerInfo.Datas
- if v.nUserId == self:getMyUserId() then
- app.user.loginInfo.curJingbiNum = tonumber(v.nTotalMoney)
- break
- end
- end
-
- Room.super.onGameXiaoJuResponse(self, status, response)
-
- --局数置为0
- self.roomInfo.nGameStartCount = 0
-
- --游戏结束置为真
- self.roomInfo.isGameOver = true
- end
-
- function Room:getCoinByUserId(nUserId)
- --金币
- if self.roomInfo then
- local memberInfo = self.roomInfo.memberList[tonumber(nUserId)]
- if memberInfo then
- return memberInfo.nTotalMoney
- end
- end
- return 0
- end
-
- --更新gps用户数据
- function Room:updateGpsUserInfo(userId,isOpenView)
- --金币场不显示gps
- end
-
- return Room
|