237 lines
7.7 KiB
Lua
237 lines
7.7 KiB
Lua
|
|
local EXTEND_MODEL_NAME = ...
|
|||
|
|
|
|||
|
|
local EXGameInfo = import('.EXGameInfo')
|
|||
|
|
local EXMainView = import('.EXMainView')
|
|||
|
|
local EXGameController = import('.EXGameController')
|
|||
|
|
local EXRoomConfig = import('.EXRoomConfig')
|
|||
|
|
local EXPlayBackView = import('.EXPlayBackView')
|
|||
|
|
local explayer = import('.EXPlayer')
|
|||
|
|
local ExtendConfig = {}
|
|||
|
|
|
|||
|
|
local M = ExtendConfig
|
|||
|
|
|
|||
|
|
function ExtendConfig.new()
|
|||
|
|
setmetatable(M, {__index = IExtendConfig})
|
|||
|
|
local self = setmetatable({}, {__index = M})
|
|||
|
|
self.class = 'ExtendConfig'
|
|||
|
|
self.extend_id = 13
|
|||
|
|
self._viewMap = {}
|
|||
|
|
self._viewMap[ViewManager.View_Main] = EXMainView
|
|||
|
|
self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView
|
|||
|
|
return self
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--卸载资源
|
|||
|
|
function M:UnAllAssets()
|
|||
|
|
UIPackage.RemovePackage('extend/zipai/hsrunbeard/ui/Info_Poker_HSRunBeard')
|
|||
|
|
self:UnAssets()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--卸载资源
|
|||
|
|
function M:UnAssets()
|
|||
|
|
UIPackage.RemovePackage('extend/zipai/hsrunbeard/ui/Extend_Poker_HSRunBeard')
|
|||
|
|
ResourcesManager.UnLoadGroup('HanShou_ZP')
|
|||
|
|
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:FillRoomConfig(room, _config)
|
|||
|
|
room.room_config = EXRoomConfig.new(_config)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:FillRoomData(s2croom)
|
|||
|
|
local room = DataManager.CurrenRoom
|
|||
|
|
local reload = s2croom['reload']
|
|||
|
|
local _tableInfo = s2croom['tableInfo']
|
|||
|
|
|
|||
|
|
local _config = _tableInfo['config']
|
|||
|
|
room.room_config = EXRoomConfig.new(_config)
|
|||
|
|
|
|||
|
|
local playerList = _tableInfo['playerData']
|
|||
|
|
room.curren_round = _tableInfo['round']
|
|||
|
|
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.entrust = _jp['entrust']
|
|||
|
|
p.self_user.host_ip = _jp['ip']
|
|||
|
|
p.self_user.location = Location.new(_jp['pos'] or '')
|
|||
|
|
p.cur_hp = _jp['cur_hp'] or 0
|
|||
|
|
p.total_hp = _jp['total_hp'] or 0
|
|||
|
|
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
|
|||
|
|
|
|||
|
|
-- 如果重写了player类,就需要传第二个参数
|
|||
|
|
-- self:FillPlayerData(playerList, explayer)
|
|||
|
|
|
|||
|
|
if (reload) then
|
|||
|
|
local _reloadInfo = s2croom['reloadInfo']
|
|||
|
|
local _hand_card = _reloadInfo['hand_card']
|
|||
|
|
local _card_list = _reloadInfo['card_list']
|
|||
|
|
local _discard = _reloadInfo['discard']
|
|||
|
|
room.discard = _discard
|
|||
|
|
-- local _index = _reloadInfo["typeface"]
|
|||
|
|
-- if _index ==1 then
|
|||
|
|
-- room.change_card_display = "2_"
|
|||
|
|
-- else
|
|||
|
|
-- room.change_card_display = "1_"
|
|||
|
|
-- end
|
|||
|
|
room.self_player.handcard_list = _hand_card
|
|||
|
|
room.self_player.card_list = {}
|
|||
|
|
for i = 1, #_card_list do
|
|||
|
|
local data = {}
|
|||
|
|
data.card_item = _card_list[i].card
|
|||
|
|
data.index_X = _card_list[i].X
|
|||
|
|
data.index_Y = _card_list[i].Y
|
|||
|
|
room.self_player.card_list[#room.self_player.card_list + 1] = data
|
|||
|
|
end
|
|||
|
|
local active_seat = _reloadInfo['active_seat']
|
|||
|
|
local bank_seat = _reloadInfo['banker_seat']
|
|||
|
|
local playing = _reloadInfo['playing']
|
|||
|
|
local _info_list = _reloadInfo['info_list']
|
|||
|
|
local last_outcard_seat = _reloadInfo['last_outcard_seat']
|
|||
|
|
|
|||
|
|
room.left_count = _reloadInfo['left_card']
|
|||
|
|
room.banker_seat = bank_seat
|
|||
|
|
room.curren_outcard_seat = _reloadInfo['curren_outcard_seat']
|
|||
|
|
if active_seat ~= 0 then
|
|||
|
|
local player = room:GetPlayerBySeat(active_seat)
|
|||
|
|
player.DiceCard = _reloadInfo['acitve_card']
|
|||
|
|
end
|
|||
|
|
room.last_outcard_seat = last_outcard_seat
|
|||
|
|
room.playing = playing
|
|||
|
|
for i = 1, #_info_list do
|
|||
|
|
local tem = _info_list[i]
|
|||
|
|
local playerid = tem['playerid']
|
|||
|
|
local p = room:GetPlayerById(playerid)
|
|||
|
|
local outcard_list = tem['outcard_list']
|
|||
|
|
p.outcard_list = outcard_list
|
|||
|
|
p.total_score = tem['score']
|
|||
|
|
p.hu_xi = tem['hu_xi']
|
|||
|
|
p.hand_left_count = tem['card_count']
|
|||
|
|
p.cur_hp = tem['cur_hp'] or 0
|
|||
|
|
p.total_hp = tem['total_hp'] or 0
|
|||
|
|
if tem['hp_info'] then
|
|||
|
|
p.cur_hp = tem.hp_info.cur_hp
|
|||
|
|
p.total_hp = tem.hp_info.total_hp
|
|||
|
|
end
|
|||
|
|
p.entrust = tem['entrust']
|
|||
|
|
|
|||
|
|
local opcard = tem['opcard']
|
|||
|
|
for k = 1, #opcard do
|
|||
|
|
local op = opcard[k]
|
|||
|
|
local fz = {}
|
|||
|
|
fz.type = op['type']
|
|||
|
|
local data = {}
|
|||
|
|
data[1] = op['card1']
|
|||
|
|
data[2] = op['card3']
|
|||
|
|
fz.opcard = data
|
|||
|
|
fz.card = op['card2']
|
|||
|
|
fz.active_card = op['card2']
|
|||
|
|
|
|||
|
|
p.fz_list[#p.fz_list + 1] = fz
|
|||
|
|
if p.seat == room.self_player.seat then
|
|||
|
|
if fz.type == RB_FZType.Kan then
|
|||
|
|
for i = 1, 3 do
|
|||
|
|
room.self_player.handcard_list[#room.self_player.handcard_list + 1] = fz.card
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if not playing and room.curren_round > 0 then
|
|||
|
|
self.GetGameController():PlayerReady()
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function M:FillPlayBackData(pd_data)
|
|||
|
|
local room = DataManager.CurrenRoom
|
|||
|
|
local _tableInfo = pd_data['info']
|
|||
|
|
|
|||
|
|
local _config = _tableInfo['config']
|
|||
|
|
room.room_id = _tableInfo.roomid
|
|||
|
|
room.room_config = EXRoomConfig.new(_config)
|
|||
|
|
room.owner_id = _config['ownerid']
|
|||
|
|
local active_seat = _tableInfo['active_seat']
|
|||
|
|
local bank_seat = _tableInfo['banker_seat']
|
|||
|
|
room.left_count = _tableInfo['left_card']
|
|||
|
|
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 = room:NewPlayer()
|
|||
|
|
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 pid == 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']
|
|||
|
|
p.self_user.host_ip = p.self_user.host_ip
|
|||
|
|
local _hand_card = _jp['hand_card']
|
|||
|
|
p.hand_card = _hand_card
|
|||
|
|
if room.self_player ~= nil and p.seat == room.self_player.seat then
|
|||
|
|
room.self_player.handcard_list = _hand_card
|
|||
|
|
end
|
|||
|
|
p.total_score = _jp['score']
|
|||
|
|
p.hand_left_count = #_hand_card
|
|||
|
|
p.cur_hp = _jp['cur_hp'] or 0
|
|||
|
|
p.total_hp = _jp['total_hp'] or 0
|
|||
|
|
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']
|
|||
|
|
room.result = pd_data['result']
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return M
|