319 lines
9.5 KiB
Lua
319 lines
9.5 KiB
Lua
---
|
|
--- Created by 谌建军.
|
|
--- DateTime: 2017/12/13 10:57
|
|
---
|
|
|
|
local EXTEND_MODEL_NAME = ...
|
|
local EXGameInfo = import(".EXGameInfo")
|
|
local EXMainView = import(".EXMainView")
|
|
local EXGameController = import(".EXGameController")
|
|
local EXRoomConfig = import(".EXRoomConfig")
|
|
local EXPlayer = import(".EXPlayer")
|
|
local EXRoom = import(".EXRoom")
|
|
local EXPlayerBackView = import(".EXPlayerBackView")
|
|
local EXWitnessView = import(".EXWitnessView")
|
|
|
|
local ExtendConfig = {}
|
|
|
|
local M = ExtendConfig
|
|
|
|
|
|
function ExtendConfig.new()
|
|
setmetatable(M, { __index = IExtendConfig })
|
|
local self = setmetatable({}, { __index = M })
|
|
self.class = "ExtendConfig"
|
|
self.extend_id = 90
|
|
self._viewMap = {}
|
|
self._viewMap[ViewManager.View_Main] = EXMainView
|
|
self._viewMap[ViewManager.View_PlayBack] = EXPlayerBackView
|
|
self._viewMap[ViewManager.View_Witness] = EXWitnessView
|
|
|
|
return self
|
|
end
|
|
|
|
--卸载资源
|
|
function M:UnAllAssets()
|
|
UIPackage.RemovePackage("extend/poker/duoduo/ui/Info_Poker_DuoDuo")
|
|
self:UnAssets()
|
|
end
|
|
|
|
function M:UnAssets()
|
|
UIPackage.RemovePackage("extend/poker/duoduo/ui/Extend_Poker_DuoDuo")
|
|
ResourcesManager.UnLoadGroup("RunFase_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 = EXGameController.new()
|
|
end
|
|
return _ctr_game
|
|
end
|
|
|
|
function M:NewRoom()
|
|
return EXRoom.new()
|
|
end
|
|
|
|
function M:GetGameRule()
|
|
return EXRuleView.new()
|
|
end
|
|
|
|
function M:GetIconUrl()
|
|
return "ui://Lobby/paodekuai2", "ui://Lobby/paodekuai1"
|
|
end
|
|
|
|
function M:FillRoomConfig(room, _config)
|
|
room.room_config = EXRoomConfig.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"]
|
|
room.xipaiScore = _tableInfo["xipai_score"]
|
|
|
|
local _config = _tableInfo["config"]
|
|
room.room_config = EXRoomConfig.new(_config)
|
|
|
|
room.curren_round = _tableInfo["round"]
|
|
if room.curren_round == 0 and reload then
|
|
room.curren_round = 1
|
|
end
|
|
room.witness_player_list = _tableInfo["playerSpectatorData"]
|
|
room._flag_updateWitness = true
|
|
local playerList = _tableInfo["playerData"]
|
|
for i = 1, #playerList do
|
|
local _jp = playerList[i]
|
|
|
|
local p = EXPlayer.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"]
|
|
local bank_seat = reloadInfo["banker_seat"]
|
|
room.banker_seat = bank_seat
|
|
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"]
|
|
p.handCards = info_list[i]["handCards"]
|
|
p.outCards = info_list[i]["outCards"]
|
|
local last_outcard = info_list[i]["last_outcard"]
|
|
if last_outcard ~= nil and last_outcard[1] ~= 0 then
|
|
local out_card_list = last_outcard.card_list
|
|
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
|
|
-- -- print("aaaaaaaaaaaaaaaa1111111111111111111111111")
|
|
--pt(s2croom)
|
|
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"]
|
|
|
|
p.handCards = info_list[i]["handCards"]
|
|
p.outCards = info_list[i]["outCards"]
|
|
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 = EXRoomConfig.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 = EXPlayer.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
|
|
|
|
function M:FillWitnessData(pd_data)
|
|
print("==========================FillWitnessData1")
|
|
local room = DataManager.CurrenRoom
|
|
pt(room)
|
|
if _ctr_game == nil then
|
|
self:GetGameController()
|
|
end
|
|
|
|
local _tableInfo = pd_data["tableInfo"]
|
|
room.xipaiScore = _tableInfo["xipai_score"]
|
|
|
|
local _config = _tableInfo["config"]
|
|
room.room_config = EXRoomConfig.new(_config)
|
|
|
|
room.curren_round = _tableInfo["round"]
|
|
|
|
room.witness_player_list = _tableInfo["playerSpectatorData"]
|
|
local playerList = _tableInfo["playerData"]
|
|
for i = 1, #playerList do
|
|
local _jp = playerList[i]
|
|
|
|
local p = EXPlayer.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 p.seat == 1 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"]
|
|
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 = pd_data["owner"]
|
|
room.owner_id = owner
|
|
room.game_status = 0
|
|
end
|
|
|
|
function M:LoadConfigToDetail(data)
|
|
return data
|
|
end
|
|
|
|
return M
|