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.

268 lines
7.3 KiB

  1. local wanfa={
  2. {
  3. playnum = {
  4. {name="两人玩",value=2},
  5. {name="三人玩",value=3},
  6. {name="四人玩",value=4},
  7. {name="快速成局",value=-1},
  8. },
  9. },
  10. {
  11. deductRule={
  12. {name="房主支付",value=0},
  13. {name="AA支付",value=1},
  14. },
  15. },
  16. {
  17. highLimit={
  18. {name="100分",value=100},
  19. {name="200分",value=200},
  20. {name="300分",value=300},
  21. {name="500分",value=500},
  22. {name="1000分",value=1000},
  23. {name="2000分",value=2000},
  24. {name="3000分",value=3000},
  25. {name="4000分",value=4000},
  26. },
  27. },
  28. {
  29. specialRule={
  30. {name="自摸翻倍",value=0x0001},
  31. {name="可无胡",value=0x0200},
  32. {name="圈牌",value=0x0400},
  33. {name="整胡翻倍",value=0x0080},
  34. {name="放炮包赔",value=0x0008},
  35. {name="过张升番胡",value=0x0010},
  36. {name="查叫",value=0x0100},
  37. {name="归翻倍",value=0x0002},
  38. {name="单杀",value=0x0800},
  39. {name="小家可看庄牌",value=0x0020},
  40. {name="吃对家",value=0x0040},
  41. },
  42. isAndOr = true;
  43. },
  44. {
  45. scoreNum={
  46. {name="1/2/3小中大",value=1},
  47. {name="5/10/15小中大",value=5},
  48. {name="10/20/30小中大",value=10},
  49. },
  50. },
  51. {
  52. baseMulti = {
  53. {name = "积分倍数x", value = 0x0001}
  54. },
  55. },
  56. {
  57. forbidProp = {
  58. {name = "屏蔽快捷语与道具", value = 1},
  59. {name = "屏蔽快捷语与道具", value = 0, hide = true},
  60. },
  61. },
  62. {
  63. forbidVoice = {
  64. {name = "屏蔽聊天", value = 1},
  65. {name = "屏蔽聊天", value = 0, hide = true},
  66. },
  67. }
  68. }
  69. wanfa.clubWanFaTitle = {
  70. playnum = "玩家人数",
  71. deductRule = "房费",
  72. highLimit = "封顶",
  73. specialRule = "玩法",
  74. scoreNum = "分数",
  75. baseMulti="积分倍数",
  76. forbidProp="其他",
  77. forbidVoice="其他",
  78. }
  79. wanfa.score1 = {
  80. [1] = "1/2/3",
  81. [5] = "5/10/15",
  82. [10] = "10/20/30",
  83. }
  84. wanfa.ruleStr = ""
  85. wanfa.RuleText =
  86. {
  87. --[1] =
  88. {
  89. title = "基础规则",
  90. content =
  91. {
  92. "1、用牌:小写“一”到“十”各4张,大写“壹”到“拾”各4张,共80张牌;其中“二七十”和“贰柒拾”为红色牌,其余为黑色牌。",
  93. "2、砌牌:大贰一般4人同玩,其中1人坐底。庄家摸21张,闲家摸20张,留19张在墩上。",
  94. "3、定庄:首局随机选庄,之后谁胡牌谁坐庄。",
  95. },
  96. },
  97. --[2] =
  98. --[[{
  99. title = "牌型介绍",
  100. content =
  101. {
  102. "1、一将牌:洗牌后,手中2个相同的牌为1对。",
  103. "2、一坎牌:洗牌后,手中3个相同的牌为1坎。",
  104. "3、一拢牌:洗牌后,手中4个相同的牌为拢。",
  105. "4、一列牌:砌牌后,手中的牌依据规则组合成相连的牌。",
  106. }
  107. },
  108. --[3] =
  109. {
  110. title = "玩法介绍",
  111. content =
  112. {
  113. "1、拢牌:拢牌为起手20张牌时,系统自动拢牌。",
  114. "2、招牌:游戏中,别人打或摸的牌与自己手中一坎牌相同时,则可招牌。",
  115. "3、碰牌:游戏中,别人打或摸的牌与自己手中一对牌相同时,则可碰牌。",
  116. "4、八块:当招或拢牌超过1次时,称为八块,此时不用从手中打牌出去,而是下家摸牌。",
  117. "5、吃牌:自己摸的或者上家出的牌,无人碰或招时,则可以与自己手中的牌组合成一列牌,称为吃牌。",
  118. "6、比牌:当吃的该牌与手中有相同牌时,必须要将手中的这张牌也根据某种组合起来,井将这2个组合的牌都放到桌上,称为比牌。",
  119. "7、过张:能吃却没有吃的牌,称为过张。",
  120. "8、进张:每进1张,必须打出1张,八块除外。",
  121. "9、爆牌:当砌牌后手中6列牌全部组合完毕,只差组成最后一列或1对时可以爆牌。",
  122. "10、胡牌:满足以下条件可以胡牌。",
  123. "(1)至少有10胡,或者0胡(无胡)。",
  124. "(2)手中的与放于桌上的牌组合完毕,而且有7列牌。",
  125. "11、荒庄:底牌都发完后却没人可胡牌时,则荒庄。",
  126. "12、圈:系统随机圈,大小贰柒拾任意一张,胡牌玩家手上有三个则为圈。",
  127. }
  128. },--]]
  129. }
  130. --获取茶馆玩法规则
  131. function wanfa.getClubRuleInfo(ruleStr)
  132. if not ruleStr then
  133. ruleStr = app.room.roomInfo.strGameInfo
  134. end
  135. local strGameInfo = json.decode(ruleStr)
  136. local temp = {}
  137. wanfa.ruleStr = ""
  138. for k,v in ipairs(wanfa) do
  139. for serverKey,serverValue in pairs(strGameInfo) do
  140. if v[serverKey] then
  141. if v.isAndOr then
  142. for i,data in ipairs(v[serverKey]) do
  143. if not data.hide then
  144. if getNumBand(serverValue,data.value) > 0 then
  145. table.insert(temp,{name=wanfa.clubWanFaTitle[serverKey] or "",value={data.name}})
  146. wanfa.ruleStr = wanfa.ruleStr..data.name.." "
  147. end
  148. end
  149. end
  150. else
  151. for i,data in ipairs(v[serverKey]) do
  152. if serverKey == "baseMulti" then
  153. table.insert(temp,{name=wanfa.clubWanFaTitle[serverKey] or "",value={data.name .. serverValue}})
  154. wanfa.ruleStr = wanfa.ruleStr..data.name .. serverValue .. " "
  155. break;
  156. end
  157. if serverValue == data.value and not data.hide then
  158. table.insert(temp,{name=wanfa.clubWanFaTitle[serverKey] or "",value={data.name}})
  159. wanfa.ruleStr = wanfa.ruleStr..data.name.." "
  160. break
  161. end
  162. end
  163. end
  164. break;
  165. end
  166. end
  167. end
  168. return temp,wanfa.ruleStr
  169. end
  170. --获取玩法规则
  171. function wanfa.getRuleInfo(ruleStr)
  172. if wanfa.ruleStr ~= "" then
  173. return wanfa.ruleStr;
  174. else
  175. local temp,tempStr = wanfa.getClubRuleInfo(ruleStr)
  176. return tempStr;
  177. end
  178. end
  179. function wanfa.getClubTableWanFaInfo(ruleStr)
  180. local strGameInfo = json.decode(ruleStr)
  181. local temp = ""
  182. for serverKey,serverValue in pairs(strGameInfo) do
  183. if serverKey == "highLimit" then
  184. for k,v in ipairs(wanfa) do
  185. if v[serverKey] then
  186. if v.isAndOr then
  187. for i,data in ipairs(v[serverKey]) do
  188. if getNumBand(serverValue,data.value) > 0 then
  189. temp = data.name.." "
  190. end
  191. end
  192. else
  193. for i,data in ipairs(v[serverKey]) do
  194. if serverKey == "baseMulti" then
  195. table.insert(temp,{name=wanfa.clubWanFaTitle[serverKey] or "",value={data.name .. serverValue}})
  196. temp = temp .. wanfa.clubWanFaTitle[serverKey] .. data.name .. serverValue .. " "
  197. break;
  198. end
  199. if serverValue == data.value then
  200. if serverValue == 0 then
  201. temp = data.name.." "
  202. else
  203. temp = wanfa.clubWanFaTitle[serverKey]..data.name.." "
  204. end
  205. break
  206. end
  207. end
  208. end
  209. break
  210. end
  211. end
  212. break
  213. end
  214. end
  215. for serverKey,serverValue in pairs(strGameInfo) do
  216. if serverKey == "scoreNum" then
  217. if serverValue >=0 and wanfa.score1[serverValue] then
  218. temp = temp..wanfa.score1[serverValue]
  219. end
  220. end
  221. end
  222. return temp
  223. end
  224. ---
  225. -- 获取亲友圈玩法
  226. -- @param gameId
  227. -- @param jushu
  228. -- @param ruleStr
  229. -- @param arena
  230. -- @return
  231. --
  232. function wanfa.getRuleFromString (gameId, jushu, ruleStr,arena)
  233. local str = wanfa.getClubRuleInfo(ruleStr, jushu)
  234. return str
  235. end
  236. ---
  237. -- 获取包间多玩法桌子上显示的信息
  238. -- @param gameId
  239. -- @param ruleStr
  240. -- @param playerNum
  241. -- @return
  242. --
  243. function wanfa.getClubTableRuleString (gameId, ruleStr, playerNum)
  244. local str = ""
  245. local jsonData=json.decode(ruleStr)
  246. if jsonData.startMode == 1 then
  247. str = "快速成局 "
  248. else
  249. if jsonData.playerNum == 2 then
  250. str = str .. "快速成局 "
  251. else
  252. str = tostring(playerNum) .. "人 "
  253. end
  254. end
  255. local wanfaStr = wanfa.getClubTableWanFaInfo(ruleStr)
  256. str = str .. wanfaStr
  257. return str
  258. end
  259. return wanfa