|
- local RoomXiaoJuView = class("RoomXiaoJuView_Coin", cc.UIView)
-
- local MJ = MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJWanFa = MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJRoomDaJuView = MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomDaJuView")
- local MJRoomXiaoJuPlayerInfo = MJFramework.MJImport("mj.luaScript.Views.Room.MJRoomXiaoJuPlayerInfo")
- local CoinFunctions = import("luaScript.Views.Coin.Util.CoinFunctions")
- local CoinData = import("luaScript.Views.Coin.Data.CoinData")
- local CoinGameLogic = import("luaScript.Views.Coin.CoinGameLogic")
-
- local HuCardType = {
- INIT = 0, --//没有牌型
- MEN_QING = 1, --//门清
- QUAN_QUI_REN = 2, --//全球人
- QING_YI_SE = 3, --//清一色
- ZI_YI_SE = 4, --//字一色
- QI_XIAO_DUI = 5, --//七小对
- HAO_HUA_QI_XIAO_DUI = 6, --//豪华七小对
- TWO_HAO_HUA_QI_XIAO_DUI = 7, --//双豪华七小对
- THREE_HAO_HUA_QI_XIAO_DUI = 8, --//三豪华七小对
- PENG_PENG_HU = 9, --//碰碰胡
- QIANG_GANG_HU = 10, --//抢杠胡
- GANG_SHANG_HUA = 11, --//杠上花
- GANG_XIA_HUA = 12, --//杠下花
- SHI_SAN = 13
- }
-
- local HuCardTypeStr = {
- [HuCardType.INIT] = "平胡", --//没有牌型
- [HuCardType.MEN_QING] = "门清", --//门清
- [HuCardType.QUAN_QUI_REN] = "全求人", --//全球人
- [HuCardType.QING_YI_SE] = "清一色", --//清一色
- [HuCardType.ZI_YI_SE] = "字一色", --//字一色
- [HuCardType.QI_XIAO_DUI] = "七小对", --//七小对
- [HuCardType.HAO_HUA_QI_XIAO_DUI] = "豪华七小对", --//豪华七小对
- [HuCardType.TWO_HAO_HUA_QI_XIAO_DUI] = "双豪华七小对", --//双豪华七小对
- [HuCardType.THREE_HAO_HUA_QI_XIAO_DUI] = "三豪华七小对", --//三豪华七小对
- [HuCardType.PENG_PENG_HU] = "碰碰胡", --//碰碰胡
- [HuCardType.QIANG_GANG_HU] = "抢杠胡", --//抢杠胡
- [HuCardType.GANG_SHANG_HUA] = "杠上花", --//杠上花
- [HuCardType.GANG_XIA_HUA] = "杠下花", --//杠下花
- [HuCardType.SHI_SAN] = ""
- }
-
- --起始位置
- local MJ_HAND_CARD_INIT_X = 130+35
- local MJ_HAND_CARD_INIT_Y = 40
- local MJ_GROUP_CARD_INIT_X = 100
-
- --麻将组间隔
- local MJ_GROUP_PADDING_X = 0
-
- --麻将直接间隔
- local MJ_PADDING_X = -3
-
- --胡牌麻将间隔
- local MJ_HU_X = 8
-
- --麻将宽度
- local MJ_WIDTH = 47
-
- --暗杠上面的牌Y轴偏移量
- local GANG_OFFSET_Y = 16
-
- function RoomXiaoJuView:ctor(add_coupons)
- RoomXiaoJuView.super.ctor(self)
- self:loadUI()
-
- self.add_coupons = add_coupons
-
- self:bindEvent(app.hall, "couponsAdd", handler(self, self.changeLiquan))
- end
-
- function RoomXiaoJuView:loadUI()
- local ui = loadUI("mj_luzhougui/res/ui_fangjian/mj_luzhou_xiaoju_coin.ui")
- self:addChild(ui)
- self.ui = ui
- end
-
- function RoomXiaoJuView:createPlayerItem()
- local ui = loadUI("mj_luzhougui/res/ui_fangjian/mj_luzhou_xiaoju_item.ui")
- autoAdapt(ui)
- return ui
- end
-
- function RoomXiaoJuView:onEnter()
- RoomXiaoJuView.super.onEnter(self)
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("mj/res/ui/zy_fangjian/mj_xiao_ju.plist")
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("mj/res/ui/zy_fangjian/mj_xiaoju_new.plist")
-
- -- 继续游戏
- self.ui.Items.Button_Next:registerClick(handler(self, self.onClickNext))
-
- -- 继续游戏
- self.ui.Items.Button_Sure:registerClick(handler(self, self.onClickNext))
-
- -- 查牌
- self.ui.Items.Button_Cha:registerClick(handler(self, self.onClickClose))
-
- -- 分享
- self.ui.Items.Button_Share:registerClick(handler(self, self.onClickShare))
-
- -- 关闭
- self.ui.Items.Button_Close:registerClick(handler(self, self.onClickCloseToHall))
-
- --初始化人物信息
- self:initPlayerView()
-
- --初始化组合牌
- self:initWeaveCard()
-
- --初始化其他数据
- self:initOther()
- end
-
- function RoomXiaoJuView:changeLiquan(eventData)
- --礼券
- if eventData then
- self.add_coupons = tonumber(eventData.attr.add_counpons or 0)
- end
-
- self.add_coupons = self.add_coupons or 0
-
- if self.add_coupons > 0 then
- self.ui.Items.Image_Quan:setVisible(true)
- self.ui.Items.TextBMFont_Quan:setText(string.format("+%d", tonumber(self.add_coupons)))
- else
- self.ui.Items.Image_Quan:setVisible(false)
- end
- end
-
- function RoomXiaoJuView:initPlayerView()
- local roomInfo=app.room.roomInfo
- self.ui.Items.Layout_Player:removeAllChildren()
-
- self.items={}
-
- for k,v in pairs(roomInfo.memberList) do
- --local i = v.nSeatId+1
- local userId = app.room:getViewIdByUserId(v.nUserId)
- local nSeatId = app.room:getSeatIdByViewId(userId)
- local i = nSeatId+1
- local item=self:createPlayerItem()
- self.ui.Items.Layout_Player:addChild(item)
- self:setPlayerItemInfo(item,v)
- self.items[i]=item
- -- table.insert(self.items,)
- end
- end
-
- function RoomXiaoJuView:setPlayerItemInfo(ui,player)
- local roomInfo=app.room.roomInfo
- local resultInfo=roomInfo.memberList
- local bg = "ImageView_ItemBg"--"ImageView_Win_"..i..""
- -- local bg2 = "ImageView_ItemBg_2"
- -- local lose = "ImageView_Lose_"..i
- local head = "ImageView_Head"
- local name = "Text_Name"
- local benJuScore = "TextBMFont_Score"
- local benJuScore1 = "Text_Score"
- local hu = "ImageView_Hu"
- local info = "Button_Info"
- local result="Text_ResultInfo"
-
- local nodeBg = ui.Items[bg]
- -- local nodeBg2 = ui.Items[bg2]
- -- local nodeLose = self.ui.Items[lose]
- local nodeHead = ui.Items[head]
- local nodeName = ui.Items[name]
- local nodeBenJu = ui.Items[benJuScore]
- local bmFontScore = true
- if not nodeBenJu then
- nodeBenJu = ui.Items[benJuScore1]
- bmFontScore = false
- end
- local nodeHu = ui.Items[hu]
- local nodeBanker= ui.Items.ImageView_Banker
- local nodeResult= ui.Items[result]
- --[[local huType = {
- [1] = "自摸(",
- [2] = "接炮(",
- [3] = "抢杠胡(",
- }--]]
- --[[local infoTab = {
- ["agang"] = "暗杠(x",
- ["bgang"] = "补杠(x",
- ["diangang_cnt"] = "点杠(x",
- ["mgang"] = "明杠(x",
- }--]]
- local infoStr = self:setHuType(player.nUserId)
- nodeResult:setText(infoStr)
-
- local userInfo = app.room:getUserInfo(player.nUserId)
-
- --先设置默认头像
- local width = nodeHead:getContentSize().width
-
- local nickname = ""
- if userInfo and userInfo.nickname then
- nickname = getSubStringNickname(userInfo.nickname)
- self:updateUserHead(nodeHead,player.nUserId, userInfo.sex, userInfo.headimgurl);
- end
-
- nodeName:setText(nickname)
-
- nodeHu:setVisible(false)
- if player.result>0 then
- nodeHu:setVisible(true)
- local orderNum = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_num"..player.huOrder..".png")
- if player.result == MJDefine.MJGameHuType.HU_ZIMO then--自摸 huOrder
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_zimo.png")
- orderNum:setPosition(cc.p(260,65))
- elseif player.result == MJDefine.MJGameHuType.HU_DIANPAO or player.result == MJDefine.MJGameHuType.HU_QIANGGANG then --点炮胡
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_jiepao.png")
- orderNum:setPosition(cc.p(300,65))
- --nodeHu:setScale(1)
- end
- nodeHu:addChild(orderNum)
-
- end
-
- --黄庄才会查叫和查花猪
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- if player.result <= 0 and player.isDj == 1 then
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_chajiao.png")
- nodeHu:setVisible(true)
- nodeHu:setScale(0.4)
- end
-
- if player.result <= 0 and player.isHz == 1 then --花猪
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_chahuazhu.png")
- nodeHu:setScale(0.4)
- nodeHu:setVisible(true)
- end
- end
-
- if app.room:getUserIdBySeatId(app.room.roomInfo.nBankSeatId)~=player.nUserId then
- nodeBanker:setVisible(false)
- end
-
- if app.room:getMyUserId() == player.nUserId then
- nodeBg:loadTexture("xj_my_bg.png",cc.TextureResType.plistType)
- --[[else
- nodeBg:loadTexture("xj_other_bg.png",cc.TextureResType.plistType)--]]
- end
-
- if tonumber(player.nTurnScore) > 0 then
- nodeBenJu:setText("+"..player.nTurnScore)
- else
- nodeBenJu:setText(player.nTurnScore)
- if tonumber(player.nTurnScore) < 0 and bmFontScore == true then
- nodeBenJu:setFntFile("res/fonts/dt_jian_num.fnt")
- end
- end
-
- --番数
- ui.Items.Text_FanShu:setText(player.fanshu.."番")
-
- local viewId = app.room:getViewIdByUserId(player.nUserId)
- --local seatId = app.room:getSeatIdByViewId(viewId)
- if viewId and viewId>0 and viewId<=4 then
- if viewId == 4 then
- ui.Items.ImageView_Pos:loadTexture("result_pos_0.png",1)
- else
- ui.Items.ImageView_Pos:loadTexture(string.format("result_pos_%d.png", viewId), 1)
- end
-
- else
- ui.Items.ImageView_Pos:setVisible(false)
- end
- end
-
- function RoomXiaoJuView:setHuType(userId)
- local roomInfo = app.room.roomInfo
- local strGameInfo = json.decode(roomInfo.strGameInfo)
- local str = ""
- local huType1 = {
- [1] = "自摸(",
- [2] = "接炮(",
- [3] = "抢杠胡(",
- }
- local huOrder1 = 0
- local player = roomInfo.memberList[userId]
- if player then
-
- huOrder1 = player.huOrder
- --胡牌顺序
- if player.result == MJDefine.MJGameHuType.HU_ZIMO then
- local huNum = 0
- --快速成局时,strGameInfo.playnum默认传来的是4人
- if strGameInfo.isfaststart == 1 then
- huNum = roomInfo.nMaxPlayCount - player.huOrder
- else
- huNum = strGameInfo.playnum - player.huOrder
- end
- str = str..huType1[player.result]..huNum.."家) "
- elseif player.result == MJDefine.MJGameHuType.HU_DIANPAO or player.result == MJDefine.MJGameHuType.HU_QIANGGANG then
- local viewId = app.room:getViewIdBySeatId(player.dpSeatId)
- local userInfo = app.room:getUserInfoByViewId(viewId)
- local nickname = getSubStringNickname(userInfo.nickname)
- str = str..huType1[player.result]..nickname..") "
- end
-
- str = str .. self:getPaiTypeStr(player)
- if player.result > 0 then
- if player.isXiQian > 0 then
- str = str.."喜钱 "
- end
- end
- end
- return str
- end
-
- --合并牌型得到最终的字符串
- function RoomXiaoJuView:getPaiTypeStr(player)
- local strTab = {}
- for k,v in pairs(MJDefine.MJGamePaiType) do
- local newType = self:_and(player.huType or 0,v)
- if newType ~= 0 then
- table.insert(strTab,MJDefine.MJGameHuStr[newType] or "")
- end
- end
-
- if player.result > 0 then
- if player.genCount > 0 then
- table.insert(strTab,player.genCount.."归")
- end
- end
- dump(strTab)
- --logD(table.toString(strTab))
- for _,v in pairs(MJDefine.MJGameHuMargeTab) do
- local list = v.tab
- local str = v.name
- dump(list)
- local indexs= {}
- for _,v in pairs(list) do
- local index = table.indexOf(strTab, v)
- if index~= -1 then
- table.insert(indexs,index)
- end
- end
- if #indexs == #list then --如果都找到则合并
- for k,v in pairs(list) do
- table.removeItem(strTab,v)
- end
- -- logD(str)
- table.insert(strTab,str)
- end
- end
-
- local info = ""
- for k,v in pairs(strTab) do
- info = info..v.." "
- end
- return info
- end
-
- function RoomXiaoJuView:initWeaveCard()
- local roomInfo=app.room.roomInfo
- self.initX={}
- for k,v in pairs(roomInfo.memberList) do
- local userId = app.room:getViewIdByUserId(v.nUserId)
- local nSeatId = app.room:getSeatIdByViewId(userId)
- local i = nSeatId+1
- local groups={}
- for _,group in pairs(v.gruoupCards) do
- table.insert(groups,self:getChangeGruopDatas(group))
- end
- self.initX[i]=MJ_HAND_CARD_INIT_X
- self:createGroupCards(self.items[i].Items.Layout_Player,groups,i)
- self.initX[i] = self.initX[i] + 10
- self:createHandCards(self.items[i].Items.Layout_Player,v.handCards,i)
- --创建胡的牌
- if v.huCard and v.huCard ~= 0 then
- self.initX[i]=self.initX[i]+MJ_HU_X
- self:createHuCard(self.items[i].Items.Layout_Player,v.huCard,i)
- -- self:createHandCards(self.items[i].Items.Layout_Player,{{card=v.huCard}},i)
- end
- end
- end
-
- function RoomXiaoJuView:createHuCard(layer,card,seatId)
- local mj=MJ:new(card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- layer:addChild(mj)
- mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y))
- self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_PADDING_X
-
- local flag = cc.Sprite:create("mj/res/ui/zy_fangjian/mj_hu_flag.png")
- mj:addChild(flag)
- if self.desktopType == MJDefine.DesktopType.TwoDGold then
- flag:setPosition(cc.p(16,40))
- else
- flag:setPosition(cc.p(16,55))
- end
- end
-
- --移除手牌胡的牌
- function RoomXiaoJuView:removeHuCard(player)
- if player.result ~= MJDefine.MJGameResultType.Win then
- return
- end
- for k, v in pairs(player.handCards) do
- if v.card == self.huCard then
- table.remove(player.handCards.Datas, k)
- return
- end
- end
- end
-
- -- 获取组合牌组
- function RoomXiaoJuView:getChangeGruopDatas(g,redNum)
- -- dump(g, "getChangeGruopDatas")
- local opType=MJDefine.MJOperateToGroupType[g.opType]
- local showType=MJDefine.MJOperateToGroupType[g.opType]
- local opCard=g.opCard
- local redNum = g.redNum
- local fromViewId = nil
- local targetSeatId = g.targetSeatId--操作位置座位号
- local fromUserId = g.opUserId or g.fromUserId --触发操作玩家
- if fromUserId<=0 or targetSeatId==nil then
- else
- fromViewId = app.room:transPos( targetSeatId, app.room:getSeatIdByUserId(fromUserId))
- --判断是否是对面玩家,对面玩家的话要做一次翻转
- local opViewId = app.room:getViewIdBySeatId(targetSeatId)
- if opViewId == 2 then --对面
- if fromViewId==1 then fromViewId = 3
- elseif fromViewId==3 then fromViewId = 1 end
- end
- --三人玩只有上下家
- if app.room:getMaxPlayerCount()==3 and fromViewId==2 then fromViewId = 3 end
- if app.room:getMaxPlayerCount()==2 and fromViewId~=0 then
- if showType == MJDefine.MJGroupType.Peng then
- fromViewId = 2
- else
- fromViewId = 4
- end
- end
- end
- --组合一下牌
- local group={
- opType=opType,
- showType=showType,
- values={},
- opCard = opCard,
- redNum = redNum,
- fromViewId = fromViewId
- }
- if MJDefine.MJGroupType.Chi==showType then
- elseif MJDefine.MJGroupType.Peng==showType then
- group.values={opCard,opCard,opCard}
- else
- group.values={opCard,opCard,opCard,opCard}
- end
-
- return group
- end
-
-
- -- 创建吃牌组合节点
- function RoomXiaoJuView:createChi(values,redNum)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
-
- for i=1,3 do
- if values[i] then
- local mj
- if redNum > 0 and i <= redNum then
- mj=MJ:new(65,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
-
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function RoomXiaoJuView:createGang(values,redNum)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
- for i=1,4 do
- if values[i] then
- local mj
- if redNum > 0 and i <= redNum then
- mj=MJ:new(65,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function RoomXiaoJuView:createAnGang(values,redNum)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
- for i=1,4 do
- if values[i] then
- local mj
- if i <= 3 then
- mj=MJ:new(values[i],MJDefine.MJType.OutBlack,MJDefine.MyViewId,self.desktopType)
- else
- --[[if redNum > 0 then
- mj=MJ:new(65,MJDefine.MJType.Out,MJDefine.MyViewId)
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId)
- end--]]
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId)
- end
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function RoomXiaoJuView:createGroupCards(layer,arg,seatId)
- local handlers={
- [MJDefine.MJGroupType.Chi]=handler(self,self.createChi),
- [MJDefine.MJGroupType.Peng]=handler(self,self.createChi),
- [MJDefine.MJGroupType.Gang]=handler(self,self.createGang),
- [MJDefine.MJGroupType.AnGang]=handler(self,self.createGang),
- }
-
- for k,v in pairs(arg) do
- if handlers[v.opType] then
- local group=handlers[v.opType](v.values,v.redNum)
- local w=(group:getContentSize().width-MJ_WIDTH)/2
- group:setPosition(cc.p(self.initX[seatId]+w,MJ_HAND_CARD_INIT_Y))
- if k<#arg then
- self.initX[seatId]=self.initX[seatId]+group:getContentSize().width+MJ_GROUP_PADDING_X
- else
- self.initX[seatId]=self.initX[seatId]+group:getContentSize().width+MJ_GROUP_PADDING_X
- end
- layer:addChild(group)
- end
- end
- end
-
- function RoomXiaoJuView:createHandCards(layer,arg,seatId)
- for k,v in pairs(arg) do
- local mj=MJ:new(v.card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- layer:addChild(mj)
- mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y))
- self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_PADDING_X
- end
- end
-
- function RoomXiaoJuView:initOther()
- local roomInfo = app.room.roomInfo
-
- --规则
- local ruleAll = string.format("泸州鬼麻将 %d人 80颗(5颗起胡) 12鬼 报叫、过张升番可胡、听牌提示、一炮多响头家庄", roomInfo.nMaxPlayCount)
- self.ui.Items.Text_Rule:setText(ruleAll)
-
- --时间
- self.ui.Items.Text_SystemTime:setText(getTimeString3())
-
- --设置房间等级
- self.ui.Items.Text_CoinLevel:setText(CoinFunctions.getLevelDisplayText(app.room.roomInfo.serverLevel))
-
- --设置底分
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- self.ui.Items.Text_BaseScore:setText(string.format("底分%s", gameInfo.baseScore or 50))
-
- --礼券
- self:changeLiquan()
-
- --隐藏二维码
- self.ui.Items.Image_Share:setVisible(false)
-
- local isHuangZhuang = app.room.roomInfo.stopFlag == MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG
- if isHuangZhuang then
- return
- end
-
- --显示输赢标题
- local myMemberInfo = roomInfo.memberList[app.room:getMyUserId()]
- if tonumber(myMemberInfo.nTurnScore) == 0 then
- self.ui.Items.ImageView_Title:loadTexture("mj/res/ui/zy_jingbichang/mj_coin_xiaoju_bushubuying.png")
- elseif tonumber(myMemberInfo.nTurnScore) > 0 then
- self.ui.Items.ImageView_Title:loadTexture("mj/res/ui/zy_jingbichang/mj_coin_xiaoju_niyingle.png")
- else
- self.ui.Items.ImageView_Title:loadTexture("mj/res/ui/zy_jingbichang/mj_coin_xiaoju_nishule.png")
- end
-
- end
-
- function RoomXiaoJuView:updateUserHead(nodeHead, nUserId, sex, headimgurl)
- setPlayerHeadImage(nUserId, headimgurl, nodeHead)
- end
-
- -- 关闭
- function RoomXiaoJuView:onClickClose()
- playBtnEffect()
- self.ui.Items.Layout_Sure:setVisible(true)
- self.ui.Items.Layout_Content:setVisible(false)
- end
-
- -- 关闭退出到大厅
- function RoomXiaoJuView:onClickCloseToHall()
- playBtnEffect()
- --self.roomInfo.isGameOver == false
- if app.room then
- self.ui:sendMsg(app.room, "callLeaveRequest")
- end
- setShowCountAll(false)
- local data = {
- gameId = GAME_IDS.LuZhouMJ or app.gameId,
- isCoin = true
- }
- app:gotoView(import("luaScript.Views.Main.MainView"):new(data))
- end
-
- -- 分享
- function RoomXiaoJuView:onClickShare()
- playBtnEffect()
- --分享截图时,需要显示下载的二维码
- --self.ui.Items.Image_Share:setVisible(true)
- self.ui.Items.Image_Share:setVisible(false)
- local fileName =
- cc.FileUtils:getInstance():getWritablePath() .. "gameID" .. tostring(GAME_IDS.LuZhouMJ) .. "_coin_screen.jpg"
- cc.FileUtils:getInstance():screenToFile(
- fileName,
- function(ret)
- if 1 == tonumber(ret) then
- local info = {}
- info.scene = "talk"
- info.contentType = "image"
- info.image = fileName
- info.imageWidth = 1000
- info.thumbWidth = 100
- app.plugin:shareGame(info)
- else
- showTooltip("截图保存失败")
- end
- end
- )
- end
-
- -- 继续游戏
- function RoomXiaoJuView:onClickNext()
- playBtnEffect()
- --发送离开房间
- self.ui:sendMsg(app.room, MJDefine.MJEvent.CallLeaveRequest)
- local gameData = CoinData.getInstance():getGameData() or {}
- local ruleList = gameData.ruleList or {}
- local gameId = tonumber(app.gameId)
- local gameRuleInfo = ruleList[gameId]
- if gameRuleInfo then
- local serverLevel = app.room.roomInfo.serverLevel
- local minServerLevel = 10
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- gameInfo.gamerule = gameInfo.gamerule or 1
- minServerLevel = minServerLevel + tonumber(gameInfo.gamerule)
- local minCoinInfo = gameRuleInfo["" .. minServerLevel]
- local curCoinInfo = gameRuleInfo["" .. serverLevel]
-
- if tonumber(app.user.loginInfo.curJingbiNum) < tonumber(minCoinInfo.min_money) or
- tonumber(app.user.loginInfo.curJingbiNum) >= tonumber(curCoinInfo.min_money)
- then
- CoinGameLogic.requestEnterCoinGame(gameId, gameInfo.gamerule, serverLevel, tonumber(curCoinInfo.min_money))
- else
- CoinGameLogic.requestEnterCoinGame(gameId, gameInfo.gamerule)
- end
- else
- CoinData.getInstance():requestGameServerConfig()
- end
- end
-
- function RoomXiaoJuView:d2b(arg)
- self.data32={}
- for i=1,32 do
- self.data32[i]=2^(32-i)
- end
- local tr={}
- for i=1,32 do
- if arg >= self.data32[i] then
- tr[i]=1
- arg=arg-self.data32[i]
- else
- tr[i]=0
- end
- end
- return tr
- end
-
- function RoomXiaoJuView:b2d(arg)
- local nr=0
- for i=1,32 do
- if arg[i] ==1 then
- nr=nr+2^(32-i)
- end
- end
- return nr
- end
-
- function RoomXiaoJuView:_and(a,b)
- local op1=self:d2b(a)
- local op2=self:d2b(b)
- local r={}
-
- for i=1,32 do
- if op1[i]==1 and op2[i]==1 then
- r[i]=1
- else
- r[i]=0
- end
- end
- local c = self:b2d(r)
- return c
-
- end
-
- return RoomXiaoJuView
|