|
|
- WordManager = WordManager or {}
- local WordManager = WordManager
-
- WordManager.goods_color_list_dark = {
- [0] = ColorUtil.GRAY_DARK,
- [1] = ColorUtil.GREEN_DARK,
- [2] = ColorUtil.BLUE_DARK,
- [3] = ColorUtil.PURPLE_DARK,
- [4] = ColorUtil.ORANGE_DARK,
- [5] = ColorUtil.RED_DARK,--红色品质
- [6] = ColorUtil.PINK_DARK,--粉色品质
- [7] = ColorUtil.YELLOW_DARK,--彩色品质(用图片蒙版)
- [8] = ColorUtil.GREEN_DARK_CH,--传闻聊天深绿
- }
-
- WordManager.partner_color_list = {
- [1] = ColorUtil.WHITE,
- [2] = ColorUtil.GREEN,
- [3] = ColorUtil.BLUE,
- [4] = ColorUtil.PURPLE,
- [5] = ColorUtil.ORANGE,
- }
-
- -- 不同价格类型对应的货币goodsID表
- WordManager.price_type_id = {
- [1] = 100000, -- 彩钻
- [2] = 100001, -- 红钻
- [3] = 100002, -- 交易券
- [4] = 100003, -- 名望券
- }
-
- WordManager.RomanNumerals =
- {
- {"I","II","III","IV","V","VI","VII","VIII","IX"},--1~9
- {"X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},--10~90
- {"C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},--100~900
- }
-
- function WordManager.GetGoodsColor(color)
- return WordManager.goods_color_list_dark[color] or WordManager.goods_color_list_dark[0]
- end
-
- --传闻之前跟物品是两套颜色的,现在统一了,先保留接口,避免策划需求又变更
- function WordManager.GetChuanwenColor(color)
- return WordManager.goods_color_list_dark[color] or WordManager.goods_color_list_dark[0]
- end
-
- function WordManager.GetPartnerColor(color)
- return WordManager.partner_color_list[color] or WordManager.partner_color_list[0]
- end
-
-
- function WordManager.ChangeToMainUIChatColor( str )
- --主界面和里边的聊天颜色要不同- -。 深浅底,这截中间做法出问题的话,就去源头传来的COLOR@1 分成两个文本存吧。
- local str = str or ""
- str = string.gsub(str, ColorUtil.GREEN_DARK, ColorUtil.GREEN_DARK)
- str = string.gsub(str, ColorUtil.GRAY_DARK, ColorUtil.GRAY_DARK)
- str = string.gsub(str, ColorUtil.GOLD_DARK, ColorUtil.GOLD_DARK)
- return str
- end
-
-
- function WordManager:GetCareerName(career)
- for _,v in pairs(Config.Career) do
- if tonumber(career) == tonumber(v.career_id) then
- return v.career_name
- end
- end
- return ""
- end
-
- function WordManager:GetRoleCareerName(career,turn)
- local ret = "通用"
- local cfg = Config.ConfigCarrerName[career.."@"..turn]
- if cfg then
- ret = cfg.name
- elseif career ~= 0 then
- for index,data in pairs(Config.Career) do
- if data.career_id == career then
- ret = Trim(data.career_name)
- break
- end
- end
- end
- return ret
- end
-
- -- level:人物等级,turn:人物转生,symbol:是否需要"等级"(非巅峰情况),symbol:是否需要"巅峰"(巅峰情况)
- function WordManager:GetRoleLevel(level,turn,symbol,symbol_top)
- if not level then
- logWarn("WordManager:GetRoleLevel=>level is nil")
- level = 0
- end
- if not turn then
- logWarn("WordManager:GetRoleLevel=>turn is nil")
- turn = 0
- end
- level = tonumber(level)
- turn = tonumber(turn)
- if level and turn and level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
- return symbol_top and level-MainRoleVo.TOP_LEVEL or (level-MainRoleVo.TOP_LEVEL)
- else
- return symbol and ("lv." .. level) or level
- end
- end
-
- -- level:人物等级,turn:人物转生,symbol:是否需要"等级"(非巅峰情况),symbol:是否需要"巅峰"(巅峰情况)
- function WordManager:GetRoleLevel2(level,turn,symbol,symbol_top)
- if not level then
- logWarn("WordManager:GetRoleLevel=>level is nil")
- level = 0
- end
- if not turn then
- logWarn("WordManager:GetRoleLevel=>turn is nil")
- turn = 0
- end
- level = tonumber(level)
- turn = tonumber(turn)
- if level and turn and level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
- return symbol_top and "传奇"..(level-MainRoleVo.TOP_LEVEL) or level-MainRoleVo.TOP_LEVEL
- else
- return symbol and (level.."级") or level
- end
- end
-
- function WordManager:RoleLevelIsTop(level,turn)
- if not level then
- logWarn("WordManager:GetRoleLevel=>level is nil")
- level = 0
- end
- if not turn then
- logWarn("WordManager:GetRoleLevel=>turn is nil")
- turn = 0
- end
- if level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
- return true
- else
- return false
- end
- end
-
- function WordManager:changeWords(text)
- local parseTypeDic = {}
- if text==nil or text=="" then
- return text
- end
- text = Trim(text)
-
- parseTypeDic["me"]="<color='#ffef67'>" .. RoleManager.Instance.mainRoleInfo.name .. "</color>"
- parseTypeDic["name"]="<color='#ffef67'>" .. RoleManager.Instance.mainRoleInfo.name .. "</color>"
- parseTypeDic["sex"]=RoleManager.Instance.mainRoleInfo.sex
- parseTypeDic["realm"]=RoleManager.Instance.mainRoleInfo.realm
- parseTypeDic["career"]=RoleManager.Instance.mainRoleInfo.career
- -- parseTypeDic["find"]=0
- -- parseTypeDic["color"]=0
-
- local function replaceFunc(...)
- local arg = {...}
- local type=arg[1]
- local values= Split(arg[2], ":")
- if parseTypeDic[type] == nil then
- return ""
- -- elseif type=="find" then
- -- return "%s" .. Join(values, "|") .. "%s"
- -- elseif type=="color" then
- -- local list = {}
- -- for i=2,#values do
- -- list[i - 1] = values[i]
- -- end
- -- local str= Join(list , ":")
- -- return string.format("<font color='%s'>%s</font>", values[1] , str)
- else
- if #values > 1 then
- return values[parseTypeDic[type]]
- else
- return parseTypeDic[type]
- end
- end
- return ""
- end
- local result = string.gsub(text, "%[(.*)%]([^%[]*)%[/%1%]", replaceFunc)
- --print("parseTaskStrResult:" .. result)
- return result
- end
-
-
- --160 坐骑系统
- --161 翅膀
- --165 宠物
- --168 法宝
- --427 神格系统
- --430 星灵系统
- --440 降神
- --441 图鉴系统
- --物品属性对应关系,module 对应功能id
- function WordManager:GetProperties(id,module_id,big_space)
- id = tonumber(id)
- module_id = tonumber(module_id)
- local cfg = Config.ConfigItemAttr.Normal[id]
- if cfg == nil then
- print("找不到对应的属性配置 ",id)
- return ""
- end
-
- if module_id and Config.ConfigItemAttr.SpecialAttr[id] then
- local name = Config.ConfigItemAttr.SpecialAttr[id][module_id]
- if name then
- return name
- end
- end
-
- return cfg.name
- end
-
-
- function WordManager:GetPropertyValue(id,value)
- local cfg = Config.ConfigItemAttr.Normal[id]
- if cfg == nil then
- cfg = {name = "", kind = 1, symbol = 1}
- end
- local mark = cfg.kind == 2 and "%" or cfg.kind == 3 and "ms" or ""
- if cfg.kind == 2 then
- value = tonumber(value) / 100
- elseif cfg.kind == 1 then
- value = math.floor(tonumber(value) + 0.5)
- end
- local sym = cfg.symbol == 1 and "+" or "-"
- value = value - value % 0.01 --保留小数点后两位
- return value .. mark, sym
- end
-
- --获取物品属性对应信息[str_format格式化 "{0}名字 {1}符号{2}数值"]
- function WordManager:GetPropertyInfo(id, value, color, str_format,module_id)
- id = tonumber(id)
- value = tonumber(value)
- local value_color = color or ColorUtil.GREEN
- local name = self:GetProperties(id,module_id)
- local value, symbol = self:GetPropertyValue(id, value)
- local str = "{0} {1}{2}"
- if str_format then
- if color then
- str = Language.substitute(str_format, name, color, symbol, value)
- else
- str = Language.substitute(str_format, name, symbol, value)
- end
- else
- if value_color then
- str = "{0} <color={1}>{2}{3}</color>"
- end
- str = Language.substitute(str, name, value_color, symbol, value)
- end
- return str, name, symbol, value
- end
-
- -- 属性 是属于高级属性
- function WordManager:GetAttrIsSpecial(attr_id)
- local t_id = attr_id or 0
- t_id = tonumber(attr_id)
- return t_id >= 9 and t_id ~= 15 and t_id ~= 16 --15固伤, 16固定减伤
- end
-
- --获取五行描述
- function WordManager.GetFiveElementStr(value)
- if value == 2 then
- return "(光)"
- elseif value == 3 then
- return "(暗)"
- elseif value == 4 then
- return "(水)"
- elseif value == 5 then
- return "(火)"
- elseif value == 6 then
- return "(风)"
- end
- end
-
-
- --物品属性对应关系,1~57的物品属性
- function WordManager:GetExtraProperties(id)
- local str = ""
- if id == 7 then
- str = "体质成长"
- elseif id == 8 then
- str = "敏捷成长"
- elseif id == 9 then
- str = "力量成长"
- elseif id == 10 then
- str = "灵巧成长"
- end
-
- return str
- end
-
- --通过格子位置,或许装备格子类型描述
- function WordManager:GetEquipStyleStr(cell)
- return Config.ConfigEquipShow[cell] and Config.ConfigEquipShow[cell].name or ""
- end
-
- --通过装备颜色获取装备前缀描述
- function WordManager:GetEquipPrefix(prefix,symbol)
- local desc = ""
- if prefix == 0 then --
- desc = ""
- elseif prefix == 1 then
- desc = "[普通]"
- elseif prefix == 2 then
- desc = "[优秀]"
- elseif prefix == 3 then
- desc = "[精良]"
- elseif prefix == 4 then
- desc = "[稀有]"
- elseif prefix == 5 then
- desc = "[卓越]"
- elseif prefix == 6 then
- desc = "[完美]"
- elseif prefix == 7 then
- desc = "[史诗]"
- elseif prefix == 8 then
- desc = "[传说]"
- elseif prefix == 9 then
- desc = "[远古]"
- elseif prefix == 10 then
- desc = "[不朽]"
- elseif prefix == 11 then
- desc = "[圣物]"
- elseif prefix == 12 then
- desc = "[神赐]"
- end
-
- if desc ~= "" and symbol then
- desc = string.sub(desc,2,string.len(desc) - 1)
- if type(symbol) == "string" then
- desc = desc..symbol
- end
- end
-
- return desc
- end
-
- --通过品质获取伙伴基础属性描述
- function WordManager:GetPartnerPropDescByQuality(quality)
- local prefix = ""
- if quality == 1 then
- prefix = "[普通]"
- elseif quality == 2 then
- prefix = "[良好]"
- elseif quality == 3 then
- prefix = "[优秀]"
- elseif quality == 4 then
- prefix = "[卓越]"
- elseif quality == 5 then
- prefix = "[完美]"
- end
-
- return prefix
- end
-
- --伙伴个性描述
- function WordManager:GetPartnerPersonality(personality)
- local prefix = ""
- if personality == 1 then
- prefix = "威严"
- elseif personality == 2 then
- prefix = "厉害"
- elseif personality == 3 then
- prefix = "简答"
- elseif personality == 4 then
- prefix = "威严"
- elseif personality == 5 then
- prefix = "威严"
- end
-
- return prefix
- end
-
- function WordManager:GetWingStepNum(type_id)
- local step = Config.Twing[type_id] and Config.Twing[type_id].grade or 0
- return step .. "阶"
- end
-
- function WordManager:GetEquipStepNum(id)
- local step = Config.Equipattr[id] and Config.Equipattr[id].stage or 0
- return step .. "阶"
- end
- function WordManager:GetEquipStepOnlyNum( id )
- local step = Config.Equipattr[id] and Config.Equipattr[id].stage or 0
- return step
- end
- --获取通用uiComponent_asset资源的游戏币图标资源名称
- --[[
- 1: 彩钻
- 2: 红钻
- 3: 交易券
- 4: 名望券(各种战场荣誉)
- 5: 经验值
- ]]
- function WordManager:GetCommonMoneyIcon(price_type)
- local source = "ui_momey_icon_1"
- local asset = "uiComponent_asset"
- if price_type == 1 then
- source = "ui_momey_icon_1"
- elseif price_type == 2 then
- source = "ui_momey_icon_2"
- elseif price_type == 3 then
- source = "ui_momey_icon_3"
- elseif price_type == 4 then
- source = "ui_momey_icon_4"
- elseif price_type == 5 then
- source = "ui_momey_icon_5"
- elseif price_type == 11 then
- source = "ui_momey_icon_11"
- elseif price_type == 12 then
- source = "ui_momey_icon_12"
- elseif price_type == 13 then
- source = "ui_momey_icon_13"
- elseif price_type == 19 then
- source = "ui_momey_icon_6"
- elseif price_type == EmpowerConst.EmpowerMoneyId then
- source = "ui_momey_icon_emPower"
- elseif price_type == GuildModel.GuildContributeType then
- source = "ui_momey_icon_8"
- else
- source = "ui_momey_icon_1"
- end
- return asset, source
- end
-
- --获取通用common_asset资源的游戏币描述字符串
- function WordManager:GetCommonMoneyStr(price_type)
- local str = ""
- if price_type then
- price_type = tonumber(price_type)
- end
- if price_type == 1 then
- str = "彩钻"
- elseif price_type == 2 then
- str = "红钻"
- elseif price_type == 3 then
- str = "金币"
- elseif price_type == 4 then
- str = "社团贡献"
- elseif price_type == 5 then
- str = "经验"
- elseif price_type == 6 then
- str = "鲜花值"
- elseif price_type == 7 then
- str = "花香值"
- elseif price_type == 8 then
- str = "社团资金"
- elseif price_type == 9 then
- str = "时装精华"
- elseif price_type == 10 then
- str = "魂珠经验"
- elseif price_type == 11 then
- str = "纹章精华"
- elseif price_type == 16 then
- str = "竞技荣耀值"
- elseif price_type == 17 then
- str = "社团成长值"
- else
- str = ""
- end
- return str
- end
-
- -- 通过价格类型获取价格类型对应的货币goodsid
- function WordManager:GetPriceTypeId(price_type)
- if not price_type then return nil end
- return WordManager.price_type_id[price_type]
- end
-
- --获取货币的图文混排标签字符串
- function WordManager:GetMoneyFaceStr( price_type )
- if (not price_type) or (not Config.ConfigNotNormalGoods[price_type]) then return "" end
- local id = Config.ConfigNotNormalGoods[price_type].face_id
- return id and ("<sprite="..id..">") or ""
-
- end
-
- --是否有足够的消耗材料
- --[[
- cost_type:
- 0: 物品
- 1: 彩钻
- 2: 绑定彩钻
- 3: 金币
- 4: 社团币
- 5: 经验
- 6: 荣誉1
- 7: 荣誉2
- num:消耗数量
- type_id:真实物品类型id,数值物品为nil
- ]]
- function WordManager:HaveEnoughCostOld(cost_type, num, type_id)
- local enough = false
- local cost_type = cost_type or 0
- local num = tonumber(num) or 0
- local desc = ""
- if cost_type == 0 then
- if type_id then
- local bag_num = GoodsModel:getInstance():GetTypeGoodsNum(type_id)
- if bag_num >= num then
- enough = true
- else
- desc = "物品不足"
- end
- end
- elseif cost_type == 1 then --彩钻
- if RoleManager.Instance.mainRoleInfo:GetRealJin() >= num then
- enough = true
- else
- desc = "彩钻不足"
- end
- elseif cost_type == 2 then --红钻
- if RoleManager.Instance.mainRoleInfo.jinLock >= num then
- enough = true
- else
- desc = "红钻不足"
- end
- elseif cost_type == 3 then --交易券
- if RoleManager.Instance.mainRoleInfo.tong >= num then
- enough = true
- else
- desc = "金币不足"
- end
- elseif cost_type == 4 then
-
- end
- return enough, desc
- end
-
- --[[
- 标签选择时文字颜色改变
-
- index: 选中的标签索引
- tab_list: 存放标签对象列表
- tab_txt_list: 存放标签Text组件列表
- tab_outline_list: 存放标签OutLine组件列表
- content: 标签文字内容列表
- ]]--
- function WordManager:SetTabColor(index,tab_list,tab_txt_list,tab_outline_list,content)
- for i=1,#tab_list do
- if i == index then
- tab_list[i].transform:SetAsLastSibling()
- tab_list[i]:GetComponent("Toggle").isOn = true
- tab_txt_list[i].text = "<color=#F3EBE7FF>"..content[i].."</color>"
- if tab_outline_list[i] then
- tab_outline_list[i].effectColor = Color(146/255,71/255,35/255,1)
- end
- else
- tab_list[i].transform:SetAsFirstSibling()
- tab_list[i]:GetComponent("Toggle").isOn = false
- tab_txt_list[i].text = "<color=#a0b4d5>"..content[i].."</color>"
- if tab_outline_list[i] then
- tab_outline_list[i].effectColor = Color(67/255,44/255,33/255,1)
- end
- end
- end
- end
-
- function WordManager:GetGoodsTypeStr(type, subtype)
- local str = "通用"
- local tbl = {
- [1] = "通用",
- [2] = "装备",
- [3] = "消耗",
- [4] = "碎片",
- [5] = "礼包",
- }
- if type and subtype then
- local key = tostring(type).."@"..tostring(subtype)
- if Config.GoodsSubtype[key] and Config.GoodsSubtype[key].sublabel_id then
- local id = Config.GoodsSubtype[key].sublabel_id
- str = tbl[id] or "通用"
- else
- print("没有找到该道具类型 type = ", type, " subtype = ", subtype)
- end
- else
- print("没有找到该道具类型 type = ", type, " subtype = ", subtype)
- end
- return str
- end
-
- function WordManager:GetSkillTypeStr(type)
- local tbl = {
- [1] = "主动技能",
- [2] = "被动技能",
- [3] = "辅助",
- [4] = "永久增益",
- }
- return tbl[type] or ""
- end
-
- --show_decimal: 显示小数点
- --is_exp: 是否是经验字体exp_font需要统一格式
- function WordManager:ConvertNum(num, show_decimal, is_exp)
- num = tonumber(num)
- show_decimal = show_decimal == nil and true or show_decimal
- if num <= 99999 then
- return num
- elseif num >= 100000 and num < 100000000 then
- local num = num/10000
- if show_decimal then
- local int_count,dec_count = self:GetNumberCount(num)
- if int_count + dec_count >4 then
- local temp_num = 1 / (10 ^ (4-int_count))
- temp_num = temp_num < 0.1 and 0.1 or temp_num
- num = num-num%temp_num
- else
- num = num-num%0.1
- end
- else
- num = math.floor(num)
- end
- if is_exp then
- num = string.gsub(num,"%.","d")
- return string.format("%sw",num)
- else
- return string.format("%s万", num)
- end
- elseif num >= 100000000 and num < 10000000000000 then
- local num = num/100000000
- if show_decimal then
- local int_count,dec_count = self:GetNumberCount(num)
- if int_count + dec_count >4 then
- local temp_num = 1 / (10 ^ (4-int_count))
- temp_num = temp_num < 0.1 and 0.1 or temp_num
- num = num-num%temp_num
- else
- num = num-num%0.1
- end
- else
- num = math.floor(num)
- end
- -- num = show_decimal and num-num%0.1 or math.floor(num)
- if is_exp then
- num = string.gsub(num,"%.","d")
- return string.format("%sy",num)
- else
- return string.format("%s亿", num)
- end
- else
- local num = num/1000000000000
- if show_decimal then
- local int_count,dec_count = self:GetNumberCount(num)
- if int_count + dec_count >4 then
- local temp_num = 1 / (10 ^ (4-int_count))
- temp_num = temp_num < 0.1 and 0.1 or temp_num
- num = num-num%temp_num
- else
- num = num-num%0.1
- end
- else
- num = math.floor(num)
- end
- if is_exp then
- num = string.gsub(num,"%.","d")
- return string.format("%sY",num)
- else
- return string.format("%s万亿", num)
- end
- end
- end
- --获取一个数字的数字个数
- function WordManager:GetNumberCount( num )
- num = tonumber(num)
- local int = (num - num % 1)
- local dec = num % 1
- dec = dec == 0 and "" or dec
- local int_count = string.len(tostring(int))
- local dec_count = string.len(tostring(dec))
- return int_count, dec_count
- end
-
-
- function WordManager:ConvertNum1(num, show_decimal)
- num = tonumber(num)
- show_decimal = show_decimal == nil and true or show_decimal
- if num <= 9999 then
- return num
- elseif num >= 10000 and num < 100000000 then
- return show_decimal and string.format("%.1f万",(num / 10000)) or string.format("%d万", math.floor(num/10000))
- elseif num >= 100000000 and num < 1000000000000 then
- return show_decimal and string.format("%.1f亿",(num / 100000000)) or string.format("%d亿", math.floor(num / 100000000))
- else
- return show_decimal and string.format("%.1f万亿",(num / 1000000000000)) or string.format("%d万亿", math.floor(num / 1000000000000))
- end
- end
-
- function WordManager:GetExpUnit(num)
- local unit = ""
- if num == "1" then
- unit = "万"
- elseif num == "2" then
- unit = "亿"
- end
- return unit
- end
-
- function WordManager:GetWeekStr( week )
- local tb = {
- [0] = "周日",
- [1] = "周一",
- [2] = "周二",
- [3] = "周三",
- [4] = "周四",
- [5] = "周五",
- [6] = "周六",
- [7] = "周日",
- }
- return tb[tonumber(week)]
- end
-
- function WordManager:GetWeekStr2( week )
- local tb = {
- [1] = "星期日",
- [2] = "星期一",
- [3] = "星期二",
- [4] = "星期三",
- [5] = "星期四",
- [6] = "星期五",
- [7] = "星期六",
- }
- return tb[tonumber(week)]
- end
-
- function WordManager:GetWeekStr3( week )
- local tb = {
- [1] = "星期一",
- [2] = "星期二",
- [3] = "星期三",
- [4] = "星期四",
- [5] = "星期五",
- [6] = "星期六",
- [7] = "星期日",
- }
- return tb[tonumber(week)]
- end
-
- function WordManager:ShowGetRewardGoodsTips(goods_list)
- for i,v in pairs(goods_list) do
- local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v.style, v.typeId)
- local gvo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
- if gvo then
- local name = gvo.goods_name
- str = "获得 <color="..WordManager.GetGoodsColor(gvo.color)..">" .. name .. "x" .. v.count .. "</color>"
- Message.show(str)
- end
- end
- end
-
- function WordManager:GetJewelTypeStr(type)
- local tbl = {
- [1] = "攻击类",
- [2] = "生命类",
- [3] = "破甲类",
- [4] = "防御类",
- [5] = "命中类",
- [6] = "闪避类",
- [7] = "暴击类",
- [8] = "韧性类",
- }
- return tbl[type] or ""
- end
-
- --得到1~999的罗马数字
- function WordManager:GetRomanNumber(num)
- if num < 1 or num > 999 then
- return
- end
-
- local str = tostring(num)
- local rt = ""
- local tbl = {}
- for c in string.gmatch(str,"%d") do
- table.insert(tbl,1,tonumber(c))
- end
- for i, v in ipairs(tbl) do
- if v ~= 0 then
- rt = WordManager.RomanNumerals[i][v]..rt
- end
- end
- return rt
- end
-
- --判断消耗品是否充足
- function WordManager:HaveEnoughCost(list)
- local enough = false
- local cost_type = tonumber(list[1]) or 0
- local type_id = tonumber(list[2])
- local num = tonumber(list[3]) or 0
- local self_num = 0
-
- if cost_type == 0 then --物品
- if type_id then
- self_num = GoodsModel:getInstance():GetTypeGoodsNum(type_id)
- end
- elseif cost_type == 1 then --彩钻
- self_num = RoleManager.Instance.mainRoleInfo:GetRealJin()
- elseif cost_type == 2 then --绑定彩钻
- self_num = RoleManager.Instance.mainRoleInfo.jinLock
- elseif cost_type == 3 then --货币
- self_num = RoleManager.Instance.mainRoleInfo.tong
- -- elseif cost_type == 4 then --社团币
- elseif cost_type == 4 then --名望券
- self_num = RoleManager.Instance.mainRoleInfo.honor
- elseif cost_type == 255 then --特殊积分
- self_num = GoodsModel:getInstance():GetSpecialScore(type_id)
- end
- if self_num >= num then
- enough = true
- end
- return enough, self_num
- end
-
- --给字符串加颜色
- function WordManager:AddColorToString( content,color,mask_tag )
- content = content or ""
- color = color or "ffffff"
- if mask_tag then
- return "<color=" .. color .. ">" .. content .. "</color>"
- else
- return "<color=#" .. color .. ">" .. content .. "</color>"
- end
- end
-
- --数字转汉字
- function WordManager:getHanZiNumber(id)
- if not id then
- id = 0
- end
- local arr = {"零","一","二","三","四","五","六","七","八","九","十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十"}
- local str = arr[id + 1]
- if id and id > 20 and id < 100 then
- local ones_place = id % 10
- local tens_place = math.floor(id / 10)
- ten_str = arr[tens_place + 1] .. arr[11]
- ones_str = ones_place == 0 and "" or arr[ones_place + 1]
- str = ten_str .. ones_str
- end
- return str
- end
|