-- local Functions = DeepCopy(require("pk.luaScript.pkFunctions")) local Functions = {} local defs = require("pk_nanchongdoudizhu.luaScript.Def_53") local define = require("luaScript.SubGameDefine.Poker.Define_53") --获取当前版本号 Functions.getCurVersion = function() local versionInfo = require("Version" .. app.gameId) return versionInfo.ResourceVersion end --获取当前玩法 Functions.getCurGameRule = function() local roomInfo = app.room.roomInfo; local jsonInfo = json.decode(roomInfo.strGameInfo) if jsonInfo then return jsonInfo.gamerule end return nil end --获取默认背景 Functions.getDefaultBg = function() return tonumber(loadUserInfo("GameBgPicture" .. app.gameId)) or getSubGameConfig(app.gameId).defaultBgIdx or 1 end --设置当前语言 Functions.setCurLanguage = function(language) Functions.curLanguage = language end --获取当前玩法 Functions.getCurLanguage = function() return Functions.curLanguage or defs.LANGUAGE_TYPE.PU_TONG_HUA end -- 以上是原先基类pkFunctions内容 ------------------------------------------------------------------------------ function Functions.getRuleStr(roomListData) local ruleStr = "" local jsonInfo = nil if roomListData then jsonInfo = roomListData else jsonInfo = json.decode(app.room.roomInfo.strGameInfo) end if jsonInfo then if jsonInfo.gamerule then for k,v in pairs(jsonInfo) do if define.GAME_RULE["" .. k] then if k == "baseMulti" then ruleStr = ruleStr .. " " .. define.GAME_RULE.baseMulti["1"] .. v else local rule = define.GAME_RULE["" .. k]["" .. v] if rule then if string.len(ruleStr) > 0 then ruleStr = ruleStr .. " " .. rule else ruleStr = ruleStr .. rule end end end end end end end logE("当前房间的规则:"..ruleStr) return ruleStr end -- 判断是否勾选了癞子玩法 function Functions.getRuleIncludeLzWanFa() if not app.room then return true end local jsonInfo = json.decode(app.room.roomInfo.strGameInfo) if jsonInfo and jsonInfo.playRule then if getNumBand(tonumber(jsonInfo.playRule), 0x01) > 0 then return true end end return false end -- 判断是否勾选了定飘玩法 function Functions.getRuleIncludeDingPiaoWanFa() if not app.room then return true end local jsonInfo = json.decode(app.room.roomInfo.strGameInfo) if jsonInfo and jsonInfo.piaoType then if tonumber(jsonInfo.piaoType) == 2 then return true end end return false end -- 判断是否勾选了屏蔽聊天互动玩法 function Functions.getRuleIncludeNotChatPlayWanFa() if not app.room then return true end local gameInfo = json.decode(app.room.roomInfo.strGameInfo) if gameInfo and gameInfo.playRule then if getNumBand(0x08, gameInfo.playRule or 0x00) > 0 then return true end end return false end -- 俱乐部邀请规则 function Functions.getRuleStrByClubInvite(roomListData) local temp = "" local jsonInfo = nil if roomListData then jsonInfo = roomListData else jsonInfo = json.decode(app.room.roomInfo.strGameInfo) end temp = temp .. string.format('%d局 ', app.room.roomInfo.nTotalGameNum) if jsonInfo.gamerule then temp = temp.."南充斗地主 " end -- if jsonInfo.multLimit and tonumber(jsonInfo.multLimit) >= 0 then -- local multLimit = jsonInfo.multLimit -- temp = temp ..'封顶'.. define.GAME_RULE.multLimit[''..multLimit]..' ' -- end -- if jsonInfo.piaoType and tonumber(jsonInfo.piaoType) >= 0 then -- local piaoType = jsonInfo.piaoType -- temp = temp .. define.GAME_RULE.piaoType[''..piaoType]..' ' -- end return temp end --音乐 function Functions.playMusic(idx) stopBGMusic() if idx == defs.BGM_CHOOSE_TYPE.HUAN_KUAI then playBGMusic("BG_Room_DouDiZhu", "pk_nanchongdoudizhu/res/sound/doudizhu_bg_huankuai.ogg") elseif idx == defs.BGM_CHOOSE_TYPE.JING_DIAN then playBGMusic("BG_Room_DouDiZhu", "pk_nanchongdoudizhu/res/sound/doudizhu_bg_jingdian.ogg") end end --播放行为操作音效 function Functions.playVoice(type, value, sex) local voiceName = "" if type == "common" then voiceName = ("" .. value) or "" playVoice(voiceName) return end --语言 local languagePath = "" if Functions.getCurLanguage() == defs.LANGUAGE_TYPE.PU_TONG_HUA then if tonumber(sex) == 2 then languagePath = "pk_nanchongdoudizhu/res/sound/language/putonghua" else -- languagePath = "pk/res/sound/language/putonghua" languagePath = "pk_nanchongdoudizhu/res/sound/language/putonghua" end else languagePath = "pk_nanchongdoudizhu/res/sound/language/fangyan" end --性别 local sexPath = "" local tag = 'pk_' if tonumber(sex) == 2 then sexPath = "woman" tag = 'ddz_' else sexPath = "man" -- tag = 'pk_' tag = 'ddz_' end --具体 local typePath = "" if type == "jiaofen" then --叫分 -- typePath = tag.. "score_".. sexPath .. "_" .. (value or 0) if value > 0 then typePath = tag.. "jiaodizhu_".. sexPath else typePath = tag.. "bujiao_".. sexPath end elseif type == 'dao' then typePath = tag.. "dao_".. sexPath elseif type == 'la' then typePath = tag.. "la_".. sexPath elseif type == "jiabei" then --加倍 typePath = tag.. "jiabei_".. sexPath .. "_" .. (value or 0) elseif type == 'piao' then typePath = tag.. "piao_".. sexPath elseif type == 'bupiao' then typePath = tag.. "bupiao_".. sexPath elseif type == "buyao" then --要不起 typePath = tag.. "buyao_".. sexPath .. "_" .. math.random(1, 4) elseif type == "chupai" then --出牌 if value.cardType == defs.CARD_TYPE.SINGLE then --单张 typePath = tag.. "".. sexPath .. "_" .. value.min elseif value.cardType == defs.CARD_TYPE.DUIZI then --对子 typePath = tag.. "dui_".. sexPath .. "_" .. value.min elseif value.cardType == defs.CARD_TYPE.SANZHANG then --三张 typePath = tag.. "tuple_".. sexPath .. "_" .. value.min elseif value.cardType == defs.CARD_TYPE.SHUNZI then --顺子 typePath = tag.. "shunzi_".. sexPath elseif value.cardType == defs.CARD_TYPE.SHUANGSHUN then --连对 typePath = tag.. "liandui_".. sexPath elseif value.cardType == defs.CARD_TYPE.SANSHUN then --三顺 typePath = tag.. "feiji_".. sexPath elseif value.cardType == defs.CARD_TYPE.SANDAIYI then --三带一 typePath = tag.. "sandaiyi_".. sexPath elseif value.cardType == defs.CARD_TYPE.SANDAIDUI then --三带一对 typePath = tag.. "sandaiyidui_".. sexPath elseif value.cardType == defs.CARD_TYPE.AIRPLANE_SINGLE or value.cardType == defs.CARD_TYPE.AIRPLANE_DUAD then --飞机 typePath = tag.. "feiji_".. sexPath playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_feiji.ogg") elseif value.cardType == defs.CARD_TYPE.SIDAIER then --四带二 typePath = tag.. "sidaier_".. sexPath elseif value.cardType == defs.CARD_TYPE.SIDAIERDUI then --四带两对 typePath = tag.. "sidailiangdui_".. sexPath elseif value.cardType == defs.CARD_TYPE.BOMB or (value.cardType == defs.CARD_TYPE.BOMB_LAIZI and #value.cards == 4) then --炸弹 typePath = tag.. "zhadan_".. sexPath playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_bomb.ogg") elseif value.cardType == defs.CARD_TYPE.BOMB_KING or (value.cardType == defs.CARD_TYPE.BOMB_LAIZI and #value.cards == 2) then --王炸 typePath = tag.. "wangzha_".. sexPath playVoice("pk_nanchongdoudizhu/res/sound/doudizhu_common_bomb.ogg") end end voiceName = languagePath .. "/" .. sexPath .. "/" .. typePath .. ".ogg" if voiceName ~= "" then playVoice(voiceName) end end -- 播放剩余牌 function Functions.playLastNumVoice(lastNum, sex) if lastNum < 1 or lastNum > 2 then -- 剩余1,2张 return end local sexPath = 'man' if tonumber(sex) == 2 then sexPath = "woman" else sexPath = "man" end local voiceName = string.format('pk_nanchongdoudizhu/res/sound/language/putonghua/%s/ddz_%s_baojing_%s.ogg', sexPath, sexPath, lastNum) playVoice(voiceName) end --- -- 是否勾选了禁止使用道具和语音选项 -- @return -- function Functions.isForbidProp () local gameInfo = json.decode(app.room.roomInfo.strGameInfo) local forbidProp = gameInfo.forbidProp or 0 return tonumber(forbidProp) > 0 end function Functions.isForbidVoice () local gameInfo = json.decode(app.room.roomInfo.strGameInfo) local forbidVoice = gameInfo.forbidVoice or 0 return tonumber(forbidVoice) > 0 end return Functions