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.

288 lines
8.2 KiB

  1. -- local Functions = DeepCopy(require("pk.luaScript.pkFunctions"))
  2. local Functions = {}
  3. local defs = require("pk_nanchongdoudizhu.luaScript.Def_53")
  4. local define = require("luaScript.SubGameDefine.Poker.Define_53")
  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.getRuleIncludeLzWanFa()
  65. if not app.room then
  66. return true
  67. end
  68. local jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  69. if jsonInfo and jsonInfo.playRule then
  70. if getNumBand(tonumber(jsonInfo.playRule), 0x01) > 0 then
  71. return true
  72. end
  73. end
  74. return false
  75. end
  76. -- 判断是否勾选了定飘玩法
  77. function Functions.getRuleIncludeDingPiaoWanFa()
  78. if not app.room then
  79. return true
  80. end
  81. local jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  82. if jsonInfo and jsonInfo.piaoType then
  83. if tonumber(jsonInfo.piaoType) == 2 then
  84. return true
  85. end
  86. end
  87. return false
  88. end
  89. -- 判断是否勾选了屏蔽聊天互动玩法
  90. function Functions.getRuleIncludeNotChatPlayWanFa()
  91. if not app.room then
  92. return true
  93. end
  94. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  95. if gameInfo and gameInfo.playRule then
  96. if getNumBand(0x08, gameInfo.playRule or 0x00) > 0 then
  97. return true
  98. end
  99. end
  100. return false
  101. end
  102. -- 俱乐部邀请规则
  103. function Functions.getRuleStrByClubInvite(roomListData)
  104. local temp = ""
  105. local jsonInfo = nil
  106. if roomListData then
  107. jsonInfo = roomListData
  108. else
  109. jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
  110. end
  111. temp = temp .. string.format('%d局 ', app.room.roomInfo.nTotalGameNum)
  112. if jsonInfo.gamerule then
  113. temp = temp.."南充斗地主 "
  114. end
  115. -- if jsonInfo.multLimit and tonumber(jsonInfo.multLimit) >= 0 then
  116. -- local multLimit = jsonInfo.multLimit
  117. -- temp = temp ..'封顶'.. define.GAME_RULE.multLimit[''..multLimit]..' '
  118. -- end
  119. -- if jsonInfo.piaoType and tonumber(jsonInfo.piaoType) >= 0 then
  120. -- local piaoType = jsonInfo.piaoType
  121. -- temp = temp .. define.GAME_RULE.piaoType[''..piaoType]..' '
  122. -- end
  123. return temp
  124. end
  125. --音乐
  126. function Functions.playMusic(idx)
  127. stopBGMusic()
  128. if idx == defs.BGM_CHOOSE_TYPE.HUAN_KUAI then
  129. playBGMusic("BG_Room_DouDiZhu", "pk_nanchongdoudizhu/res/sound/doudizhu_bg_huankuai.ogg")
  130. elseif idx == defs.BGM_CHOOSE_TYPE.JING_DIAN then
  131. playBGMusic("BG_Room_DouDiZhu", "pk_nanchongdoudizhu/res/sound/doudizhu_bg_jingdian.ogg")
  132. end
  133. end
  134. --播放行为操作音效
  135. function Functions.playVoice(type, value, sex)
  136. local voiceName = ""
  137. if type == "common" then
  138. voiceName = ("" .. value) or ""
  139. playVoice(voiceName)
  140. return
  141. end
  142. --语言
  143. local languagePath = ""
  144. if Functions.getCurLanguage() == defs.LANGUAGE_TYPE.PU_TONG_HUA then
  145. if tonumber(sex) == 2 then
  146. languagePath = "pk_nanchongdoudizhu/res/sound/language/putonghua"
  147. else
  148. -- languagePath = "pk/res/sound/language/putonghua"
  149. languagePath = "pk_nanchongdoudizhu/res/sound/language/putonghua"
  150. end
  151. else
  152. languagePath = "pk_nanchongdoudizhu/res/sound/language/fangyan"
  153. end
  154. --性别
  155. local sexPath = ""
  156. local tag = 'pk_'
  157. if tonumber(sex) == 2 then
  158. sexPath = "woman"
  159. tag = 'ddz_'
  160. else
  161. sexPath = "man"
  162. -- tag = 'pk_'
  163. tag = 'ddz_'
  164. end
  165. --具体
  166. local typePath = ""
  167. if type == "jiaofen" then --叫分
  168. -- typePath = tag.. "score_".. sexPath .. "_" .. (value or 0)
  169. if value > 0 then
  170. typePath = tag.. "jiaodizhu_".. sexPath
  171. else
  172. typePath = tag.. "bujiao_".. sexPath
  173. end
  174. elseif type == 'dao' then
  175. typePath = tag.. "dao_".. sexPath
  176. elseif type == 'la' then
  177. typePath = tag.. "la_".. sexPath
  178. elseif type == "jiabei" then --加倍
  179. typePath = tag.. "jiabei_".. sexPath .. "_" .. (value or 0)
  180. elseif type == 'piao' then
  181. typePath = tag.. "piao_".. sexPath
  182. elseif type == 'bupiao' then
  183. typePath = tag.. "bupiao_".. sexPath
  184. elseif type == "buyao" then --要不起
  185. typePath = tag.. "buyao_".. sexPath .. "_" .. math.random(1, 4)
  186. elseif type == "chupai" then --出牌
  187. if value.cardType == defs.CARD_TYPE.SINGLE then --单张
  188. typePath = tag.. "".. sexPath .. "_" .. value.min
  189. elseif value.cardType == defs.CARD_TYPE.DUIZI then --对子
  190. typePath = tag.. "dui_".. sexPath .. "_" .. value.min
  191. elseif value.cardType == defs.CARD_TYPE.SANZHANG then --三张
  192. typePath = tag.. "tuple_".. sexPath .. "_" .. value.min
  193. elseif value.cardType == defs.CARD_TYPE.SHUNZI then --顺子
  194. typePath = tag.. "shunzi_".. sexPath
  195. elseif value.cardType == defs.CARD_TYPE.SHUANGSHUN then --连对
  196. typePath = tag.. "liandui_".. sexPath
  197. elseif value.cardType == defs.CARD_TYPE.SANSHUN then --三顺
  198. typePath = tag.. "feiji_".. sexPath
  199. elseif value.cardType == defs.CARD_TYPE.SANDAIYI then --三带一
  200. typePath = tag.. "sandaiyi_".. sexPath
  201. elseif value.cardType == defs.CARD_TYPE.SANDAIDUI then --三带一对
  202. typePath = tag.. "sandaiyidui_".. sexPath
  203. elseif value.cardType == defs.CARD_TYPE.AIRPLANE_SINGLE or value.cardType == defs.CARD_TYPE.AIRPLANE_DUAD then --飞机
  204. typePath = tag.. "feiji_".. sexPath
  205. playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_feiji.ogg")
  206. elseif value.cardType == defs.CARD_TYPE.SIDAIER then --四带二
  207. typePath = tag.. "sidaier_".. sexPath
  208. elseif value.cardType == defs.CARD_TYPE.SIDAIERDUI then --四带两对
  209. typePath = tag.. "sidailiangdui_".. sexPath
  210. elseif value.cardType == defs.CARD_TYPE.BOMB or (value.cardType == defs.CARD_TYPE.BOMB_LAIZI and #value.cards == 4) then --炸弹
  211. typePath = tag.. "zhadan_".. sexPath
  212. playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_bomb.ogg")
  213. elseif value.cardType == defs.CARD_TYPE.BOMB_KING or (value.cardType == defs.CARD_TYPE.BOMB_LAIZI and #value.cards == 2) then --王炸
  214. typePath = tag.. "wangzha_".. sexPath
  215. playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_bomb.ogg")
  216. end
  217. end
  218. voiceName = languagePath .. "/" .. sexPath .. "/" .. typePath .. ".ogg"
  219. if voiceName ~= "" then
  220. playVoice(voiceName)
  221. end
  222. end
  223. -- 播放剩余牌
  224. function Functions.playLastNumVoice(lastNum, sex)
  225. if lastNum < 1 or lastNum > 2 then -- 剩余1,2张
  226. return
  227. end
  228. local sexPath = 'man'
  229. if tonumber(sex) == 2 then
  230. sexPath = "woman"
  231. else
  232. sexPath = "man"
  233. end
  234. local voiceName = string.format('pk_nanchongdoudizhu/res/sound/language/putonghua/%s/ddz_%s_baojing_%s.ogg', sexPath, sexPath, lastNum)
  235. playVoice(voiceName)
  236. end
  237. ---
  238. -- 是否勾选了禁止使用道具和语音选项
  239. -- @return
  240. --
  241. function Functions.isForbidProp ()
  242. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  243. local forbidProp = gameInfo.forbidProp or 0
  244. return tonumber(forbidProp) > 0
  245. end
  246. function Functions.isForbidVoice ()
  247. local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
  248. local forbidVoice = gameInfo.forbidVoice or 0
  249. return tonumber(forbidVoice) > 0
  250. end
  251. return Functions