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.

299 lines
8.2 KiB

  1. -- local Functions = DeepCopy(require("pk.luaScript.pkFunctions"))
  2. local Functions = {}
  3. local defs = require("pk_erdoudizhu.luaScript.Def_ERDouDiZhu")
  4. local define = require("luaScript.SubGameDefine.Poker.Define_ERDouDiZhu")
  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. elseif k == 'specialRule' then
  47. ruleStr = ruleStr .. ' ' .. define.getSpecialRuleString(v)
  48. else
  49. local rule = define.GAME_RULE["" .. k]["" .. v]
  50. if rule then
  51. if string.len(ruleStr) > 0 then
  52. ruleStr = ruleStr .. " " .. rule
  53. else
  54. ruleStr = ruleStr .. rule
  55. end
  56. end
  57. end
  58. end
  59. end
  60. end
  61. end
  62. logE("当前房间的规则:"..ruleStr)
  63. return ruleStr
  64. end
  65. -- 俱乐部邀请规则
  66. function Functions.getRuleStrByClubInvite(roomListData)
  67. local temp = ""
  68. local jsonInfo = nil
  69. if roomListData then
  70. jsonInfo = roomListData
  71. else
  72. jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  73. end
  74. local roundCount = app.room.roomInfo.nTotalGameNum
  75. if roundCount then
  76. temp = temp .. roundCount .. "局"
  77. end
  78. temp = temp .. ' ' .. '二人斗地主'
  79. -- if jsonInfo.gamerule then
  80. -- if tonumber(jsonInfo.gamerule) == 0 then
  81. -- temp = temp.."经典斗地主 "
  82. -- elseif tonumber(jsonInfo.gamerule) == 1 then
  83. -- temp = temp.."不洗牌斗地主 "
  84. -- end
  85. -- end
  86. -- if jsonInfo.multLimit and tonumber(jsonInfo.multLimit) >= 0 then
  87. -- local multLimit = jsonInfo.multLimit
  88. -- if multLimit == 0 then
  89. -- temp = temp.."不限倍数 "
  90. -- else
  91. -- temp = temp..multLimit.."倍 "
  92. -- end
  93. -- end
  94. -- if jsonInfo.piaoType and tonumber(jsonInfo.piaoType) >= 0 then
  95. -- local piaoType = jsonInfo.piaoType
  96. -- if piaoType == 0 then
  97. -- temp = temp.."不飘"
  98. -- else
  99. -- temp = temp.."飘"..piaoType.."分"
  100. -- end
  101. -- end
  102. return temp
  103. end
  104. --音乐
  105. function Functions.playMusic()
  106. playBGMusic("BG_Room_DouDiZhu", "pk_erdoudizhu/res/sound/doudizhu_bg.ogg")
  107. end
  108. --播放行为操作音效
  109. function Functions.playVoice(type, value, sex)
  110. local voiceName = ""
  111. if type == "common" then
  112. voiceName = ("" .. value) or ""
  113. playVoice(voiceName)
  114. return
  115. end
  116. --语言
  117. local languagePath = ""
  118. if Functions.getCurLanguage() == defs.LANGUAGE_TYPE.PU_TONG_HUA then
  119. if tonumber(sex) == 2 then
  120. languagePath = "pk_erdoudizhu/res/sound/language/putonghua"
  121. else
  122. -- languagePath = "pk/res/sound/language/putonghua"
  123. languagePath = "pk_erdoudizhu/res/sound/language/putonghua"
  124. end
  125. else
  126. languagePath = "pk_erdoudizhu/res/sound/language/fangyan"
  127. end
  128. --性别
  129. local sexPath = ""
  130. local tag = 'pk_'
  131. if tonumber(sex) == 2 then
  132. sexPath = "woman"
  133. tag = 'ddz_'
  134. else
  135. sexPath = "man"
  136. -- tag = 'pk_'
  137. tag = 'ddz_'
  138. end
  139. --具体
  140. local typePath = ""
  141. if type == "jiaofen" then --叫分
  142. typePath = tag.. "score_".. sexPath .. "_" .. (value or 0)
  143. elseif type == "jiaodizhu" then
  144. if value == 0 then
  145. typePath = tag.. "score_".. sexPath.. "_0"
  146. else
  147. typePath = tag.. "jiaodizhu_".. sexPath
  148. end
  149. elseif type == "qiangdizhu" then
  150. if value == 0 then
  151. typePath = tag.. "qiangdizhu_".. sexPath .. "_0"
  152. else
  153. typePath = tag.. "qiangdizhu_".. sexPath .. "_" .. math.random(1, 3)
  154. end
  155. elseif type == "jiabei" then --加倍
  156. typePath = tag.. "jiabei_".. sexPath .. "_" .. (value or 0)
  157. elseif type == "buyao" then --要不起
  158. typePath = tag.. "buyao_".. sexPath .. "_" .. math.random(1, 4)
  159. elseif type == "chupai" then --出牌
  160. if value.cardType == defs.CARD_TYPE.SINGLE then --单张
  161. typePath = tag.. "".. sexPath .. "_" .. value.min
  162. elseif value.cardType == defs.CARD_TYPE.DUIZI then --对子
  163. typePath = tag.. "dui_".. sexPath .. "_" .. value.min
  164. elseif value.cardType == defs.CARD_TYPE.SANZHANG then --三张
  165. typePath = tag.. "tuple_".. sexPath .. "_" .. value.min
  166. elseif value.cardType == defs.CARD_TYPE.SHUNZI then --顺子
  167. typePath = tag.. "shunzi_".. sexPath
  168. elseif value.cardType == defs.CARD_TYPE.SHUANGSHUN then --连对
  169. typePath = tag.. "liandui_".. sexPath
  170. elseif value.cardType == defs.CARD_TYPE.SANSHUN then --三顺
  171. typePath = tag.. "feiji_".. sexPath
  172. elseif value.cardType == defs.CARD_TYPE.SANDAIYI then --三带一
  173. typePath = tag.. "sandaiyi_".. sexPath
  174. elseif value.cardType == defs.CARD_TYPE.SANDAIDUI then --三带一对
  175. typePath = tag.. "sandaiyidui_".. sexPath
  176. elseif value.cardType == defs.CARD_TYPE.AIRPLANE_SINGLE or value.cardType == defs.CARD_TYPE.AIRPLANE_DUAD then --飞机
  177. typePath = tag.. "feiji_".. sexPath
  178. playVoice("pk_erdoudizhu/res/sound/doudizhu_common_feiji.ogg")
  179. elseif value.cardType == defs.CARD_TYPE.SIDAIER then --四带二
  180. typePath = tag.. "sidaier_".. sexPath
  181. elseif value.cardType == defs.CARD_TYPE.SIDAIERDUI then --四带两对
  182. typePath = tag.. "sidailiangdui_".. sexPath
  183. elseif value.cardType == defs.CARD_TYPE.BOMB then --炸弹
  184. typePath = tag.. "zhadan_".. sexPath
  185. playVoice("pk_erdoudizhu/res/sound/doudizhu_common_bomb.ogg")
  186. elseif value.cardType == defs.CARD_TYPE.BOMB_KING then --王炸
  187. typePath = tag.. "wangzha_".. sexPath
  188. playVoice("pk_erdoudizhu/res/sound/doudizhu_common_bomb.ogg")
  189. end
  190. end
  191. voiceName = languagePath .. "/" .. sexPath .. "/" .. typePath .. ".ogg"
  192. if voiceName ~= "" then
  193. playVoice(voiceName)
  194. end
  195. end
  196. -- 播放剩余牌
  197. function Functions.playLastNumVoice(lastNum, sex)
  198. do
  199. return
  200. end
  201. if lastNum < 1 or lastNum > 2 then -- 剩余1,2张
  202. return
  203. end
  204. local sexPath = 'man'
  205. if tonumber(sex) == 2 then
  206. sexPath = "woman"
  207. else
  208. sexPath = "man"
  209. end
  210. local voiceName = string.format('pk_erdoudizhu/res/sound/language/putonghua/%s/ddz_%s_baojing_%s.ogg', sexPath, sexPath, lastNum)
  211. playVoice(voiceName)
  212. end
  213. -- 是否勾选了禁止使用道具和语音选项
  214. function Functions.getIsForbidVoiceAndProp()
  215. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  216. if getNumBand(0x01, gameInfo.extPlay or 0x00) > 0 then
  217. return true
  218. end
  219. return false
  220. end
  221. function Functions.getIsForbidFace()
  222. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  223. if getNumBand(0x01, gameInfo.forbidProp or 0x00) > 0 then
  224. return true
  225. end
  226. return false
  227. end
  228. function Functions.getIsForbidVoice()
  229. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  230. if getNumBand(0x01, gameInfo.forbidVoice or 0x00) > 0 then
  231. return true
  232. end
  233. return false
  234. end
  235. -- 是否勾选了加倍阶段10s不操作则默认不加倍
  236. function Functions.getIsAutoAskBeiAfterTimeout()
  237. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  238. if getNumBand(0x08, gameInfo.extPlay or 0x00) > 0 then
  239. return true
  240. end
  241. return false
  242. end
  243. -- 当前游戏模式(1 叫地主, 2 叫分)
  244. function Functions.getGameMode()
  245. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  246. return tonumber(gameInfo.playMode) or 0
  247. end
  248. -- 当前让牌数
  249. function Functions.getRangCount()
  250. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  251. return tonumber(gameInfo.rangPai)
  252. end
  253. -- 当前最大倍数
  254. function Functions.getMaxMult()
  255. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  256. return tonumber(gameInfo.scoreLimit)
  257. end
  258. return Functions