2025-04-01 10:48:36 +08:00
|
|
|
local EXTEND_MODEL_NAME = ...
|
|
|
|
|
|
|
|
|
|
local EXGameInfo = import(".EXGameInfo")
|
|
|
|
|
local EXMainView = import(".EXMainView")
|
|
|
|
|
local EXGameController = import(".EXGameController")
|
|
|
|
|
local EXRoomConfig = import(".EXRoomConfig")
|
2025-04-02 19:03:26 +08:00
|
|
|
local EXPlayBackView = import(".EXPlayBackView")
|
2025-06-25 22:49:44 +08:00
|
|
|
local EXWitnessView = import(".EXWitnessView")
|
2025-04-01 10:48:36 +08:00
|
|
|
local MJRoom = require("main.majiang.MJRoom")
|
|
|
|
|
|
|
|
|
|
local ExtendConfig = {}
|
|
|
|
|
|
|
|
|
|
local M = ExtendConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ExtendConfig.new()
|
2025-04-02 19:03:26 +08:00
|
|
|
setmetatable(M, { __index = IExtendConfig })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.class = "ExtendConfig"
|
|
|
|
|
self.extend_id = 33
|
|
|
|
|
self._viewMap = {}
|
|
|
|
|
self._viewMap[ViewManager.View_Main] = EXMainView
|
|
|
|
|
self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView
|
2025-06-25 22:49:44 +08:00
|
|
|
self._viewMap[ViewManager.View_Witness] = EXWitnessView
|
2025-04-02 19:03:26 +08:00
|
|
|
return self
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--卸载资源
|
|
|
|
|
function M:UnAllAssets()
|
|
|
|
|
UIPackage.RemovePackage("extend/majiang/nancheng/ui/Info_MJ_NanCheng")
|
|
|
|
|
self:UnAssets()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--卸载资源
|
|
|
|
|
function M:UnAssets()
|
|
|
|
|
UIPackage.RemovePackage("extend/majiang/nancheng/ui/Extend_MJ_NanCheng")
|
|
|
|
|
ResourcesManager.UnLoadGroup("NanCheng_MJ")
|
|
|
|
|
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()
|
2025-04-02 19:03:26 +08:00
|
|
|
if _ctr_game == nil then
|
|
|
|
|
_ctr_game = EXGameController.new()
|
|
|
|
|
end
|
|
|
|
|
return _ctr_game
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:NewRoom()
|
|
|
|
|
return MJRoom.new()
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
function M:FillRoomConfig(room, _config)
|
2025-04-01 10:48:36 +08:00
|
|
|
room.room_config = EXRoomConfig.new(_config)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:FillRoomData(s2croom)
|
2025-04-02 19:03:26 +08:00
|
|
|
local room = DataManager.CurrenRoom
|
2025-04-01 10:48:36 +08:00
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
|
|
|
local reload = s2croom["reload"]
|
2025-04-01 10:48:36 +08:00
|
|
|
local _tableInfo = s2croom["tableInfo"]
|
2025-04-02 19:03:26 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
local _config = _tableInfo["config"]
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
|
|
|
pt(_config)
|
2025-04-01 10:48:36 +08:00
|
|
|
room.room_config = EXRoomConfig.new(_config)
|
|
|
|
|
|
|
|
|
|
local playerList = _tableInfo["playerData"]
|
|
|
|
|
room.curren_round = _tableInfo["round"]
|
2025-08-28 19:15:06 +08:00
|
|
|
room.witness_player_list = _tableInfo["playerSpectatorData"]
|
|
|
|
|
room._flag_updateWitness = true
|
2025-04-01 10:48:36 +08:00
|
|
|
self:FillPlayerData(playerList)
|
|
|
|
|
|
|
|
|
|
if (reload) then
|
|
|
|
|
local _reloadInfo = s2croom["reloadInfo"]
|
2025-09-09 14:58:47 +08:00
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
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"]
|
|
|
|
|
room.last_outcard_seat = last_outcard_seat
|
|
|
|
|
room.playing = playing
|
2025-09-03 16:52:14 +08:00
|
|
|
room.reload = reload
|
2025-09-09 14:58:47 +08:00
|
|
|
local _hand_card = _reloadInfo["hand_card"]
|
|
|
|
|
room.self_player.card_list = _hand_card
|
2025-09-16 21:35:09 +08:00
|
|
|
if room.self_player.seat == room.curren_outcard_seat then
|
|
|
|
|
local getCard = _hand_card[#_hand_card]
|
|
|
|
|
table.remove(_hand_card, #_hand_card)
|
2025-09-19 18:50:28 +08:00
|
|
|
table.sort(_hand_card, self.HandCardSortAndJing)
|
2025-09-16 21:35:09 +08:00
|
|
|
table.insert(_hand_card, getCard)
|
|
|
|
|
else
|
2025-09-19 18:50:28 +08:00
|
|
|
table.sort(_hand_card, self.HandCardSortAndJing)
|
2025-09-16 21:35:09 +08:00
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
for i = 1, #_info_list do
|
|
|
|
|
local tem = _info_list[i]
|
|
|
|
|
local playerid = tem["playerid"]
|
|
|
|
|
local p = room:GetPlayerById(playerid)
|
|
|
|
|
p.total_score = tem["score"]
|
|
|
|
|
p.piao_niao = tem["piao_niao"] or 0
|
2025-09-12 17:10:34 +08:00
|
|
|
if playing then
|
|
|
|
|
local outcard_list = tem["outcard_list"]
|
|
|
|
|
p.hand_left_count = tem["card_count"]
|
|
|
|
|
p.outcard_list = outcard_list
|
|
|
|
|
local opcard = tem["opcard"]
|
|
|
|
|
for k = 1, #opcard do
|
|
|
|
|
local op = opcard[k]
|
|
|
|
|
local fz = {}
|
|
|
|
|
fz.type = op["type"]
|
|
|
|
|
fz.card = op["card"]
|
|
|
|
|
fz.from_seat = op["from_seat"]
|
|
|
|
|
p.fz_list[#p.fz_list + 1] = fz
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
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"]
|
2025-04-02 19:03:26 +08:00
|
|
|
for i = 1, #_info_list do
|
2025-04-01 10:48:36 +08:00
|
|
|
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"]
|
|
|
|
|
p.piao_niao = _jp["piao_niao"]
|
2025-04-11 12:49:08 +08:00
|
|
|
-- -- print(DataManager.SelfUser.account_id,pid)
|
2025-04-01 10:48:36 +08:00
|
|
|
-- if (278 == pid) then
|
|
|
|
|
-- room.self_player = p
|
|
|
|
|
-- p.self_user = DataManager.SelfUser
|
|
|
|
|
-- else
|
|
|
|
|
if p.seat == 1 then room.self_player = p end
|
2025-04-02 19:03:26 +08:00
|
|
|
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"]
|
2025-04-01 10:48:36 +08:00
|
|
|
-- end
|
|
|
|
|
p.self_user.host_ip = p.self_user.host_ip
|
2025-04-02 19:03:26 +08:00
|
|
|
local _hand_card = _jp["hand_card"]
|
2025-04-01 10:48:36 +08:00
|
|
|
p.card_list = _hand_card
|
|
|
|
|
--room.self_player.card_list = _hand_card
|
2025-09-19 18:50:28 +08:00
|
|
|
table.sort(_hand_card, self.HandCardSortAndJing)
|
2025-04-01 10:48:36 +08:00
|
|
|
p.total_score = _jp["score"]
|
|
|
|
|
p.hand_left_count = #_hand_card
|
|
|
|
|
if _jp.hp_info then
|
|
|
|
|
room.room_config.isNonnegative = 1
|
|
|
|
|
p.cur_hp = _jp.hp_info.cur_hp
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
room:AddPlayer(p)
|
|
|
|
|
end
|
|
|
|
|
room.cmdList = pd_data["cmdList"]
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-25 22:49:44 +08:00
|
|
|
function M:FillWitnessData(pd_data)
|
|
|
|
|
print("==========================FillWitnessData1")
|
|
|
|
|
local room = DataManager.CurrenRoom
|
|
|
|
|
pt(room)
|
|
|
|
|
-- room.self_player =
|
|
|
|
|
local _tableInfo = pd_data["tableInfo"]
|
|
|
|
|
|
|
|
|
|
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"]
|
2025-09-03 16:52:14 +08:00
|
|
|
room.witness_player_list = _tableInfo["playerSpectatorData"]
|
2025-06-25 22:49:44 +08:00
|
|
|
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"]
|
|
|
|
|
p.piao_niao = _jp["piao_niao"]
|
|
|
|
|
-- -- print(DataManager.SelfUser.account_id,pid)
|
|
|
|
|
-- if (278 == pid) then
|
|
|
|
|
-- room.self_player = p
|
|
|
|
|
-- p.self_user = DataManager.SelfUser
|
|
|
|
|
-- else
|
|
|
|
|
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"]
|
|
|
|
|
-- end
|
|
|
|
|
p.self_user.host_ip = p.self_user.host_ip
|
|
|
|
|
local _hand_card = {}
|
|
|
|
|
p.hand_left_count = _jp["card_count"]
|
|
|
|
|
p.card_list = _hand_card
|
|
|
|
|
--room.self_player.card_list = _hand_card
|
|
|
|
|
-- table.sort(_hand_card, self.HandCardSortAndJing)
|
|
|
|
|
p.total_score = _jp["score"]
|
|
|
|
|
p.outcard_list = _jp["outcard_list"]
|
|
|
|
|
local opcard = _jp["opcard"]
|
|
|
|
|
for k = 1, #opcard do
|
|
|
|
|
local op = opcard[k]
|
|
|
|
|
local fz = {}
|
|
|
|
|
fz.type = op["type"]
|
|
|
|
|
fz.card = op["card"]
|
|
|
|
|
fz.from_seat = op["from_seat"]
|
|
|
|
|
p.fz_list[#p.fz_list + 1] = fz
|
|
|
|
|
end
|
|
|
|
|
-- if _jp.hp_info then
|
|
|
|
|
-- room.room_config.isNonnegative = 1
|
|
|
|
|
-- p.cur_hp = _jp.hp_info.cur_hp
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
room:AddPlayer(p)
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-09-19 18:50:28 +08:00
|
|
|
|
|
|
|
|
function M.HandCardSortAndJing(a, b)
|
|
|
|
|
local jing = DataManager.CurrenRoom.jing
|
|
|
|
|
if a == jing or b == jing then
|
|
|
|
|
if a == b then
|
|
|
|
|
return a < b
|
|
|
|
|
end
|
|
|
|
|
return a == jing
|
|
|
|
|
else
|
|
|
|
|
if a < 200 then
|
|
|
|
|
a = a + 1000
|
|
|
|
|
elseif a < 300 then
|
|
|
|
|
a = a + 3000
|
|
|
|
|
elseif a < 400 then
|
|
|
|
|
a = a + 2000
|
|
|
|
|
else
|
|
|
|
|
a = a + 4000
|
|
|
|
|
end
|
|
|
|
|
if b < 200 then
|
|
|
|
|
b = b + 1000
|
|
|
|
|
elseif b < 300 then
|
|
|
|
|
b = b + 3000
|
|
|
|
|
elseif b < 400 then
|
|
|
|
|
b = b + 2000
|
|
|
|
|
else
|
|
|
|
|
b = b + 4000
|
|
|
|
|
end
|
|
|
|
|
return a < b
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
return M
|