|
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJ = MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJRoomXiaoJuView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomXiaoJuView")
-
- -- 房间设置界面
- local NeiJiangMJRoomXiaoJuView = class("NeiJiangMJRoomXiaoJuView", MJRoomXiaoJuView)
-
- local MJ_WIDTH=47
- --起始位置
- local MJ_HAND_CARD_INIT_X=130 + 40
- 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
- --暗杠上面的牌Y轴偏移量
- local GANG_OFFSET_Y=16
-
- function NeiJiangMJRoomXiaoJuView:ctor(...)
- NeiJiangMJRoomXiaoJuView.super.ctor(self,...)
- end
-
- function NeiJiangMJRoomXiaoJuView:loadUI()
- local ui = loadUI("mj_neijiang/res/ui_fangjian/mj_neijiang_xiaoju_jiesuan.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function NeiJiangMJRoomXiaoJuView:onEnter()
- NeiJiangMJRoomXiaoJuView.super.onEnter(self)
-
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("mj_neijiang/res/zy_fangjian/mj_neijiang_xiaoju_jiesuan.plist");
- cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("mj_neijiang/res/zy_fangjian/mj_neijiang_dice.plist");
-
- local visibleSize = cc.Director:getInstance():getVisibleSize();
- self.ui.Items.Text_Tip_1:setPositionX(visibleSize.width - 250);
- self.ui.Items.Text_Tip_2:setPositionX(visibleSize.width - 250);
-
- self:createDiceView();
- end
-
- function NeiJiangMJRoomXiaoJuView:initPlayerView()
- local roomInfo=app.room.roomInfo
- self.ui.Items.Layout_Player:removeAllChildren()
-
- self.items={}
- local index = 1;
- for k,v in pairs(roomInfo.memberList) do
- --local i = v.nSeatId+1
- local otherPlayerState = self:getOtherPlayerState(v);
- 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, index, otherPlayerState)
- self.items[i]=item
- -- table.insert(self.items,)
- index = index + 1
- end
- end
- --[[/**
- * 获取每个玩家的操作状态
- * @param userId
- * @return
- */--]]
- function NeiJiangMJRoomXiaoJuView:getOtherPlayerState (player)
- local otherPlayerState = {};
- local index = 1;
- for k, v in pairs(app.room.roomInfo.memberList or {}) do
- if v.nUserId ~= player.nUserId then
- local data = {};
- data.strTitle = index .. "玩家";
- if player.nPiaoState == 1 then
- data.strPiaoState = v.nPiaoState == 1 and "对飘" or "飘";
- else
- data.strPiaoState = v.nPiaoState == 1 and "飘" or "无飘";
- end
-
- if player.nBaoCardState == 1 or player.nBaoCardState == 2 then
- data.strBaoState = (v.nBaoCardState == 1 or v.nBaoCardState == 2) and "对报" or "报";
- else
- data.strBaoState = (v.nBaoCardState == 1 or v.nBaoCardState == 2) and "报" or "无报";
- end
- table.insert(otherPlayerState, data);
- end
- index = index + 1;
- end
-
- return otherPlayerState;
- end
-
- function NeiJiangMJRoomXiaoJuView:createPlayerItem()
- local ui=loadUI("mj_neijiang/res/ui_fangjian/mj_neijiang_xiaoju_item.ui")
- autoAdapt(ui)
- return ui
- end
- --[[/**
- *更新每个玩家信息
- * @param ui
- * @param player
- * @return
- */--]]
- function NeiJiangMJRoomXiaoJuView:setPlayerItemInfo(ui,player, index, otherPlayerState)
- 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 color = (app.room:getMyUserId() == player.nUserId) and cc.c3b(255,243,176) or cc.c3b(230,192,117);
- local infoStr = self:setHuType(player.nUserId)
- nodeResult:setText(infoStr)
- nodeResult:setColor(color);
-
- 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.ImageView: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(70 + 170, 70 ))
- 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_hu.png")
- orderNum:setPosition(cc.p(100 + 50, 70))
- --nodeHu:setScale(1)
- end
- nodeHu:addChild(orderNum)
-
- end
-
- --黄庄才会查叫和查花猪
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- -- 查叫显示在听牌的人右边
- if player.userStatus == 2 and player.result <= 0 and player.isDj == 0 then
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_chajiao.png")
- nodeHu:setVisible(true)
- nodeHu:setScale(0.3)
- 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.3)
- -- 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("mj_neijiang_result_detail_pos_0.png",1)
- -- else
- -- ui.Items.ImageView_Pos:loadTexture(string.format("mj_neijiang_result_detail_pos_%d.png", viewId), 1)
- -- end
-
- -- else
- -- ui.Items.ImageView_Pos:setVisible(false)
- -- end
- if index >= 1 and index <= 4 then
- ui.Items.ImageView_Pos:loadTexture(string.format("mj_neijiang_result_detail_pos_%d.png", index - 1), 1)
- end
-
- ui.Items.ImageView_Piao:setVisible(player.nPiaoState == 1);
-
- for i = 1, 3 do
- ui.Items["Text_Player_State_" .. i]:setVisible(false);
- ui.Items["Text_Player_Piao_State_" .. i]:setVisible(false);
- ui.Items["Text_Player_Bao_State_" .. i]:setVisible(false);
- end
-
- -- local color = (app.room:getMyUserId() == player.nUserId) and cc.c3b(255,243,176) or cc.c3b(230,192,117);
- for k, v in ipairs(otherPlayerState or {}) do
- ui.Items["Text_Player_State_" .. k]:setColor(color);
- ui.Items["Text_Player_State_" .. k]:setString(v.strTitle);
- ui.Items["Text_Player_Piao_State_" .. k]:setString(v.strPiaoState);
- ui.Items["Text_Player_Bao_State_" .. k]:setString(v.strBaoState);
-
-
- ui.Items["Text_Player_State_" .. k]:setVisible(true);
- ui.Items["Text_Player_Piao_State_" .. k]:setVisible(true);
- ui.Items["Text_Player_Bao_State_" .. k]:setVisible(true);
- end
- end
-
- function NeiJiangMJRoomXiaoJuView: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
- --牌型
- -- for k,v in pairs(MJDefine.MJGamePaiType) do
- -- local newType = self:_and(player.huType,v)
- -- if self:_and(player.huType,v) ~= 0 then
- -- local newType = self:_and(player.huType,v)
- -- str = str..MJDefine.MJGameHuStr[newType].." "
- -- end
- -- end
- str = str .. self:getPaiTypeStr(player)
- str = str .. self:getGangTypeStr(player)
- if player.result > 0 then
- -- if player.genCount > 0 then
- -- str = str..player.genCount.."根 "
- -- end
- end
-
- if player.userStatus == 2
- and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG
- and player.result ~= MJDefine.MJGameHuType.HU_ZIMO
- and player.result ~= MJDefine.MJGameHuType.HU_DIANPAO
- and player.result ~= MJDefine.MJGameHuType.HU_QIANGGANG then
- local strType = self:getPaiTypeStr(player);
- strType = strType .. self:getGangTypeStr(player)
- if #strType > 0 then
- str = "有叫" .. " " .. strType .. "";
- else
- str = "有叫"
- end
- end
- end
- return str
- end
-
- --合并牌型得到最终的字符串
- function NeiJiangMJRoomXiaoJuView:getPaiTypeStr(player)
- local strTab = {}
- -- for k,v in pairs(MJDefine.MJGamePaiType) do
- -- local newType = self:_and(player.huType,v)
- -- if newType ~= 0 then
- -- table.insert(strTab,MJDefine.MJGameHuStr[newType] or "")
- -- end
- -- end
-
- if player.nPiaoState == 1 then
- table.insert(strTab, "飘");
- end
-
- if player.nBaoCardState == 1 then
- table.insert(strTab, "报叫");
- end
-
- if player.nBaoCardState == 2 then
- table.insert(strTab, "博自摸");
- end
-
- if player.nGeneralHigh == 1 then
- table.insert(strTab, "一般高");
- end
-
- if player.nBaoRersaState == 1 then
- table.insert(strTab, "报叫反查");
- end
-
- for k, v in pairs(MJDefine.MJGameHuStr) do
- if k == player.huType then
- table.insert(strTab, v);
- end
- if k == player.subHuType then
- table.insert(strTab, v);
- end
- end
-
- local roomInfo = app.room.roomInfo;
- local isChaJiao = player.isDj == 0 and roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG and player.result <= 0;
- if player.result > 0 or isChaJiao or player.nBaoRersaState == 1 then
- -- 1自摸胡 2点炮胡 3抢杠胡
- -- 胡牌情况下,判断是不是有豹子
- local gameInfo = json.decode(roomInfo.strGameInfo);
- local diceNum = roomInfo.diceNum or {};
- if diceNum[1] and diceNum[2] then
- if gameInfo.baoziext == 0x0002 and diceNum[1] == diceNum[2] then
- -- 骰子相同做豹子
- table.insert(strTab, "豹子");
- elseif gameInfo.baoziext == 0x0040 and ((diceNum[1] + diceNum[2]) % 2 == 0) then
- -- 骰子相加双数做豹子
- table.insert(strTab, "豹子");
- end
- end
-
- if player.genCount and player.genCount > 0 then
- table.insert(strTab,player.genCount.."根")
- end
- end
-
-
-
- if player.bIsJueZhang == 1 then
- table.insert(strTab, "绝张");
- end
-
- if player.bIsKaErTiaoHu == 1 then
- table.insert(strTab, "卡二条");
- end
-
- if player.bIsHaiDiLaoYue == 1 then
- table.insert(strTab, "海底胡");
- end
-
- if player.bIsHaiDiPao == 1 then
- table.insert(strTab, "海底炮");
- end
-
- if player.bGangShangKaiHua == 1 then
- table.insert(strTab, "杠上开花");
- end
-
- if player.bGangShangPao == 1 then
- table.insert(strTab, "杠上炮");
- end
-
- if player.bQiangGangHu == 1 then
- table.insert(strTab, "抢杠胡");
- 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 NeiJiangMJRoomXiaoJuView:getGangTypeStr( player )
- local infoStr = "";
- local infoTab = {
- ["mgang"] = "明杠x",
- ["agang"] = "暗杠x",
- ["bgang"] = "巴杠x",
- ["gsgang"] = "过手杠x",
- ["diangang_cnt"] = "点杠x",
- }
- local detailInfo = json.decode(app.room.roomInfo.opsCntMapString)
- if not detailInfo then
- return "";
- end
-
- for k,v in pairs(detailInfo[tostring(player.nUserId)]) do
- if v > 0 then
- infoStr = infoStr..infoTab[k]..v.." ";
- end
- end
- return infoStr;
- end
-
- function NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView:createGang(values)
- 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 =MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- node:addChild(mj)
-
- local offsetY = self.desktopType == MJDefine.DesktopType.TwoDGold and 10 or 0;
-
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- if i <= 3 then
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=MJ_HAND_CARD_INIT_Y - 4 - offsetY
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- else
- local x = mjWidth/2+(2-1)*(mjWidth+MJ_PADDING_X)
- local y = MJ_HAND_CARD_INIT_Y + 6 - offsetY
- height = mjHeight
- mj:setPosition(x,y)
- end
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function NeiJiangMJRoomXiaoJuView:createAnGang(values)
- 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(0,MJDefine.MJType.OutBlack,MJDefine.MyViewId,self.desktopType)
- if self.desktopType == MJDefine.DesktopType.TwoDGold then
- mj:setAutoSize(false)
- mj:setSize(cc.size(36,55))
- elseif self.desktopType == MJDefine.DesktopType.TwoD then
- mj:setAutoSize(false)
- mj:setSize(cc.size(44,68))
- end
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
- node:addChild(mj)
-
- local offsetY = self.desktopType == MJDefine.DesktopType.TwoDGold and 4 or 0;
-
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- if i <= 3 then
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X) + 4
- local y=mjHeight/2 + 4 - offsetY
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- else
- local x=mjWidth/2+(2-1)*(mjWidth+MJ_PADDING_X) + 2
- local y=mjHeight/2 + 10 + 2 - offsetY
- height=mjHeight
- mj:setPosition(x, y);
- end
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function NeiJiangMJRoomXiaoJuView: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.createAnGang),
- [MJDefine.MJGroupType.GuoShouGang]=handler(self,self.createGang),
- }
-
- for k,v in pairs(arg) do
- if handlers[v.opType] then
- local group=handlers[v.opType](v.values)
- local w=(group:getContentSize().width-MJ_WIDTH)/2
- group:setPosition(cc.p(self.initX[seatId] + 10 + 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 NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView:initOther()
- local roomInfo = app.room.roomInfo
- -- local winUserId = app.room.roomInfo.winUserId
-
- self.ui.Items.Text_Round:setText("局数:"..roomInfo.nGameStartCount..'/'..roomInfo.nTotalGameNum)
-
- --规则
- local ruleAll = MJWanFa.getWanFaInfo(roomInfo.strGameInfo)
- -- self.ui.Items.Text_Rule:setText(ruleAll)
-
- local item = self.ui.Items.Text_Rule:getCopied()
- item:setVisible(true)
- item:setText(ruleAll)
-
- self.ui.Items.ListView:addChild(item)
- self.ui.Items.ListView:hideAllBar()
- self.ui.Items.ListView:getInnerContainer():setAutoSize(true)
- self.ui.Items.ListView:requestDoLayout();
- self.ui.Items.ListView:doLayout();
-
- --时间
- self.ui.Items.Text_Time:setText(os.date("%m-%d %X"))--(getTimeString())
- --房号
- self.ui.Items.Text_RoomNum:setText("房号:"..roomInfo.nShowTableId)
-
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- self.ui.Items.ImageView_Title:loadTexture("xj_liuju.png",cc.TextureResType.plistType)
- end
- end
-
- function NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView: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 NeiJiangMJRoomXiaoJuView:_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
-
- function NeiJiangMJRoomXiaoJuView:createDiceView ()
- if not self.diceView then
- self.diceView = cc.ImageView:create();
- self.diceView:loadTexture("mj_neijiang_dice_bg.png", 1);
- self.diceView:setPosition(cc.p(100, 60))
- self.ui.Items.Layout_Content:addChild(self.diceView);
- end
-
- local roomInfo = app.room.roomInfo;
- local diceNum = roomInfo.diceNum or {};
- local dice1 = diceNum[1];
- local dice2 = diceNum[2];
- if not (dice1 and dice2 and dice1 > 0 and dice2 > 0) then
- self.diceView:setVisible(false);
- return ;
- end
-
- self.diceView:removeAllChildren();
-
- local imgDice1 = cc.ImageView:create();
- imgDice1:loadTexture(string.format("mj_neijiang_dice_s_%d.png", dice1), 1);
- imgDice1:setPosition(cc.p(37, 38));
- self.diceView:addChild(imgDice1);
-
- local imgDice2 = cc.ImageView:create();
- imgDice2:loadTexture(string.format("mj_neijiang_dice_s_%d.png", dice2), 1);
- imgDice2:setPosition(cc.p(87, 38));
- self.diceView:addChild(imgDice2);
- end
-
- return NeiJiangMJRoomXiaoJuView
|