您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字

334 行
12 KiB

  1. --获取创建房间选项配置
  2. local PDKDefine = require("luaScript.SubGameDefine.PDKDefine")
  3. local Define_28 = import("luaScript.SubGameDefine.Poker.Define_28")
  4. local Define_53 = import("luaScript.SubGameDefine.Poker.Define_53")
  5. function getRuleFromString(gameId, jushu, ruleStr)
  6. local config=getSubGameConfig(tonumber(gameId))
  7. if config and type(config.wanfaConfig) == "string" then
  8. local isRequired, wanfa = pcall(require, config.wanfaConfig)
  9. if isRequired and wanfa and type(wanfa.getRuleFromString) == "function" then
  10. local tt = wanfa.getRuleFromString(gameId, jushu, ruleStr)
  11. return tt or {}
  12. end
  13. end
  14. local tt = {}
  15. local jsonData = json.decode(ruleStr);
  16. --"{\"kun\":14,\"gamerule\":0,\"baozi\":10,\"minHuShu\":18,\"specRule\":1}",
  17. -- 局数
  18. local jushuText = string.format("%d 局",jushu);
  19. table.insert(tt, {name = "局数", value = {jushuText}})
  20. if tonumber(gameId) == GAME_IDS.PaoDeKuai then--deductRule gamerule playerNum specialRule
  21. if jsonData.deductRule and jsonData.deductRule >= 0 then
  22. local specStr =jsonData.deductRule==0 and "房主付费" or "AA付费"
  23. if specStr ~= "" then
  24. table.insert(tt, {name = "房费", value = {specStr}})
  25. end
  26. end
  27. if jsonData.gamerule and jsonData.gamerule>0 then
  28. local specStr = PDKDefine.GameTypesStr[jsonData.gamerule] or ""
  29. if specStr ~= "" then
  30. table.insert(tt, {name = "玩法", value = {specStr}})
  31. end
  32. end
  33. if jsonData.playerNum and jsonData.playerNum>=0 then
  34. local specStr = PDKDefine.GamePlayerCount[jsonData.playerNum] or ""
  35. if specStr ~= "" then
  36. table.insert(tt, {name = "人数", value = {specStr}})
  37. end
  38. end
  39. if jsonData.allowPass and jsonData.allowPass >= 0 then
  40. local specStr = PDKDefine.GameWanfa[jsonData.allowPass] or ""
  41. if specStr ~= "" then
  42. table.insert(tt, {name = "玩法", value = {specStr}})
  43. end
  44. end
  45. local function getRule( rule )
  46. local CreateParamsMean = PDKDefine.CreateParamsMean
  47. local ruleStr = ""
  48. if getNumBand(rule, 0x0001)>0 then
  49. ruleStr = ruleStr..CreateParamsMean[0x0001]..","
  50. end
  51. if getNumBand(rule, 0x0002)>0 then
  52. ruleStr = ruleStr..CreateParamsMean[0x0002]..","
  53. end
  54. if getNumBand(rule, 0x0004)>0 then
  55. ruleStr = ruleStr..CreateParamsMean[0x0004]..","
  56. end
  57. -- if getNumBand(rule, 0x0008)>0 then
  58. -- -- ruleStr = ruleStr..CreateParamsMean[0x0008]..","
  59. -- end
  60. if getNumBand(rule, 0x0010)>0 then
  61. ruleStr = ruleStr..CreateParamsMean[0x0010]..","
  62. end
  63. if getNumBand(rule, 0x0020)>0 then
  64. ruleStr = ruleStr..CreateParamsMean[0x0020]..","
  65. end
  66. if getNumBand(rule, 0x0040)>0 then
  67. ruleStr = ruleStr..CreateParamsMean[0x0040]..","
  68. end
  69. if getNumBand(rule, 0x0080)>0 then
  70. ruleStr = ruleStr..CreateParamsMean[0x0080]..","
  71. end
  72. if string.len(ruleStr) > 0 then
  73. ruleStr = string.sub(ruleStr, 1, string.len(ruleStr)-1)
  74. end
  75. return ruleStr
  76. end
  77. if jsonData.specialRule and jsonData.specialRule>=0 then
  78. local specStr = getRule(jsonData.specialRule)
  79. if specStr ~= "" then
  80. table.insert(tt, {name = "规则", value = {specStr}})
  81. end
  82. end
  83. -- elseif tonumber(gameId) == GAME_IDS.zgWuRenDouDiZhu then
  84. -- local wrDdzDefine = require("luaScript.SubGameDefine.zgwrDdzDefine")
  85. -- local tt1 = wrDdzDefine.getClubWaFaInfo(ruleStr)
  86. -- table.insertTo(tt,tt1)
  87. -- elseif tonumber(gameId) == GAME_IDS.DouDiZhu then
  88. -- if jsonData.multLimit and jsonData.multLimit >= 0 then
  89. -- local specStr = Define_28.GAME_RULE.multLimit["" .. jsonData.multLimit] or ""
  90. -- if specStr ~= "" then
  91. -- table.insert(tt, {name = "倍数", value = {specStr}})
  92. -- end
  93. -- end
  94. -- if jsonData.lordType and jsonData.lordType >= 0 then
  95. -- local specStr = Define_28.GAME_RULE.lordType["" .. jsonData.lordType] or ""
  96. -- if specStr ~= "" then
  97. -- table.insert(tt, {name = "地主", value = {specStr}})
  98. -- end
  99. -- end
  100. -- if jsonData.nobLord and jsonData.nobLord >= 0 then
  101. -- local specStr = Define_28.GAME_RULE.nobLord["" .. jsonData.nobLord] or ""
  102. -- if specStr ~= "" then
  103. -- table.insert(tt, {name = "无人叫牌", value = {specStr}})
  104. -- end
  105. -- end
  106. -- if jsonData.sanDai and jsonData.sanDai >= 0 then
  107. -- local specStr = Define_28.GAME_RULE.sanDai["" .. jsonData.sanDai] or ""
  108. -- if specStr ~= "" then
  109. -- table.insert(tt, {name = "三带", value = {specStr}})
  110. -- end
  111. -- end
  112. -- if jsonData.siDai and jsonData.siDai >= 0 then
  113. -- local specStr = Define_28.GAME_RULE.siDai["" .. jsonData.siDai] or ""
  114. -- if specStr ~= "" then
  115. -- table.insert(tt, {name = "四带", value = {specStr}})
  116. -- end
  117. -- end
  118. -- if jsonData.piaoType and jsonData.piaoType >= 0 then
  119. -- local specStr = Define_28.GAME_RULE.piaoType["" .. jsonData.piaoType] or ""
  120. -- if specStr ~= "" then
  121. -- table.insert(tt, {name = "飘分", value = {specStr}})
  122. -- end
  123. -- end
  124. -- if jsonData.extPlay and jsonData.extPlay >= 0 then
  125. -- local specStr = Define_28.GAME_RULE.extPlay["" .. jsonData.extPlay] or ""
  126. -- if specStr ~= "" then
  127. -- table.insert(tt, {name = "其它", value = {specStr}})
  128. -- end
  129. -- end
  130. elseif tonumber(gameId) == GAME_IDS.NanChongDouDiZhu then
  131. if jsonData.multLimit and jsonData.multLimit >= 0 then
  132. local specStr = Define_53.GAME_RULE.multLimit["" .. jsonData.multLimit] or ""
  133. if specStr ~= "" then
  134. table.insert(tt, {name = "封顶", value = {specStr}})
  135. end
  136. end
  137. if jsonData.piaoType and jsonData.piaoType >= 0 then
  138. local specStr = Define_53.GAME_RULE.piaoType["" .. jsonData.piaoType] or ""
  139. if specStr ~= "" then
  140. table.insert(tt, {name = "漂分", value = {specStr}})
  141. end
  142. end
  143. if jsonData.calcFan and jsonData.calcFan >= 0 then
  144. local specStr = Define_53.GAME_RULE.calcFan["" .. jsonData.calcFan] or ""
  145. if specStr ~= "" then
  146. table.insert(tt, {name = "算番", value = {specStr}})
  147. end
  148. end
  149. if jsonData.playRule and jsonData.playRule >= 0 then
  150. local specStr = Define_53.GAME_RULE.playRule["" .. jsonData.playRule] or ""
  151. if specStr ~= "" then
  152. table.insert(tt, {name = "玩法", value = {specStr}})
  153. end
  154. end
  155. elseif tonumber(gameId) == GAME_IDS.BanZiPao then
  156. tt = PKFramework.ImportWanFa("luaScript.SubGameDefine.PuKe.PKWanFa", gameId).getClubRuleInfo(ruleStr)
  157. --手动添加局数
  158. table.insert(tt, 1, {name = "局数", value = {jushuText}})
  159. end
  160. --判断游戏配置是麻将
  161. local config=getSubGameConfig(tonumber(gameId))
  162. if config and config.belongType==3 then
  163. if jsonData.deductRule and jsonData.deductRule >= 0 then
  164. local specStr =jsonData.deductRule==0 and "房主付费" or "AA付费"
  165. if specStr ~= "" then
  166. table.insert(tt, {name = "房费", value = {specStr}})
  167. end
  168. end
  169. local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa",gameId)
  170. table.insertTo(tt,MJWanFa.getClubWaFaInfo(ruleStr))
  171. elseif config and config.belongType==2 then
  172. if jsonData.deductRule and jsonData.deductRule >= 0 then
  173. local specStr =jsonData.deductRule==0 and "房主付费" or "AA付费"
  174. if specStr ~= "" then
  175. table.insert(tt, {name = "房费", value = {specStr}})
  176. end
  177. end
  178. --[[-- 是否已下载
  179. local isDownGame = app.subGameManager:isInstaller(tonumber(gameId))
  180. -- 是否需要更新
  181. local isUpdate = app.subGameManager:isNeedUpdate(tonumber(gameId))
  182. if isDownGame == false or isUpdate == true then
  183. return tt
  184. end--]]
  185. local ZPWanFa = ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa",gameId)
  186. table.insertTo(tt,ZPWanFa.getClubRuleInfo(ruleStr))
  187. end
  188. return tt;
  189. end
  190. function getClubMatchRule(arena,isUseName)
  191. local tt = {}
  192. if app.club_php:getIsQuanMinSai(app.club_php.clubID) then
  193. if arena and arena ~= "" then
  194. isUseName = isUseName or ""
  195. local arena = json.decode(arena)
  196. str = "排名赛参与门槛"..tostring(arena.enterHongHua).."排名分"
  197. table.insert(tt, {name = "", value = {str}})
  198. str = "解散房间最低排名分"..tostring(arena.disHongHua or -500)
  199. table.insert(tt, {name = "", value = {str}})
  200. --抽奖区间下午写
  201. for k,v in pairsByKeys(arena.list) do
  202. str = "分数>="..tostring(v.min).."分扣除"..tostring(v.score).."排名分"
  203. table.insert(tt, {name = "", value = {str}})
  204. end
  205. else
  206. table.insert(tt, {name = isUseName, value = {"未设置排名规则"}})
  207. end
  208. else
  209. if arena and arena ~= "" then
  210. isUseName = isUseName or ""
  211. local arena = json.decode(arena)
  212. local str = tostring(arena.numHongHua).."红花=1游戏分"
  213. table.insert(tt, {name = isUseName, value = {str}})
  214. str = "最低"..tostring(arena.enterHongHua).."红花可以进房"
  215. table.insert(tt, {name = "", value = {str}})
  216. str = "大赢家>="..tostring(arena.prizedGreen).."分送"..tostring(arena.subGreen).."红花"
  217. table.insert(tt, {name = "", value = {str}})
  218. if arena.prizedGreen2 and arena.subGreen2 then
  219. str = "大赢家>="..tostring(arena.prizedGreen2).."分送"..tostring(arena.subGreen2).."红花"
  220. table.insert(tt, {name = "", value = {str}})
  221. end
  222. str = "解散房间红花数"..tostring(arena.disHongHua or -500)
  223. table.insert(tt, {name = "", value = {str}})
  224. else
  225. table.insert(tt, {name = isUseName, value = {"未设置比赛规则"}})
  226. end
  227. end
  228. return tt
  229. end
  230. function getClubCestRule(arena,isUseName)
  231. local tt = {}
  232. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  233. if arena and arena ~= "" then
  234. isUseName = isUseName or ""
  235. local arena = json.decode(arena)
  236. str = "赛事参与门槛"..tostring(arena.enterHongHua).."比赛分"
  237. table.insert(tt, {name = "", value = {str}})
  238. str = "解散房间最低比赛分"..tostring(arena.disHongHua or -500)
  239. table.insert(tt, {name = "", value = {str}})
  240. if arena.contributelist then
  241. for k, v in pairs(arena.contributelist) do
  242. str = "分数>="..tostring(v.min).."分奖励"..tostring(v.score).."赛点"
  243. table.insert(tt, {name = "", value = {str}})
  244. end
  245. end
  246. if arena.contribute then
  247. str = "冠军奖励"..tostring(arena.contribute).."赛点"
  248. table.insert(tt, {name = "", value = {str}})
  249. end
  250. else
  251. table.insert(tt, {name = isUseName, value = {"未设置排名规则"}})
  252. end
  253. end
  254. return tt
  255. end
  256. --获取包间多玩法桌子上显示的信息
  257. function getClubTableRuleString(gameId, ruleStr,playerNum)
  258. --判断游戏配置是麻将
  259. local str =""
  260. local config=getSubGameConfig(tonumber(gameId))
  261. if config and type(config.wanfaConfig) == "string" then
  262. local isRequired, wanfa = pcall(require, config.wanfaConfig)
  263. if isRequired and wanfa and type(wanfa.getClubTableRuleString) == "function" then
  264. local str = wanfa.getClubTableRuleString(gameId, ruleStr, playerNum)
  265. return str or ""
  266. end
  267. end
  268. if config and (config.belongType==3 or config.belongType==2) then
  269. str = tostring(playerNum).."人"
  270. else
  271. if tonumber(gameId) == 36 then--经典跑得快没有内容显示,显示人数
  272. str = tostring(playerNum).."人"
  273. end
  274. end
  275. --俱乐部切换多玩法桌子显示的玩法
  276. local jsonData=json.decode(ruleStr)
  277. if jsonData.startMode == 1 then
  278. str = "快速成局"
  279. else
  280. if tonumber(gameId) == GAME_IDS.PaoDeKuai then
  281. if jsonData.playerNum == 2 then
  282. str = str .. "快速成局"
  283. else
  284. str = tostring(playerNum) .. "人"
  285. end
  286. end
  287. end
  288. if config and config.belongType==3 then
  289. local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa",gameId)
  290. str = str..MJWanFa.getClubTableWanFaInfo(ruleStr)
  291. elseif config and config.belongType==2 then
  292. local ZPWanFa = ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa",gameId)
  293. str = str..ZPWanFa.getClubTableWanFaInfo(ruleStr)
  294. end
  295. if tonumber(gameId) == GAME_IDS.PaoDeKuai then
  296. local PDKDefine = require("luaScript.SubGameDefine.PDKDefine")
  297. str = str..PDKDefine.getClubTableWanFaInfo(ruleStr)
  298. elseif tonumber(gameId) == GAME_IDS.NanChongDouDiZhu then
  299. local wrDdzDefine = require("luaScript.SubGameDefine.Poker.Define_53")
  300. str = str..wrDdzDefine.getClubTableWanFaInfo(ruleStr)
  301. elseif tonumber(gameId) == GAME_IDS.BanZiPao then
  302. local bzpWanFa = require("luaScript.SubGameDefine.PuKe.bzpWanFa")
  303. str = str..bzpWanFa.getClubTableWanFaString(ruleStr)
  304. end
  305. return str;
  306. end