|
- -- local Functions = DeepCopy(require("pk.luaScript.pkFunctions"))
- local Functions = {}
-
- local defs = require("pk_erdoudizhu.luaScript.Def_ERDouDiZhu")
- local define = require("luaScript.SubGameDefine.Poker.Define_ERDouDiZhu")
-
- --获取当前版本号
- 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
- elseif k == 'specialRule' then
- ruleStr = ruleStr .. ' ' .. define.getSpecialRuleString(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.getRuleStrByClubInvite(roomListData)
- local temp = ""
- local jsonInfo = nil
- if roomListData then
- jsonInfo = roomListData
- else
- jsonInfo = json.decode(app.room.roomInfo.strGameInfo)
- end
-
- local roundCount = app.room.roomInfo.nTotalGameNum
- if roundCount then
- temp = temp .. roundCount .. "局"
- end
-
- temp = temp .. ' ' .. '二人斗地主'
-
- -- if jsonInfo.gamerule then
- -- if tonumber(jsonInfo.gamerule) == 0 then
- -- temp = temp.."经典斗地主 "
- -- elseif tonumber(jsonInfo.gamerule) == 1 then
- -- temp = temp.."不洗牌斗地主 "
- -- end
- -- end
-
- -- if jsonInfo.multLimit and tonumber(jsonInfo.multLimit) >= 0 then
- -- local multLimit = jsonInfo.multLimit
- -- if multLimit == 0 then
- -- temp = temp.."不限倍数 "
- -- else
- -- temp = temp..multLimit.."倍 "
- -- end
- -- end
-
- -- if jsonInfo.piaoType and tonumber(jsonInfo.piaoType) >= 0 then
- -- local piaoType = jsonInfo.piaoType
- -- if piaoType == 0 then
- -- temp = temp.."不飘"
- -- else
- -- temp = temp.."飘"..piaoType.."分"
- -- end
- -- end
-
- return temp
- end
-
- --音乐
- function Functions.playMusic()
- playBGMusic("BG_Room_DouDiZhu", "pk_erdoudizhu/res/sound/doudizhu_bg.ogg")
- 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_erdoudizhu/res/sound/language/putonghua"
- else
- -- languagePath = "pk/res/sound/language/putonghua"
- languagePath = "pk_erdoudizhu/res/sound/language/putonghua"
- end
- else
- languagePath = "pk_erdoudizhu/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)
- elseif type == "jiaodizhu" then
- if value == 0 then
- typePath = tag.. "score_".. sexPath.. "_0"
- else
- typePath = tag.. "jiaodizhu_".. sexPath
- end
- elseif type == "qiangdizhu" then
- if value == 0 then
- typePath = tag.. "qiangdizhu_".. sexPath .. "_0"
- else
- typePath = tag.. "qiangdizhu_".. sexPath .. "_" .. math.random(1, 3)
- end
- elseif type == "jiabei" then --加倍
- typePath = tag.. "jiabei_".. sexPath .. "_" .. (value or 0)
- 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_erdoudizhu/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 then --炸弹
- typePath = tag.. "zhadan_".. sexPath
- playVoice("pk_erdoudizhu/res/sound/doudizhu_common_bomb.ogg")
- elseif value.cardType == defs.CARD_TYPE.BOMB_KING then --王炸
- typePath = tag.. "wangzha_".. sexPath
- playVoice("pk_erdoudizhu/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)
- do
- return
- end
-
- 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_erdoudizhu/res/sound/language/putonghua/%s/ddz_%s_baojing_%s.ogg', sexPath, sexPath, lastNum)
- playVoice(voiceName)
- end
-
- -- 是否勾选了禁止使用道具和语音选项
- function Functions.getIsForbidVoiceAndProp()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- if getNumBand(0x01, gameInfo.extPlay or 0x00) > 0 then
- return true
- end
-
- return false
- end
-
- function Functions.getIsForbidFace()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- if getNumBand(0x01, gameInfo.forbidProp or 0x00) > 0 then
- return true
- end
-
- return false
- end
-
- function Functions.getIsForbidVoice()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- if getNumBand(0x01, gameInfo.forbidVoice or 0x00) > 0 then
- return true
- end
-
- return false
- end
-
-
- -- 是否勾选了加倍阶段10s不操作则默认不加倍
- function Functions.getIsAutoAskBeiAfterTimeout()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- if getNumBand(0x08, gameInfo.extPlay or 0x00) > 0 then
- return true
- end
-
- return false
- end
-
- -- 当前游戏模式(1 叫地主, 2 叫分)
- function Functions.getGameMode()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- return tonumber(gameInfo.playMode) or 0
- end
-
- -- 当前让牌数
- function Functions.getRangCount()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- return tonumber(gameInfo.rangPai)
- end
-
- -- 当前最大倍数
- function Functions.getMaxMult()
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- return tonumber(gameInfo.scoreLimit)
- end
-
- return Functions
|