源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

841 lines
22 KiB

  1. WordManager = WordManager or {}
  2. local WordManager = WordManager
  3. WordManager.goods_color_list_dark = {
  4. [0] = ColorUtil.GRAY_DARK,
  5. [1] = ColorUtil.GREEN_DARK,
  6. [2] = ColorUtil.BLUE_DARK,
  7. [3] = ColorUtil.PURPLE_DARK,
  8. [4] = ColorUtil.ORANGE_DARK,
  9. [5] = ColorUtil.RED_DARK,--红色品质
  10. [6] = ColorUtil.PINK_DARK,--粉色品质
  11. [7] = ColorUtil.YELLOW_DARK,--彩色品质(用图片蒙版)
  12. [8] = ColorUtil.GREEN_DARK_CH,--传闻聊天深绿
  13. }
  14. WordManager.partner_color_list = {
  15. [1] = ColorUtil.WHITE,
  16. [2] = ColorUtil.GREEN,
  17. [3] = ColorUtil.BLUE,
  18. [4] = ColorUtil.PURPLE,
  19. [5] = ColorUtil.ORANGE,
  20. }
  21. -- 不同价格类型对应的货币goodsID表
  22. WordManager.price_type_id = {
  23. [1] = 100000, -- 彩钻
  24. [2] = 100001, -- 红钻
  25. [3] = 100002, -- 交易券
  26. [4] = 100003, -- 名望券
  27. }
  28. WordManager.RomanNumerals =
  29. {
  30. {"I","II","III","IV","V","VI","VII","VIII","IX"},--1~9
  31. {"X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},--10~90
  32. {"C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},--100~900
  33. }
  34. function WordManager.GetGoodsColor(color)
  35. return WordManager.goods_color_list_dark[color] or WordManager.goods_color_list_dark[0]
  36. end
  37. --传闻之前跟物品是两套颜色的,现在统一了,先保留接口,避免策划需求又变更
  38. function WordManager.GetChuanwenColor(color)
  39. return WordManager.goods_color_list_dark[color] or WordManager.goods_color_list_dark[0]
  40. end
  41. function WordManager.GetPartnerColor(color)
  42. return WordManager.partner_color_list[color] or WordManager.partner_color_list[0]
  43. end
  44. function WordManager.ChangeToMainUIChatColor( str )
  45. --主界面和里边的聊天颜色要不同- -。 深浅底,这截中间做法出问题的话,就去源头传来的COLOR@1 分成两个文本存吧。
  46. local str = str or ""
  47. str = string.gsub(str, ColorUtil.GREEN_DARK, ColorUtil.GREEN_DARK)
  48. str = string.gsub(str, ColorUtil.GRAY_DARK, ColorUtil.GRAY_DARK)
  49. str = string.gsub(str, ColorUtil.GOLD_DARK, ColorUtil.GOLD_DARK)
  50. return str
  51. end
  52. function WordManager:GetCareerName(career)
  53. for _,v in pairs(Config.Career) do
  54. if tonumber(career) == tonumber(v.career_id) then
  55. return v.career_name
  56. end
  57. end
  58. return ""
  59. end
  60. function WordManager:GetRoleCareerName(career,turn)
  61. local ret = "通用"
  62. local cfg = Config.ConfigCarrerName[career.."@"..turn]
  63. if cfg then
  64. ret = cfg.name
  65. elseif career ~= 0 then
  66. for index,data in pairs(Config.Career) do
  67. if data.career_id == career then
  68. ret = Trim(data.career_name)
  69. break
  70. end
  71. end
  72. end
  73. return ret
  74. end
  75. -- level:人物等级,turn:人物转生,symbol:是否需要"等级"(非巅峰情况),symbol:是否需要"巅峰"(巅峰情况)
  76. function WordManager:GetRoleLevel(level,turn,symbol,symbol_top)
  77. if not level then
  78. logWarn("WordManager:GetRoleLevel=>level is nil")
  79. level = 0
  80. end
  81. if not turn then
  82. logWarn("WordManager:GetRoleLevel=>turn is nil")
  83. turn = 0
  84. end
  85. level = tonumber(level)
  86. turn = tonumber(turn)
  87. if level and turn and level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
  88. return symbol_top and level-MainRoleVo.TOP_LEVEL or (level-MainRoleVo.TOP_LEVEL)
  89. else
  90. return symbol and ("lv." .. level) or level
  91. end
  92. end
  93. -- level:人物等级,turn:人物转生,symbol:是否需要"等级"(非巅峰情况),symbol:是否需要"巅峰"(巅峰情况)
  94. function WordManager:GetRoleLevel2(level,turn,symbol,symbol_top)
  95. if not level then
  96. logWarn("WordManager:GetRoleLevel=>level is nil")
  97. level = 0
  98. end
  99. if not turn then
  100. logWarn("WordManager:GetRoleLevel=>turn is nil")
  101. turn = 0
  102. end
  103. level = tonumber(level)
  104. turn = tonumber(turn)
  105. if level and turn and level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
  106. return symbol_top and "传奇"..(level-MainRoleVo.TOP_LEVEL) or level-MainRoleVo.TOP_LEVEL
  107. else
  108. return symbol and (level.."") or level
  109. end
  110. end
  111. function WordManager:RoleLevelIsTop(level,turn)
  112. if not level then
  113. logWarn("WordManager:GetRoleLevel=>level is nil")
  114. level = 0
  115. end
  116. if not turn then
  117. logWarn("WordManager:GetRoleLevel=>turn is nil")
  118. turn = 0
  119. end
  120. if level >= MainRoleVo.TOP_LEVEL and turn >= 4 then
  121. return true
  122. else
  123. return false
  124. end
  125. end
  126. function WordManager:changeWords(text)
  127. local parseTypeDic = {}
  128. if text==nil or text=="" then
  129. return text
  130. end
  131. text = Trim(text)
  132. parseTypeDic["me"]="<color='#ffef67'>" .. RoleManager.Instance.mainRoleInfo.name .. "</color>"
  133. parseTypeDic["name"]="<color='#ffef67'>" .. RoleManager.Instance.mainRoleInfo.name .. "</color>"
  134. parseTypeDic["sex"]=RoleManager.Instance.mainRoleInfo.sex
  135. parseTypeDic["realm"]=RoleManager.Instance.mainRoleInfo.realm
  136. parseTypeDic["career"]=RoleManager.Instance.mainRoleInfo.career
  137. -- parseTypeDic["find"]=0
  138. -- parseTypeDic["color"]=0
  139. local function replaceFunc(...)
  140. local arg = {...}
  141. local type=arg[1]
  142. local values= Split(arg[2], ":")
  143. if parseTypeDic[type] == nil then
  144. return ""
  145. -- elseif type=="find" then
  146. -- return "%s" .. Join(values, "|") .. "%s"
  147. -- elseif type=="color" then
  148. -- local list = {}
  149. -- for i=2,#values do
  150. -- list[i - 1] = values[i]
  151. -- end
  152. -- local str= Join(list , ":")
  153. -- return string.format("<font color='%s'>%s</font>", values[1] , str)
  154. else
  155. if #values > 1 then
  156. return values[parseTypeDic[type]]
  157. else
  158. return parseTypeDic[type]
  159. end
  160. end
  161. return ""
  162. end
  163. local result = string.gsub(text, "%[(.*)%]([^%[]*)%[/%1%]", replaceFunc)
  164. --print("parseTaskStrResult:" .. result)
  165. return result
  166. end
  167. --160 坐骑系统
  168. --161 翅膀
  169. --165 宠物
  170. --168 法宝
  171. --427 神格系统
  172. --430 星灵系统
  173. --440 降神
  174. --441 图鉴系统
  175. --物品属性对应关系,module 对应功能id
  176. function WordManager:GetProperties(id,module_id,big_space)
  177. id = tonumber(id)
  178. module_id = tonumber(module_id)
  179. local cfg = Config.ConfigItemAttr.Normal[id]
  180. if cfg == nil then
  181. print("找不到对应的属性配置 ",id)
  182. return ""
  183. end
  184. if module_id and Config.ConfigItemAttr.SpecialAttr[id] then
  185. local name = Config.ConfigItemAttr.SpecialAttr[id][module_id]
  186. if name then
  187. return name
  188. end
  189. end
  190. return cfg.name
  191. end
  192. function WordManager:GetPropertyValue(id,value)
  193. local cfg = Config.ConfigItemAttr.Normal[id]
  194. if cfg == nil then
  195. cfg = {name = "", kind = 1, symbol = 1}
  196. end
  197. local mark = cfg.kind == 2 and "%" or cfg.kind == 3 and "ms" or ""
  198. if cfg.kind == 2 then
  199. value = tonumber(value) / 100
  200. elseif cfg.kind == 1 then
  201. value = math.floor(tonumber(value) + 0.5)
  202. end
  203. local sym = cfg.symbol == 1 and "+" or "-"
  204. value = value - value % 0.01 --保留小数点后两位
  205. return value .. mark, sym
  206. end
  207. --获取物品属性对应信息[str_format格式化 "{0}名字 {1}符号{2}数值"]
  208. function WordManager:GetPropertyInfo(id, value, color, str_format,module_id)
  209. id = tonumber(id)
  210. value = tonumber(value)
  211. local value_color = color or ColorUtil.GREEN
  212. local name = self:GetProperties(id,module_id)
  213. local value, symbol = self:GetPropertyValue(id, value)
  214. local str = "{0} {1}{2}"
  215. if str_format then
  216. if color then
  217. str = Language.substitute(str_format, name, color, symbol, value)
  218. else
  219. str = Language.substitute(str_format, name, symbol, value)
  220. end
  221. else
  222. if value_color then
  223. str = "{0} <color={1}>{2}{3}</color>"
  224. end
  225. str = Language.substitute(str, name, value_color, symbol, value)
  226. end
  227. return str, name, symbol, value
  228. end
  229. -- 属性 是属于高级属性
  230. function WordManager:GetAttrIsSpecial(attr_id)
  231. local t_id = attr_id or 0
  232. t_id = tonumber(attr_id)
  233. return t_id >= 9 and t_id ~= 15 and t_id ~= 16 --15固伤, 16固定减伤
  234. end
  235. --获取五行描述
  236. function WordManager.GetFiveElementStr(value)
  237. if value == 2 then
  238. return "(光)"
  239. elseif value == 3 then
  240. return "(暗)"
  241. elseif value == 4 then
  242. return "(水)"
  243. elseif value == 5 then
  244. return "(火)"
  245. elseif value == 6 then
  246. return "(风)"
  247. end
  248. end
  249. --物品属性对应关系,1~57的物品属性
  250. function WordManager:GetExtraProperties(id)
  251. local str = ""
  252. if id == 7 then
  253. str = "体质成长"
  254. elseif id == 8 then
  255. str = "敏捷成长"
  256. elseif id == 9 then
  257. str = "力量成长"
  258. elseif id == 10 then
  259. str = "灵巧成长"
  260. end
  261. return str
  262. end
  263. --通过格子位置,或许装备格子类型描述
  264. function WordManager:GetEquipStyleStr(cell)
  265. return Config.ConfigEquipShow[cell] and Config.ConfigEquipShow[cell].name or ""
  266. end
  267. --通过装备颜色获取装备前缀描述
  268. function WordManager:GetEquipPrefix(prefix,symbol)
  269. local desc = ""
  270. if prefix == 0 then --
  271. desc = ""
  272. elseif prefix == 1 then
  273. desc = "[普通]"
  274. elseif prefix == 2 then
  275. desc = "[优秀]"
  276. elseif prefix == 3 then
  277. desc = "[精良]"
  278. elseif prefix == 4 then
  279. desc = "[稀有]"
  280. elseif prefix == 5 then
  281. desc = "[卓越]"
  282. elseif prefix == 6 then
  283. desc = "[完美]"
  284. elseif prefix == 7 then
  285. desc = "[史诗]"
  286. elseif prefix == 8 then
  287. desc = "[传说]"
  288. elseif prefix == 9 then
  289. desc = "[远古]"
  290. elseif prefix == 10 then
  291. desc = "[不朽]"
  292. elseif prefix == 11 then
  293. desc = "[圣物]"
  294. elseif prefix == 12 then
  295. desc = "[神赐]"
  296. end
  297. if desc ~= "" and symbol then
  298. desc = string.sub(desc,2,string.len(desc) - 1)
  299. if type(symbol) == "string" then
  300. desc = desc..symbol
  301. end
  302. end
  303. return desc
  304. end
  305. --通过品质获取伙伴基础属性描述
  306. function WordManager:GetPartnerPropDescByQuality(quality)
  307. local prefix = ""
  308. if quality == 1 then
  309. prefix = "[普通]"
  310. elseif quality == 2 then
  311. prefix = "[良好]"
  312. elseif quality == 3 then
  313. prefix = "[优秀]"
  314. elseif quality == 4 then
  315. prefix = "[卓越]"
  316. elseif quality == 5 then
  317. prefix = "[完美]"
  318. end
  319. return prefix
  320. end
  321. --伙伴个性描述
  322. function WordManager:GetPartnerPersonality(personality)
  323. local prefix = ""
  324. if personality == 1 then
  325. prefix = "威严"
  326. elseif personality == 2 then
  327. prefix = "厉害"
  328. elseif personality == 3 then
  329. prefix = "简答"
  330. elseif personality == 4 then
  331. prefix = "威严"
  332. elseif personality == 5 then
  333. prefix = "威严"
  334. end
  335. return prefix
  336. end
  337. function WordManager:GetWingStepNum(type_id)
  338. local step = Config.Twing[type_id] and Config.Twing[type_id].grade or 0
  339. return step .. ""
  340. end
  341. function WordManager:GetEquipStepNum(id)
  342. local step = Config.Equipattr[id] and Config.Equipattr[id].stage or 0
  343. return step .. ""
  344. end
  345. function WordManager:GetEquipStepOnlyNum( id )
  346. local step = Config.Equipattr[id] and Config.Equipattr[id].stage or 0
  347. return step
  348. end
  349. --获取通用uiComponent_asset资源的游戏币图标资源名称
  350. --[[
  351. 1:
  352. 2:
  353. 3:
  354. 4:
  355. 5:
  356. ]]
  357. function WordManager:GetCommonMoneyIcon(price_type)
  358. local source = "ui_momey_icon_1"
  359. local asset = "uiComponent_asset"
  360. if price_type == 1 then
  361. source = "ui_momey_icon_1"
  362. elseif price_type == 2 then
  363. source = "ui_momey_icon_2"
  364. elseif price_type == 3 then
  365. source = "ui_momey_icon_3"
  366. elseif price_type == 4 then
  367. source = "ui_momey_icon_4"
  368. elseif price_type == 5 then
  369. source = "ui_momey_icon_5"
  370. elseif price_type == 11 then
  371. source = "ui_momey_icon_11"
  372. elseif price_type == 12 then
  373. source = "ui_momey_icon_12"
  374. elseif price_type == 13 then
  375. source = "ui_momey_icon_13"
  376. elseif price_type == 19 then
  377. source = "ui_momey_icon_6"
  378. elseif price_type == EmpowerConst.EmpowerMoneyId then
  379. source = "ui_momey_icon_emPower"
  380. elseif price_type == GuildModel.GuildContributeType then
  381. source = "ui_momey_icon_8"
  382. else
  383. source = "ui_momey_icon_1"
  384. end
  385. return asset, source
  386. end
  387. --获取通用common_asset资源的游戏币描述字符串
  388. function WordManager:GetCommonMoneyStr(price_type)
  389. local str = ""
  390. if price_type then
  391. price_type = tonumber(price_type)
  392. end
  393. if price_type == 1 then
  394. str = "彩钻"
  395. elseif price_type == 2 then
  396. str = "红钻"
  397. elseif price_type == 3 then
  398. str = "金币"
  399. elseif price_type == 4 then
  400. str = "社团贡献"
  401. elseif price_type == 5 then
  402. str = "经验"
  403. elseif price_type == 6 then
  404. str = "鲜花值"
  405. elseif price_type == 7 then
  406. str = "花香值"
  407. elseif price_type == 8 then
  408. str = "社团资金"
  409. elseif price_type == 9 then
  410. str = "时装精华"
  411. elseif price_type == 10 then
  412. str = "魂珠经验"
  413. elseif price_type == 11 then
  414. str = "纹章精华"
  415. elseif price_type == 16 then
  416. str = "竞技荣耀值"
  417. elseif price_type == 17 then
  418. str = "社团成长值"
  419. else
  420. str = ""
  421. end
  422. return str
  423. end
  424. -- 通过价格类型获取价格类型对应的货币goodsid
  425. function WordManager:GetPriceTypeId(price_type)
  426. if not price_type then return nil end
  427. return WordManager.price_type_id[price_type]
  428. end
  429. --获取货币的图文混排标签字符串
  430. function WordManager:GetMoneyFaceStr( price_type )
  431. if (not price_type) or (not Config.ConfigNotNormalGoods[price_type]) then return "" end
  432. local id = Config.ConfigNotNormalGoods[price_type].face_id
  433. return id and ("<sprite="..id..">") or ""
  434. end
  435. --是否有足够的消耗材料
  436. --[[
  437. cost_type:
  438. 0:
  439. 1:
  440. 2:
  441. 3:
  442. 4:
  443. 5:
  444. 6: 1
  445. 7: 2
  446. num:
  447. type_id:idnil
  448. ]]
  449. function WordManager:HaveEnoughCostOld(cost_type, num, type_id)
  450. local enough = false
  451. local cost_type = cost_type or 0
  452. local num = tonumber(num) or 0
  453. local desc = ""
  454. if cost_type == 0 then
  455. if type_id then
  456. local bag_num = GoodsModel:getInstance():GetTypeGoodsNum(type_id)
  457. if bag_num >= num then
  458. enough = true
  459. else
  460. desc = "物品不足"
  461. end
  462. end
  463. elseif cost_type == 1 then --彩钻
  464. if RoleManager.Instance.mainRoleInfo:GetRealJin() >= num then
  465. enough = true
  466. else
  467. desc = "彩钻不足"
  468. end
  469. elseif cost_type == 2 then --红钻
  470. if RoleManager.Instance.mainRoleInfo.jinLock >= num then
  471. enough = true
  472. else
  473. desc = "红钻不足"
  474. end
  475. elseif cost_type == 3 then --交易券
  476. if RoleManager.Instance.mainRoleInfo.tong >= num then
  477. enough = true
  478. else
  479. desc = "金币不足"
  480. end
  481. elseif cost_type == 4 then
  482. end
  483. return enough, desc
  484. end
  485. --[[
  486. index:
  487. tab_list:
  488. tab_txt_list: Text组件列表
  489. tab_outline_list OutLine组件列表
  490. content:
  491. ]]--
  492. function WordManager:SetTabColor(index,tab_list,tab_txt_list,tab_outline_list,content)
  493. for i=1,#tab_list do
  494. if i == index then
  495. tab_list[i].transform:SetAsLastSibling()
  496. tab_list[i]:GetComponent("Toggle").isOn = true
  497. tab_txt_list[i].text = "<color=#F3EBE7FF>"..content[i].."</color>"
  498. if tab_outline_list[i] then
  499. tab_outline_list[i].effectColor = Color(146/255,71/255,35/255,1)
  500. end
  501. else
  502. tab_list[i].transform:SetAsFirstSibling()
  503. tab_list[i]:GetComponent("Toggle").isOn = false
  504. tab_txt_list[i].text = "<color=#a0b4d5>"..content[i].."</color>"
  505. if tab_outline_list[i] then
  506. tab_outline_list[i].effectColor = Color(67/255,44/255,33/255,1)
  507. end
  508. end
  509. end
  510. end
  511. function WordManager:GetGoodsTypeStr(type, subtype)
  512. local str = "通用"
  513. local tbl = {
  514. [1] = "通用",
  515. [2] = "装备",
  516. [3] = "消耗",
  517. [4] = "碎片",
  518. [5] = "礼包",
  519. }
  520. if type and subtype then
  521. local key = tostring(type).."@"..tostring(subtype)
  522. if Config.GoodsSubtype[key] and Config.GoodsSubtype[key].sublabel_id then
  523. local id = Config.GoodsSubtype[key].sublabel_id
  524. str = tbl[id] or "通用"
  525. else
  526. print("没有找到该道具类型 type = ", type, " subtype = ", subtype)
  527. end
  528. else
  529. print("没有找到该道具类型 type = ", type, " subtype = ", subtype)
  530. end
  531. return str
  532. end
  533. function WordManager:GetSkillTypeStr(type)
  534. local tbl = {
  535. [1] = "主动技能",
  536. [2] = "被动技能",
  537. [3] = "辅助",
  538. [4] = "永久增益",
  539. }
  540. return tbl[type] or ""
  541. end
  542. --show_decimal: 显示小数点
  543. --is_exp: 是否是经验字体exp_font需要统一格式
  544. function WordManager:ConvertNum(num, show_decimal, is_exp)
  545. num = tonumber(num)
  546. show_decimal = show_decimal == nil and true or show_decimal
  547. if num <= 99999 then
  548. return num
  549. elseif num >= 100000 and num < 100000000 then
  550. local num = num/10000
  551. if show_decimal then
  552. local int_count,dec_count = self:GetNumberCount(num)
  553. if int_count + dec_count >4 then
  554. local temp_num = 1 / (10 ^ (4-int_count))
  555. temp_num = temp_num < 0.1 and 0.1 or temp_num
  556. num = num-num%temp_num
  557. else
  558. num = num-num%0.1
  559. end
  560. else
  561. num = math.floor(num)
  562. end
  563. if is_exp then
  564. num = string.gsub(num,"%.","d")
  565. return string.format("%sw",num)
  566. else
  567. return string.format("%s万", num)
  568. end
  569. elseif num >= 100000000 and num < 10000000000000 then
  570. local num = num/100000000
  571. if show_decimal then
  572. local int_count,dec_count = self:GetNumberCount(num)
  573. if int_count + dec_count >4 then
  574. local temp_num = 1 / (10 ^ (4-int_count))
  575. temp_num = temp_num < 0.1 and 0.1 or temp_num
  576. num = num-num%temp_num
  577. else
  578. num = num-num%0.1
  579. end
  580. else
  581. num = math.floor(num)
  582. end
  583. -- num = show_decimal and num-num%0.1 or math.floor(num)
  584. if is_exp then
  585. num = string.gsub(num,"%.","d")
  586. return string.format("%sy",num)
  587. else
  588. return string.format("%s亿", num)
  589. end
  590. else
  591. local num = num/1000000000000
  592. if show_decimal then
  593. local int_count,dec_count = self:GetNumberCount(num)
  594. if int_count + dec_count >4 then
  595. local temp_num = 1 / (10 ^ (4-int_count))
  596. temp_num = temp_num < 0.1 and 0.1 or temp_num
  597. num = num-num%temp_num
  598. else
  599. num = num-num%0.1
  600. end
  601. else
  602. num = math.floor(num)
  603. end
  604. if is_exp then
  605. num = string.gsub(num,"%.","d")
  606. return string.format("%sY",num)
  607. else
  608. return string.format("%s万亿", num)
  609. end
  610. end
  611. end
  612. --获取一个数字的数字个数
  613. function WordManager:GetNumberCount( num )
  614. num = tonumber(num)
  615. local int = (num - num % 1)
  616. local dec = num % 1
  617. dec = dec == 0 and "" or dec
  618. local int_count = string.len(tostring(int))
  619. local dec_count = string.len(tostring(dec))
  620. return int_count, dec_count
  621. end
  622. function WordManager:ConvertNum1(num, show_decimal)
  623. num = tonumber(num)
  624. show_decimal = show_decimal == nil and true or show_decimal
  625. if num <= 9999 then
  626. return num
  627. elseif num >= 10000 and num < 100000000 then
  628. return show_decimal and string.format("%.1f万",(num / 10000)) or string.format("%d万", math.floor(num/10000))
  629. elseif num >= 100000000 and num < 1000000000000 then
  630. return show_decimal and string.format("%.1f亿",(num / 100000000)) or string.format("%d亿", math.floor(num / 100000000))
  631. else
  632. return show_decimal and string.format("%.1f万亿",(num / 1000000000000)) or string.format("%d万亿", math.floor(num / 1000000000000))
  633. end
  634. end
  635. function WordManager:GetExpUnit(num)
  636. local unit = ""
  637. if num == "1" then
  638. unit = ""
  639. elseif num == "2" then
  640. unit = "亿"
  641. end
  642. return unit
  643. end
  644. function WordManager:GetWeekStr( week )
  645. local tb = {
  646. [0] = "周日",
  647. [1] = "周一",
  648. [2] = "周二",
  649. [3] = "周三",
  650. [4] = "周四",
  651. [5] = "周五",
  652. [6] = "周六",
  653. [7] = "周日",
  654. }
  655. return tb[tonumber(week)]
  656. end
  657. function WordManager:GetWeekStr2( week )
  658. local tb = {
  659. [1] = "星期日",
  660. [2] = "星期一",
  661. [3] = "星期二",
  662. [4] = "星期三",
  663. [5] = "星期四",
  664. [6] = "星期五",
  665. [7] = "星期六",
  666. }
  667. return tb[tonumber(week)]
  668. end
  669. function WordManager:GetWeekStr3( week )
  670. local tb = {
  671. [1] = "星期一",
  672. [2] = "星期二",
  673. [3] = "星期三",
  674. [4] = "星期四",
  675. [5] = "星期五",
  676. [6] = "星期六",
  677. [7] = "星期日",
  678. }
  679. return tb[tonumber(week)]
  680. end
  681. function WordManager:ShowGetRewardGoodsTips(goods_list)
  682. for i,v in pairs(goods_list) do
  683. local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v.style, v.typeId)
  684. local gvo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
  685. if gvo then
  686. local name = gvo.goods_name
  687. str = "获得 <color="..WordManager.GetGoodsColor(gvo.color)..">" .. name .. "x" .. v.count .. "</color>"
  688. Message.show(str)
  689. end
  690. end
  691. end
  692. function WordManager:GetJewelTypeStr(type)
  693. local tbl = {
  694. [1] = "攻击类",
  695. [2] = "生命类",
  696. [3] = "破甲类",
  697. [4] = "防御类",
  698. [5] = "命中类",
  699. [6] = "闪避类",
  700. [7] = "暴击类",
  701. [8] = "韧性类",
  702. }
  703. return tbl[type] or ""
  704. end
  705. --得到1~999的罗马数字
  706. function WordManager:GetRomanNumber(num)
  707. if num < 1 or num > 999 then
  708. return
  709. end
  710. local str = tostring(num)
  711. local rt = ""
  712. local tbl = {}
  713. for c in string.gmatch(str,"%d") do
  714. table.insert(tbl,1,tonumber(c))
  715. end
  716. for i, v in ipairs(tbl) do
  717. if v ~= 0 then
  718. rt = WordManager.RomanNumerals[i][v]..rt
  719. end
  720. end
  721. return rt
  722. end
  723. --判断消耗品是否充足
  724. function WordManager:HaveEnoughCost(list)
  725. local enough = false
  726. local cost_type = tonumber(list[1]) or 0
  727. local type_id = tonumber(list[2])
  728. local num = tonumber(list[3]) or 0
  729. local self_num = 0
  730. if cost_type == 0 then --物品
  731. if type_id then
  732. self_num = GoodsModel:getInstance():GetTypeGoodsNum(type_id)
  733. end
  734. elseif cost_type == 1 then --彩钻
  735. self_num = RoleManager.Instance.mainRoleInfo:GetRealJin()
  736. elseif cost_type == 2 then --绑定彩钻
  737. self_num = RoleManager.Instance.mainRoleInfo.jinLock
  738. elseif cost_type == 3 then --货币
  739. self_num = RoleManager.Instance.mainRoleInfo.tong
  740. -- elseif cost_type == 4 then --社团币
  741. elseif cost_type == 4 then --名望券
  742. self_num = RoleManager.Instance.mainRoleInfo.honor
  743. elseif cost_type == 255 then --特殊积分
  744. self_num = GoodsModel:getInstance():GetSpecialScore(type_id)
  745. end
  746. if self_num >= num then
  747. enough = true
  748. end
  749. return enough, self_num
  750. end
  751. --给字符串加颜色
  752. function WordManager:AddColorToString( content,color,mask_tag )
  753. content = content or ""
  754. color = color or "ffffff"
  755. if mask_tag then
  756. return "<color=" .. color .. ">" .. content .. "</color>"
  757. else
  758. return "<color=#" .. color .. ">" .. content .. "</color>"
  759. end
  760. end
  761. --数字转汉字
  762. function WordManager:getHanZiNumber(id)
  763. if not id then
  764. id = 0
  765. end
  766. local arr = {"","","","","","","","","","","","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十"}
  767. local str = arr[id + 1]
  768. if id and id > 20 and id < 100 then
  769. local ones_place = id % 10
  770. local tens_place = math.floor(id / 10)
  771. ten_str = arr[tens_place + 1] .. arr[11]
  772. ones_str = ones_place == 0 and "" or arr[ones_place + 1]
  773. str = ten_str .. ones_str
  774. end
  775. return str
  776. end