260 lines
8.0 KiB
Lua
260 lines
8.0 KiB
Lua
|
|
---
|
||
|
|
--- Created by 谌建军.
|
||
|
|
--- DateTime: 2017/12/13 10:57
|
||
|
|
---
|
||
|
|
|
||
|
|
local EXTEND_MODEL_NAME = ...
|
||
|
|
local EXGameInfo = import(".EXGameInfo")
|
||
|
|
local TwoDouDiZhu_MainView = import(".TwoDouDiZhu_MainView")
|
||
|
|
local TwoDouDiZhu_GameController = import(".TwoDouDiZhu_GameController")
|
||
|
|
local TwoDouDiZhu_RoomConfig = import(".TwoDouDiZhu_RoomConfig")
|
||
|
|
local TwoDouDiZhu_Player = import(".TwoDouDiZhu_Player")
|
||
|
|
local TwoDouDiZhu_Room = import(".TwoDouDiZhu_Room")
|
||
|
|
local TwoDouDiZhu_PlayerBackView = import(".TwoDouDiZhu_PlayerBackView")
|
||
|
|
|
||
|
|
local ExtendConfig = {}
|
||
|
|
|
||
|
|
local M = ExtendConfig
|
||
|
|
|
||
|
|
|
||
|
|
function ExtendConfig.new()
|
||
|
|
setmetatable(M, {__index = IExtendConfig})
|
||
|
|
local self = setmetatable({}, {__index = M})
|
||
|
|
self.class = "ExtendConfig"
|
||
|
|
self.extend_id = 14
|
||
|
|
self._viewMap = {}
|
||
|
|
self._viewMap[ViewManager.View_Main] = TwoDouDiZhu_MainView
|
||
|
|
self._viewMap[ViewManager.View_PlayBack] = TwoDouDiZhu_PlayerBackView
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
--卸载资源
|
||
|
|
function M:UnAllAssets()
|
||
|
|
UIPackage.RemovePackage("extend/poker/twodoudizhu/ui/Info_Poker_TwoDouDiZhu")
|
||
|
|
self:UnAssets()
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:UnAssets()
|
||
|
|
UIPackage.RemovePackage("extend/poker/twodoudizhu/ui/Extend_Poker_TwoDouDiZhu")
|
||
|
|
ResourcesManager.UnLoadGroup("TwoDouDiZhu_PK")
|
||
|
|
end
|
||
|
|
|
||
|
|
local _gameInfo = nil
|
||
|
|
function M:GetGameInfo()
|
||
|
|
if not _gameInfo then
|
||
|
|
_gameInfo = EXGameInfo.new()
|
||
|
|
end
|
||
|
|
return _gameInfo
|
||
|
|
end
|
||
|
|
|
||
|
|
local _ctr_game = nil
|
||
|
|
function M:GetGameController()
|
||
|
|
if _ctr_game == nil then
|
||
|
|
_ctr_game = TwoDouDiZhu_GameController.new()
|
||
|
|
end
|
||
|
|
return _ctr_game
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:NewRoom()
|
||
|
|
return TwoDouDiZhu_Room.new()
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:GetGameRule()
|
||
|
|
return TwoDouDiZhu_RuleView.new()
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:GetIconUrl()
|
||
|
|
return "ui://Extend_Poker_TwoDouDiZhu/icon"
|
||
|
|
--
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:FillRoomConfig(room,_config)
|
||
|
|
room.room_config = TwoDouDiZhu_RoomConfig.new(_config)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:FillRoomData(s2croom)
|
||
|
|
local room = DataManager.CurrenRoom
|
||
|
|
if _ctr_game == nil then
|
||
|
|
self:GetGameController()
|
||
|
|
end
|
||
|
|
|
||
|
|
local reload = s2croom["reload"]
|
||
|
|
|
||
|
|
local _tableInfo = s2croom["tableInfo"]
|
||
|
|
|
||
|
|
local _config = _tableInfo["config"]
|
||
|
|
room.room_config = TwoDouDiZhu_RoomConfig.new(_config)
|
||
|
|
|
||
|
|
room.curren_round = _tableInfo["round"]
|
||
|
|
if room.curren_round == 0 and reload then
|
||
|
|
room.curren_round = 1
|
||
|
|
end
|
||
|
|
|
||
|
|
local playerList = _tableInfo["playerData"]
|
||
|
|
for i = 1,#playerList do
|
||
|
|
local _jp = playerList[i]
|
||
|
|
|
||
|
|
local p = TwoDouDiZhu_Player.new()
|
||
|
|
p.seat = _jp["seat"]
|
||
|
|
local online = _jp["online"]
|
||
|
|
p.line_state = online
|
||
|
|
p.ready = _jp["ready"] == 1 and true or false
|
||
|
|
local pid = _jp["aid"]
|
||
|
|
if (DataManager.SelfUser.account_id == pid) then
|
||
|
|
room.self_player = p
|
||
|
|
p.self_user = DataManager.SelfUser
|
||
|
|
else
|
||
|
|
local u = User.new()
|
||
|
|
u.account_id = pid
|
||
|
|
p.self_user = u
|
||
|
|
u.nick_name = _jp["nick"]
|
||
|
|
u.head_url = _jp["portrait"]
|
||
|
|
u.sex = _jp["sex"]
|
||
|
|
end
|
||
|
|
p.self_user.location = Location.new(_jp["pos"] or "")
|
||
|
|
p.self_user.host_ip = _jp["ip"]
|
||
|
|
p.total_score = _jp["score"] or 0
|
||
|
|
if _jp.hp_info then
|
||
|
|
p.cur_hp = _jp.hp_info.cur_hp
|
||
|
|
end
|
||
|
|
p.hp_info = _jp["hp_info"]
|
||
|
|
|
||
|
|
if _jp["entrust"] then
|
||
|
|
p.entrust = _jp.entrust
|
||
|
|
end
|
||
|
|
room:AddPlayer(p)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
local owner = s2croom["owner"]
|
||
|
|
room.owner_id = owner
|
||
|
|
room.game_status = 0
|
||
|
|
if reload then
|
||
|
|
|
||
|
|
|
||
|
|
local reloadInfo = s2croom["reloadInfo"]
|
||
|
|
room.nineCards = reloadInfo["gameStatusData"]["nineCards"]
|
||
|
|
room.threeCards = reloadInfo["gameStatusData"]["threeCards"]
|
||
|
|
room.gameStatus = reloadInfo["gameStatusData"]["gameStatus"]
|
||
|
|
room.gameSeat = reloadInfo["gameStatusData"]["seat"]
|
||
|
|
room.threeCardMul = reloadInfo["gameStatusData"]["threeCardMul"]
|
||
|
|
room.curMul = reloadInfo["gameStatusData"]["curMul"]
|
||
|
|
|
||
|
|
local playing = reloadInfo["playing"]
|
||
|
|
|
||
|
|
room.curren_turn_seat = reloadInfo["active_seat"]
|
||
|
|
local info_list = reloadInfo["info_list"]
|
||
|
|
if playing == true then
|
||
|
|
|
||
|
|
|
||
|
|
room.CurnrenState = StateType.Palying
|
||
|
|
room.game_status=1
|
||
|
|
|
||
|
|
for i = 1, #info_list do
|
||
|
|
local p = room:GetPlayerById(info_list[i]["playerid"])
|
||
|
|
|
||
|
|
if p == room.self_player then
|
||
|
|
p.hand_list = reloadInfo["hand_card"]
|
||
|
|
p.open= reloadInfo["open"]
|
||
|
|
end
|
||
|
|
|
||
|
|
p.hand_count = info_list[i]["card_size"]
|
||
|
|
p.piao = info_list[i]["piao"]
|
||
|
|
local last_outcard = info_list[i]["last_outcard"]
|
||
|
|
if last_outcard ~= nil and last_outcard[1] ~= 0 then
|
||
|
|
local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true)
|
||
|
|
local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list)
|
||
|
|
p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count)
|
||
|
|
else
|
||
|
|
p.out_card_list = {0}
|
||
|
|
end
|
||
|
|
end
|
||
|
|
else
|
||
|
|
|
||
|
|
room.game_status=1
|
||
|
|
|
||
|
|
room.CurnrenState = StateType.PalyingWait
|
||
|
|
|
||
|
|
room.winseat = reloadInfo["winseat"]
|
||
|
|
room.remaincards = reloadInfo["remaincards"]
|
||
|
|
|
||
|
|
for i = 1, #info_list do
|
||
|
|
local playerData = info_list[i]
|
||
|
|
local p = room:GetPlayerById(playerData["playerid"])
|
||
|
|
|
||
|
|
p.ready = playerData["certainseat"] == 1 and true or false
|
||
|
|
|
||
|
|
local last_outcard = info_list[i]["last_outcard"]
|
||
|
|
if last_outcard ~= nil and last_outcard[1] ~= 0 then
|
||
|
|
|
||
|
|
local out_card_list = _ctr_game:ChangeCodeByFrom(last_outcard.card_list,true)
|
||
|
|
local card_type,number,length,plan_three_count = _ctr_game:GetCardListInfo(out_card_list)
|
||
|
|
p.out_card_list = _ctr_game:GetSortOutCardList(out_card_list,card_type,number,plan_three_count)
|
||
|
|
else
|
||
|
|
p.out_card_list = {0}
|
||
|
|
end
|
||
|
|
|
||
|
|
p.hand_list = info_list[i]["cards"]
|
||
|
|
p.winscore = info_list[i]["winscore"]
|
||
|
|
p.piao = info_list[i]["piao"]
|
||
|
|
p.hand_count = info_list[i]["card_size"]
|
||
|
|
p.thisboomnum=info_list[i]["thisboomnum"]
|
||
|
|
p.open= info_list[i]["open"]
|
||
|
|
end
|
||
|
|
end
|
||
|
|
else
|
||
|
|
room.CurnrenState = StateType.Ready
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function M:FillPlayBackData(pd_data)
|
||
|
|
local room = DataManager.CurrenRoom
|
||
|
|
local _tableInfo = pd_data["info"]
|
||
|
|
|
||
|
|
local _config = _tableInfo["config"]
|
||
|
|
room.room_id = _tableInfo.room_id
|
||
|
|
room.room_config = TwoDouDiZhu_RoomConfig.new(_config)
|
||
|
|
room.owner_id = _config["ownerid"]
|
||
|
|
local active_seat = _tableInfo["active_seat"]
|
||
|
|
local bank_seat = _tableInfo["banker_seat"]
|
||
|
|
room.banker_seat = bank_seat
|
||
|
|
room.curren_turn_seat = active_seat
|
||
|
|
room.curren_round = _tableInfo["round"]
|
||
|
|
local _info_list = _tableInfo["playerData"]
|
||
|
|
for i = 1,#_info_list do
|
||
|
|
local _jp = _info_list[i]
|
||
|
|
local p = TwoDouDiZhu_Player.new()
|
||
|
|
p.seat = _jp["seat"]
|
||
|
|
p.aid = _jp["aid"]
|
||
|
|
local pid = _jp["aid"]
|
||
|
|
if p.aid == DataManager.SelfUser.account_id then
|
||
|
|
room.self_player = p
|
||
|
|
end
|
||
|
|
local u = User.new()
|
||
|
|
u.account_id = pid
|
||
|
|
p.self_user = u
|
||
|
|
u.nick_name = _jp["nick"]
|
||
|
|
u.head_url = _jp["portrait"]
|
||
|
|
u.sex = _jp["sex"]
|
||
|
|
-- end
|
||
|
|
p.self_user.host_ip = p.self_user.host_ip
|
||
|
|
local _hand_card = _jp["hand_card"]
|
||
|
|
p.hand_list = _hand_card
|
||
|
|
p.hand_count = #_hand_card
|
||
|
|
p.total_score = _jp["score"]
|
||
|
|
p.piao = _jp["piao"]
|
||
|
|
p.open= _jp["open"]
|
||
|
|
p.hp_info = _jp["hp_info"]
|
||
|
|
if _jp['hp_info'] then
|
||
|
|
p.cur_hp = _jp.hp_info.cur_hp
|
||
|
|
p.total_hp = _jp.hp_info.total_hp
|
||
|
|
end
|
||
|
|
room:AddPlayer(p)
|
||
|
|
end
|
||
|
|
room.cmdList = pd_data["cmdList"]
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|