hengyang_client/lua_probject/base_project/Game/IGameInfo.lua

130 lines
3.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- Edit by ChenGY
--@type IGameInfo
--扩展UI
--需要两个控制器agent控制支付类型显示Cost控制目前选中的支付类型
--回合数对应的显示价格组件统一命名为tex_price1、tex_price2、...
--房主支付、AA支付显示价格的组件需要统一名称tex_owner、tex_aa
IGameInfo = {
-- 回合选项数量,必填
_roundChoice = 2,
-- 玩家数量,在子类中赋值,如果玩家数量可选,需要重载 OnChangeOption 方法, 详见长沙麻将
_maxPlayer = 2,
_game_data = nil,
}
local M = IGameInfo
function M:SelectedCardNum()
return 0
end
function M:SelectedConfigData()
return {}
end
function M:FillData()
end
function M:ShowRoomPrice(ctype)
local list = DataManager.SelfUser.games
if not self._game_data then
for i = 1, #list do
if list[i].game_id == self.game_data.game_id then
self._game_data = list[i]
end
end
end
self:ShowVariablePrice(ctype)
end
function M:OnChangeOption(ctype)
self:ShowRoomPrice(ctype)
-- local round = self._config:GetController("round")
-- round.onChanged:Set(function()
-- self:ShowVariablePrice(ctype)
-- end)
end
function M:ShowVariablePrice(ctype)
-- 显示回合数后面的价格tex_price1、tex_price2
for i = 1, self._roundChoice do
local price = "0"
price = self._game_data[string.format("pay%s_%s", i, self._maxPlayer)]
local tex_price = self._config:GetChild("tex_price" .. i)
if tex_price then
tex_price.text = price
end
end
-- 显示房主支付、aa支付的价格tex_aa/tex_owner
-- local tex_aa = self._config:GetChild("tex_aa")
-- local tex_owner = self._config:GetChild("tex_owner")
-- local opt = self._config:GetController("round").selectedIndex
-- local price = self._game_data[string.format("pay%s_%s", opt + 1, self._maxPlayer)]
-- tex_aa.text = math.ceil(price / self._maxPlayer)
-- tex_owner.text = price
end
function M:SetDefault()
end
function M:LoadConfigToDetail(configData, hpData)
local returnString = ""
if configData.GPSDetection then
returnString = string.format("%s%s", returnString,
configData.GPSDetection == 0 and ",距离不限制" or string.format(",距离限制%s米", configData.GPSDetection))
end
if configData.tuoguan_active_time then
returnString = string.format("%s%s", returnString,
configData.tuoguan_active_time == 0 and ",不自动托管" or string.format(",%s秒托管", configData.tuoguan_active_time))
end
if hpData then
if hpData.JieShan then
returnString = string.format("%s%s", returnString,
hpData.JieShan == 1 and ",托管结束后不解散" or
string.format(",托管%s结束后强制解散", hpData.JieShan == 2 and "当局" or string.format("%s局", hpData.JieShan - 1)))
end
if hpData.BanChat then
returnString = string.format("%s%s", returnString, hpData.BanChat == 1 and ",不允许快捷聊天" or "")
end
if hpData.BanMissile then
returnString = string.format("%s%s", returnString, hpData.BanMissile == 1 and ",关闭互动表情" or "")
end
end
return returnString
end
function M:LoadConfigOneInfo(data, hpdata, name)
local configData = data
if type(data) == 'string' then
configData = json.decode(data)
end
local hpData = configData.hpData or hpdata
if type(hpData) == 'string' then
if hpData == "null" then
hpData = nil
else
hpData = json.decode(hpData)
end
end
local returnString = nil
if configData[name] then
returnString = configData[name]
end
if hpData[name] then
returnString = hpData[name]
end
return returnString
end
return M