286 lines
9.8 KiB
Lua
286 lines
9.8 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 checkHuxi = import('.checkHuxi')
|
||
local ExtendConfig = {}
|
||
|
||
local M = ExtendConfig
|
||
|
||
function ExtendConfig.new()
|
||
setmetatable(M, {__index = IExtendConfig})
|
||
local self = setmetatable({}, {__index = M})
|
||
self.class = 'ExtendConfig'
|
||
self.extend_id = 50
|
||
self._viewMap = {}
|
||
self._viewMap[ViewManager.View_Main] = EXMainView
|
||
self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView
|
||
return self
|
||
end
|
||
|
||
--卸载资源
|
||
function M:UnAllAssets()
|
||
UIPackage.RemovePackage('extend/zipai/weimaque/ui/Info_Poker_WeiMaQue')
|
||
self:UnAssets()
|
||
end
|
||
|
||
--卸载资源
|
||
function M:UnAssets()
|
||
UIPackage.RemovePackage('extend/zipai/weimaque/ui/Extend_Poker_WeiMaQue')
|
||
ResourcesManager.UnLoadGroup('WeiMaQue_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']
|
||
printlog("jefe s2croom")
|
||
pt(s2croom)
|
||
|
||
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['hand_px_data']
|
||
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 = {}
|
||
if _card_list ~= nil and #_card_list > 0 then
|
||
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
|
||
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']
|
||
local show_card = _reloadInfo['show_card']
|
||
if active_seat ~= 0 and show_card ~= 0 then
|
||
local player = room:GetPlayerBySeat(active_seat)
|
||
player.DiceCard = show_card
|
||
end
|
||
room.last_outcard_seat = last_outcard_seat
|
||
room.playing = playing
|
||
room.suoCard = _reloadInfo['suoCard']
|
||
room.showtinglist = _reloadInfo['tinglist']
|
||
room.tinglist = _reloadInfo['ting']
|
||
room.score_pool = _reloadInfo['score_pool']
|
||
|
||
for i = 1, #_info_list do
|
||
local tem = _info_list[i]
|
||
local playerid = tem['playerid']
|
||
local p = room:GetPlayerById(playerid)
|
||
local outcard_list = {}
|
||
local tlist = tem['outcard_list']
|
||
--local exlist = tem["ex_outcard_list"]
|
||
for i=1,#tlist do
|
||
local c = tlist[i]
|
||
-- local chu = exlist[i]
|
||
local t = {}
|
||
t.card = c
|
||
--t.ischu = chu or 0
|
||
t.ischu = 0
|
||
table.insert( outcard_list, t )
|
||
end
|
||
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']
|
||
p.sishou = tem['sishou']
|
||
local opcard = tem['opcard']
|
||
for k = 1, #opcard do
|
||
local op = opcard[k]
|
||
local fz = {}
|
||
fz.type = op.type
|
||
local data = {}
|
||
for j = 1, #op.opcard do
|
||
data[#data + 1] = op.opcard[j]
|
||
end
|
||
fz.opcard = data
|
||
fz.card = op.card
|
||
fz.active_card = op.card
|
||
fz.huxi = op.huxi
|
||
p.fz_list[#p.fz_list + 1] = fz
|
||
end
|
||
-- if p.seat == room.self_player.seat then
|
||
-- local handcards = room.self_player.handcard_list
|
||
-- for i=1,#handcards do
|
||
-- if checkHuxi:checkCard(handcards[i],handcards,3) then
|
||
-- local fz = {}
|
||
-- fz.card = handcards[i]
|
||
-- fz.type = RB_FZType.Kan
|
||
-- fz.active_card = handcards[i]
|
||
-- fz.from_seat = room.self_player.seat
|
||
-- fz.opcard ={handcards[i],handcards[i]}
|
||
-- if fz.card % 100 == 2 or fz.card % 100 == 7 or fz.card == 110 or fz.card == 210 then
|
||
-- fz.huxi = 4
|
||
-- else
|
||
-- fz.huxi = 3
|
||
-- end
|
||
-- if #room.self_player.fz_list>0 then
|
||
-- local count =0
|
||
-- for j=1,#room.self_player.fz_list do
|
||
-- if room.self_player.fz_list[j].card == handcards[i] then
|
||
-- count = count+1
|
||
-- end
|
||
-- end
|
||
-- if count ==0 then
|
||
-- room.self_player.fz_list[#room.self_player.fz_list+1] = fz
|
||
-- end
|
||
-- else
|
||
-- room.self_player.fz_list[#room.self_player.fz_list+1] = fz
|
||
-- 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
|