Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

257 righe
7.2 KiB

  1. -- local Functions = DeepCopy(require("pk.luaScript.pkFunctions"))
  2. local Functions = {}
  3. local defs = require("pk_doudizhu.luaScript.Def_28")
  4. local define = require("luaScript.SubGameDefine.Poker.Define_28")
  5. --获取当前版本号
  6. Functions.getCurVersion = function()
  7. local versionInfo = require("Version" .. app.gameId)
  8. return versionInfo.ResourceVersion
  9. end
  10. --获取当前玩法
  11. Functions.getCurGameRule = function()
  12. local roomInfo = app.room.roomInfo;
  13. local jsonInfo = json.decode(roomInfo.strGameInfo)
  14. if jsonInfo then
  15. return jsonInfo.gamerule
  16. end
  17. return nil
  18. end
  19. --获取默认背景
  20. Functions.getDefaultBg = function()
  21. return tonumber(loadUserInfo("GameBgPicture" .. app.gameId)) or getSubGameConfig(app.gameId).defaultBgIdx or 1
  22. end
  23. --设置当前语言
  24. Functions.setCurLanguage = function(language)
  25. Functions.curLanguage = language
  26. end
  27. --获取当前玩法
  28. Functions.getCurLanguage = function()
  29. return Functions.curLanguage or defs.LANGUAGE_TYPE.PU_TONG_HUA
  30. end
  31. -- 以上是原先基类pkFunctions内容 ------------------------------------------------------------------------------
  32. function Functions.getRuleStr(roomListData)
  33. local ruleStr = ""
  34. local jsonInfo = nil
  35. if roomListData then
  36. jsonInfo = roomListData
  37. else
  38. jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  39. end
  40. if jsonInfo then
  41. if jsonInfo.gamerule then
  42. for k,v in pairs(jsonInfo) do
  43. if define.GAME_RULE["" .. k] then
  44. if k == "baseMulti" then
  45. ruleStr = ruleStr .. " " .. define.GAME_RULE.baseMulti["1"] .. v
  46. else
  47. local rule = define.GAME_RULE["" .. k]["" .. v]
  48. if rule then
  49. if string.len(ruleStr) > 0 then
  50. ruleStr = ruleStr .. " " .. rule
  51. else
  52. ruleStr = ruleStr .. rule
  53. end
  54. end
  55. end
  56. end
  57. end
  58. end
  59. end
  60. logE("当前房间的规则:"..ruleStr)
  61. return ruleStr
  62. end
  63. -- 俱乐部邀请规则
  64. function Functions.getRuleStrByClubInvite(roomListData)
  65. local temp = ""
  66. local jsonInfo = nil
  67. if roomListData then
  68. jsonInfo = roomListData
  69. else
  70. jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  71. end
  72. local roundCount = app.room.roomInfo.nTotalGameNum
  73. if roundCount then
  74. temp = temp .. roundCount .. "局"
  75. end
  76. if jsonInfo.gamerule then
  77. if tonumber(jsonInfo.gamerule) == 0 then
  78. temp = temp.."经典斗地主 "
  79. elseif tonumber(jsonInfo.gamerule) == 1 then
  80. temp = temp.."不洗牌斗地主 "
  81. end
  82. end
  83. -- if jsonInfo.multLimit and tonumber(jsonInfo.multLimit) >= 0 then
  84. -- local multLimit = jsonInfo.multLimit
  85. -- if multLimit == 0 then
  86. -- temp = temp.."不限倍数 "
  87. -- else
  88. -- temp = temp..multLimit.."倍 "
  89. -- end
  90. -- end
  91. -- if jsonInfo.piaoType and tonumber(jsonInfo.piaoType) >= 0 then
  92. -- local piaoType = jsonInfo.piaoType
  93. -- if piaoType == 0 then
  94. -- temp = temp.."不飘"
  95. -- else
  96. -- temp = temp.."飘"..piaoType.."分"
  97. -- end
  98. -- end
  99. return temp
  100. end
  101. --音乐
  102. function Functions.playMusic()
  103. playBGMusic("BG_Room_DouDiZhu", "pk_doudizhu/res/sound/doudizhu_bg.ogg")
  104. end
  105. --播放行为操作音效
  106. function Functions.playVoice(type, value, sex)
  107. local voiceName = ""
  108. if type == "common" then
  109. voiceName = ("" .. value) or ""
  110. playVoice(voiceName)
  111. return
  112. end
  113. --语言
  114. local languagePath = ""
  115. if Functions.getCurLanguage() == defs.LANGUAGE_TYPE.PU_TONG_HUA then
  116. if tonumber(sex) == 2 then
  117. languagePath = "pk_doudizhu/res/sound/language/putonghua"
  118. else
  119. -- languagePath = "pk/res/sound/language/putonghua"
  120. languagePath = "pk_doudizhu/res/sound/language/putonghua"
  121. end
  122. else
  123. languagePath = "pk_doudizhu/res/sound/language/fangyan"
  124. end
  125. --性别
  126. local sexPath = ""
  127. local tag = 'pk_'
  128. if tonumber(sex) == 2 then
  129. sexPath = "woman"
  130. tag = 'ddz_'
  131. else
  132. sexPath = "man"
  133. -- tag = 'pk_'
  134. tag = 'ddz_'
  135. end
  136. --具体
  137. local typePath = ""
  138. if type == "jiaofen" then --叫分
  139. typePath = tag.. "score_".. sexPath .. "_" .. (value or 0)
  140. elseif type == "jiabei" then --加倍
  141. typePath = tag.. "jiabei_".. sexPath .. "_" .. (value or 0)
  142. elseif type == "buyao" then --要不起
  143. typePath = tag.. "buyao_".. sexPath .. "_" .. math.random(1, 4)
  144. elseif type == "chupai" then --出牌
  145. if value.cardType == defs.CARD_TYPE.SINGLE then --单张
  146. typePath = tag.. "".. sexPath .. "_" .. value.min
  147. elseif value.cardType == defs.CARD_TYPE.DUIZI then --对子
  148. typePath = tag.. "dui_".. sexPath .. "_" .. value.min
  149. elseif value.cardType == defs.CARD_TYPE.SANZHANG then --三张
  150. typePath = tag.. "tuple_".. sexPath .. "_" .. value.min
  151. elseif value.cardType == defs.CARD_TYPE.SHUNZI then --顺子
  152. typePath = tag.. "shunzi_".. sexPath
  153. elseif value.cardType == defs.CARD_TYPE.SHUANGSHUN then --连对
  154. typePath = tag.. "liandui_".. sexPath
  155. elseif value.cardType == defs.CARD_TYPE.SANSHUN then --三顺
  156. typePath = tag.. "feiji_".. sexPath
  157. elseif value.cardType == defs.CARD_TYPE.SANDAIYI then --三带一
  158. typePath = tag.. "sandaiyi_".. sexPath
  159. elseif value.cardType == defs.CARD_TYPE.SANDAIDUI then --三带一对
  160. typePath = tag.. "sandaiyidui_".. sexPath
  161. elseif value.cardType == defs.CARD_TYPE.AIRPLANE_SINGLE or value.cardType == defs.CARD_TYPE.AIRPLANE_DUAD then --飞机
  162. typePath = tag.. "feiji_".. sexPath
  163. playVoice("pk_doudizhu/res/sound/doudizhu_common_feiji.ogg")
  164. elseif value.cardType == defs.CARD_TYPE.SIDAIER then --四带二
  165. typePath = tag.. "sidaier_".. sexPath
  166. elseif value.cardType == defs.CARD_TYPE.SIDAIERDUI then --四带两对
  167. typePath = tag.. "sidailiangdui_".. sexPath
  168. elseif value.cardType == defs.CARD_TYPE.BOMB then --炸弹
  169. typePath = tag.. "zhadan_".. sexPath
  170. playVoice("pk_doudizhu/res/sound/doudizhu_common_bomb.ogg")
  171. elseif value.cardType == defs.CARD_TYPE.BOMB_KING then --王炸
  172. typePath = tag.. "wangzha_".. sexPath
  173. playVoice("pk_doudizhu/res/sound/doudizhu_common_bomb.ogg")
  174. end
  175. end
  176. voiceName = languagePath .. "/" .. sexPath .. "/" .. typePath .. ".ogg"
  177. if voiceName ~= "" then
  178. playVoice(voiceName)
  179. end
  180. end
  181. -- 播放剩余牌
  182. function Functions.playLastNumVoice(lastNum, sex)
  183. if lastNum < 1 or lastNum > 2 then -- 剩余1,2张
  184. return
  185. end
  186. local sexPath = 'man'
  187. if tonumber(sex) == 2 then
  188. sexPath = "woman"
  189. else
  190. sexPath = "man"
  191. end
  192. local voiceName = string.format('pk_doudizhu/res/sound/language/putonghua/%s/ddz_%s_baojing_%s.ogg', sexPath, sexPath, lastNum)
  193. playVoice(voiceName)
  194. end
  195. -- 是否勾选了禁止使用道具和语音选项
  196. function Functions.getIsForbidVoiceAndProp()
  197. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  198. if getNumBand(0x01, gameInfo.extPlay or 0x00) > 0 then
  199. return true
  200. end
  201. return false
  202. end
  203. function Functions.getIsForbidFace()
  204. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  205. if getNumBand(0x01, gameInfo.forbidProp or 0x00) > 0 then
  206. return true
  207. end
  208. return false
  209. end
  210. function Functions.getIsForbidVoice()
  211. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  212. if getNumBand(0x01, gameInfo.forbidVoice or 0x00) > 0 then
  213. return true
  214. end
  215. return false
  216. end
  217. -- 是否勾选了加倍阶段10s不操作则默认不加倍
  218. function Functions.getIsAutoAskBeiAfterTimeout()
  219. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  220. if getNumBand(0x08, gameInfo.extPlay or 0x00) > 0 then
  221. return true
  222. end
  223. return false
  224. end
  225. return Functions