|
-
- local RoomInfo = class("huamajiangRoomInfo");
-
- function RoomInfo.getInstance (isForceCreate)
- if isForceCreate then
- RoomInfo.__instance = nil;
- end
- if not RoomInfo.__instance then
- RoomInfo.__instance = RoomInfo:new();
- end
- return RoomInfo.__instance;
- end
-
- function RoomInfo:ctor( )
- self.memberList = {};
- end
-
- function RoomInfo:reset()
- self.memberList = {};
- self.nMaxPlayCount = nil;
- self.needOutCardId = nil;
- self.nLeaveCardNum = 72;
- self.tings = {};
- self.tingStatus = -1;
-
- self.gameId = 0;
- self.nShowTableId = 0;
- self.nRoomOwnedUid = 0;
- self.nTotalGameNum = 0;
- self.nGameStartCount = 0;
- self.nBankSeatId = -1;
- self.nMySeatId = -1;
- self.bUserDisbandGame = false;
- self.outCardUserId = 0;
- self.outCardSeatId = 0;
- self.lastOpCard = 0;
- self.stopFlag = nil;
- self.isGameOver = 0;
- self.nStatus = -1;
- self.nEndTime = nil;
- self.operates = {};
- self.playerInfos = {};
- self.resultInfos = {};
- self.quickStartInfo = {};
- self.lastOutViewId = nil;
- self.needJieSuanInfo = 0;
-
- self.luoboCards = {};
- self.scoreInfo = {};
- self.passGuo = false;
-
- --ljx 所有人的流水信息
- self.allPlayerScoreInfo = {};
- end
-
- -- 保存最大玩牌人数
- function RoomInfo:setMaxPlayerCount (maxPlayerCount)
- self.nMaxPlayCount = maxPlayerCount;
- end
-
- -- 获取最大玩牌人数
- function RoomInfo:getMaxPlayerCount ()
- return self.nMaxPlayCount;
- end
-
- -- 保存剩余牌
- -- @param leaveCards table
- function RoomInfo:setLeaveCards (leaveCards)
- self.leaveCards = leaveCards;
- end
-
- -- 获取剩余牌
- -- @return table
- function RoomInfo:getLeaveCards ()
- return self.leaveCards or {};
- end
-
- -- 保存剩余牌张数
- function RoomInfo:setLeaveCardNum( leaveCardNum )
- self.nLeaveCardNum = leaveCardNum;
- end
-
- -- 获取剩余牌张数
- function RoomInfo:getLeaveCardNum ()
- return self.nLeaveCardNum;
- end
-
- -- 保存是否需要出牌
- -- @param isNeedOutCard boolean
- function RoomInfo:setIsNeedOutCard (isNeedOutCard)
- self.isNeedOutCard = isNeedOutCard;
- end
-
- -- 获取是否需要出牌
- function RoomInfo:getIsNeedOutCard ()
- return self.isNeedOutCard;
- end
-
- -- 保存需要出牌的玩家id
- function RoomInfo:setNeedOutCardId( userId )
- self.needOutCardId = userId;
- end
-
- -- 获取需要出牌的玩家id
- function RoomInfo:getNeedOutCardId()
- return self.needOutCardId;
- end
-
- -- 保存出牌玩家id(重连使用)
- -- @param userId int
- function RoomInfo:setOutCardUserId (userId)
- self.outCardUserId = userId;
- end
-
- -- 获取出牌玩家id(重连使用)
- function RoomInfo:getOutCardUserId ()
- return self.outCardUserId or 0;
- end
-
- -- 保存出牌玩家座位(重连使用)
- -- @param seatId int 逻辑座位
- function RoomInfo:setOutCardSeatId (seatId)
- self.outCardSeatId = seatId;
- end
-
- -- 获取出牌玩家座位(重连使用)
- function RoomInfo:getOutCardSeatId ()
- return self.outCardSeatId or 0;
- end
-
- -- 保存最后操作的牌(重连使用)
- -- @param card int
- function RoomInfo:setLastOpCard (card)
- self.lastOpCard = card;
- end
-
- -- 获取最后操作的牌(重连使用)
- function RoomInfo:getLastOpCard ()
- return self.lastOpCard or 0;
- end
-
- -- 保存游戏状态(重连使用)
- function RoomInfo:setGameStatus (status)
- self.nStatus = status;
- end
-
- -- 获取游戏状态(重连使用)
- function RoomInfo:getGameStatus ()
- return self.nStatus;
- end
-
- -- 保存玩家信息(重连使用)
- function RoomInfo:setPlayerInfos (playerInfos)
- self.playerInfos = playerInfos;
- end
-
- -- 获取玩家信息(重连使用)
- function RoomInfo:getPlayerInfos ()
- return self.playerInfos or {};
- end
-
- -- 保存胡牌玩家列表(重连使用)(只发现在回放RoomView使用)
- -- @param resultInfos table
- function RoomInfo:setResultInfos (resultInfos)
- self.resultInfos = resultInfos;
- end
-
- -- 获取胡牌玩家列表(重连使用)
- function RoomInfo:getResultInfos ()
- return self.resultInfos or {};
- end
-
- -- 保存操作列表(重连使用)
- function RoomInfo:setOperates (operates)
- self.operates = operates;
- end
-
- -- 获取操作列表(重连使用)
- function RoomInfo:getOperates ()
- return self.operates;
- end
-
- -- 保存听牌信息
- -- @param tingCards { outCard: 0x01, tingCards: {0x01, 0x02}}
- function RoomInfo:setTingCards(tingCards)
- self.tings = tingCards;
- end
-
- -- 获取听牌信息
- function RoomInfo:getTingCards()
- return self.tings or {};
- end
- --- RoomInfo:getTingCardsByCard 通过指定牌,获取听牌信息
- -- @param card int
- function RoomInfo:getTingCardsByCard (card)
- local curTingCards = {};
- for k, v in pairs(self.tings) do
- if v.outCard == card then
- curTingCards = v.tingCards;
- break;
- end
- end
- return curTingCards;
- end
-
- -- 保存听牌状态
- -- @ param tingStatus -1为没听 0为听
- function RoomInfo:setTingStatus(tingStatus)
- self.tingStatus = tingStatus;
- end
-
- -- 获取听牌状态
- function RoomInfo:getTingStatus()
- return self.tingStatus;
- end
-
- -- 保存游戏id
- -- @param gameId int
- function RoomInfo:setGameId(gameId)
- self.gameId = gameId;
- end
-
- -- 获取游戏id
- function RoomInfo:getGameId()
- return self.gameId;
- end
-
- -- 保存桌子号
- -- @param int 426146
- function RoomInfo:setShowTableId(showTableId)
- self.nShowTableId = showTableId;
- end
-
- -- 获取桌子号
- function RoomInfo:getShowTableId()
- return self.nShowTableId;
- end
-
- -- 保存房主id
- -- @param userId int
- function RoomInfo:setRoomOwnedUid(userId)
- self.nRoomOwnedUid = userId;
- end
-
- -- 获取房主id
- function RoomInfo:getRoomOwnedUid()
- return self.nRoomOwnedUid;
- end
-
- -- 保存庄家座位
- -- @param bankSeatId int
- function RoomInfo:setBankSeatId(bankSeatId)
- self.nBankSeatId = bankSeatId;
- end
-
- -- 获取庄家座位
- function RoomInfo:getBankSeatId()
- return self.nBankSeatId;
- end
-
- -- 保存本家逻辑座位
- -- @param mySeatId int
- function RoomInfo:setMySeatId(mySeatId)
- self.nMySeatId = mySeatId;
- end
-
- -- 获取本家座位
- function RoomInfo:getMySeatId()
- return self.nMySeatId or -1;
- end
-
- -- 保存总局数
- -- @param totalGameNum int
- function RoomInfo:setTotalGameNum( totalGameNum )
- self.nTotalGameNum = totalGameNum;
- end
-
- -- 获取总局数
- function RoomInfo:getTotalGameNum()
- return self.nTotalGameNum;
- end
-
- -- 保存底注
- -- @param baseChips int
- function RoomInfo:setBaseChips(baseChips)
- self.nBaseChips = baseChips;
- end
-
- -- 获取底注
- function RoomInfo:getBaseChips()
- return self.nBaseChips;
- end
-
- -- 保存玩法规则
- -- @param strGameInfo string json串
- function RoomInfo:setStrGameInfo( strGameInfo )
- self.strGameInfo = strGameInfo;
- end
-
- -- 获取玩法规则
- -- @return string json串
- function RoomInfo:getStrGameInfo()
- return self.strGameInfo;
- end
-
- -- 获取玩法规则
- -- @return table
- function RoomInfo:getGameRule()
- return json.decode(self.strGameInfo);
- end
-
- -- 通过key获取玩法规则
- -- @param ruleKey 玩法规则key
- function RoomInfo:getGameRuleByKey (ruleKey)
- if not ruleKey then
- return "";
- end
-
- local gameRule = self:getGameRule();
- if not gameRule then
- return "";
- end
-
- return gameRule[ruleKey] or "";
- end
-
- -- 保存已开局数
- -- @param gameStartCount int
- function RoomInfo:setGameStartCount (gameStartCount)
- self.nGameStartCount = gameStartCount;
- end
-
- -- 获取已开局数
- function RoomInfo:getGameStartCount ()
- return self.nGameStartCount or 0;
- end
-
- -- 保存快速开始信息
- function RoomInfo:setQuickStartInfo (info)
- self.quickStartInfo = info;
- end
-
- -- 获取快速开始信息
- function RoomInfo:getQuickStartInfo ()
- return self.quickStartInfo or {};
- end
-
- -- 保存上次出牌玩家id
- function RoomInfo:setLastOutViewId (viewId)
- self.lastOutViewId = viewId;
- end
-
- -- 获取上次出牌玩家id
- function RoomInfo:getLastOutViewId ()
- return self.lastOutViewId;
- end
-
- -- 保存是否有玩家解散房间
- -- @param isDisban boolean
- function RoomInfo:setIsUserDisbandGame(isDisband)
- self.bUserDisbandGame = isDisband;
- end
-
- -- 是否有玩家解散房间
- -- @return boolean
- function RoomInfo:getIsUserDisbandGame ()
- return self.bUserDisbandGame;
- end
-
- -- 保存解散剩余时间
- -- @dismissTime int 秒数
- function RoomInfo:setDismissStateTime (dismissTime)
- self.nDismissStateTime = dismissTime;
- end
-
- -- 获取解散剩余时间
- function RoomInfo:getDismissStateTime ()
- return self.nDismissStateTime or 0;
- end
-
- -- 保存牌局结束原因
- -- @param stopFlag int
- function RoomInfo:setStopFlag (stopFlag)
- self.stopFlag = stopFlag;
- end
-
- -- 获取牌局结束原因
- function RoomInfo:getStopFlag ()
- return self.stopFlag;
- end
-
- -- 操作统计 opsCntMapString
- function RoomInfo:setOpsCntMapString (opsCntMapString)
- self.opsCntMapString = opsCntMapString;
- end
-
- -- 操作统计 opsCntMapString
- function RoomInfo:getOpsCntMapString ()
- return self.opsCntMapString;
- end
-
- -- 保存是否大局结束
- -- @param isGameOver 1为大局结束
- function RoomInfo:setIsGameOver (isGameOver)
- self.isGameOver = isGameOver;
- end
-
- -- 是否大局结束
- function RoomInfo:getIsGameOver ()
- return self.isGameOver;
- end
-
- -- 保存牌局结束时间
- -- @param endTime 结束时间
- function RoomInfo:setEndTime (endTime)
- self.nEndTime = endTime or os.time();
- end
-
- function RoomInfo:getEndTime ()
- return self.nEndTime;
- end
-
- -- 保存萝卜牌
- -- @param luoboCards table
- function RoomInfo:setLuoBoCards ( luoboCards )
- self.luoboCards = luoboCards;
- end
-
- -- 获取所有萝卜牌
- function RoomInfo:getLuoBoCards ( )
- return self.luoboCards or {};
- end
-
- -- 获取指定萝卜牌张数
- -- @param card int
- function RoomInfo:getLuoBoCardCount( card )
- local count = 0;
- for k, v in ipairs(self.luoboCards or {}) do
- if v == card then
- count = count + 1;
- end
- end
- return count;
- end
-
- -- 获取萝卜牌汇总
- -- @param cards table
- function RoomInfo:getLuoBoCardsSummary (cards)
- local result = {};
- for k, v in ipairs(cards or {}) do
- result[v] = result[v] and (result[v] + 1) or 1;
- end
- return result;
- end
-
- -- 保存流水明细数据
- -- @param scoreInfo {{gs = 0, hs = 0, ht = 0x08, gf = 0, ls = 0, ot = 0x02, seat = "1;3;4"}, ...}
- -- @desc gs: 杠分
- -- hs: 胡分
- -- ht: 胡牌类型(自摸or点炮)
- -- gf: 杠番
- -- ls: 萝卜分
- -- ot: 操作类型,胡 or 杠等
- -- seat: 本次收费的座位id,多个;分割
- function RoomInfo:setScoreInfo (scoreInfo)
- self.scoreInfo = scoreInfo;
- end
-
- -- 获取流水明细数据
- function RoomInfo:getScoreInfo ()
- return self.scoreInfo or {};
- end
-
- return RoomInfo;
|