diff --git a/lua_probject/base_project/Game/Controller/LoginController.lua b/lua_probject/base_project/Game/Controller/LoginController.lua index fe7877f3..397fcc44 100644 --- a/lua_probject/base_project/Game/Controller/LoginController.lua +++ b/lua_probject/base_project/Game/Controller/LoginController.lua @@ -14,7 +14,7 @@ end local _LocalConfigAllGame = { 10, 33, - -- 90, + 90, 66, 86, 87, 88, 89 } diff --git a/lua_probject/base_project/Game/View/Family/FamilyAllNumbers.lua b/lua_probject/base_project/Game/View/Family/FamilyAllNumbers.lua index 5d70e35c..deda90a3 100644 --- a/lua_probject/base_project/Game/View/Family/FamilyAllNumbers.lua +++ b/lua_probject/base_project/Game/View/Family/FamilyAllNumbers.lua @@ -8,6 +8,8 @@ function FamilyInviteFamilyView.new(root) setmetatable(M, { __index = root }) local self = setmetatable({}, { __index = M }) local numbers = self._group.members + print("lingmengFamilyInviteFamilyView", self._group.lev) + pt(self._group) self._viewList_allNumbers = self._view:GetChild('list_number') self._btn_numberSearch = self._view:GetChild('btn_search') @@ -21,9 +23,9 @@ end function M:initBtn() self._btn_numberSearch.onClick:Set(function() local tempNumberList = {} - for i = 1,self._group.member_num do - if string.find(self._group.members[i].nick,self._input_numberSearch.text) then - table.insert(tempNumberList,self._group.members[i]) + for i = 1, self._group.member_num do + if string.find(self._group.members[i].nick, self._input_numberSearch.text) then + table.insert(tempNumberList, self._group.members[i]) end end if #tempNumberList == 0 then @@ -48,8 +50,8 @@ function M:FillList(numbers) obj.onClick:Set(function() print("lingmengtextBtn_detail") - fgCtr:FG_FindMember(self._group.id,numbers[i].uid,function(res) - local familyNumberDetail = FamilyNumberDetail.new(self._group.id,res) + fgCtr:FG_FindMember(self._group.id, numbers[i].uid, function(res) + local familyNumberDetail = FamilyNumberDetail.new(self._group.id, self._group.lev, res) familyNumberDetail:SetTickCallback(self.TickNumberCallback) familyNumberDetail:Show() end) diff --git a/lua_probject/base_project/Game/View/Family/FamilyNumberDetail.lua b/lua_probject/base_project/Game/View/Family/FamilyNumberDetail.lua index 4492683c..0674b0ac 100644 --- a/lua_probject/base_project/Game/View/Family/FamilyNumberDetail.lua +++ b/lua_probject/base_project/Game/View/Family/FamilyNumberDetail.lua @@ -5,27 +5,31 @@ local FamilyNumberDetail = {} local M = FamilyNumberDetail setmetatable(M, { __index = BaseWindow }) -function FamilyNumberDetail.new(groupId,res) +function FamilyNumberDetail.new(groupId, lev, res) local self = setmetatable({}, { __index = M }) self.class = 'FamilyNumberDetail' self._close_destroy = true self.groupId = groupId - self:init('ui://Family/NumberDetail',res) + self:init('ui://Family/NumberDetail', lev, res) return self end -function M:init(url,res) +function M:init(url, lev, res) local fgCtr = ControllerManager.GetController(NewGroupController) BaseWindow.init(self, url) local info = res.Data.members[1] - self._view:GetChild('name').text = string.format("%s(%s)",info.nick,info.uid) + local flag_assistant = info.lev == 2 and 1 or 0 + + self._view:GetChild('name').text = string.format("%s(%s)", info.nick, info.uid) self._view:GetChild('text_allRounds').text = info.total_round self._view:GetChild('text_joinTime').text = os.date('%Y-%m-%d %H:%M', info.join_time) self._view:GetChild('text_score_majiang').text = 0 self._view:GetChild('text_score_poker').text = 0 + self._view:GetController('isAssistant').selectedIndex = info.lev == 1 and 0 or (lev == 2 and 1 or 2) + self._view:GetChild('btn_changeTag').onClick:Set(function() ViewUtil.ShowOneChooose("该功能还未开放") end) @@ -39,19 +43,35 @@ function M:init(url,res) end) self._view:GetChild('btn_tick').onClick:Set(function() - ViewUtil.ShowTwoChooose(string.format("是否将用户(%s)踢出",info.nick),function() - fgCtr:FG_GroupRemoveMember(self.groupId,info.uid,self._callback_tick) + ViewUtil.ShowTwoChooose(string.format("是否将用户(%s)踢出", info.nick), function() + fgCtr:FG_GroupRemoveMember(self.groupId, info.uid, self._callback_tick) self:Destroy() end) end) self._view:GetChild('btn_band').onClick:Set(function() - ViewUtil.ShowTwoChooose(string.format("是否禁止用户(%s)进入房间",info.nick),function() - fgCtr:FG_GroupRemoveMember(self.groupId,info.uid,function() - ViewUtil.ShowOneChooose("用户(%s)已禁止进入房间",info.nick) + ViewUtil.ShowTwoChooose(string.format("是否禁止用户(%s)进入房间", info.nick), function() + fgCtr:FG_GroupRemoveMember(self.groupId, info.uid, function() + ViewUtil.ShowOneChooose(string.format("用户(%s)已禁止进入房间", info.nick)) end) end) end) + + self._view:GetChild('btn_makeOver').onClick:Set(function() + ViewUtil.ShowOneChooose("该功能还未开放") + end) + + self._view:GetChild('btn_assistant'):GetController('isAssistant').selectedIndex = flag_assistant + self._view:GetChild('btn_assistant').onClick:Set(function() + ViewUtil.ShowTwoChooose( + string.format("是否%s用户(%s)%s", flag_assistant == 1 and "取消" or "将", info.nick, + flag_assistant == 1 and "助理身份" or "设置为助理"), function() + fgCtr:FG_SetManager(self.groupId, info.uid, flag_assistant + 1, function(res) + flag_assistant = 1 - flag_assistant + self._view:GetChild('btn_assistant'):GetController('isAssistant').selectedIndex = flag_assistant + end) + end) + end) end function M:SetTickCallback(callback) diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua index c30f69a0..c6eb1067 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/EXMainView.lua @@ -833,7 +833,8 @@ function M:OnFangziAction(...) local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end - info:UpdateFzList(fz, index, true, player.seat) + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi printlog(getcard) info:UpdateHandCard(getcard) diff --git a/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua b/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua index cfea23b0..9c6a553e 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/EXMainView.lua @@ -834,7 +834,8 @@ function M:OnFangziAction(...) local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end - info:UpdateFzList(fz, index, true) + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi printlog(getcard) info:UpdateHandCard(getcard) diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua index 11f8452c..83def1fd 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXMainView.lua @@ -660,20 +660,16 @@ function M:__FangziTip(tip, weight) local info = self._player_card_info[1] local _chipeng_tip = info._view_FZTips local _ctr_tips = info._ctr_tip - printlog("__FangziTip1q") local _lit_fanzi = _chipeng_tip:GetChild("list") _lit_fanzi:SetVirtual() local _tlist = tip.tip_map_id - printlog("__FangziTip1") - _lit_fanzi.itemRenderer = function(index, obj) local type = obj:GetController('type') if index == tip.tip_num then type.selectedIndex = 0 obj.onClick:Set(function() --测试暂时取消过提示 - -- local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) -- guo_msg.onOk:Add(function() _gamectr:SendAction(0) @@ -840,7 +836,8 @@ function M:OnFangziAction(...) local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end - info:UpdateFzList(fz, index, true) + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi printlog(getcard) info:UpdateHandCard(getcard) diff --git a/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua b/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua index 7ccd6f9d..585df5ce 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/EXMainView.lua @@ -836,7 +836,8 @@ function M:OnFangziAction(...) local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end - info:UpdateFzList(fz, index, true) + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi print(getcard) info:UpdateHandCard(getcard) @@ -844,18 +845,14 @@ function M:OnFangziAction(...) end function M:RunNiao(list, start_seat) - print("lingmengniao1") local _room = self._room --local _niao_View = self._niao_View self._niao_View = UIPackage.CreateObject("Extend_MJ_NanCheng", "Panel_Birds") - print("lingmengniao2") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") - print("lingmengniao3") - list_niao_card:RemoveChildrenToPool() for i = 1, #list do --添加背面的麻將 @@ -863,8 +860,6 @@ function M:RunNiao(list, start_seat) item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") item:GetChild("tex_score").text = "+" .. list[i].score end - print("lingmengniao4") - for i = 1, #list do --顯示正面 local item = list_niao_card:GetChildAt(i - 1) @@ -874,8 +869,6 @@ function M:RunNiao(list, start_seat) item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card) if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end - print("lingmengniao5") - coroutine.start(function() coroutine.wait(1) _niao_View:Dispose() @@ -1029,10 +1022,12 @@ end function M:FillShowCards(obj, card, num) if DataManager.CurrenRoom.jing and obj:GetController('jing') then - if card == DataManager.CurrenRoom.jing then - obj:GetController('jing').selectedIndex = 1 - else - obj:GetController('jing').selectedIndex = 0 + if DataManager.CurrenRoom.jing and obj:GetController('jing') then + if card == DataManager.CurrenRoom.jing then + obj:GetController('jing').selectedIndex = 1 + else + obj:GetController('jing').selectedIndex = 0 + end end end if obj.icon then diff --git a/lua_probject/extend_project/extend/poker2/suoha/CardCheck.lua b/lua_probject/extend_project/extend/poker2/suoha/CardCheck.lua new file mode 100644 index 00000000..19894ca3 --- /dev/null +++ b/lua_probject/extend_project/extend/poker2/suoha/CardCheck.lua @@ -0,0 +1,645 @@ +local CardCheck = { + + cardList = {}, + cardListSord = {}, + cardNum = 0, + cardSize = 0, + long = false, + planeNoBelt = false, + threeNoBelt = false, + planelack = false, + threelack = false, + fourDaiThree = false, + fristCard = true, + tipCardList = {}, + touchCardSet = {}, + touchCardMao = {} +} + +local CardType = { + one = 1, + long = 2, + dui = 3, + duiLong = 10, + threeAndTwo = 4, + normolPlant = 5, + zha = 6, + onlyThree = 7, + onlyPlant = 8, + zhaAndThreee = 9 +} + +local M = CardCheck + +function M:InitFlag() + local config = DataManager.CurrenRoom.room_config.config + self.planeNoBelt = config.planeNoBelt == 1 + self.threeNoBelt = config.threeNoBelt == 1 + self.planelack = config.planelack == 1 + self.threelack = config.threelack == 1 + self.fourDaiThree = config.fourDaiThree + self._flag_fristCard = true + print("==============================lingmengcheckinitFlag") + pt(config) + pt(self) + return self +end + +function M:InitLastCard(cardList, mustPutMaxCard) + self._flag_fristCard = false + self:Clear() + self._flag_mustMax = mustPutMaxCard + self.type = 0 + self.lastCardNum = #cardList + self._flag_allCards = false + self._flag_checkLst = true + if #cardList == 0 then + self._flag_fristCard = true + return + end + table.sort(cardList) + pt(cardList) + self.lastMinCard = math.floor(cardList[1] / 10) + local temp_long = 0 + for i = 1, #cardList do + local number = math.floor(cardList[i] / 10) + if self.cardList[number] then + self.cardList[number] = self.cardList[number] + 1 + else + self.cardList[number] = 1 + self.cardSize = self.cardSize + 1 + table.insert(self.cardListSord, number) + end + self.cardNum = self.cardNum + 1 + if i == 1 then + temp_long = 1 + elseif temp_long == i - 1 then + if math.abs(math.floor(cardList[i - 1] / 10) - number) == 1 then + temp_long = i + end + end + end + self.long = temp_long == self.cardNum and self.cardNum >= 5 + print("lingmengCheckAloneOrLong2") + if self:CheckAloneOrLong() then + self.type = self:CheckAloneOrLong() + return + end + print("lingmengCheckDuiZi2") + if self:CheckDuiZi() then + self.type = self:CheckDuiZi() + return + end + print("lingmengCheckSanDai2") + + if self:CheckSanDai() then + self.type = self:CheckSanDai() + return + end + print("lingmengCheckZha2") + + if self:CheckZha() then + self.type = self:CheckZha() + return + end + if self.type == 0 then + ViewUtil.ErrorTip(-1, "上一份牌型判断错误") + end +end + +function M:initCards(cardList, flag, flag_allCards) + print("lingmenginitCards") + pt(cardList) + local temp_long = 0 + self:Clear() + self._flag_allCards = flag_allCards or false + if flag then + for i = 1, #cardList do + local number = math.floor(cardList[i][1].card_code_number / 10) + if self.cardList[number] then + self.cardList[number] = self.cardList[number] + 1 + else + self.cardList[number] = 1 + self.cardSize = self.cardSize + 1 + table.insert(self.cardListSord, number) + end + self.cardNum = self.cardNum + 1 + if i == 1 then + temp_long = 1 + elseif temp_long == i - 1 then + if math.abs(math.floor(cardList[i - 1][1].card_code_number / 10) - number) == 1 then + temp_long = i + end + end + end + else + for i = 1, #cardList do + local number = math.floor(cardList[i].card_code_number / 10) + if self.cardList[number] then + self.cardList[number] = self.cardList[number] + 1 + else + self.cardList[number] = 1 + self.cardSize = self.cardSize + 1 + table.insert(self.cardListSord, number) + end + self.cardNum = self.cardNum + 1 + if i == 1 then + temp_long = 1 + elseif temp_long == i - 1 then + if math.abs(math.floor(cardList[i - 1].card_code_number / 10) - number) == 1 then + temp_long = i + end + end + end + end + + print(self.cardNum, self.cardSize, temp_long) + pt(self.cardList) + self.long = temp_long == self.cardNum and self.cardNum >= 5 +end + +function M:CheckCards() + if self.cardNum ~= 4 and self.cardNum ~= self.lastCardNum and not self._flag_fristCard then + return + end + if self.cardNum == 1 and self._flag_mustMax and self.maxCard ~= self.cardListSord[1] then + return + end + if self.cardNum == 0 then + return + end + + print("lingmengCheckAloneOrLong") + if self:CheckAloneOrLong() then + return true + end + print("lingmengCheckDuiZi") + + if self:CheckDuiZi() then + return true + end + print("lingmengCheckSanDai") + + if self:CheckSanDai() then + return true + end + print("lingmengCheckZha") + + if self:CheckZha() then + return true + end + + return false +end + +function M:CheckOutCard(cardList) + print("lingmengCheckOutCard===============") + pt(cardList) + self.tipCardList = {} + self.touchCardSet = {} + self.touchCardMao = {} + local cardMap = {} + local cardSet = {} + local temp_long = 0 + local temp_longList = {} + local longList = {} + local lastCard = -1 + + local flag_threeOrFour = false + for i = 1, #cardList do + local number = math.floor(cardList[i].card_code_number / 10) + if cardMap[number] then + cardMap[number].value = cardMap[number].value + 1 + table.insert(cardMap[number].cardList, cardList[i]) + else + cardMap[number] = {} + cardMap[number].value = 1 + cardMap[number].cardList = {} + table.insert(cardMap[number].cardList, cardList[i]) + table.insert(cardSet, number) + end + if cardMap[number].value >= 3 then + flag_threeOrFour = true + end + if lastCard ~= number then + if lastCard - number ~= 1 then + if temp_long >= 5 then + table.insert(longList, temp_longList) + end + temp_long = 1 + temp_longList = {} + else + temp_long = temp_long + 1 + end + lastCard = number + table.insert(temp_longList, number) + end + end + if temp_long >= 4 then + table.insert(longList, temp_longList) + end + + table.sort(cardSet) + self.maxCard = cardSet[#cardSet] + + if self._flag_fristCard then + if self._flag_mustMax then + self:CheckOutCardGetMustMax(cardSet, cardMap, flag_threeOrFour, longList) + else + self:CheckOutCardGetFristTipList(cardSet, cardMap) + end + return + end + + local cardType, only, longLength = self:CheckOutCardGetType() + + + local tipCardSet = self:CheckOutCardGetTouchSet(cardSet, cardMap, cardType, longLength) + + self:CheckOutCardSetTipList(tipCardSet, longLength, cardMap, cardType) + + if cardType >= 3 and only == 0 then + self:CheckOutCardGetAllCardSetAndMap() + end +end + +function M:CheckOutCardGetAllCardSetAndMap() + self.touchCardSet = {} + self.touchCardMao = {} + for i = 3, 15 do + table.insert(self.touchCardSet, i) + self.touchCardMao[i] = 1 + end +end + +function M:CheckOutCardGetFristTipList(cardSet, cardMap) + for i = 1, #cardSet do + local card = cardSet[i] + table.insert(self.touchCardSet, card) + self.touchCardMao[card] = 1 + local temp = {} + table.insert(temp, cardMap[card].cardList[1]) + table.insert(self.tipCardList, temp) + end +end + +function M:CheckOutCardGetMustMax(cardSet, cardMap, flag_threeOrFour, longList) + if flag_threeOrFour then + for i = 3, 15 do + if cardMap[i] then + if i == cardSet[#cardSet] then + table.insert(self.touchCardSet, i) + self.touchCardMao[i] = 1 + table.insert(self.tipCardList, cardMap[i].cardList) + elseif cardMap[i].value >= 2 then + table.insert(self.touchCardSet, i) + self.touchCardMao[i] = 1 + table.insert(self.tipCardList, cardMap[i].cardList) + else + table.insert(self.touchCardSet, i) + self.touchCardMao[i] = 1 + end + else + table.insert(self.touchCardSet, i) + self.touchCardMao[i] = 1 + end + end + else + for i = 1, #cardSet do + local card = cardSet[i] + if i == #cardSet then + table.insert(self.touchCardSet, card) + self.touchCardMao[card] = 1 + table.insert(self.tipCardList, cardMap[card].cardList) + elseif cardMap[card].value >= 2 then + table.insert(self.touchCardSet, card) + self.touchCardMao[card] = 1 + table.insert(self.tipCardList, cardMap[card].cardList) + end + end + end + ---单数顺另外添加到提示和现实 + for i = 1, #longList do + local tempTipList = {} + for j = 1, #longList[i] do + local card = longList[i][j] + if not self.touchCardMao[card] then + table.insert(self.touchCardSet, card) + self.touchCardMao[card] = 1 + end + table.insert(tempTipList, cardMap[card].cardList[1]) + end + table.insert(self.tipCardList, tempTipList) + end +end + +function M:CheckOutCardGetType() + local cardType = 0 + local only = 0 + local longLength = 1 + if self.type == 0 then + return cardType, only, longLength + end + if self.type == CardType.one or self.type == CardType.long then + cardType = 1 + if self.type == CardType.long then + longLength = self.lastCardNum + end + elseif self.type == CardType.dui or self.type == CardType.duiLong then + cardType = 2 + if self.lastCardNum > 2 then + longLength = self.lastCardNum / 2 + end + elseif self.type == CardType.threeAndTwo or self.type == CardType.onlyThree or self.type == CardType.normolPlant or self.type == CardType.onlyPlant then + cardType = 3 + if self.type == CardType.onlyThree or self.type == CardType.onlyPlant then + only = 1 + if self.type == CardType.onlyPlant then + longLength = self.lastCardNum / 3 + end + end + if self.type == CardType.normolPlant then + longLength = self.lastCardNum / 5 + end + elseif self.type == CardType.zha or self.type == CardType.zhaAndThreee then + cardType = 4 + if self.type == CardType.zha then + only = 1 + end + end + return cardType, only, longLength +end + +function M:CheckOutCardGetTouchSet(cardSet, cardMap, cardType, longLength) + print("lingmengCheckOutCardGetTouchSet", cardType, longLength, self.lastMinCard) + pt(cardSet) + pt(cardMap) + local tempLong = 0 + local lastCard = 0 + local tempCardSet = {} + local tipCardSet = {} + for i = 1, #cardSet do + local card = cardSet[i] + if cardMap[card].value >= cardType and card > self.lastMinCard then + if tempLong == 0 then + tempLong = 1 + else + if lastCard - card == -1 then + tempLong = tempLong + 1 + else + if tempLong >= longLength then + for j = 1, tempLong do + table.insert(self.touchCardSet, tempCardSet[j]) + self.touchCardMao[tempCardSet[j]] = 1 + end + end + table.insert(tipCardSet, tempCardSet) + tempLong = 1 + tempCardSet = {} + end + end + table.insert(tempCardSet, card) + lastCard = card + end + if cardMap[card].value == 4 then + table.insert(self.touchCardSet, card) + self.touchCardMao[card] = 1 + table.insert(tipCardSet, card) + end + end + if tempLong >= longLength then + for j = 1, tempLong do + table.insert(self.touchCardSet, tempCardSet[j]) + self.touchCardMao[tempCardSet[j]] = 1 + end + end + table.insert(tipCardSet, tempCardSet) + return tipCardSet +end + +function M:CheckOutCardSetTipList(tipCardSet, longLength, cardMap, cardType) + print("lingmengCheckOutCardSetTipList", longLength, cardMap, cardType) + pt(tipCardSet) + for i = 1, #tipCardSet do + if type(tipCardSet[i]) == 'number' then + table.insert(self.tipCardList, cardMap[tipCardSet[i]].cardList) + else + local tipCardSetLen = #tipCardSet[i] + if tipCardSetLen == longLength then + local tempList = {} + for j = 1, tipCardSetLen do + local card = tipCardSet[i][j] + local minNum = Mathf.Min(cardMap[card].value, cardType) + for k = 1, minNum do + table.insert(tempList, cardMap[card].cardList[k]) + end + end + table.insert(self.tipCardList, tempList) + else + for j = 1, tipCardSetLen do + if j + longLength - 1 <= tipCardSetLen then + local tempList = {} + for k = j, j + longLength - 1 do + local card = tipCardSet[i][k] + local minNum = Mathf.Min(cardMap[card].value, cardType) + for l = 1, minNum do + table.insert(tempList, cardMap[card].cardList[l]) + end + end + table.insert(self.tipCardList, tempList) + end + end + end + end + end +end + +function M:CheckAloneOrLong() + if self.cardNum == 1 and M:CheckType(CardType.one) then + return CardType.one + end + if self.long and M:CheckType(CardType.long) then + return CardType.long + end +end + +function M:CheckDuiZi() + if self.cardNum == 2 and self.cardSize == 1 and M:CheckType(CardType.dui) then + return CardType.dui + end + if self.cardNum % 2 == 0 and M:CheckType(CardType.duiLong) then + local last_k + for i = 1, self.cardSize do + local k = self.cardListSord[i] + local v = self.cardList[k] + if v == 2 then + if not last_k then + last_k = k + else + if math.abs(last_k - k) ~= 1 then + return + end + last_k = k + end + else + return + end + end + return CardType.duiLong + end +end + +function M:CheckSanDai() + --三张 + if self.cardNum == 5 and M:CheckType(CardType.threeAndTwo) then + for i = 1, self.cardSize do + local k = self.cardListSord[i] + local v = self.cardList[k] + if v >= 3 then + return CardType.threeAndTwo + end + end + end + + if self.threelack and self.cardNum == 4 and self.cardSize == 2 and self._flag_allCards and M:CheckType(CardType.threeAndTwo) then + return CardType.threeAndTwo + end + + if self.threeNoBelt and self.cardNum == 3 and self.cardSize == 1 and M:CheckType(CardType.onlyThree) then + return CardType.onlyThree + end + + + --飞机 + local temp_normol_feiji + if self.cardNum % 5 == 0 then + temp_normol_feiji = self.cardNum / 5 + end + + if temp_normol_feiji and M:CheckType(CardType.normolPlant) then + local last_k + local num_san = 0 + for i = 1, self.cardSize do + local k = self.cardListSord[i] + local v = self.cardList[k] + if v >= 3 then + num_san = num_san + 1 + if not last_k then + last_k = k + else + if math.abs(last_k - k) ~= 1 then + return + end + last_k = k + end + end + end + if num_san >= temp_normol_feiji then + return CardType.normolPlant + else + return + end + end + + print("liengmengCheckthreelack", self.threelack, self._flag_allCards) + + if self.threelack and self._flag_allCards and M:CheckType(CardType.normolPlant) then + local last_k + local num_san = 0 + for k, v in pairs(self.cardList) do + if v >= 3 then + num_san = num_san + 1 + print("liengmengCheckthreelack2", last_k, k) + + if not last_k then + last_k = k + else + if math.abs(last_k - k) ~= 1 then + return + end + last_k = k + end + end + end + print("liengmengCheckthreelack4", num_san, self.cardNum - num_san * 3 < num_san * 2) + + if self.cardNum - num_san * 3 < num_san * 2 then + return CardType.normolPlant + else + return + end + end + + print("liengmengCheckplaneNoBelt", self.planeNoBelt, self.cardNum % 3) + + if self.planeNoBelt and self.cardNum % 3 == 0 and M:CheckType(CardType.onlyPlant) then + local last_k + for i = 1, self.cardSize do + local k = self.cardListSord[i] + local v = self.cardList[k] + if v == 3 then + if not last_k then + last_k = k + else + if math.abs(last_k - k) ~= 1 then + return + end + last_k = k + end + else + return + end + end + return CardType.onlyPlant + end +end + +function M:CheckZha() + if self.cardNum == 4 and self.cardSize == 1 then + return CardType.zha + end + + if self.fourDaiThree and self.cardNum == 7 and M:CheckType(CardType.zhaAndThreee) then + local flag_four + for i = 1, self.cardSize do + local k = self.cardListSord[i] + local v = self.cardList[k] + if v == 4 then + return CardType.zhaAndThreee + end + end + return + end +end + +function M:CheckType(type) + if type == CardType.duiLong then + print() + return self._flag_checkLst or self._flag_fristCard or (type == self.type and self.cardNum == self.lastCardNum) + else + return self._flag_checkLst or self._flag_fristCard or type == self.type + end +end + +function M:GetTipsList() + return self.tipCardList +end + +function M:GetTouchSet() + return self.touchCardSet +end + +function M:GetTouchCardMap() + return self.touchCardMao +end + +function M:Clear() + self.cardList = {} + self.cardListSord = {} + self.cardNum = 0 + self.cardSize = 0 + self.long = false + self._flag_checkLst = false +end + +return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/CardType.lua b/lua_probject/extend_project/extend/poker2/suoha/CardType.lua deleted file mode 100644 index 4db14f23..00000000 --- a/lua_probject/extend_project/extend/poker2/suoha/CardType.lua +++ /dev/null @@ -1,24 +0,0 @@ ---- ---- Created by 谌建军. ---- DateTime: 2017/12/18 11:30 ---- - -local ExCardType = { - None = 0, - OneCard = 1, --一张 - OnePair = 2, --一对 - Three = 3, --三张 - Pairs = 4, --连对 - ThreeAndTwo = 5, --三带二 - ThreeAndOne = 6, --三带一 - Plane = 7, --飞机 - PlaneAndTwo = 8, --飞机带二 - PlaneAndOne = 9, --飞机带一 - Straight = 10, --顺子 - - Bomb = 11, --炸 - FourAndtThree = 12, --四代三 - -} - -return ExCardType diff --git a/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo.lua b/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo.lua index 7a6a647b..7d005223 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo.lua @@ -6,12 +6,11 @@ local EXGameInfo = {} local M = EXGameInfo -local roundTable = { 10, 15, 20 } function EXGameInfo.new(blur_view) setmetatable(M, { __index = IGameInfo }) local self = setmetatable({}, { __index = M }) self.class = "EXGameInfo" - UIPackage.AddPackage("extend/poker/suoha/ui/Info_Poker_SuoHa") + UIPackage.AddPackage("extend/poker2/suoha/ui/Info_Poker_SuoHa") return self end @@ -19,39 +18,294 @@ function M:FillData(view, index) self._maxPlayer = 2 -- 默认玩家人数 self._roundChoice = 5 -- 回合选项数 - self._config = UIPackage.CreateObjectFromURL("ui://Info_Poker_RunFastNew/Label_Detail_Play") + -- if oldGameVersion == 1 then + self._config = UIPackage.CreateObjectFromURL("ui://Info_Poker_SuoHa/Label_Detail_Play") + -- else + -- self._config = UIPackage.CreateObjectFromURL("ui://Info_Poker_SuoHa/Creat_EXyueyang") + -- end - local jiangmaSlider = self._config:GetChild("slider_people") - jiangmaSlider.onChanged:Set(function() - self._config:GetChild("text_people").text = string.format("共%s人", Mathf.Round(jiangmaSlider.value)) + + if oldGameVersion == 2 then + self._config:GetController("xipai").selectedIndex = 0 + + self.xipaiValueText = self._config:GetChild('xipaifen') + self.xipaiValueText.text = 1 + self.xipaiValue = 1 + + self.anchouValueText = self._config:GetChild('anchoufen') + self.anchouValueText.text = 1 + self.anchouValue = 1 + + local btn_cr = self._config:GetChild('sdsrbtn') + btn_cr.onClick:Set( + function() + local gniv = GroupNumberInputView_Game.new(nil, function(num) + local value = limit + if otype == 1 then + value = value + ad2d(num) + elseif otype == -1 then + value = value - ad2d(num) + else + value = ad2d(num) + end + + if value < 0 then + ViewUtil.ErrorTip(1, "输入数据异常!") + end + + self.xipaiValueText.text = value / 1000 + self.xipaiValue = value / 1000 + end, 0, nil) + gniv:Show() + end + ) + + + local btn_cr2 = self._config:GetChild('anchoubtn') + btn_cr2.onClick:Set( + function() + local gniv = GroupNumberInputView_Game.new(nil, function(num) + local value = limit + if otype == 1 then + value = value + ad2d(num) + elseif otype == -1 then + value = value - ad2d(num) + else + value = ad2d(num) + end + + if value < 0 then + ViewUtil.ErrorTip(1, "输入数据异常!") + end + + self.anchouValueText.text = value / 1000 + self.anchouValue = value / 1000 + end, 3, nil) + gniv:Show() + end + ) + end + + + + self._config:GetChild("people_2").onClick:Set(function() + self._config:GetController("rule").selectedIndex = 0 end) + + local piao = self._config:GetController("piao") + local daniao = self._config:GetController("daniao") + + piao.onChanged:Add(function() + if piao.selectedIndex ~= 0 then + daniao.selectedIndex = 0 + end + end) + + daniao.onChanged:Add(function() + if daniao.selectedIndex ~= 0 then + piao.selectedIndex = 0 + end + end) +end + +local _help_url = "ui://Info_Poker_SuoHa/Com_help" +function M:GetHelpUrl() + return _help_url +end + +local _icon_url = "ui://Info_Poker_SuoHa/icon" +function M:GetIconUrl() + return _icon_url +end + +local _icon_url1 = "ui://Info_Poker_SuoHa/icon1" +function M:GetIconUrl1() + return _icon_url1 +end + +local _play_list = { "15张玩法", "16张玩法" } +function M:GetPlayList() + return _play_list end function M:LoadConfigData(data) local _config = self._config + _config:GetController("round").selectedIndex = data.opt - 1 + _config:GetController("rule").selectedIndex = data.rule == 2 and 0 or 1 + _config:GetController("play_list").selectedIndex = data.leaf - 1 + _config:GetController("willBeOut").selectedIndex = data.willBeOut - 1 + _config:GetController("heart10").selectedIndex = data.heartten - 1 + _config:GetController("bombSpring").selectedIndex = data.minboom - 1 + _config:GetController("player_num").selectedIndex = data.maxPlayers == 2 and 0 or 1 + _config:GetController("Cost").selectedIndex = data.AA == 0 and 0 or 1 + _config:GetController("showlength").selectedIndex = data.showlength + _config:GetController("fourBeltThree").selectedIndex = data.fourBeltThree + _config:GetController("demolition").selectedIndex = data.demolition + _config:GetController("fangzuobi").selectedIndex = data.fangzuobi + + local sandaidan = data.sandaidan + if sandaidan ~= nil and sandaidan == 1 then + _config:GetChild("sandaidan").selected = true + + _config:GetChild("planelack").selected = false + _config:GetChild("Threelack").selected = false + else + _config:GetChild("sandaidan").selected = false + + _config:GetChild("planelack").selected = data.planelack == 1 and true or false + _config:GetChild("Threelack").selected = data.threelack == 1 and true or false + end + + local fs = data.fs + if fs ~= nil and fs == 1 then + _config:GetChild("fan_sprint").selected = true + else + _config:GetChild("fan_sprint").selected = false + end + + local ba = data.ba + if ba ~= nil and ba == 1 then + _config:GetChild("boom_add").selected = true + else + _config:GetChild("boom_add").selected = false + end + + _config:GetChild("ThreeA").selected = data.threeA == 1 and true or false + + if data.piao ~= nil then + _config:GetController("piao").selectedIndex = data.piao + end + + if data.daniao ~= nil then + _config:GetController("daniao").selectedIndex = data.daniao + end + + if _config:GetChild("fourBeltThree") then + _config:GetChild("fourBeltThree").selected = data.fourDaiTwo + end + + if _config:GetChild("fourBeltTwo") then + _config:GetChild("fourBeltTwo").selected = data.fourDaiThree + end + + if _config:GetChild("xipai") then + _config:GetChild("xipai").selected = data.xi_pai + end + + + if oldGameVersion == 2 then + self.xipaiValueText.text = data.xi_pai_score / 1000 + self.xipaiValue = data.xi_pai_score / 1000 + + self.anchouValueText.text = data.an_chou_score / 1000 + self.anchouValue = data.an_chou_score / 1000 + end end function M:SelectedConfigData() local _config = self._config local round = _config:GetController("round").selectedIndex + local rule = _config:GetController("rule").selectedIndex + local leaf = _config:GetController("play_list").selectedIndex + local willBeOut = _config:GetController("willBeOut").selectedIndex + local bombSpring = _config:GetController("bombSpring").selectedIndex + local heart10 = _config:GetController("heart10").selectedIndex + local player_num = _config:GetController("player_num").selectedIndex + local AA = _config:GetController("Cost").selectedIndex + local showlength = _config:GetController("showlength").selectedIndex + local fourBeltThree = _config:GetController("fourBeltThree").selectedIndex + local demolition = _config:GetController("demolition").selectedIndex + local fangzuobi = _config:GetController("fangzuobi").selectedIndex + local planelack = _config:GetChild("planelack").selected and 1 or 0 + local threelack = _config:GetChild("Threelack").selected and 1 or 0 + local ThreeA = _config:GetChild("ThreeA").selected and 1 or 0 + local piao = _config:GetController("piao").selectedIndex + local daniao = _config:GetController("daniao").selectedIndex + local sandaidan = _config:GetController("sandaidan").selectedIndex + local ba = _config:GetChild("boom_add").selected and 1 or 0 + local fs = _config:GetChild("fan_sprint").selected and 1 or 0 - local peopleNum = Mathf.Round(_config:GetChild("slider_people").value) + ----- + local fourDaiTwo = false + if _config:GetChild("fourBeltThree") then + fourDaiTwo = _config:GetChild("fourBeltThree").selected + end + local fourDaiThree = false + if _config:GetChild("fourBeltTwo") then + fourDaiThree = _config:GetChild("fourBeltTwo").selected + end + + local xi_pai = false + if _config:GetChild("xipai") then + xi_pai = _config:GetChild("xipai").selected + end + + ---- local _data = {} _data["account_id"] = DataManager.SelfUser.Id + _data["opt"] = round + 1 + _data["rule"] = rule == 0 and 2 or 1 + _data["leaf"] = leaf + 1 + _data["AA"] = AA + _data["willBeOut"] = willBeOut + 1 + _data["showlength"] = showlength + _data["heartten"] = willBeOut == 0 and heart10 + 1 or 2 + _data["minboom"] = (willBeOut == 0 and leaf == 1 and player_num == 1) and bombSpring + 1 or 2 + _data["maxPlayers"] = player_num + 2 + _data["fourBeltThree"] = fourBeltThree + _data["demolition"] = demolition + _data["fangzuobi"] = fangzuobi + _data["threeA"] = ThreeA + _data["piao"] = piao + _data["daniao"] = daniao + _data["sandaidan"] = sandaidan + _data["ba"] = ba + _data["fs"] = fs - _data["opt"] = round + 1 --局数 - _data["maxPlayers"] = peopleNum --人数为peopleNum - _data["min_score"] = 0 - _data["max_score"] = 0 - _data["max_bet"] = 0 - _data["join_score"] = 0 - _data["min_player"] = 0 - _data["base_score"] = 0 + _data["fourDaiTwo"] = fourDaiTwo + _data["fourDaiThree"] = fourDaiThree + + + if willBeOut == 1 then + -- body + _data["planelack"] = 0 + _data["threelack"] = 0 + else + if sandaidan == 1 then + _data["planelack"] = 0 + _data["threelack"] = 0 + else + _data["planelack"] = planelack + _data["threelack"] = threelack + end + end + + _data['xi_pai'] = xi_pai + + local xi_pai_score = 0 + local an_chou_score = 0 + + if oldGameVersion == 2 then + xi_pai_score = self.xipaiValue + an_chou_score = self.anchouValue + end + + _data['xi_pai_score'] = xi_pai_score * 1000 + _data['an_chou_score'] = an_chou_score * 1000 return _data end +function M:OnChangeOption(ctype, pay_obj) + IGameInfo.OnChangeOption(self, ctype, pay_obj) + local people = self._config:GetController("player_num") + people.onChanged:Set(function() + self._maxPlayer = people.selectedIndex + 2 + self:ShowVariablePrice(ctype, pay_obj) + end) +end + function M:LoadConfigToDetail(data) local configData = json.decode(data) local returnString = string.format("人数%s人", configData.maxPlayers) diff --git a/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo_jiangxi.lua b/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo_jiangxi.lua new file mode 100644 index 00000000..65a75ff9 --- /dev/null +++ b/lua_probject/extend_project/extend/poker2/suoha/EXGameInfo_jiangxi.lua @@ -0,0 +1,83 @@ +--- +--- Created by 谌建军. +--- DateTime: 2017/12/18 15:19 +--- +local EXGameInfo = {} + +local M = EXGameInfo + +local roundTable = { 10, 15, 20 } +function EXGameInfo.new(blur_view) + setmetatable(M, { __index = IGameInfo }) + local self = setmetatable({}, { __index = M }) + self.class = "EXGameInfo" + UIPackage.AddPackage("extend/poker2/suoha/ui/Info_Poker_SuoHa") + return self +end + +function M:FillData(view, index) + self._maxPlayer = 2 -- 默认玩家人数 + self._roundChoice = 5 -- 回合选项数 + + self._config = UIPackage.CreateObjectFromURL("ui://Info_Poker_SuoHa/Label_Detail_Play") + + self.peopleSlider = self._config:GetChild("slider_people") + self.peopleSlider.onChanged:Set(function() + self._config:GetChild("text_people").text = string.format("共%s牛马", Mathf.Round(self.peopleSlider.value) + 1) + end) +end + +local _help_url = "ui://Info_Poker_RunFastNew/Com_help" +function M:GetHelpUrl() + return _help_url +end + +local _icon_url = "ui://Info_Poker_RunFastNew/icon" +function M:GetIconUrl() + return _icon_url +end + +local _icon_url1 = "ui://Info_Poker_RunFastNew/icon1" +function M:GetIconUrl1() + return _icon_url1 +end + +function M:LoadConfigData(data) + local _config = self._config +end + +function M:SelectedConfigData() + local _config = self._config + local round = _config:GetController("round").selectedIndex + + + local _data = {} + _data["round"] = round + _data["peopleNum"] = Mathf.Round(self.peopleSlider.value) + 1 + _data["min_score"] = 0 + _data["max_score"] = 0 + _data["max_bet"] = 0 + _data["join_score"] = 0 + _data["min_player"] = 0 + _data["base_score"] = 0 + + return _data +end + +-- function M:OnChangeOption(ctype, pay_obj) +-- IGameInfo.OnChangeOption(self, ctype, pay_obj) +-- local peopleNum = self._config:GetController("peopleNum") +-- peopleNum.onChanged:Set(function() +-- self._maxPlayer = peopleNum.selectedIndex == 1 and 2 or 3 +-- self:ShowVariablePrice(ctype, pay_obj) +-- end) +-- end + +function M:LoadConfigToDetail(data) + local configData = json.decode(data) + local returnString = string.format("人数%s人", configData.maxPlayers) + + return returnString +end + +return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/Player.lua b/lua_probject/extend_project/extend/poker2/suoha/EXPlayer.lua similarity index 94% rename from lua_probject/extend_project/extend/poker2/suoha/Player.lua rename to lua_probject/extend_project/extend/poker2/suoha/EXPlayer.lua index 0d1eeadd..8194e835 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/Player.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXPlayer.lua @@ -2,7 +2,7 @@ --- Created by 谌建军. --- DateTime: 2017/12/13 10:42 --- -local ExPlayer = { +local EXPlayer = { -- 手牌列表 hand_count = 0, out_card_list = {}, @@ -10,7 +10,7 @@ local ExPlayer = { isOneCard = false, -- 报单 } -local M = ExPlayer +local M = EXPlayer --- Create a new EXPlayer function M.new() diff --git a/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua index 40516ef6..541ed751 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXPlayerInfoView.lua @@ -13,6 +13,33 @@ end function M:FillData(player) PlayerInfoView.FillData(self, player) + -- if player.cur_hp ~= nil then + -- self:UpdateScore(d2ad(player.cur_hp)) + -- else + -- local rt = 1 + -- if self._main_view._room.hpOnOff == 1 then + -- rt = self._main_view._room.score_times + -- end + -- self:UpdateScore(player.total_score * rt) + -- end +end + +function M:UpdatePiao(piao) + if piao == nil or piao == -1 then + self._view:GetChild("piao").text = "" + elseif piao == 0 then + self._view:GetChild("piao").text = "不飘" + elseif piao == 1 then + self._view:GetChild("piao").text = "飘1分" + elseif piao == 2 then + self._view:GetChild("piao").text = "飘2分" + elseif piao == 3 then + self._view:GetChild("piao").text = "飘3分" + elseif piao == 5 then + self._view:GetChild("piao").text = "飘5分" + elseif piao == 8 then + self._view:GetChild("piao").text = "飘8分" + end end return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/Room.lua b/lua_probject/extend_project/extend/poker2/suoha/EXRoom.lua similarity index 74% rename from lua_probject/extend_project/extend/poker2/suoha/Room.lua rename to lua_probject/extend_project/extend/poker2/suoha/EXRoom.lua index 3826d090..140b85fc 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/Room.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXRoom.lua @@ -2,12 +2,12 @@ --- Created by 谌建军. --- DateTime: 2017/12/19 14:36 --- -local ExPlayer = import(".ExPlayer") +local EXPlayer = import(".EXPlayer") -local ExRoom = { +local EXRoom = { } -local M = ExRoom +local M = EXRoom --- Create a new EXPlayer function M.new() @@ -18,7 +18,7 @@ function M.new() end function M:NewPlayer() - return ExPlayer.new() + return EXPlayer.new() end return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/RoomConfig.lua b/lua_probject/extend_project/extend/poker2/suoha/EXRoomConfig.lua similarity index 61% rename from lua_probject/extend_project/extend/poker2/suoha/RoomConfig.lua rename to lua_probject/extend_project/extend/poker2/suoha/EXRoomConfig.lua index 5d25ddcc..7ba3aea0 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/RoomConfig.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/EXRoomConfig.lua @@ -7,57 +7,57 @@ local M = {} --- Create a new RoomConfig function M.new(config) - setmetatable(M, { __index = RoomConfig }) - local self = setmetatable({}, { __index = M }) - RoomConfig.init(self, config) - self.class = "ExRoomConfig" - self.config = config - self.Leaf = config.leaf - self.Rule = config.rule - self.Times = config.times - self.WillBeOut = config.willBeOut - self.Heart10 = config.heartten - self.BombSpring = config.minboom - self.AA = config.aa - self.PlayerNum = config.maxPlayers - self.showlength = config.showlength - self.fourBeltThree = config.fourBeltThree - self.demolition = config.demolition - self.fangzuobi = config.fangzuobi - self.planelack = config.planelack - self.threelack = config.threelack - self.threeA = config.threeA - self.tuoguan_active_time = config.tuoguan_active_time - self.tuoguan = config.tuoguan - self.tuoguan_result_type = config.tuoguan_result_type - self.isNonnegative = config.isNonnegative - self.sandaidan = config.sandaidan - self.isHidden = config.isHidden - self.ba = config.ba - self.fs = config.fs + setmetatable(M, { __index = RoomConfig }) + local self = setmetatable({}, { __index = M }) + RoomConfig.init(self, config) + self.class = "EXRoomConfig" + self.config = config + self.Leaf = config.leaf + self.Rule = config.rule + self.Times = config.times + self.WillBeOut = config.willBeOut + self.Heart10 = config.heartten + self.BombSpring = config.minboom + self.AA = config.aa + self.PlayerNum = config.maxPlayers + self.showlength = config.showlength + self.fourBeltThree = config.fourBeltThree + self.demolition = config.demolition + self.fangzuobi = config.fangzuobi + self.planelack = config.planelack + self.threelack = config.threelack + self.threeA = config.threeA + self.tuoguan_active_time = config.tuoguan_active_time + self.tuoguan = config.tuoguan + self.tuoguan_result_type = config.tuoguan_result_type + self.isNonnegative = config.isNonnegative + self.sandaidan = config.sandaidan + self.isHidden = config.isHidden + self.ba = config.ba + self.fs = config.fs - if config.piao ~= nil then - self.piao = config.piao - else - self.piao = 0 - end + if config.piao ~= nil then + self.piao = config.piao + else + self.piao = 0 + end - if config.daniao ~= nil then - self.daniao = config.daniao - else - self.daniao = 0 - end + if config.daniao ~= nil then + self.daniao = config.daniao + else + self.daniao = 0 + end - if self.isNonnegative == nil then - self.isNonnegative = 0 - end - self.energyTab = config.energyTab + if self.isNonnegative == nil then + self.isNonnegative = 0 + end + self.energyTab = config.energyTab - if self.energyTab == nil then - self.energyTab = 0 - end + if self.energyTab == nil then + self.energyTab = 0 + end - return self + return self end --[[function M:GetDes(sp) @@ -383,104 +383,104 @@ end--]] function M:GetDes(sp) - sp = sp or " " - local str = "" - -- str = str.. self.Times.."局"..sp - str = str .. RoomConfig.GetDes(self, sp) - if self.Leaf == 1 then - str = str .. "15张玩法" .. sp - else - str = str .. "16张玩法" .. sp - end + sp = sp or " " + local str = "" + -- str = str.. self.Times.."局"..sp + str = str .. RoomConfig.GetDes(self, sp) + if self.Leaf == 1 then + str = str .. "15张玩法" .. sp + else + str = str .. "16张玩法" .. sp + end - if self.Rule == 1 then - str = str .. "第一局黑桃3先出,随后赢家先出" .. sp - else - str = str .. "第一局系统随机选一张先出,随后赢家先出" .. sp - end + if self.Rule == 1 then + str = str .. "第一局黑桃3先出,随后赢家先出" .. sp + else + str = str .. "第一局系统随机选一张先出,随后赢家先出" .. sp + end - if self.WillBeOut == 1 then - str = str .. "能出必出" .. sp - else - str = str .. "可不必出" .. sp - end - if self.showlength == 1 then - str = str .. "显示剩余牌" .. sp - end - if self.fourBeltThree == 3 then - str = str .. "四带三" .. sp - elseif self.fourBeltThree == 2 then - str = str .. "四带二" .. sp - end - if self.Heart10 == 1 then - str = str .. "红桃10分数翻倍" .. sp - end + if self.WillBeOut == 1 then + str = str .. "能出必出" .. sp + else + str = str .. "可不必出" .. sp + end + if self.showlength == 1 then + str = str .. "显示剩余牌" .. sp + end + if self.fourBeltThree == 3 then + str = str .. "四带三" .. sp + elseif self.fourBeltThree == 2 then + str = str .. "四带二" .. sp + end + if self.Heart10 == 1 then + str = str .. "红桃10分数翻倍" .. sp + end - if self.BombSpring == 1 then - str = str .. "4个3 或者3个A 1个2 春天" .. sp - end - if self.demolition == 1 then - str = str .. "炸弹不能拆" .. sp - end - if self.fangzuobi == 1 and self.PlayerNum == 3 then - str = str .. "防作弊" .. sp - end + if self.BombSpring == 1 then + str = str .. "4个3 或者3个A 1个2 春天" .. sp + end + if self.demolition == 1 then + str = str .. "炸弹不能拆" .. sp + end + if self.fangzuobi == 1 and self.PlayerNum == 3 then + str = str .. "防作弊" .. sp + end - if self.sandaidan == 1 then - str = str .. "三张飞机带单或者对子" .. sp - end + if self.sandaidan == 1 then + str = str .. "三张飞机带单或者对子" .. sp + end - if self.ba == 1 then - str = str .. "炸弹分数算赢家" .. sp - end + if self.ba == 1 then + str = str .. "炸弹分数算赢家" .. sp + end - if self.fs == 1 then - str = str .. "反春天" .. sp - end + if self.fs == 1 then + str = str .. "反春天" .. sp + end - if self.planelack == 1 then - str = str .. "飞机少带可接完" .. sp - end - if self.threelack == 1 then - str = str .. "三张少带可接完" .. sp - end - if self.threeA == 1 then - str = str .. "三张A算炸弹" .. sp - end + if self.planelack == 1 then + str = str .. "飞机少带可接完" .. sp + end + if self.threelack == 1 then + str = str .. "三张少带可接完" .. sp + end + if self.threeA == 1 then + str = str .. "三张A算炸弹" .. sp + end - if self.piao == 0 then + if self.piao == 0 then - elseif self.piao == 1 then - str = str .. "飘123" .. sp - elseif self.piao == 2 then - str = str .. "飘235" .. sp - elseif self.piao == 3 then - str = str .. "飘258" .. sp - end + elseif self.piao == 1 then + str = str .. "飘123" .. sp + elseif self.piao == 2 then + str = str .. "飘235" .. sp + elseif self.piao == 3 then + str = str .. "飘258" .. sp + end - if self.daniao == 1 then - str = str .. "打鸟+10" .. sp - elseif self.daniao == 2 then - str = str .. "打鸟+20" .. sp - elseif self.daniao == 3 then - str = str .. "打鸟+50" .. sp - end + if self.daniao == 1 then + str = str .. "打鸟+10" .. sp + elseif self.daniao == 2 then + str = str .. "打鸟+20" .. sp + elseif self.daniao == 3 then + str = str .. "打鸟+50" .. sp + end - return str + return str end function M:GetGameJS() - local gamerulepanel = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/gamerule") - return gamerulepanel + local gamerulepanel = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/gamerule") + return gamerulepanel end function M:GetGameSMSize() - return 467, 500 + return 467, 500 end function M:GetGameName() - return "跑得快" + return "跑得快" end --function M:GetIsShowCardNumber() diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExCardType.lua b/lua_probject/extend_project/extend/poker2/suoha/ExCardType.lua new file mode 100644 index 00000000..34ffa6c2 --- /dev/null +++ b/lua_probject/extend_project/extend/poker2/suoha/ExCardType.lua @@ -0,0 +1,24 @@ +--- +--- Created by 谌建军. +--- DateTime: 2017/12/18 11:30 +--- + +local EXCardType = { + None = 0, + OneCard = 1, --一张 + OnePair = 2, --一对 + Three = 3, --三张 + Pairs = 4, --连对 + ThreeAndTwo = 5, --三带二 + ThreeAndOne = 6, --三带一 + Plane = 7, --飞机 + PlaneAndTwo = 8, --飞机带二 + PlaneAndOne = 9, --飞机带一 + Straight = 10, --顺子 + + Bomb = 11, --炸 + FourAndtThree = 12, --四代三 + +} + +return EXCardType diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExGameController.lua b/lua_probject/extend_project/extend/poker2/suoha/ExGameController.lua index b334124f..ff90f832 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExGameController.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExGameController.lua @@ -3,20 +3,25 @@ --- DateTime: 2017/12/13 11:28 --- -local ExProtocol = import(".ExProtocol") -local ExGameEvent = import(".ExGameEvent") -local CardType = import(".CardType") +local EXProtocol = import(".EXProtocol") +local EXGameEvent = import(".EXGameEvent") +local EXCardType = import(".EXCardType") +local EXPutError = { + "必须先出最小的牌", + "出牌不符合规定牌型 ", + "下家报单,请出最大的牌 ", + "炸弹不能拆" +} +local EXGameController = {} -local ExGameController = {} - -local M = ExGameController +local M = EXGameController function M.new() setmetatable(M, { __index = GameController }) local self = setmetatable({}, { __index = M }) self:init("跑得快") - self.class = "ExGameController" + self.class = "EXGameController" return self end @@ -27,7 +32,639 @@ end -- 事件注册 function M:RegisterEvt() + self._eventmap[EXProtocol.GAME_EVT_PLAYER_DEAL] = self.OnSendCard + self._eventmap[EXProtocol.GAME_EVT_ACTION] = self.OnTipAction + self._eventmap[EXProtocol.GAME_EVT_RESULT1] = self.OnResult1 + self._eventmap[EXProtocol.GAME_EVT_RESULT2] = self.OnResult2 + self._eventmap[EXProtocol.GAME_EVT_CHANGE_ACTIVE_PLAYER] = self.OnTurnAction +end +-- function M:SendXiPaiAction(callBack) +-- local _data = {} +-- local _client = ControllerManager.GameNetClinet +-- _client:send(EXProtocol.GAME_XIPAI, _data) +-- self.XiPaiCallBack = callBack +-- end + +-- function M:OnEventXiPai(evt_data) +-- if evt_data["result"] == 0 then +-- if self.XiPaiCallBack then +-- self.XiPaiCallBack() +-- end +-- else +-- ViewUtil.ErrorTip(1000000, "申请洗牌失败") +-- end +-- end + +-- function M:OnEventXiPaiAnim(evt_data) +-- printlog("洗牌动画===》》》》") +-- pt(evt_data) +-- local playeridList = evt_data["list"] +-- local my_isXiPai = false +-- local other_isXiPai = false +-- if playeridList and #playeridList > 0 then +-- for i = 1, #playeridList do +-- local p = self._room:GetPlayerById(playeridList[i]) +-- if p == self._room.self_player then +-- my_isXiPai = true +-- else +-- other_isXiPai = true +-- end +-- end +-- end + +-- self._cacheEvent:Enqueue(function() +-- DispatchEvent(self._dispatcher, EXGameEvent.EventXiPai, my_isXiPai, other_isXiPai) +-- end) +-- end + +--我发出的协议 + +--绑定协议为事件 +function M:OnSendCard(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnSendCard, evt_data) + end + ) +end + +function M:OnTipAction(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnTipAction, evt_data) + end + ) +end + +function M:OnResult1(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnResult1, evt_data) + end + ) +end + +function M:OnResult2(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnResult2, evt_data) + end + ) +end + +function M:OnTurnAction(evt_data) + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnTurnAction, evt_data) + end + ) +end + +-- +function M:OnMingCard(evt_data) + if ViewManager.GetCurrenView().dview_class == LobbyView then + self:ReturnToRoom() + return + end + + local card = evt_data["mingpai"] + self._cacheEvent:Enqueue( + function() + self._room.ming_card = card + DispatchEvent(self._dispatcher, EXGameEvent.OnMingCard, card) + end + ) +end + +function M:OnInitCard(evt_data) + if ViewManager.GetCurrenView().dview_class == LobbyView then + self:ReturnToRoom() + return + end + + local cardlist = evt_data["cards"] + local round = evt_data["round"] + self._cacheEvent:Enqueue( + function() + for _, player in ipairs(self._room.player_list) do + player:Clear() + player.hand_count = #cardlist + end + + self._room.curren_round = round + DispatchEvent(self._dispatcher, EXGameEvent.OnInitCard, round, cardlist) + end + ) +end + +function M:OnBombScore(evt_data) + local scoreList = evt_data["gold_list"] + self._cacheEvent:Enqueue( + function() + for i = 1, #scoreList do + local score = scoreList[i].bom_score + local player = self._room:GetPlayerById(scoreList[i].aid) + player.total_score = player.total_score + score + end + DispatchEvent(self._dispatcher, EXGameEvent.OnBombScore, scoreList) + end + ) +end + +function M:OnPlaySucc(evt_data) + if pcall( + self.OnPlaySuccCheck, self, evt_data + ) then + + else + printlog("数据异常OnPlaySucc==>>>") + end +end + +function M:OnPlaySuccCheck(evt_data) + local seat = evt_data["player"] + local card_obj = evt_data["card_obj"] + local cards = card_obj["card_list"] + local remain = evt_data["remain"] -- 报单 + self._cacheEvent:Enqueue( + function() + local otherList = self:GetOtherSeatList(seat) + local player = self._room:GetPlayerBySeat(seat) + local out_card_list = self:ChangeCodeByFrom(cards, true) + player.hand_count = remain + local card_type, number, length, plan_three_count = self:GetCardListInfo(out_card_list) + player.out_card_list = self:GetSortOutCardList(out_card_list, card_type, number, plan_three_count) + DispatchEvent(self._dispatcher, EXGameEvent.OnPlaySucc, player, remain, card_type, number, otherList, + length) + end + ) +end + +function M:OnPlaySuccCheckHandCard(evt_data) + local seat = evt_data["player"] + local cards = evt_data["handCards"] + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnPassSuccCheckCard, seat, cards) + end + ) +end + +function M:OnPassSucc(evt_data) + local seat = evt_data["seat"] + self._cacheEvent:Enqueue( + function() + local p = self._room:GetPlayerBySeat(seat) + p.out_card_list = { 0 } + DispatchEvent(self._dispatcher, EXGameEvent.OnPassSucc, p) + end + ) +end + +function M:OnPutError(evt_data) + local code = evt_data["error"] + self._cacheEvent:Enqueue( + function() + local error_str = self:GetErrorStr(code) + DispatchEvent(self._dispatcher, EXGameEvent.OnErrorTip, error_str) + end + ) +end + +function M:TuoGuan(isTuo) + local _data = {} + _data["tuoguan"] = isTuo + local _client = ControllerManager.GameNetClinet + _client:send(EXProtocol.SEND_TUOGUAN, _data) +end + +function M:Game_TuoGuan(evt_data) + local tuoguan = evt_data["tuoguan"] + local seat = evt_data["seat"] + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, EXGameEvent.Game_TuoGuan, tuoguan, seat) + end) +end + +function M:OnIndexMove(evt_data) + local seat = evt_data["index"] + self._cacheEvent:Enqueue( + function() + self._room.curren_turn_seat = seat + self._room.is_new_bout = self:GetIsNewBout(seat) + DispatchEvent(self._dispatcher, EXGameEvent.OnIndexMove, seat) + end + ) +end + +function M:OnOptions(evt_data) + local play = evt_data["play"] + local pass = evt_data["pass"] + + self._cacheEvent:Enqueue( + function() + local lastCardList = self:GetLastCardList(self._room.self_player.seat) + local cardType, cardNum, cardLength = self:GetCardListInfo(lastCardList) + DispatchEvent(self._dispatcher, EXGameEvent.OnOptions, play, cardType, cardNum, cardLength, pass, + lastCardList) + end + ) +end + +function M:OnPiaoTip(evt_data) + if ViewManager.GetCurrenView().dview_class == LobbyView then + self:ReturnToRoom() + return + end + + local piao = evt_data["piao"] + local reload = evt_data["reload"] + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnPiaoTips, piao, reload) + end + ) +end + +function M:OnPiaoAction(evt_data) + local seat = evt_data["seat"] + local piao = evt_data["piao"] + + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnPiaoAction, seat, piao) + end + ) +end + +function M:OnResult(evt_data) + local result_type = evt_data["type"] + + local info = evt_data["info"] + local winseat = evt_data["winseat"] + local remaincards = evt_data["remaincards"] + DataManager.CurrenRoom.xipaiScore = evt_data["xipai_score"] + --printlog("wwwwwwwwwwwwwwwwwwwww1111111 ",result_type) + --pt(evt_data) + if result_type == 1 then + local over = 1 + ControllerManager.SetGameNetClient(nil, true) + self._cacheEvent:Enqueue( + function() + for i = 1, #info do + local p = self._room:GetPlayerBySeat(info[i]["seat"]) + p.total_score = info[i]["score"] + info[i]["self_user"] = p.self_user + end + + DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards) + end + ) + elseif result_type == 0 then + local over = 0 + self._cacheEvent:Enqueue( + function() + for i = 1, #info do + local p = self._room:GetPlayerBySeat(info[i]["seat"]) + p.total_score = info[i]["score"] + info[i]["self_user"] = p.self_user + end + DispatchEvent(self._dispatcher, EXGameEvent.OnResult, over, info, winseat, remaincards) + end + ) + else + local dissolve = 1 + ControllerManager.SetGameNetClient(nil, true) + for i = 1, #info do + local p = self._room:GetPlayerBySeat(info[i]["seat"]) + p.total_score = info[i]["score"] + info[i]["self_user"] = p.self_user + end + -- ControllerManager.ChangeController(LoddyController) + DispatchEvent(self._dispatcher, EXGameEvent.OnResultByDissolve, over, info, winseat, dissolve) + end +end + +function M:OnConfrimToNextGameSucc(evt_data) + local aid = evt_data["aid"] + self._cacheEvent:Enqueue( + function() + DispatchEvent(self._dispatcher, EXGameEvent.OnConfrimToNextGameSucc, aid) + end + ) +end + +function M:Game_TuoGuan(evt_data) + local tuoguan = evt_data["tuoguan"] + local seat = evt_data["seat"] + self._cacheEvent:Enqueue(function() + DispatchEvent(self._dispatcher, EXGameEvent.Game_TuoGuan, tuoguan, seat) + end) +end + +function M:ChangeCodeByFrom(cardList, isSort) + isSort = isSort or false + local new_card_list = {} + for i = 1, #cardList do + local flower = math.floor(cardList[i] / 100) + local number = cardList[i] % 100 + if number == 2 then + number = 15 + end + local card = number * 10 + flower + new_card_list[#new_card_list + 1] = card + end + return isSort == true and table.sort(new_card_list) or new_card_list +end + +function M:GetOtherSeatList(seat) + local list = {} + for i = 1, self._room.room_config.people_num do + if seat ~= i then + list[#list + 1] = i + end + end + return list +end + +-- +function M:GetIsNewBout(seat) + local passCount = 0 + for i = 1, #self._room.player_list do + local player = self._room.player_list[i] + if seat ~= player.seat then + local isPass = self:GetIsPass(player.out_card_list) + if isPass then + passCount = passCount + 1 + end + end + end + if passCount == self._room.room_config.people_num - 1 then + return true + else + return false + end +end + +function M:GetLastSeat(seat) + local last_seat = seat - 1 + if last_seat < 1 then + last_seat = last_seat + self._room.room_config.people_num + end + return last_seat +end + +function M:GetLastCardList(seat) + local last_seat = self:GetLastSeat(seat) + local player = self._room:GetPlayerBySeat(last_seat) + local isPass = self:GetIsPass(player.out_card_list) + if isPass then + if self._room.room_config.people_num == 2 then + return {} + end + local last_seat_2 = self:GetLastSeat(last_seat) + local player_2 = self._room:GetPlayerBySeat(last_seat_2) + local isPass_2 = self:GetIsPass(player_2.out_card_list) + if isPass_2 then + return {} + else + return player_2.out_card_list + end + else + return player.out_card_list + end +end + +function M:GetErrorStr(code) + return EXPutError[code + 1] +end + +function M:GetSortOutCardList(outCardList, cardType, cardNumber, plan_three_count) + if cardType == 3 or cardType == 5 or cardType == 6 then + local removeList = {} + for i = #outCardList, 1, -1 do + local card = outCardList[i] + if math.floor(card / 10) == cardNumber then + removeList[#removeList + 1] = card + table.remove(outCardList, i) + end + end + for i = 1, #removeList do + table.insert(outCardList, 1, removeList[i]) + end + elseif cardType >= 7 and cardType <= 9 then + local removeList = {} + for i = #outCardList, 1, -1 do + local card = outCardList[i] + if math.floor(card / 10) <= cardNumber and math.floor(card / 10) > cardNumber - plan_three_count then + removeList[#removeList + 1] = card + table.remove(outCardList, i) + end + end + for i = 1, #removeList do + table.insert(outCardList, 1, removeList[i]) + end + end + return outCardList +end + +--None = 0, +--OneCard = 1, +--OnePair = 2, +--Three = 3, +--Pairs = 4, +--ThreeAndTwo = 5, +--ThreeAndOne = 6, +--Plane = 7, +--PlaneAndTwo = 8, +--PlaneAndOne = 9, +--Straight = 10, +--Bomb = 11 +-- 牌型,大小, 长度 +function M:GetCardListInfo(cardlist) + if #cardlist == 0 then + return 0, 0, 0, 0 + end + -- 检测牌型 + local card_type, card_num, card_length, plan_three_count = EXCardType.None, 0, #cardlist, 0 + local card_map = self:GetCardMapByList(cardlist) + + if #cardlist == 1 then + card_type = EXCardType.OneCard + card_num = math.floor(cardlist[1] / 10) + elseif #cardlist == 2 then + card_type = EXCardType.OnePair + card_num = math.floor(cardlist[1] / 10) + elseif #cardlist == 3 then + card_num = math.floor(cardlist[1] / 10) + if card_num == 14 and DataManager.CurrenRoom.room_config.threeA == 1 then + -- body + card_type = EXCardType.Bomb + else + card_type = EXCardType.Three + end + elseif #cardlist == 4 then + local max_key = 0 + for k, v in pairs(card_map) do + if #v == 4 then + card_type = EXCardType.Bomb + card_num = k + elseif #v == 3 then + card_type = EXCardType.ThreeAndOne + card_num = k + elseif #v == 2 then + if k > max_key then + max_key = k + end + card_type = EXCardType.Pairs + card_num = max_key + end + end + elseif #cardlist == 5 then + local count, max_key = 0, 0 + for k, v in pairs(card_map) do + if #v >= 3 then + card_type = EXCardType.ThreeAndTwo + card_num = k + elseif #v == 1 then + count = count + 1 + if k > max_key then + max_key = k + end + if count == 5 then + card_type = EXCardType.Straight + card_num = max_key + end + end + end + elseif #cardlist == 7 then + local count, max_key = 0, 0 + for k, v in pairs(card_map) do + if #v >= 4 then + card_type = EXCardType.FourAndtThree + card_num = k + elseif #v == 1 then + count = count + 1 + if k > max_key then + max_key = k + end + if count == 7 then + card_type = EXCardType.Straight + card_num = max_key + end + end + end + else + local one_count, two_count, three_count = 0, 0, 0 + local max_one_key, max_two_key, max_three_key = 0, 0, 0 + + for k, v in pairs(card_map) do + if #v == 2 then + if k > max_two_key then + max_two_key = k + end + two_count = two_count + 1 + if two_count == #cardlist / 2 then + card_type = EXCardType.Pairs + card_num = max_two_key + end + elseif #v == 1 then + if k > max_one_key then + max_one_key = k + end + one_count = one_count + 1 + if one_count == #cardlist then + card_type = EXCardType.Straight + card_num = max_one_key + end + elseif #v == 3 then + if max_three_key == 0 then + max_three_key = k + three_count = three_count + 1 + elseif k > max_three_key and k == max_three_key + 1 then + max_three_key = k + three_count = three_count + 1 + elseif k < max_three_key and k == max_three_key - 1 then + max_three_key = k + three_count = three_count + 1 + -- else + -- max_three_key = k + end + + --three_count = three_count + 1 + end + end + -- plan_three_count = three_count + -- if three_count * 5 >= #cardlist then + -- card_type = EXCardType.PlaneAndTwo + -- card_num = max_three_key + -- elseif three_count * 4 >= #cardlist then + -- card_type = EXCardType.PlaneAndOne + -- card_num = max_three_key + -- elseif three_count * 3 >= #cardlist then + -- card_type = EXCardType.Plane + -- card_num = max_three_key + -- end + plan_three_count = three_count + + if three_count * 3 == #cardlist then + card_type = EXCardType.Plane + card_num = max_three_key + elseif three_count * 4 >= #cardlist and #cardlist % 4 == 0 then + card_type = EXCardType.PlaneAndOne + card_num = max_three_key + elseif three_count * 5 >= #cardlist and #cardlist % 5 == 0 then + card_type = EXCardType.PlaneAndTwo + card_num = max_three_key + end + end + + return card_type, card_num, card_length, plan_three_count +end + +function M:GetCardMapByList(cardlist) + local card_map = {} + for i = 1, #cardlist do + local card = cardlist[i] + local card_num = math.floor(cardlist[i] / 10) + if card_map[card_num] == nil then + card_map[card_num] = { card } + else + card_map[card_num][#card_map[card_num] + 1] = card + end + end + return card_map +end + +function M:GetIsPass(cardlist) + if #cardlist == 0 then + return true + end + if cardlist[1] ~= nil and cardlist[1] == 0 then + return true + end + return false +end + +--请求离开房间 +function M:LevelRoom(callBack) + local _client = ControllerManager.GameNetClinet + if not _client then + return + end + _client:send( + Protocol.GAME_EXIT_ROOM, + nil, + function(res) + if res.ReturnCode == 0 then + ControllerManager.ChangeController(LoddyController) + elseif res.ReturnCode == 27 then + ViewUtil.ErrorTip(res.ReturnCode, "退出房间失败!") + end + callBack(res) + end + ) end return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExGameEvent.lua b/lua_probject/extend_project/extend/poker2/suoha/ExGameEvent.lua index cebbc7c4..cf7be9cd 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExGameEvent.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExGameEvent.lua @@ -2,7 +2,11 @@ --- Created by 谌建军. --- DateTime: 2017/12/13 10:55 --- -local ExGameEvent = { - +local EXGameEvent = { + OnSendCard = "OnSendCard", + OnTipAction = "OnTipAction", + OnResult1 = "OnResult1", + OnResult2 = "OnResult2", + OnTurnAction = "OnTurnAction" } -return ExGameEvent +return EXGameEvent diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExMainView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExMainView.lua index 57986319..b22c34be 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExMainView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExMainView.lua @@ -2,19 +2,19 @@ --- Created by 谌建军. --- DateTime: 2017/12/18 9:41 --- -local PKMainView = import("main.poker.PKMainView") -local ExPlayerPokerInfoView = import(".ExPlayerPokerInfoView") -local ExPlayerSelfPokerInfoView = import(".ExPlayerSelfPokerInfoView") -local ExGameEvent = import(".ExGameEvent") -local ExResultView = import(".ExResultView") -local ExRightPanelView = import(".ExRightPanelView") +local PKMainView = import("main.poker2.PKMainView") +local EXPlayerPokerInfoView = import(".EXPlayerPokerInfoView") +local EXPlayerSelfPokerInfoView = import(".EXPlayerSelfPokerInfoView") +local EXGameEvent = import(".EXGameEvent") +local EXResultView = import(".EXResultView") +local EXRightPanelView = import(".EXRightPanelView") local PlayerInfoView = import(".EXPlayerInfoView") local TableBG = import('Game.Data.TableBG') local M = {} function M.new() setmetatable(M, { __index = PKMainView }) local self = setmetatable({}, { __index = M }) - self.class = "ExMainView" + self.class = "EXMainView" self:init() self._gamectr = ControllerManager.GetController(GameController) return self @@ -22,15 +22,15 @@ end local default_bg = 1 local bg_config = { - { id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1' }, - { id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2' }, - { id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3' } + { id = 1, url = 'extend/poker2/suoha/bg/bg1', thumb = 'ui://Extend_Poker_SuoHa/table_bg1' }, + { id = 2, url = 'extend/poker2/suoha/bg/bg2', thumb = 'ui://Extend_Poker_SuoHa/table_bg2' }, + { id = 3, url = 'extend/poker2/suoha/bg/bg3', thumb = 'ui://Extend_Poker_SuoHa/table_bg3' } } function M:InitView(url) local room = self._room - UIPackage.AddPackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew") - PKMainView.InitView(self, "ui://Extend_Poker_RunFastNew/ExMain_New_" .. room.room_config.people_num, nil, 1, + UIPackage.AddPackage("extend/poker2/suoha/ui/Extend_Poker_SuoHa") + PKMainView.InitView(self, "ui://Extend_Poker_SuoHa/EXMain_New_" .. room.room_config.people_num, nil, 1, default_bg, bg_config, nil) local _room = DataManager.CurrenRoom local user_id = DataManager.SelfUser.account_id @@ -76,7 +76,7 @@ function M:InitView(url) self._rightPanelView:Destroy() end - self._rightPanelView = ExRightPanelView.new(self, rightpanel) + self._rightPanelView = EXRightPanelView.new(self, rightpanel) for i = 1, #self._room.player_list do if self._room.self_player.seat == self._room.player_list[i].seat and self._room.self_player.self_user.account_id ~= self._room.player_list[i].self_user.account_id then -- body @@ -125,22 +125,9 @@ function M:InitView(url) _player_card_info[i] = self:NewPlayerCardInfoView(tem, i) end - local list = room.player_list - if not room.self_player.ready then - local round = DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round > 1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - else - self._ctr_action.selectedIndex = 1 - end - else - self._ctr_action.selectedIndex = 0 - end + --默认直接展示准备按钮 + self._ctr_action.selectedIndex = 1 + self._left_time = 0 self.bgm_index = 1 local state = self._room.CurnrenState @@ -270,9 +257,9 @@ end function M:NewPlayerCardInfoView(tem, index) if index == 1 then - return ExPlayerSelfPokerInfoView.new(tem, self) + return EXPlayerSelfPokerInfoView.new(tem, self) end - return ExPlayerPokerInfoView.new(tem, self) + return EXPlayerPokerInfoView.new(tem, self) end function M:OnPlayerEnter(...) @@ -286,9 +273,6 @@ function M:OnPlayerEnter(...) selecet_seat.visible = true end info:FillData(p) - if self._room.banker_seat == self._room.self_player.seat and self._room.self_player.ready then - self._ctr_action.selectedIndex = 0 - end end function M:OnPlayerReady(...) @@ -296,44 +280,11 @@ function M:OnPlayerReady(...) local p = arg[1] local _room = self._room local _player_info = self._player_info - if p.seat == _room.self_player.seat then - self._ctr_action.selectedIndex = 0 - end - local info = _player_info[self:GetPos(p.seat)] - info:Ready(true) - --local readyNum = 0 - --for i = 1, #_room.player_list do - -- local player = _room.player_list[i] - -- if player.ready then readyNum = readyNum + 1 end - --end - --if _room.banker_seat == _room.self_player.seat and readyNum > 1 and readyNum == _room.room_config.people_num then - -- if self._state.selectedIndex == 2 then - -- local _gamectr = ControllerManager.GetController(GameController) - -- _gamectr:StartGame() - -- end - -- --self._ctr_action.selectedIndex = 2 - --end end function M:OnPlayerLeave(...) MainView.OnPlayerLeave(self, ...) local _room = self._room - if not _room.self_player.ready then - --self._ctr_action.selectedIndex = 1 - local round = DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round > 1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - else - self._ctr_action.selectedIndex = 1 - end - else - self._ctr_action.selectedIndex = 0 - end end function M:EventInit() @@ -343,694 +294,24 @@ function M:EventInit() local _player_card_info = self._player_card_info local _room = self._room - - _gamectr:AddEventListener(ExGameEvent.EventXiPai, function(...) - if self.result_view ~= nil then - self.result_view:Destroy() - self.result_view = nil - end - - self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then - -- body - self.MypokerList = cardlist - end - local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible = false - otherpoker_list:RemoveChildrenToPool() - end - self.ctr_state.selectedIndex = 1 - self.ctr_card_eff.selectedIndex = 0 - if self.rank_view ~= nil then - self.rank_view:Dispose() - self.rank_view = nil - end - - local list = _room.player_list - for i = 1, #list do - local p = list[i] - local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then - -- body - - if self._room.room_config.showlength == 1 then - -- body - head_info._view:GetController("shengyu").selectedIndex = 1 - else - head_info._view:GetController("shengyu").selectedIndex = 0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" - end - p:Clear() - head_info:FillData(p) - local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:Clear() - head_info:Ready(false) - end - - - --[[if ( currentPlayer ) then - self._popEvent = false - local xipaiCB=function () - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - else - ViewUtil.ShowModalWait(self._root_view,"等待其它玩家洗牌...") - coroutine.start(function() - coroutine.wait(3) - ViewUtil.CloseModalWait() - end) - - - end--]] - - + _gamectr:AddEventListener(EXGameEvent.OnSendCard, function(...) local arg = { ... } - local currentPlayer1 = arg[1] - local currentPlayer2 = arg[2] - self._popEvent = false - if (currentPlayer1) then - local xipaiCB = function() - self._popEvent = true - end - self:PlayXiPai(xipaiCB) - end - - - if (currentPlayer2) then - --self._popEvent = false - local xipaiCB2 = function() - self._popEvent = true - end - self:PlayXiPai1(xipaiCB2) - end end) - _gamectr:AddEventListener(ExGameEvent.OnMingCard, function(...) + _gamectr:AddEventListener(EXGameEvent.OnTipAction, function(...) local arg = { ... } - local card = arg[1] - self.ctr_state.selectedIndex = 1 - self.ctr_card_eff.selectedIndex = 1 - self:PlayCardEff(card) end) - _gamectr:AddEventListener(ExGameEvent.OnInitCard, function(...) + _gamectr:AddEventListener(EXGameEvent.OnResult1, function(...) local arg = { ... } - local round = arg[1] - local cardlist = arg[2] - - - if self.result_view ~= nil then - self.result_view:Destroy() - self.result_view = nil - end - - self._player_card_info[1]:HidePiao() - - if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then - -- body - self.MypokerList = cardlist - end - local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible = false - otherpoker_list:RemoveChildrenToPool() - end - self.ctr_state.selectedIndex = 1 - self.ctr_card_eff.selectedIndex = 0 - if self.rank_view ~= nil then - self.rank_view:Dispose() - self.rank_view = nil - end - self:UpdateRound(round) - ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/runfast/sound/fapai.mp3") - local list = _room.player_list - for i = 1, #list do - local p = list[i] - local head_info = self._player_info[self:GetPos(p.seat)] - if head_info._view:GetChild("shengyu") ~= nil and head_info._view:GetController("shengyu") ~= nil then - -- body - - if self._room.room_config.showlength == 1 then - -- body - head_info._view:GetController("shengyu").selectedIndex = 1 - else - head_info._view:GetController("shengyu").selectedIndex = 0 - end - - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. p.hand_count .. "张" - end - p:Clear() - head_info:FillData(p) - local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:Clear() - head_info:Ready(false) - - if p.seat == self._room.self_player.seat then - if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then - -- body - card_info:InitPoker(cardlist, false, 1) - else - card_info:InitPoker(cardlist, false) - end - else - --card_info:UpdateHandPoker(#cardlist,true,false) --todo - --card_info:UpdateRemainCard(#cardlist,true) - end - end end) - - -- _gamectr:AddEventListener(ExGameEvent.Oener,function ( ... ) - -- local arg = {...} - -- local seat = arg[1] - -- local head_info = self._player_info[self:GetPos(seat)] - -- head_info._view:GetController("Oener").selectedIndex=1 - -- end) - _gamectr:AddEventListener(ExGameEvent.OnIndexMove, function(...) + _gamectr:AddEventListener(EXGameEvent.OnResult2, function(...) local arg = { ... } - local seat = arg[1] - local isNewBout = arg[2] - local index = self:GetPos(seat) - - self.ctr_time.selectedIndex = index - -- for i=1,#self._player_info do - -- if index==i then - -- -- body - -- local head_info = self._player_info[index] - -- head_info:MarkBank(true) - -- else - -- local head_info = self._player_info[i] - -- head_info:MarkBank(false) - -- end - -- end - - if index == 1 then - local card_info = self._player_card_info[index] - card_info:SetOutCardInfo(nil, false) - -- if self.MypokerList ~= nil then - -- -- body - -- card_info:Clear() - -- card_info:InitPoker(self.MypokerList, false) - -- self.MypokerList = nil - -- end - end - self._left_time = 20 - if self._room.ming_card ~= nil then - self._view:GetTransition("t" .. index):Play() - self._room.ming_card = nil - if self.tween ~= nil then - TweenUtils.Kill(self.tween) - self.tween = nil - end - end end) - _gamectr:AddEventListener(ExGameEvent.OnBombScore, function(...) + _gamectr:AddEventListener(EXGameEvent.OnTurnAction, function(...) local arg = { ... } - local scoreList = arg[1] - -- for i = 1, #scoreList do - -- local player = self._room:GetPlayerBySeat(i) - -- local card_info = self._player_card_info[self:GetPos(i)] - -- local head_info = self._player_info[self:GetPos(i)] - -- card_info:PlayScore(scoreList[i], true) - -- head_info:UpdateScore(player.total_score) - -- end - end) - - _gamectr:AddEventListener(ExGameEvent.OnPlaySucc, function(...) - local arg = { ... } - local p = arg[1] - local card_number = arg[2] - local cardstype = arg[3] - local num = arg[4] - local otherList = arg[5] - local length = arg[6] - self.ctr_time.selectedIndex = 0 - local index = self:GetPos(p.seat) - if index == 1 then - self.caozuo = 0 - end - - local head_info = self._player_info[index] - if head_info._view:GetChild("shengyu") ~= nil then - -- body - -- body - if card_number ~= nil then - -- body - head_info._view:GetChild("shengyu"):GetChild("shengyu").text = "剩" .. card_number .. "张" - end - end - - local card_info = self._player_card_info[index] - card_info:SetOutCardInfo(p.out_card_list, false, true) - - for i = 1, #otherList do - local other_seat = otherList[i] - local other_card_info = self._player_card_info[self:GetPos(other_seat)] - other_card_info:SetOutCardBlack() - end - - if index == 1 then - card_info:DeleteHandCards(p.out_card_list) - else - card_info:SetRemainCardNumber(card_number == 1) - --card_info:UpdateHandPoker(card_number,false,false) -- todo - end - - if self._room.is_new_bout == true then - for i = 1, #self._room.player_list do - local player = self._room.player_list[i] - local card_info_i = self._player_card_info[self:GetPos(player.seat)] - if p.seat ~= player.seat then - card_info_i:SetOutCardInfo(nil, false) - end - end - -- card_info:PlayCardTypeEff(cardstype) - -- if cardstype~=12 then - -- -- body - - - -- if cardstype==10 and length>=6 then - -- -- card_info_i - -- local chuan = UIPackage.CreateObject("Extend_Poker_RunFast", "chuan1") - -- local card_info_i = self._player_card_info[self:GetPos(p.seat)] - - -- card_info_i._mask_liangpai:AddChild(chuan) - -- chuan:GetChild("n0").asMovieClip.playing = true - -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/sunzi.mp3") - -- coroutine.start(function() - -- coroutine.wait(1.5) - -- if chuan~=nil then - -- -- body - -- chuan:Dispose() - -- end - - -- end) - - -- else - -- self:_Effect(cardstype, p) - -- end - -- end - self:_Effect(cardstype, p) - else - if cardstype == 11 and cardstype ~= 12 then - self:_Effect(cardstype, p) - end - end - - self:PlaySound(p.self_user.sex, self:GetSoundFileName(cardstype, num, self._room.is_new_bout)) - if card_number == 1 then - --self:ChangeBgmMusic(2) - self:ChangeBgmMusic(1) - if self._cor_sound ~= nil then - coroutine.stop(self._cor_sound) - end - self._cor_sound = nil - self._cor_sound = coroutine.start(function() - coroutine.wait(1) - self:PlaySound(p.self_user.sex, "card_1") - end) - end - end) - - - _gamectr:AddEventListener(ExGameEvent.OnPassSuccCheckCard, function(...) - self._popEvent = false - local arg = { ... } - local seat = arg[1] - local cards = arg[2] - --self.MypokerList=cards - self.ctr_time.selectedIndex = 0 - local card_info = self._player_card_info[self:GetPos(seat)] - if seat == self._room.self_player.seat then - card_info:ClearCheck() - card_info:InitPoker(cards, false) - - --local player=self._room:GetPlayerBySeat(seat) - --if player.out_card_list[1] == 0 then - -- player_card_info:SetOutCardInfo(nil, true) - --else - --player:SetOutCardInfo({207}, false) - -- end - end - - self._popEvent = true - end) - - _gamectr:AddEventListener(ExGameEvent.OnPassSucc, function(...) - local arg = { ... } - local p = arg[1] - - self.ctr_time.selectedIndex = 0 - local card_info = self._player_card_info[self:GetPos(p.seat)] - - --card_info:SetOutCardInfo(nil, false) - if p.seat == self._room.self_player.seat and self.MypokerList ~= nil then - -- body - card_info:Clear() - card_info:InitPoker(self.MypokerList, false) - self.MypokerList = nil - end - card_info:SetOutCardInfo(nil, true) - self:PlaySound(p.self_user.sex, "pass_" .. math.random(1, 4)) - end) - - _gamectr:AddEventListener(ExGameEvent.OnErrorTip, function(...) - local arg = { ... } - local error_str = arg[1] - self._player_card_info[1]:ErrorTip(error_str) - -- self._player_card_info[1]:ResetPoker() - end) - - _gamectr:AddEventListener(ExGameEvent.OnPiaoTips, function(...) - local arg = { ... } - local piao = arg[1] - local reload = arg[2] - if reload == 0 then - if self._room.room_config.people_num == 3 and self._room.room_config.fangzuobi == 1 then - -- body - self.MypokerList = cardlist - end - local otherpoker_list = self._view:GetChild("otherpoker_list") - - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible = false - otherpoker_list:RemoveChildrenToPool() - end - self.ctr_state.selectedIndex = 1 - self.ctr_card_eff.selectedIndex = 0 - if self.rank_view ~= nil then - self.rank_view:Dispose() - self.rank_view = nil - end - self:UpdateRound(self._room.curren_round) - - local list = _room.player_list - for i = 1, #list do - local p = list[i] - local head_info = self._player_info[self:GetPos(p.seat)] - - p:Clear() - head_info:FillData(p) - local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:Clear() - head_info:Ready(false) - head_info:UpdatePiao(-1) - end - end - - self._player_card_info[1]:ShowPiao(piao) - end) - - _gamectr:AddEventListener(ExGameEvent.OnPiaoAction, function(...) - local arg = { ... } - local seat = arg[1] - local piao = arg[2] - local head_info = self._player_info[self:GetPos(seat)] - head_info:UpdatePiao(piao) - end) - - _gamectr:AddEventListener(ExGameEvent.OnOptions, function(...) - local arg = { ... } - local play = arg[1] - local pass = arg[5] - local card_type = arg[2] - local card_number = arg[3] - local card_length = arg[4] - local ctr_number = pass == nil and 2 or 1 - self.caozuo = 1 --记录是否是自己出牌的阶段 - self.pass = pass - local m = false - local next_seat = self._room.self_player.seat + 1 - local card_info = self._player_card_info[1] - --card_info:SetOutCardInfo(nil, false) - if self.MypokerList ~= nil then - -- body - card_info:Clear() - card_info:InitPoker(self.MypokerList, false) - self.MypokerList = nil - end - if next_seat > self._room.room_config.people_num then - next_seat = next_seat - self._room.room_config.people_num - end - if self._room:GetPlayerBySeat(next_seat).hand_count == 1 and self._room.room_config.WillBeOut == 1 then - m = true - end - local zdts = self._view:GetController("zidongtishi").selectedIndex - self._player_card_info[1]:ShowOutCardOption(ctr_number, card_type, card_number, card_length, m, play, zdts) - end) - -- 托管 - _gamectr:AddEventListener(ExGameEvent.Game_TuoGuan, function(...) - local arg = { ... } - local tuoguan = arg[1] - local seat = arg[2] - - local tuoguanzhong = self._view:GetChild("tuoguanzhong") - local zhezhao = self._view:GetChild("n109") - local head_info = self._player_info[self:GetPos(seat)] - if (tuoguan == 1) then - if (seat == self._room.self_player.seat) then - tuoguanzhong.visible = true - -- tuoguanzhong.sortingOrder = 2 - zhezhao.visible = true - zhezhao.onClick:Set(function() - _gamectr:TuoGuan(0) - end) - else - head_info._view:GetController("tuoguan").selectedIndex = 1 - end - -- if self.ispanguangzhe == true then - -- -- body - -- zhezhao.visible = false - -- end - else - if (seat == self._room.self_player.seat) then - tuoguanzhong.visible = false - zhezhao.visible = false - -- local btn_tuoguan = self._view:GetChild("n107") - -- btn_tuoguan.onClick:Set(function() - -- _gamectr:TuoGuan(1) - -- -- self:ZhiNengtuoguan() - -- end) - else - head_info._view:GetController("tuoguan").selectedIndex = 0 - end - end - end) - _gamectr:AddEventListener(ExGameEvent.OnResult, function(...) - local arg = { ... } - local over = arg[1] - local info = arg[2] - local win_seat = arg[3] - local remaincards = arg[4] - -- local energyTab = arg[5] - local otherpoker_list = self._view:GetChild("otherpoker_list") - local card_info = self._player_card_info[self:GetPos(self._room.self_player.seat)] - - if self.MypokerList ~= nil then - -- body - card_info:Clear() - card_info:InitPoker(self.MypokerList, false) - self.MypokerList = nil - end - if otherpoker_list ~= nil then - -- body - otherpoker_list:RemoveChildrenToPool() - otherpoker_list.visible = true - end - - if self._cor_sound ~= nil then - coroutine.stop(self._cor_sound) - self._cor_sound = nil - end - - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) - end - - self.destory_win = nil - self.destory_win = coroutine.start(function() - -- -- print("11111111111111") - -- coroutine.wait(1) - coroutine.wait(1) - if self._room.self_player.seat == win_seat then - local sprint_seat_list = self:GetSpringSeats(info) - if #sprint_seat_list > 0 then - local url = "ui://Extend_Poker_RunFastNew/Spring" - self.WinItem_view = UIPackage.CreateObjectFromURL(url) - self._view:AddChild(self.WinItem_view) - self.WinItem_view:Center() - self.WinItem_view:GetTransition("t0"):Play() - ViewUtil.PlaySound("RunFastNew_PK", "base/common/sound/win new.mp3") - end - -- local url = #sprint_seat_list > 0 and "ui://Extend_Poker_RunFastNew/Spring" or "ui://Extend_Poker_RunFastNew/Win_Mine" - else - local beigang = false - if #self:GetSpringSeats(info) > 0 then - for i = 1, #self:GetSpringSeats(info) do - if self:GetSpringSeats(info)[i] == self._room.self_player.seat then - local url = "ui://Extend_Poker_RunFastNew/spring2" - self.WinItem_view = UIPackage.CreateObjectFromURL(url) - self._view:AddChild(self.WinItem_view) - self.WinItem_view:Center() - self.WinItem_view:GetTransition("t0"):Play() - beigang = true - end - end - end - -- if beigang == false then - -- self:CreateRankEff() - -- end - end - for i = 1, #info do - local player = info[i] - local p = self._room:GetPlayerBySeat(player.seat) - local head_info = self._player_info[self:GetPos(player.seat)] - local card_info = self._player_card_info[self:GetPos(player.seat)] - if player.hp_info ~= nil and player.hp_info.cur_hp ~= nil then - p.hp_info = player.hp_info - head_info:UpdateScore(d2ad(player.hp_info.cur_hp)) - head_info._view:GetChild('zhanji').visible = true - local num = player.hp_info.total_hp - if num > 0 then - head_info._view:GetController('text_color').selectedIndex = 0 - head_info._view:GetChild('text_score').text = "+" .. d2ad(player.hp_info.total_hp) - else - head_info._view:GetController('text_color').selectedIndex = 1 - head_info._view:GetChild('text_score').text = d2ad(player.hp_info.total_hp) - end - card_info:PlayScore(d2ad(player.hp_info.round_actual_hp), false, win_seat == player.seat) - else - local rt = 1 - if self._room.hpOnOff == 1 then - rt = self._room.score_times - end - if over == 1 and self._room.hpOnOff == 1 then - head_info:UpdateScore(player.score / 10) --不可负分 - else - head_info:UpdateScore(player.score * rt) - end - card_info:PlayScore(player.winscore * rt, false, win_seat == player.seat) - end - - - if player.seat ~= self._room.self_player.seat then - card_info:UpdateHandPoker(player.cards, false, true) - card_info:SetRemainCardNumber(false) - - card_info._view_resultOut:RemoveChildrenToPool() - card_info._ctr_resultOut.selectedIndex = 1 - card_info.ctr_outpoker.selectedIndex = 0 - for i = 1, #player.handCards do - local child_card = card_info._view_resultOut:AddItemFromPool() - card_info:FillPoker(child_card, "", nil, player.handCards[i]) - coroutine.wait(0.2) - end - end - end - self:ChangeBgmMusic(1) - -- if over == 0 then - if #self:GetSpringSeats(info) > 0 then - -- -- print("222222222222222222") - coroutine.wait(1) - else - -- -- print("333333333333333333") - -- coroutine.wait(2) - end - - self.result_view = ExResultView.new(self._root_view, info, self._room.room_id, over, win_seat, 0, - remaincards) - self.result_view:Show() - if self.WinItem_view ~= nil then - self.WinItem_view:Dispose() - self.WinItem_view = nil - end - if self.rank_view ~= nil then - self.rank_view:Dispose() - self.rank_view = nil - end - - if self._room.self_player.entrust == true then - local btn_confirm = self.result_view._view:GetChild("btn_confirm") - btn_confirm.onClick:Call() - end - - -- local _actionView = UIPackage.CreateObject("Common", "Btn_Yellow") - -- _actionView.icon = "ui://Common/btn_comfirm" - -- _actionView.onClick:Set(function () - -- --local _gamectr = ControllerManager.GetController(GameController) - -- _gamectr:ConformToNextGame() - -- _actionView:Dispose() - -- end) - -- _actionView.xy = Vector2(900, 625) - -- self._view:AddChild(_actionView) - -- else - -- coroutine.wait(4) - -- self.result_view = ExResultView.new(self._root_view,info,self._room.room_id) - -- self.result_view:Show() - -- end - end) - if over == 1 then - -- body - self:UnmarkSelfTuoguan() - ControllerManager.ChangeController(LoddyController) - end - end) - - _gamectr:AddEventListener(ExGameEvent.OnResultByDissolve, function(...) - local arg = { ... } - local over = arg[1] - local info = arg[2] - local winseat = arg[3] - local dissolve = arg[4] - - self.result_view = ExResultView.new(self._root_view, info, self._room.room_id, over, winseat, dissolve, nil) - self.result_view:Show() - ControllerManager.ChangeController(LoddyController) - self:UnmarkSelfTuoguan() - end) - - -- 确定开始下一局 成功 - _gamectr:AddEventListener(ExGameEvent.OnConfrimToNextGameSucc, function(...) - local arg = { ... } - local aid = arg[1] - local p = self._room:GetPlayerById(aid) - if p.seat == self._room.self_player.seat then - if self.rank_view ~= nil then - self.rank_view:Dispose() - self.rank_view = nil - end - if self.destory_win ~= nil then - coroutine.stop(self.destory_win) - self.destory_win = nil - end - for _, player in ipairs(self._room.player_list) do - local player_card_info = self._player_card_info[self:GetPos(player.seat)] - local player_head = self._player_info[self:GetPos(player.seat)] - player_card_info:Clear() - local otherpoker_list = self._view:GetChild("otherpoker_list") - if otherpoker_list ~= nil then - -- body - otherpoker_list.visible = false - otherpoker_list:RemoveChildrenToPool() - end - --player_head._view:GetController("Oener").selectedIndex=0 - end - end - local player_info = self._player_info[self:GetPos(p.seat)] - player_info:Ready(true) end) end @@ -1177,7 +458,7 @@ function M:ReconnectForClearing() coroutine.start(function() coroutine.wait(0.3) - self.result_view = ExResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, + self.result_view = EXResultView.new(self._root_view, self._room.player_list, self._room.room_id, 0, win_seat, 0, remaincards) self.result_view:Show() local card_info = self._player_card_info[1] @@ -1203,20 +484,20 @@ function M:ReconnectForClearing() local flow = newremaincards[i] % 10 local num = (newremaincards[i] - (newremaincards[i] % 10)) / 10 local card_n = flow * 100 + num - local poker_item = UIPackage.CreateObject("Extend_Poker_RunFastNew", "poker6") + local poker_item = UIPackage.CreateObject("Extend_Poker_SuoHa", "poker6") --local code = self:ChangeCodeByTo(card_n) - -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card_n) + -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/" .. card_n) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") local card_code_obj if DataManager.CurrenRoom.pai == 0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/" .. card_n) else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card_n .. "_2") end if card_n == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then -- body - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card_n .. "_1") + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/" .. card_n .. "_1") end card_code_obj:SetScale(0.6, 0.6) poker_item:AddChild(card_code_obj) @@ -1228,7 +509,7 @@ function M:ReconnectForClearing() end function M:CreateRankEff() - self.rank_view = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/rank_eff") + self.rank_view = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/rank_eff") self._view:AddChild(self.rank_view) self.rank_view:Center() self.rank_view:GetTransition("t0"):Play() @@ -1256,8 +537,8 @@ function M:_Effect(type1, player) end local info = self._player_card_info[self:GetPos(player.seat)] local pNode = info._mask_liangpai - local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_" .. eff_code) - -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff2_1") + local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/eff_" .. eff_code) + -- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/eff2_1") effect.touchable = false effect:GetTransition("t0"):Play() -- effect:SetXY((self._view.width - effect.width) / 2,(self._view.hight - effect.hight) / 2) @@ -1269,7 +550,7 @@ function M:_Effect(type1, player) if eff_code == 1 then - self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/eff_feiji") + self.eff_feiji = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/eff_feiji") self._view:AddChild(self.eff_feiji) self.eff_feiji:Center() self.eff_feiji:GetTransition("t0"):Play() @@ -1316,7 +597,7 @@ end -- end -- local info = self._player_card_info[self:GetPos(player.seat)] -- local pNode = info._mask_liangpai --- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/MovieClip" .. eff_code) +-- local effect = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/MovieClip" .. eff_code) -- effect.touchable = false @@ -1417,14 +698,14 @@ function M:PlayCardEff(card) self.cor_card_eff = coroutine.start(function() self._popEvent = false local eff = self._view:GetChild("poker_eff") - local poker_obj = eff:GetChild("poker") + local poker_obj = eff:GetChild("poker2") local poker_back = eff:GetChild("di") poker_back.visible = false - -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. card) + -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_suoha/" .. card) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") local card_code_obj if DataManager.CurrenRoom.pai == 0 then - card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFastNew/" .. card) + card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_SuoHa/" .. card) else card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. card .. "_2") end @@ -1460,8 +741,8 @@ end function M:PlaySound(sex, path) local sex_path = ViewUtil.Sex_Chat[sex] -- 1 男 2 女 - local sound_path = string.format("extend/poker/runfast/sound/%s/%s.mp3", sex_path, path) - ViewUtil.PlaySound("RunFastNew_PK", sound_path) + local sound_path = string.format("extend/poker2/suoha/sound/%s/%s.mp3", sex_path, path) + ViewUtil.PlaySound("SuoHa_PK", sound_path) end function M:ChangeBgmMusic(bgm_index) @@ -1470,7 +751,7 @@ function M:ChangeBgmMusic(bgm_index) else self.bgm_index = bgm_index end - ViewUtil.PlayMuisc("RunFastNew_PK", string.format("extend/poker/runfast/sound/bgm%d.mp3", 1)) + ViewUtil.PlayMuisc("SuoHa_PK", string.format("extend/poker2/suoha/sound/bgm%d.mp3", 1)) end function M:OnPlayerEnter(...) @@ -1526,7 +807,7 @@ function M:Destroy() end end PKMainView.Destroy(self) - UIPackage.RemovePackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew") + UIPackage.RemovePackage("extend/poker2/suoha/ui/Extend_Poker_SuoHa") end return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerBackView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerBackView.lua index 39140f2e..7e5aff6d 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerBackView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerBackView.lua @@ -2,15 +2,15 @@ --- Created by 谌建军. --- DateTime: 2017/12/25 13:52 --- -local PKPlayBackView = require('main.poker.PKPlayBackView') -local ExPlayerCardInfoView = import('.ExPlayerPokerInfoView') -local ExPlayerSelfCardInfoView = import('.ExPlayerSelfPokerInfoView') +local PKPlayBackView = require('main.poker2.PKPlayBackView') +local EXPlayerCardInfoView = import('.EXPlayerPokerInfoView') +local EXPlayerSelfCardInfoView = import('.EXPlayerSelfPokerInfoView') local PlayerInfoView = import('.EXPlayerInfoView') -local ExRightPanelView = import(".ExRightPanelView") -local ExResultView = import(".ExResultView") +local EXRightPanelView = import(".EXRightPanelView") +local EXResultView = import(".EXResultView") local M = {} -local ExRecord_Event = { +local EXRecord_Event = { Evt_OutCard = 'OutCard', Evt_Pass = 'pass', Evt_NewRound = 'newindex', @@ -20,16 +20,16 @@ local ExRecord_Event = { local default_bg = 1 local bg_config = { - { id = 1, url = 'extend/poker/runfast/bg/bg1', thumb = 'ui://Extend_Poker_RunFastNew/table_bg1' }, - { id = 2, url = 'extend/poker/runfast/bg/bg2', thumb = 'ui://Extend_Poker_RunFastNew/table_bg2' }, - { id = 3, url = 'extend/poker/runfast/bg/bg3', thumb = 'ui://Extend_Poker_RunFastNew/table_bg3' } + { id = 1, url = 'extend/poker2/suoha/bg/bg1', thumb = 'ui://Extend_Poker_SuoHa/table_bg1' }, + { id = 2, url = 'extend/poker2/suoha/bg/bg2', thumb = 'ui://Extend_Poker_SuoHa/table_bg2' }, + { id = 3, url = 'extend/poker2/suoha/bg/bg3', thumb = 'ui://Extend_Poker_SuoHa/table_bg3' } } --- Create a new function M.new() setmetatable(M, { __index = PKPlayBackView }) local self = setmetatable({}, { __index = M }) - self.class = 'ExPlayBackView' + self.class = 'EXPlayBackView' self:init() return self @@ -41,8 +41,8 @@ function M:InitView(url) room.self_player = room:GetPlayerBySeat(1) end self._gamectr = ControllerManager.GetController(GameController) - UIPackage.AddPackage('extend/poker/runfast/ui/Extend_Poker_RunFastNew') - PKPlayBackView.InitView(self, 'ui://Extend_Poker_RunFastNew/ExMain_' .. self._room.room_config.people_num, + UIPackage.AddPackage('extend/poker2/suoha/ui/Extend_Poker_SuoHa') + PKPlayBackView.InitView(self, 'ui://Extend_Poker_SuoHa/EXMain_' .. self._room.room_config.people_num, default_bg, bg_config) self._tex_round = self._view:GetChild('round') self._player_card_info = {} @@ -56,7 +56,7 @@ function M:InitView(url) self._rightPanelView:Destroy() end - self._rightPanelView = ExRightPanelView.new(self, rightpanel) + self._rightPanelView = EXRightPanelView.new(self, rightpanel) rightpanel:GetChild("btn_setting").onClick:Clear() self._player_info = {} @@ -80,18 +80,18 @@ function M:InitView(url) end self._eventmap = {} self._cmdmap = {} - self._cmdmap[ExRecord_Event.Evt_OutCard] = self.CmdOutCard - self._cmdmap[ExRecord_Event.Evt_Pass] = self.CmdPass - self._cmdmap[ExRecord_Event.Evt_NewRound] = self.CmdNewRound - self._cmdmap[ExRecord_Event.Evt_result] = self.Cmdresult - self._cmdmap[ExRecord_Event.Evt_Result] = self.CmdResult + self._cmdmap[EXRecord_Event.Evt_OutCard] = self.CmdOutCard + self._cmdmap[EXRecord_Event.Evt_Pass] = self.CmdPass + self._cmdmap[EXRecord_Event.Evt_NewRound] = self.CmdNewRound + self._cmdmap[EXRecord_Event.Evt_result] = self.Cmdresult + self._cmdmap[EXRecord_Event.Evt_Result] = self.CmdResult end function M:NewPlayerPokerInfoView(view, index) if index == 1 then - return ExPlayerSelfCardInfoView.new(view, self) + return EXPlayerSelfCardInfoView.new(view, self) end - return ExPlayerCardInfoView.new(view, self) + return EXPlayerCardInfoView.new(view, self) end function M:FillRoomData(data) @@ -154,7 +154,7 @@ function M:ShowStep(index) end end - if step.cmd == ExRecord_Event.Evt_OutCard then + if step.cmd == EXRecord_Event.Evt_OutCard then local seat = step.current_out_seat local p = self._room:GetPlayerBySeat(seat) local info = self._player_card_info[self:GetPos(seat)] @@ -164,21 +164,21 @@ function M:ShowStep(index) self:ClearNextSeatOutCard(seat) end - if step.cmd == ExRecord_Event.Evt_Pass then + if step.cmd == EXRecord_Event.Evt_Pass then local seat = step.current_out_seat local p = self._room:GetPlayerBySeat(seat) local info = self._player_card_info[self:GetPos(seat)] info:SetOutCardInfo(nil, true) self:ClearNextSeatOutCard(seat) end - if step.cmd == ExRecord_Event.Evt_NewRound then + if step.cmd == EXRecord_Event.Evt_NewRound then for i = 1, #self._room.player_list do local p = self._room:GetPlayerBySeat(i) local card_info = self._player_card_info[self:GetPos(p.seat)] card_info:SetOutCardInfo(nil, false) end end - if step.cmd == ExRecord_Event.Evt_result then + if step.cmd == EXRecord_Event.Evt_result then local result = step.result for i = 1, #result do local card_info = self._player_card_info[self:GetPos(result[i].seat)] @@ -191,9 +191,9 @@ function M:ShowStep(index) card_info:PlayScore(result[i].score, false, step.win_seat == result[i].seat) end end - if step.cmd == ExRecord_Event.Evt_Result then + if step.cmd == EXRecord_Event.Evt_Result then local Result = step.Result - self.result_view = ExResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, + self.result_view = EXResultView.new(self._root_view, Result.info, self._room.room_id, Result.type, Result.winseat, 0, Result.remaincards) local num = self._view:GetChildIndex(self._view:GetChild("panel_record")) self._view:AddChildAt(self.result_view._view, num) diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerPokerInfoView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerPokerInfoView.lua index d8363ba7..d18af0df 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerPokerInfoView.lua @@ -2,13 +2,13 @@ --- Created by 谌建军. --- DateTime: 2017/12/13 16:35 --- -local ExPlayerPokerInfoView = { +local EXPlayerPokerInfoView = { _view = nil, _mainView = nil, _mask_liangpai = nil, } -local M = ExPlayerPokerInfoView +local M = EXPlayerPokerInfoView function M.new(view, mainView) local self = {} @@ -22,16 +22,37 @@ end function M:init() local view = self._view self._gameCtr = ControllerManager.GetController(GameController) + + self._view_handCardList = view:GetChild('list_handCard') +end + +function M:UpdateHandPoker(cardList) + +end + +function M:FillPoker(poker2, prefix, num, code) + if num ~= nil then + code = self:ChangeCodeByTo(num) + end + code = code == 1 and "00" or code + if not poker2.icon then + poker2:GetChild('icon').url = string.format("ui://Extend_Poker_SuoHa/%s%s", prefix, code) + else + poker2.icon = string.format("ui://Extend_Poker_SuoHa/%s%s", prefix, code) + end +end + +function M:ChangeCodeByTo(card) + local flower = card % 10 + local number = math.floor(card / 10) + if number == 15 then + number = 2 + end + return flower * 100 + number end function M:Clear() - self:PlayScore(nil) - self:SetRemainCardNumber(false) - self:SetOutCardInfo(nil, false) self.hand_card_list:RemoveChildren(0, -1, true) - self._mask_liangpai:RemoveChildren(0, -1, true) - self._view_Out:RemoveChildren(0, -1, true) - self._view_resultOut:RemoveChildren(0, -1, true) end function M:Destroy() diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerSelfPokerInfoView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerSelfPokerInfoView.lua index 29bb1197..a8b3f9c1 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExPlayerSelfPokerInfoView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExPlayerSelfPokerInfoView.lua @@ -2,44 +2,20 @@ --- Created by 谌建军. --- DateTime: 2017/12/13 17:04 --- -local ExPlayerPokerInfoView = import('.ExPlayerPokerInfoView') -local ExCardType = import('.ExCardType') -local ExCardCheck = import(".CardCheck") +local EXPlayerPokerInfoView = import('.EXPlayerPokerInfoView') +local EXCardType = import('.EXCardType') +local EXCardCheck = import(".CardCheck") -local CardView = { - btn_card = nil, - -- 牌号码 (大小) - card_code_number = 0, - -- 牌号码 (花色) - card_code_flower = 0, - -- 索引 - index = 0 -} - -local function NewCardView(card, cardcodenum, cardcodeflower) - local self = {} - setmetatable(self, { __index = CardView }) - self.btn_card = card - self.card_code_number = cardcodenum - self.card_code_flower = cardcodeflower - self.card_isTouchable = 0 - return self -end - -local function tableSortNumber(a, b) - return a.card_code_number > b.card_code_number -end - -local ExPlayerSelfPokerInfoView = { +local EXPlayerSelfPokerInfoView = { _view = nil, _mainView = nil, _mask_liangpai = nil } -local M = ExPlayerSelfPokerInfoView +local M = EXPlayerSelfPokerInfoView function M.new(view, mainView) - setmetatable(M, { __index = ExPlayerPokerInfoView }) + setmetatable(M, { __index = EXPlayerPokerInfoView }) local self = setmetatable({}, { __index = M }) self._view = view self._mainView = mainView @@ -49,1612 +25,15 @@ function M.new(view, mainView) end function M:init() - self.Reset = false - self.ctr_outpoker = self._view:GetController('output') - self.outpoker_list = self._view:GetChild('out_card_list') - self.item_data = json.decode(self._view:GetChild('area_mask').text) - self.out_card_data = self.item_data['outcard_list'] - self.hand_card_list = self._view:GetChild('hand_card_list') - self.ctr_hand_card_pos = self._view:GetChild('hand_card_list') - self._mask_liangpai = self._view:GetChild('mask_liangpai') - self.card_width = 171 - self.cards_view = self._view:GetChild('hand_poker_c') - self.card_list = {} - self.out_card_list = {} - self.touchMoveFun = handler(self, self.TouchMoving) - self.ctr_put_card_option = self._view:GetController('out_card_option') - self.ctr_piao = self._view:GetController('piao') - self.ctr_piao_value = self._view:GetController('piao_value') - self.ctr_put_error = self._view:GetController('put_error') - self.put_error_text = self._view:GetChild('put_error') - - self.ctr_select_card_type = self._view:GetController('select_card_type') - self.select_card_type_view = self._view:GetChild('choose_type') - - self.text_bomb_score = self._view:GetChild('Score') - self.ani_bomb_score = self._view:GetTransition('score') - self.ani_result_score = self._view:GetTransition('score_1') - - self.send_card = {} - self.tips_click_count = 0 - self:BtnEvent() - - ------------------------------lingmeng------------------------ - self.touchMoveEndFun = handler(self, self.TouchMoveEnd) - - self._view_handCard = self._view:GetChild('List_HandCard') - self._view_Out = self._view:GetChild('List_Out') - - self._cardCheck = ExCardCheck:initFlag() - -------------------------------------------------------------- + EXPlayerPokerInfoView.init(self) end --- function M:InitPoker(pokerList, isPlayAni, open) --- -- self.zhizhanctr_select=0 --- -- self.zhizhantype=0 --- -- self.zhizhannumber=0 --- -- self.zhizhanlength=0 --- -- self.zhizhanmustPutMaxCard=0 --- -- self.zhizhanplay=0 --- -- self.zhizhanzdts=0 --- local cs = 1.25 --- -- print("==========================DataManager.CurrenRoom.cardsize", DataManager.CurrenRoom.cardsize) --- if DataManager.CurrenRoom.cardsize == 0 then --- cs = 2.5 --- elseif DataManager.CurrenRoom.cardsize == 1 then --- cs = 2 --- elseif DataManager.CurrenRoom.cardsize == 2 then --- cs = 1.75 --- end --- print("lingmengInitPoker", pokerList, isPlayAni, open) --- if self.cor_init_poker ~= nil then --- coroutine.stop(self.cor_init_poker) --- end --- -- -- print(vardump(self.card_list)) --- self.cor_init_poker = nil --- self.card_list = {} - --- self.cards_view:RemoveChildren(0, -1, true) --- if isPlayAni == true then --- self.cor_init_poker = --- coroutine.start( --- function() --- self._mainView._popEvent = false --- if self._mainView._rightPanelView._settingView ~= nil then --- self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) --- end --- table.sort(pokerList) - --- for i = 1, #pokerList do --- local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) --- local card_flower_code = pokerList[i] --- local btn_card = self:CreatPoker(card_number_code, cs, open) --- local x, y = self._view.width / 2 + 100, -200 --- btn_card:SetXY(x, y) --- btn_card.alpha = 0 --- btn_card.touchable = false --- -- coroutine.wait(0.05) --- self.cards_view:AddChild(btn_card) --- local card_view = NewCardView(btn_card, card_number_code, card_flower_code) --- self.card_list[#self.card_list + 1] = card_view - --- table.sort(self.card_list, tableSortNumber) - --- if i == #pokerList then --- for j = 1, #self.card_list do --- local card = self.card_list[j] --- card.btn_card.touchable = true --- if open ~= 1 then --- -- body --- self:AddCardMoveEvent(card) --- end --- end --- end --- end --- for j = #self.card_list, 1, -1 do --- -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/mopai.mp3') --- local card_view = self.card_list[j] --- card_view.index = j --- self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - --- card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) --- DSTween.To( --- 0.7, --- 1, --- 0.1, --- function(value) --- card_view.btn_card:SetScale(value, value) --- end --- ) --- DSTween.To( --- 0.7, --- 1, --- 0.1, --- function(value) --- card_view.btn_card.alpha = value --- end --- ) --- card_view.btn_card.alpha = 1 --- end - --- self._mainView._popEvent = true --- if self._mainView._rightPanelView._settingView ~= nil then --- self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) --- end --- end --- ) --- else --- for i = 1, #pokerList do --- local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) --- local card_flower_code = pokerList[i] --- local btn_card = self:CreatPoker(card_number_code, cs, open) --- self.cards_view:AddChild(btn_card) --- local card_view = NewCardView(btn_card, card_number_code, card_flower_code) --- self.card_list[#self.card_list + 1] = card_view --- end --- table.sort(self.card_list, tableSortNumber) --- for i = 1, #self.card_list do --- local card = self.card_list[i] --- card.index = i --- self.cards_view:SetChildIndex(card.btn_card, card.index - 1) --- card.btn_card.xy = self:GetHandCardPos(i, #self.card_list) --- if open ~= 1 then --- -- body --- self:AddCardMoveEvent(card) --- end --- end --- end --- end - function M:InitPoker(pokerList, isPlayAni, open) - if self.cor_init_poker ~= nil then - coroutine.stop(self.cor_init_poker) - end - -- -- print(vardump(self.card_list)) - self.cor_init_poker = nil - self.card_list = {} - self._view_handCard:RemoveChildren(0, -1, true) - if isPlayAni == true then - self.cor_init_poker = - coroutine.start( - function() - self._mainView._popEvent = false - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(false) - end - table.sort(pokerList) - table.sort(self.card_list, tableSortNumber) - for i = #pokerList, 1, -1 do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - -- local btn_card = self:CreatPoker(card_number_code, cs, open) - local btn_card = self._view_handCard:AddItemFromPool() - self:FillPoker(btn_card, "", card_number_code) - -- local x, y = self._view.width / 2 + 100, -200 - -- btn_card:SetXY(x, y) - btn_card.alpha = 0 - btn_card.touchable = false - -- coroutine.wait(0.05) - -- self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view - - self:AddTouchMoveEvent(self._view_handCard) - - if i == #pokerList then - for j = 1, #self.card_list do - local card = self.card_list[j] - card.btn_card.touchable = true - if open ~= 1 then - -- body - self:AddCardTouchEvent(card) - end - end - end - end - for j = #self.card_list, 1, -1 do - -- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/mopai.mp3') - local card_view = self.card_list[j] - card_view.index = j - -- self.cards_view:SetChildIndex(card_view.btn_card, card_view.index - 1) - - card_view.btn_card:TweenMove(self:GetHandCardPos(j, #self.card_list), 0.10) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card:SetScale(value, value) - end - ) - DSTween.To( - 0.7, - 1, - 0.1, - function(value) - card_view.btn_card.alpha = value - end - ) - card_view.btn_card.alpha = 1 - end - - self._mainView._popEvent = true - if self._mainView._rightPanelView._settingView ~= nil then - self._mainView._rightPanelView._settingView:SetBtnDismissRoomEnable(true) - end - end - ) - else - for i = #pokerList, 1, -1 do - local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) - local card_flower_code = pokerList[i] - local btn_card = self._view_handCard:AddItemFromPool() - self:FillPoker(btn_card, "", card_number_code) - -- self.cards_view:AddChild(btn_card) - local card_view = NewCardView(btn_card, card_number_code, card_flower_code) - self.card_list[#self.card_list + 1] = card_view - end - table.sort(self.card_list, tableSortNumber) - self:AddTouchMoveEvent(self._view_handCard) - for i = 1, #self.card_list do - local card = self.card_list[i] - -- card.index = i - -- self.cards_view:SetChildIndex(card.btn_card, card.index - 1) - -- card.btn_card.xy = self:GetHandCardPos(i, #self.card_list) - if open ~= 1 then - -- body - self:AddCardTouchEvent(card) - end - end - end -end - -function M:updatePoker() - local templist = {} - for i = 1, #self.card_list do - templist[#templist + 1] = self.card_list[i].card_code_flower - end - self:InitPoker(templist, false, 0) -end - --- function M:AddCardMoveEvent(card) --- local send_card = {} - --- card.btn_card.onTouchBegin:Set( --- function(context) --- self.send_card = {} --- if card.btn_card.touchable == false then --- return --- end --- local fristCard = self._view_handCard:GetChildAt(0) --- local CardWidth = fristCard.width --- local columnGap = self._view_handCard.columnGap --- local oneCardWidth = CardWidth - columnGap --- local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) --- -- if xy.y > -21 and xy.y < 316 then --- self.touchBegin = xy --- Stage.inst.onTouchMove:Add(self.touchMoveFun) --- --Stage.inst.onClick:Add(self.touchMoveFun) --- card.btn_card.onTouchEnd:Set( --- function(context) --- local downCards = #self.card_list --- local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) --- Stage.inst.onTouchMove:Remove(self.touchMoveFun) --- --Stage.inst.onClick:onTouchMove(self.touchMoveFun) --- -- if xy.y > -21 and xy.y < 316 then --- local max_x --- local min_x --- if xy.x - self.touchBegin.x > 0 then --- max_x = xy.x --- min_x = self.touchBegin.x --- else --- max_x = self.touchBegin.x --- min_x = xy.x --- end - --- for k = 1, #self.card_list do --- local card = self.card_list[k] --- if not card.btn_card.selected then --- downCards = downCards - 1 --- end --- -- for i = 1, #self.card_list do --- -- local card = self.card_list[i] --- -- if card.btn_card.selected then --- -- send_card[#send_card + 1] = card.card_code_flower --- -- self.send_card[#self.send_card + 1] = card --- -- end --- -- end --- if card.btn_card.touchable == true then --- send_card[#send_card + 1] = card - --- self:SetBtnCardColor(card, 0) --- -- if k == #self.card_list then --- -- if --- -- card.btn_card.x + self.card_width > min_x and card.btn_card.x < max_x and --- -- card.card_isTouchable == 0 --- -- then --- -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- -- --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") --- -- end --- -- else --- -- if --- -- card.btn_card.x + --- -- (self.card_width + self:GetHandCardOffset(#self.card_list)) > --- -- min_x and --- -- card.btn_card.x < max_x and --- -- card.card_isTouchable == 0 --- -- then --- -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- -- --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") --- -- end --- -- end --- if --- (card.btn_card.x + oneCardWidth > min_x or (k == #self.card_list and card.btn_card.x + CardWidth > min_x)) --- and card.btn_card.x < max_x and card.card_isTouchable == 0 --- then --- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") --- end --- end --- end - --- ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/click.mp3') - --- Stage.inst:ResetInputState() --- card.btn_card.onTouchEnd:Set(nil) - --- if downCards == 0 then --- self:zhizhanxuanpai() --- end --- end --- ) --- -- else --- -- local button = card.btn_card --- -- button.onChanged:Add( --- -- function() --- -- -- body --- -- if card.btn_card.selected == true then --- -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- -- else --- -- self:UpdateCardMove(card.btn_card, card.btn_card.selected, false) --- -- end --- -- end --- -- ) --- -- end --- end --- ) --- end - -function M:AddTouchMoveEvent(list) - local send_card = {} - - list.onTouchBegin:Set( - function(context) - self.send_card = {} - if list.touchable == false then - return - end - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth - columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - -- if xy.y > -21 and xy.y < 316 then - self.touchBegin = xy - Stage.inst.onTouchMove:Add(self.touchMoveFun) - Stage.inst.onTouchEnd:Add(self.touchMoveEndFun) - --Stage.inst.onClick:Add(self.touchMoveFun) - -- else - -- local button = card.btn_card - -- button.onChanged:Add( - -- function() - -- -- body - -- if card.btn_card.selected == true then - -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - -- else - -- self:UpdateCardMove(card.btn_card, card.btn_card.selected, false) - -- end - -- end - -- ) - -- end - end - ) -end - -function M:AddCardTouchEvent(card) - card.btn_card.onTouchBegin:Set( - function(context) - if card.btn_card.touchable == false then - return - end - self:SetBtnCardColor(card, 1) - end - ) -end - --- function M:zhizhanxuanpai() --智障选牌 --- print("lingmengxuan", #self.send_card) --- -- body --- local temp_send_card = {} --- for i = 1, #self.send_card do --- if self.send_card[i] ~= self.send_card[i - 1] then --- -- body --- temp_send_card[#temp_send_card + 1] = self.send_card[i] --- end --- end - --- local card_map, max_key = self:GetCardMapAndMaxKey(temp_send_card) - --- list_type1, touch_type1 = self:CheckPairs(card_map, 0, 8) - --- list_type2, touch_type2 = self:CheckPlane(card_map, 0, 6, 0) --- list_bomb, touch_bomb = self:CheckBomb(card_map, 0, 4) - --- local list_type, touch_type = self:CheckOnes(card_map, 0, 11) --- for i = 5, 11 do --- local list_temp, touch_temp = self:CheckOnes(card_map, 0, i) --- if list_temp[1] ~= nil then --- -- body --- list_type = list_temp --- end --- end --- local temp_list = list_type[1] --- local temp_list1 = list_type1[1] --- local temp_list2 = list_type2[1] --- local temp_bomb = list_bomb[1] --- if self.xunpai == nil then --- -- body --- self.xunpai = {} --- end - --- -- if temp_list ~= nil and temp_list1 == nil and temp_list2 == nil and temp_bomb == nil and #temp_list > #self.xunpai then --- if temp_list ~= nil and temp_list1 == nil and temp_list2 == nil and temp_bomb == nil then --- -- for i = 1, #self.send_card do --- for i = 1, #self.card_list do --- self:UpdateCardMove(self.card_list[i].btn_card, false, false) --- end --- for i = 1, #self.send_card do --- for j = 1, #temp_list do --- if self.send_card[i] == temp_list[j] then --- -- body --- self:UpdateCardMove(self.send_card[i].btn_card, true, false) --- end --- end --- end --- self.xunpai = temp_list --- else --- self.xunpai = {} --- end --- end -function M:zhizhanxuanpai() --智障选牌 - -- body - local temp_send_card = {} - for i = 1, #self.send_card do - if self.send_card[i] ~= self.send_card[i - 1] then - -- body - temp_send_card[#temp_send_card + 1] = self.send_card[i] - end - end - - local card_map, max_key = self:GetCardMapAndMaxKey(temp_send_card) - local list_ones = self:CheckOnes(card_map) - - if list_ones ~= nil and #list_ones > 0 then - for i = 1, #self.card_list do - self:UpdateCardMove(self.card_list[i].btn_card, false, false) - end - for i = 1, #self.send_card do - for j = 1, #list_ones do - if self.send_card[i] == list_ones[j][1] then - -- body - self:UpdateCardMove(self.send_card[i].btn_card, true, false) - end - end - end - return list_ones - else - return {} - end -end - --- function M:TouchMoving(context) --- if self.cards_view == nil then --- return --- end --- local send_card1 = {} --- local xy = self.cards_view:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) --- self.isTouching = true --- if xy.x - self.touchBegin.x > 0 then -- 往右边滑 --- local max_x = xy.x --- local min_x = self.touchBegin.x --- for i = 1, #self.card_list do --- local card = self.card_list[i] --- if card.btn_card.touchable == false or card.card_isTouchable == 1 then --- else --- if --- card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and --- card.btn_card.x < max_x --- then --- printlog("cccccccccccccc22222222222222") --- self:SetBtnCardColor(card, 0.8) --- if #send_card1 == 0 then --- -- body --- send_card1[1] = card --- end --- for i = 1, #send_card1 do --- if send_card1[i] ~= card then --- -- body --- send_card1[#send_card1 + 1] = card --- end --- end --- else --- -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- -- card.card_isTouchable = 1 --- -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") --- self:SetBtnCardColor(card, 1) --- end --- end --- end --- elseif xy.x - self.touchBegin.x < 0 then -- 左边滑 --- local max_x = self.touchBegin.x --- local min_x = xy.x --- for i = 1, #self.card_list do --- local card = self.card_list[i] --- if card.btn_card.touchable == false or card.card_isTouchable == 1 then --- else --- if --- card.btn_card.x + (self.card_width + self:GetHandCardOffset(#self.card_list)) > min_x and --- card.btn_card.x < max_x --- then --- -- self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) --- -- card.card_isTouchable = 1 --- -- ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") --- self:SetBtnCardColor(card, 0.8) --- if #send_card1 == 0 then --- -- body --- send_card1[1] = card --- end --- for i = 1, #send_card1 do --- if send_card1[i] ~= card then --- -- body --- send_card1[#send_card1 + 1] = card --- end --- end --- else --- self:SetBtnCardColor(card, 1) --- end --- end --- end --- end --- ---- print(vardump(send_card1)) --- -- local send_card = {} --- -- self.send_card = {} --- -- for i = 1, #self.card_list do --- -- local card = self.card_list[i] --- -- if card.btn_card.selected then --- -- send_card[#send_card + 1] = card.card_code_flower --- -- self.send_card[#self.send_card + 1] = card --- -- end --- -- end --- self.send_card = send_card1 --- end - -function M:TouchMoving(context) - if self._view_handCard == nil then - return - end - local send_card1 = {} - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth + columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - self.isTouching = true - local max_x - local min_x - if xy.x - self.touchBegin.x > 0 then -- 往右边滑 - max_x = xy.x - min_x = self.touchBegin.x - -- elseif xy.x - self.touchBegin.x < 0 then -- 左边滑 - else - max_x = self.touchBegin.x - min_x = xy.x - end - for i = 1, #self.card_list do - local card = self.card_list[i] - if card.btn_card.touchable == false or card.card_isTouchable == 1 then - else - if - (card.btn_card.x + oneCardWidth > min_x or (i == #self.card_list and card.btn_card.x + CardWidth > min_x)) - and card.btn_card.x < max_x - then - self:SetBtnCardColor(card, 1) - if #send_card1 == 0 then - send_card1[1] = card - end - if send_card1[#send_card1] ~= card then - send_card1[#send_card1 + 1] = card - end - else - self:SetBtnCardColor(card, 0) - end - end - end - self.send_card = send_card1 -end - -function M:TouchMoveEnd(context) - local send_card = {} - local currentCard = {} - local xuan_card = {} - - local fristCard = self._view_handCard:GetChildAt(0) - local CardWidth = fristCard.width - local columnGap = self._view_handCard.columnGap - local oneCardWidth = CardWidth + columnGap - local xy = fristCard:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) - local downCards = #self.card_list - Stage.inst.onTouchMove:Remove(self.touchMoveFun) - Stage.inst.onTouchEnd:Remove(self.touchMoveEndFun) - - local max_x - local min_x - if xy.x - self.touchBegin.x > 0 then - max_x = xy.x - min_x = self.touchBegin.x - else - max_x = self.touchBegin.x - min_x = xy.x - end - - for k = 1, #self.card_list do - local card = self.card_list[k] - table.insert(currentCard, card.card_code_flower) - if not card.btn_card.selected then - downCards = downCards - 1 - end - if card.btn_card.touchable == false or card.card_isTouchable == 1 then - else - self:SetBtnCardColor(card, 0) - if - (card.btn_card.x + oneCardWidth > min_x or (k == #self.card_list and card.btn_card.x + CardWidth > min_x)) - and card.btn_card.x < max_x - then - self:UpdateCardMove(card.btn_card, not card.btn_card.selected, false) - if card.btn_card.selected then - send_card[#send_card + 1] = card - end - --ViewUtil.PlaySound("RunFastNew_PK", "extend/poker/paodekuai/sound/click.mp3") - else - if card.btn_card.selected then - send_card[#send_card + 1] = card - end - end - end - end - - ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/click.mp3') - - Stage.inst:ResetInputState() - - if downCards == 0 then - xuan_card = self:zhizhanxuanpai() - end - - if #send_card > 0 then - table.sort(send_card, tableSortNumber) - self._cardCheck:initCards(#xuan_card > 0 and xuan_card or send_card, #xuan_card > 0) - self._ctr_canSendCard.selectedIndex = self._cardCheck:CheckCards() and 1 or 0 - else - self._ctr_canSendCard.selectedIndex = 0 - end -end - --- function M:SetBtnCardColor(card, num) --- if --- card.btn_card:GetChildAt(0) ~= nil and card.btn_card:GetChildAt(0):GetChildAt(0) ~= nil and --- card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0) ~= nil --- then --- -- body --- card.btn_card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(num, num, num) --- end - --- --if card.card_code_flower < 500 then --- -- card.btn_card:GetChildAt(0):GetChildAt(2).color = Color(num,num,num) --- -- card.btn_card:GetChildAt(0):GetChildAt(3).color = Color(num,num,num) --- --end --- end -function M:SetBtnCardColor(card, num) - card.btn_card:GetController('choose').selectedIndex = num -end - -function M:ShowPiao(piao) - self.ctr_piao.selectedIndex = piao -end - -function M:HidePiao() - self.ctr_piao.selectedIndex = 0 -end - -function M:ShowOutCardOption(ctr_select, type, number, length, mustPutMaxCard, play, zdts) - --for i = 1, #self.out_card_list do - -- local card = self.out_card_list[i] - -- self.cards_view:RemoveChild(card.btn_card,true) - --end - --self.out_card_list = {} - - -- self.zhizhanctr_select=ctr_select - -- self.zhizhantype=type - -- self.zhizhannumber=number - -- self.zhizhanlength=length - -- self.zhizhanmustPutMaxCard=mustPutMaxCard - -- self.zhizhanplay=play - -- self.zhizhanzdts=zdts - self.tips_click_count = 0 - self.send_card = {} - self.tips_card_list = self:GetCardTips(type, number, length, mustPutMaxCard) - - if #self.tips_card_list >= 1 then - -- body - self:UpdateHandCardsColor() - end - -- - -- 自动提示 - -- if #self.tips_card_list ~= 0 and play~=0 and mustPutMaxCard==false and zdts==1 then - -- local index = self.tips_click_count % #self.tips_card_list + 1 - -- self:ShowTipsCard(index) - -- self.tips_click_count = self.tips_click_count + 1 - -- end - if #self.tips_card_list == 2 and self.tips_card_list[2][1].index == self.tips_card_list[1][1].index then - if #self.tips_card_list[2] == #self.tips_card_list[1] then - for i = 1, #self.tips_card_list[2] do - if self.tips_card_list[2][i].index == self.tips_card_list[1][i].index then - self:ShowTipsCard(1) - end - end - end - elseif #self.tips_card_list == 1 then - self:ShowTipsCard(1) - end - if mustPutMaxCard and play ~= 0 and zdts == 1 then - -- body - self:ShowTipsCard(#self.tips_card_list) - end - self.ctr_put_card_option.selectedIndex = ctr_select -end - --- function M:SetOutCardInfo(cardlist, isPass, isAnim) --- self.ctr_put_card_option.selectedIndex = 0 --- for i = 1, #self.out_card_list do --- local card = self.out_card_list[i] --- self.cards_view:RemoveChild(card, true) --- end --- self.out_card_list = {} --- if cardlist ~= nil then --- -- todo --- self:SetOutCardList(cardlist, isAnim) --- else --- if isPass == true then --- self.ctr_outpoker.selectedIndex = 2 --- for i = 1, #self.card_list do --- local card_view = self.card_list[i] --- card_view.btn_card.touchable = true --- self:UpdateCardMove(card_view.btn_card, false, false) --- self:SetBtnCardColor(card_view, 0) --- end --- else --- self.ctr_outpoker.selectedIndex = 0 --- end --- end --- end - -function M:SetOutCardBlack() - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - if card and card:GetChildAt(0) and card:GetChildAt(0):GetChildAt(0) and card:GetChildAt(0):GetChildAt(0):GetChildAt(0) then - card:GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7, 0.7, 0.7) - end - end -end - -function M:SetOutCardList(cardlist, isAnim) - local pos_y = -320 - if isAnim then - -- self.zhizhanctr_select=0 - -- self.zhizhantype=0 - -- self.zhizhannumber=0 - -- self.zhizhanlength=0 - -- self.zhizhanmustPutMaxCard=0 - -- self.zhizhanplay=0 - -- self.zhizhanzdts=0 - if self.move_cor then - coroutine.stop(self.move_cor) - self.move_cor = nil - end - local time = 0.1 - for i = 1, #cardlist do - local card_code_number = cardlist[i] - for j = 1, #self.card_list do - local card = self.card_list[j] - if card_code_number == card.card_code_number then - card.btn_card.onTouchBegin:Set(nil) - self.out_card_list[#self.out_card_list + 1] = card.btn_card - list_remove(self.card_list, card) - -- todo 出牌动画 - local pos = - self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - card.btn_card, - self.out_card_data['maxcount_x'], - 1.5 - ) - card.btn_card:TweenMove(Vector2.New(pos.x, pos_y), time) - -- self.tween = TweenUtils.TweenFloat(1, 0.7, time, function(x) - -- card.btn_card:GetChildAt(0):SetScale(x, x) - -- end) - card.btn_card:GetChildAt(0):SetScale(1.5, 1.5) - break - end - end - end - self.move_cor = - coroutine.start( - function() - coroutine.wait(0.05) - for i = 1, #self.out_card_list do - local card = self.out_card_list[i] - self.cards_view:SetChildIndex(card, i - 1) - end - coroutine.wait(0.1) - ViewUtil.PlaySound('RunFastNew_PK', 'extend/poker/runfast/sound/chupai.mp3') - end - ) - else - for i = 1, #cardlist do - local poker_item = UIPackage.CreateObject('Extend_Poker_RunFastNew', 'poker7') - local code = self:ChangeCodeByTo(cardlist[i]) - -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. code) - local card_code_obj - -- if DataManager.CurrenRoom.pai==0 then - -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/"..code) - -- else - -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") - -- end - -- if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then - -- -- body - -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_RunFast/" .. code .. "_1") - -- end - if DataManager.CurrenRoom.pai == 0 then - if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then - -- body - card_code_obj = UIPackage.CreateObjectFromURL('ui://Extend_Poker_RunFastNew/' .. code .. '_1') - else - card_code_obj = UIPackage.CreateObjectFromURL('ui://Extend_Poker_RunFastNew/' .. code) - end - else - if code == 310 and DataManager.CurrenRoom.room_config.Heart10 == 2 then - -- body - card_code_obj = UIPackage.CreateObjectFromURL('ui://Extend_Poker_RunFastNew/' .. code .. '_2') - else - card_code_obj = UIPackage.CreateObjectFromURL('ui://Main_Poker/' .. code .. '_2') - end - end - if card_code_obj == nil then - card_code_obj = UIPackage.CreateObjectFromURL('ui://Main_Poker/00') - end - card_code_obj:SetScale(1.5, 1.5) - poker_item:AddChild(card_code_obj) - --local poker = self:CreatPoker(cardlist[i],0.7) - self.cards_view:AddChild(poker_item) - local pos = - self:GetOutCardEndPokerPos( - i, - #cardlist, - self.cards_view, - poker_item, - self.out_card_data['maxcount_x'], - 1.5 - ) - poker_item.xy = Vector2.New(pos.x, pos_y) - self.out_card_list[#self.out_card_list + 1] = poker_item - end - end -end - --- function M:DeleteHandCards(cardlist) --- for i = 1, #cardlist do --- local card_code_number = cardlist[i] --- for j = 1, #self.card_list do --- local card = self.card_list[j] --- if card_code_number == card.card_code_number then --- --self.out_card_list[#self.out_card_list + 1] = card --- list_remove(self.card_list, card) --- -- todo 出牌动画 --- self.cards_view:RemoveChild(card.btn_card, true) --- break --- end --- end --- end --- self:UpdateHandCardsPos() --- end -function M:DeleteHandCards(cardlist) - self.ctr_put_card_option.selectedIndex = 0 - for i = 1, #cardlist do - local card_code_number = cardlist[i] - for j = 1, #self.card_list do - local card = self.card_list[j] - if card_code_number == card.card_code_number then - list_remove(self.card_list, card) - self._view_handCard:RemoveChild(card.btn_card, true) - break - end - end - end - self:UpdateHandCardsPos() -end - -function M:UpdateHandCardsPos() - for i = 1, #self.card_list do - local card_view = self.card_list[i] - card_view.index = i - card_view.btn_card.touchable = true - self:UpdateCardMove(card_view.btn_card, false, false) - self:SetBtnCardColor(card_view, 0) - end -end - -function M:ResetPoker() - self.Reset = true - for i = 1, #self.card_list do - local card_view = self.card_list[i] - self:UpdateCardMove(card_view.btn_card, false, false) - end - self.send_card = {} - self.Reset = false -end - -function M:UpdateCardMove(btn_card, isSelected, isPlay) - btn_card.selected = isSelected - -- local card_Move = btn_card - -- local xy = isSelected == true and Vector2.New(0, -65) or Vector2.New(0, 0) - -- if isPlay then - -- -- body - -- card_Move:TweenMove(xy, 0) - -- else - -- card_Move:TweenMove(xy, 0) - -- end -end - --- -function M:UpdateHandCardsColor() - for i = 1, #self.card_list do - local card_view = self.card_list[i] - local num = card_view.btn_card.touchable == true and 0 or 1 - self:SetBtnCardColor(card_view, num) - end -end - -function M:BtnEvent() - self.btn_not_put = self._view:GetChild('btn_not_put') - self.btn_tips = self._view:GetChild('Btn_Tip') -- 覆盖 - self.btn_sendCards = self._view:GetChild('Btn_SendCard') - self._ctr_canSendCard = self.btn_sendCards:GetController('can') - - self.btn_sendCards.onClick:Set( - function() - if self.Reset then - return - end - if self._ctr_canSendCard.selectedIndex == 0 then - return - end - local send_card = {} - self.send_card = {} - local currentCard = {} - for i = 1, #self.card_list do - local card = self.card_list[i] - table.insert(currentCard, card.card_code_flower) - if card.btn_card.selected then - send_card[#send_card + 1] = card.card_code_flower - self.send_card[#self.send_card + 1] = card - end - end - - if #send_card == 0 then - self:ErrorTip('请选择要出的牌') - else - self.gameCtr:SendCard(send_card, currentCard) - end - end - ) - self.btn_tips.onClick:Set( - function() - --printlog("wwwwwwwwwww111111111111111111111111") - --pt(self.tips_card_list) - self._ctr_canSendCard.selectedIndex = 1 - if self.tips_card_list ~= nil and #self.tips_card_list ~= 0 then - local index = self.tips_click_count % #self.tips_card_list + 1 - self:ShowTipsCard(index) - self.tips_click_count = self.tips_click_count + 1 - end - end - ) - -- 过 - self.btn_not_put.onClick:Set( - function() - self.gameCtr:SendPass() - end - ) - - local function click_piao() - self.ctr_piao.selectedIndex = 0 - self.gameCtr:SendPiao(tonumber(self.ctr_piao_value.selectedPage)) - end - - local btn_piao0 = self._view:GetChild('piao0') - btn_piao0.onClick:Set(click_piao) - - local btn_piao1 = self._view:GetChild('piao1') - btn_piao1.onClick:Set(click_piao) - - local btn_piao2 = self._view:GetChild('piao2') - btn_piao2.onClick:Set(click_piao) - - local btn_piao3 = self._view:GetChild('piao3') - btn_piao3.onClick:Set(click_piao) - - local btn_piao5 = self._view:GetChild('piao5') - btn_piao5.onClick:Set(click_piao) - - local btn_piao8 = self._view:GetChild('piao8') - btn_piao8.onClick:Set(click_piao) -end - -function M:ShowTipsCard(index) - local item = self.tips_card_list[index] - for i = 1, #self.card_list do - local card = self.card_list[i] - local isExsit = false - for j = 1, #item do - if item[j] == self.card_list[i] then - self:UpdateCardMove(card.btn_card, true, false) - isExsit = true - end - end - if isExsit == false then - self:UpdateCardMove(card.btn_card, false, false) - end - end -end - -function M:GetHandCardOffset(count) - local start = -90 ---54 - - local offset = 0 - if count > 10 then - offset = start - count + 26 - else - offset = -30 - end - return 20 -end - -function M:GetHandCardPos(index, card_count) - local x, y = 0, -20 - local offset = self:GetHandCardOffset(card_count) - local middle_x = self.cards_view.width / 2 - local start_x = middle_x - (card_count / 2 * (self.card_width + offset)) + (offset / 2) - x = start_x + (self.card_width + offset) * (index - 1) - return Vector2.New(x, y) -end - -function M:GetHandCardPos1(index, card_count) - local x, y = 0, -18 - local offset = self:GetHandCardOffset(card_count) - local middle_x = self.cards_view.width / 2 - local start_x = middle_x - (card_count / 2 * (self.card_width + offset)) + (offset / 2) - x = start_x + (self.card_width + offset) * (index - 1) - return x, y -end - -function M:ChangeOneCodeByFrom(card) - local flower = math.floor(card / 100) - local number = card % 100 - if number == 2 then - number = 15 - end - return number * 10 + flower -end - -function M:ErrorTip(error_text) - if self.cor_init_poker ~= nil then - coroutine.stop(self.cor_init_poker) - end - self.cor_init_poker = nil - self.cor_init_poker = - coroutine.start( - function() - self.put_error_text.text = error_text - self.ctr_put_error.selectedIndex = 1 - coroutine.wait(2) - self.ctr_put_error.selectedIndex = 0 - end - ) -end - ---ExCardType ---None = 0, ---OneCard = 1, ---OnePair = 2, ---Three = 3, ---Pairs = 4, ---ThreeAndTwo = 5, ---ThreeAndOne = 6, ---Plane = 7, ---PlaneAndTwo = 8, ---PlaneAndOne = 9, ---Straight = 10, ---Bomb = 11 -function M:GetCardTips(type, number, length, mustPutMaxCard, tip_templist) - local tip_list = {} - local sidaisan = false - local touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } - --printlog("aaaaaaaaaaaaacccccccccccccccccccc11111111111111111111111111111") - --pt(self.card_list) - local card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) - --printlog("aaaaaaaaaaaaaaaaaa222222222222222222222222222222222222222 ",max_key) - --pt(card_map) - if type == ExCardType.None then - if DataManager.CurrenRoom.is_new_bout then - tip_list = self:NewBoutTips(card_map) - end - return tip_list, touch_key_list - elseif type == ExCardType.Bomb then - tip_list, touch_key_list = self:CheckBomb(card_map, number, length) - else - local list_type, list_bomb = {}, {} - local touch_type, touch_bomb - list_bomb, touch_bomb = self:CheckBomb(card_map, 0, 4) - - local card_templist = membe_clone(self.card_list) - - if list_bomb ~= nil and tip_templist == nil then - -- body - for i = 1, #list_bomb do - local templist_bomb = list_bomb[i] - for j = 1, #templist_bomb do - for k = 1, #card_templist do - if templist_bomb[j] == card_templist[k] then - -- body - list_remove(card_templist, card_templist[k]) - end - end - end - end - card_map, max_key = self:GetCardMapAndMaxKey(card_templist) - end - - if type == ExCardType.OneCard then - -- if mustPutMaxCard then - -- number = max_key - 1 - -- self:ErrorTip("下家报单,请出最大的牌 ") - -- end - list_type, touch_type = self:CheckOneCard(card_map, number, length) - elseif type == ExCardType.OnePair then - list_type, touch_type = self:CheckOnePair(card_map, number, length) - elseif type == ExCardType.Three then - list_type, touch_type = self:CheckThree(card_map, number, length) - elseif type == ExCardType.Pairs then - list_type, touch_type = self:CheckPairs(card_map, number, length) - elseif type == ExCardType.ThreeAndTwo then - list_type, touch_type = self:CheckThreeAndTwo(card_map, number, length) - elseif type == ExCardType.ThreeAndOne then - list_type, touch_type = self:CheckThreeAndOne(card_map, number, length) - elseif type == ExCardType.Plane then - list_type, touch_type = self:CheckPlane(card_map, number, length, 0) - elseif type == ExCardType.PlaneAndTwo then - list_type, touch_type = self:CheckPlane(card_map, number, length, 2) - elseif type == ExCardType.PlaneAndOne then - list_type, touch_type = self:CheckPlane(card_map, number, length, 1) - elseif type == ExCardType.Straight then - list_type, touch_type = self:CheckStraight(card_map, number, length) - elseif type == ExCardType.FourAndtThree then - list_type, touch_type = self:CheckBomb(card_map, 0, 4) - if #list_type > 0 then - -- body - sidaisan = true - end - end - card_map, max_key = self:GetCardMapAndMaxKey(self.card_list) - tip_list = self:GetMergeAllList(list_type, list_bomb) - --list_bomb, touch_bomb = self:CheckBomb(card_map, 0, 4) - touch_key_list = self:GetMergeAllList(touch_type, touch_bomb) - local tip_templist2 = {} - if tip_templist == nil then - -- body - tip_templist2 = self:GetCardTips(type, number, length, mustPutMaxCard, tip_list) - end - if #tip_templist2 > 0 then - -- body - tip_list = self:GetMergeAllList(tip_list, tip_templist2) - end - end - - if (tip_templist ~= nil and sidaisan == false and #tip_templist >= 1) then - -- body - self:SetNotTouchCard(touch_key_list, card_map) - end - - return tip_list -end - --- 合并多个list -function M:GetMergeAllList(...) - local lists = { ... } - local merge_list = {} - for i = 1, #lists do - local list_item = lists[i] - for j = 1, #list_item do - merge_list[#merge_list + 1] = list_item[j] - end - end - - return merge_list -end - -function M:NewBoutTips(pokerMap) - local new_bout_list = {} - for k, v in pairs(pokerMap) do - new_bout_list[#new_bout_list + 1] = v - end - return new_bout_list -end - -function M:CheckOneCard(pokerMap, num, length) - local one_card_list = {} - local touch_key_list = {} - if #self.card_list < length then - return one_card_list, touch_key_list - end - for k, v in pairs(pokerMap) do - if k > num and #v == 1 then - one_card_list[#one_card_list + 1] = { v[1] } - touch_key_list[#touch_key_list + 1] = k - end - end - for k, v in pairs(pokerMap) do - if k > num and #v ~= 1 then - one_card_list[#one_card_list + 1] = { v[1] } - touch_key_list[#touch_key_list + 1] = k - end - end - return one_card_list, touch_key_list -end - -function M:CheckOnePair(pokerMap, num, length) - local one_pair_list = {} - local touch_key_list = {} - if #self.card_list < length then - return one_pair_list, touch_key_list - end - for k, v in pairs(pokerMap) do -- 从三条和对子里面提取 - if #v > 1 and k > num then - one_pair_list[#one_pair_list + 1] = { v[1], v[2] } - touch_key_list[#touch_key_list + 1] = k - end - end - return one_pair_list, touch_key_list -end - -function M:CheckThree(pokerMap, num, length) - local three_list = {} - local touch_key_list = {} - if #self.card_list < length then - return three_list, touch_key_list - end - for k, v in pairs(pokerMap) do - if #v > 2 and k > num then - three_list[#three_list + 1] = { v[1], v[2], v[3] } - touch_key_list[#touch_key_list + 1] = k - end - end - return three_list, touch_key_list -end - -function M:CheckPairs(pokerMap, num, length) - local pairs_list = {} - local touch_key_list = {} - if #self.card_list < length then - return pairs_list, touch_key_list - end - local pair_length = length / 2 - local number_start = num - pair_length + 2 - local number_end = 15 - pair_length - for i = number_start, number_end do - local item_all_list = {} - for j = i, i + pair_length - 1 do - local item_list = pokerMap[j] - if item_list == nil then - break - elseif #item_list < 2 then - break - else - item_all_list[#item_all_list + 1] = item_list[1] - item_all_list[#item_all_list + 1] = item_list[2] - end - if j == i + pair_length - 1 then - pairs_list[#pairs_list + 1] = item_all_list - for k = i, i + pair_length - 1 do - touch_key_list[#touch_key_list + 1] = k - end - end - end - end - return pairs_list, touch_key_list -end - -function M:CheckThreeAndOne(pokerMap, num, length) - local three_and_one_list = {} - local touch_key_list = {} - if #self.card_list < length then - return three_and_one_list, touch_key_list - end - for k, v in pairs(pokerMap) do - if #v >= 3 and k > num then - three_and_one_list[#three_and_one_list + 1] = { v[1], v[2], v[3] } - touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } - end - end - return three_and_one_list, touch_key_list -end - -function M:CheckThreeAndTwo(pokerMap, num, length) - local three_and_two_list = {} - local touch_key_list = {} - if #self.card_list < length then - return three_and_two_list, touch_key_list - end - for k, v in pairs(pokerMap) do - if #v >= 3 and k > num then - three_and_two_list[#three_and_two_list + 1] = { v[1], v[2], v[3] } - touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } - end - end - return three_and_two_list, touch_key_list -end - -function M:CheckStraight(pokerMap, num, length) - local straight_list = {} - local touch_key_list = {} - if #self.card_list < length then - return straight_list, touch_key_list - end - local number_start = num - length + 2 - local number_end = 15 - length - for i = number_start, number_end do - local item_all_list = {} - for j = i, i + length - 1 do - local item_list = pokerMap[j] - if item_list == nil then - break - else - item_all_list[#item_all_list + 1] = item_list[1] - end - if j == i + length - 1 then - straight_list[#straight_list + 1] = item_all_list - for k = i, i + length - 1 do - touch_key_list[#touch_key_list + 1] = k - end - end - end - end - return straight_list, touch_key_list -end - -function M:CheckBomb(pokerMap, num, length) - local bomb_list = {} - local touch_key_list = {} - local threeA = DataManager.CurrenRoom.room_config.threeA - if threeA == 0 then - -- body - if #self.card_list < length then - return bomb_list, touch_key_list - end - else - if #self.card_list < 3 then - return bomb_list, touch_key_list - end - end - - for k, v in pairs(pokerMap) do - if #v == 4 and k > num then - bomb_list[#bomb_list + 1] = v - touch_key_list[#touch_key_list + 1] = k - end - if threeA == 1 and #v == 3 and k == 14 then - bomb_list[#bomb_list + 1] = v - touch_key_list[#touch_key_list + 1] = k - end - end - - return bomb_list, touch_key_list -end - -function M:CheckPlane(pokerMap, num, length, and_num) - local plane_list = {} - local touch_key_list = {} - local l = and_num + 3 - local pair_length = length / l - local number_start = num - pair_length + 2 - local number_end = 15 - pair_length - for i = number_start, number_end do - local item_all_list = {} - for j = i, i + pair_length - 1 do - local item_list = pokerMap[j] - if item_list == nil then - break - elseif #item_list < 3 then - break - else - item_all_list[#item_all_list + 1] = item_list[1] - item_all_list[#item_all_list + 1] = item_list[2] - item_all_list[#item_all_list + 1] = item_list[3] - end - if j == i + pair_length - 1 then - plane_list[#plane_list + 1] = item_all_list - touch_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } - end - end - end - return plane_list, touch_key_list -end - -function M:SetNotTouchCard(touch_key_list, card_map) - local all_key_list = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } - for i = 1, #all_key_list do - local key = all_key_list[i] - local isExsit = self:IsExistByList(touch_key_list, key) - if isExsit == false then - local key_card_item = card_map[key] - if key_card_item ~= nil then - for j = 1, #key_card_item do - local card = key_card_item[j] - card.btn_card.touchable = false - self:UpdateCardMove(card.btn_card, false, false) - end - end - end - end -end - -function M:IsExistByList(list, item) - for i = 1, #list do - if list[i] == item then - return true - end - end - return false -end - -function M:GetCardByNumber(list, number) - for i = 1, #list do - if list[i].card_code_number == number then - return list[i] - end - end - return nil -end - -function M:GetCardMapAndMaxKey(pokerList) - local map, max_key = {}, 0 - for i = 1, #pokerList do - local number = math.floor(pokerList[i].card_code_number / 10) - if number > max_key then - max_key = number - end - if map[number] == nil then - map[number] = { pokerList[i] } - else - map[number][#map[number] + 1] = pokerList[i] - end - end - return map, max_key -end - --- function M:CheckOnes(pokerMap, num, length) --- local one_card_list = {} --- local touch_key_list = {} --- local text = {} --- local text2 = {} --- local x = 0 --- if #self.card_list < length then --- return one_card_list, touch_key_list --- end --- for k, v in pairs(pokerMap) do --- text = {} --- text2 = {} --- if k > num then --- for l, p in pairs(pokerMap) do --- for i = 0, length - 1 do --- if l == k + i and l ~= 15 and l ~= 16 then --- -- body --- text[#text + 1] = { p[1] } --- text2[#text2 + 1] = l --- if #text >= length then --- -- body --- local x = #one_card_list --- local y = #touch_key_list --- for i = 1, #text - 1 do --- one_card_list[x + 1] = text[1] --- touch_key_list[y + 1] = text2[2] --- -- for i, v in pairs(text2[i + 1]) do --- -- if v ~= nil then --- -- table.insert(touch_key_list[x + 1], v) --- -- end --- -- end --- for i, v in pairs(text[i + 1]) do --- if v ~= nil then --- table.insert(one_card_list[x + 1], v) --- end --- end --- end --- end --- end --- end --- end --- end --- end --- return one_card_list, touch_key_list, length --- end - -function M:CheckOnes(pokerMap) - local one_card_list = {} - local old_k = 0 - for k, v in pairs(pokerMap) do - if #one_card_list == 0 then - table.insert(one_card_list, v) - old_k = k - else - if k == 15 then - break - end - if k ~= old_k + 1 and #one_card_list >= 5 then - break - end - if k ~= old_k + 1 then - one_card_list = {} - end - table.insert(one_card_list, v) - old_k = k - end - end - if #one_card_list < 5 then - one_card_list = {} - end - return one_card_list end function M:Clear() - self:PlayScore(nil) - self:SetOutCardInfo(nil, false) - self.card_list = {} - self.out_card_list = {} - self._view_handCard:RemoveChildren(0, -1, true) - -- self.mask_liangpai:RemoveChildren(0,-1,true) -end - -function M:ClearCheck() - self.card_list = {} - self.out_card_list = {} - self._view_handCard:RemoveChildren(0, -1, true) -end - -function M:Destroy() - Stage.inst.onTouchMove:Remove(self.touchMoveFun) - Stage.inst.onTouchEnd:Remove(self.touchMoveEndFun) + EXPlayerPokerInfoView.Clear(self) end return M diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExProtocol.lua b/lua_probject/extend_project/extend/poker2/suoha/ExProtocol.lua index b3b87f52..f82be2e9 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExProtocol.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExProtocol.lua @@ -2,8 +2,46 @@ --- Created by 谌建军. --- DateTime: 2017/12/13 10:51 --- -local ExProtocol = { +local EXProtocol = { + --执行操作 + GAME_ACTION = "1011", + + -- 发牌协议 + GAME_EVT_PLAYER_DEAL = "2010", + + -- 下注提示协议 + GAME_EVT_ACTION = "2011", + + -- 下注事件 + GAME_EVT_BET = "2012", + + -- 跟注事件 + GAME_EVT_CALL = "2013", + + -- 加注事件 + GAME_EVT_RAISE = "2014", + + -- 梭哈事件 + GAME_EVT_ALL_IN = "2015", + + -- 弃牌事件 + GAME_EVT_FOLD = "2016", + + -- 过牌事件 + GAME_EVT_CHECK = "2017", + + + -- 小结算 + GAME_EVT_RESULT1 = "2007", + + -- 大结算 + GAME_EVT_RESULT2 = "2008", + + + + -- 转盘指向事件 + GAME_EVT_CHANGE_ACTIVE_PLAYER = "2099", } -return ExProtocol +return EXProtocol diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExResultView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExResultView.lua index 4b90ed31..2b1591fe 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExResultView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExResultView.lua @@ -4,20 +4,20 @@ --- require("Game.View.ResultView") -local ExResultView = {} +local EXResultView = {} -local M = ExResultView +local M = EXResultView -function ExResultView.new(blur_view, data, roomid, over, win_seat, dissolve, remaincards) +function EXResultView.new(blur_view, data, roomid, over, win_seat, dissolve, remaincards) setmetatable(M, { __index = ResultView }) local self = setmetatable({}, { __index = M }) - self.class = "ExResultView" + self.class = "EXResultView" self._currenIndex = 0 self._close_zone = false --self._blur_view = blur_view self._gamectr = ControllerManager.GetController(GameController) - self:init("ui://Extend_Poker_RunFastNew/clearing_new", data, roomid, over, win_seat, dissolve, remaincards) + self:init("ui://Extend_Poker_SuoHa/clearing_new", data, roomid, over, win_seat, dissolve, remaincards) print("=======================lingmengresult", data, roomid, over, win_seat, dissolve, remaincards) return self end diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExRightPanelView.lua b/lua_probject/extend_project/extend/poker2/suoha/ExRightPanelView.lua index f12c582a..76a5ce28 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExRightPanelView.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExRightPanelView.lua @@ -1,6 +1,6 @@ local MainRightPanelView = require("Game.View.MainRightPanelView") -local ExRightPanelView = {} -local M = ExRightPanelView +local EXRightPanelView = {} +local M = EXRightPanelView local function __init(self, mainView, view) local right_panel = view @@ -59,10 +59,10 @@ local function __init(self, mainView, view) -- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true) -- self._timer:Start() end -function ExRightPanelView.new(mainView, view) +function EXRightPanelView.new(mainView, view) setmetatable(M, { __index = MainRightPanelView }) local self = setmetatable({}, { __index = M }) - self.class = "ExRightPanelView" + self.class = "EXRightPanelView" __init(self, mainView, view) return self end diff --git a/lua_probject/extend_project/extend/poker2/suoha/ExtendConfig.lua b/lua_probject/extend_project/extend/poker2/suoha/ExtendConfig.lua index 39a0a460..35cf9761 100644 --- a/lua_probject/extend_project/extend/poker2/suoha/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/poker2/suoha/ExtendConfig.lua @@ -5,12 +5,12 @@ local EXTEND_MODEL_NAME = ... local EXGameInfo = import(".EXGameInfo_jiangxi") -local ExMainView = import(".ExMainView") -local ExGameController = import(".ExGameController") -local ExRoomConfig = import(".ExRoomConfig") -local ExPlayer = import(".ExPlayer") -local ExRoom = import(".ExRoom") -local ExPlayerBackView = import(".ExPlayerBackView") +local EXMainView = import(".EXMainView") +local EXGameController = import(".EXGameController") +local EXRoomConfig = import(".EXRoomConfig") +local EXPlayer = import(".EXPlayer") +local EXRoom = import(".EXRoom") +local EXPlayerBackView = import(".EXPlayerBackView") local ExtendConfig = {} @@ -23,19 +23,19 @@ function ExtendConfig.new() self.class = "ExtendConfig" self.extend_id = 14 self._viewMap = {} - self._viewMap[ViewManager.View_Main] = ExMainView - self._viewMap[ViewManager.View_PlayBack] = ExPlayerBackView + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayerBackView return self end --卸载资源 function M:UnAllAssets() - UIPackage.RemovePackage("extend/poker/runfast/ui/Info_Poker_RunFastNew") + UIPackage.RemovePackage("extend/poker2/suoha/ui/Info_Poker_SuoHa") self:UnAssets() end function M:UnAssets() - UIPackage.RemovePackage("extend/poker/runfast/ui/Extend_Poker_RunFastNew") + UIPackage.RemovePackage("extend/poker2/suoha/ui/Extend_Poker_SuoHa") ResourcesManager.UnLoadGroup("RunFase_PK") end @@ -50,22 +50,26 @@ end local _ctr_game = nil function M:GetGameController() if _ctr_game == nil then - _ctr_game = ExGameController.new() + _ctr_game = EXGameController.new() end return _ctr_game end function M:NewRoom() - return ExRoom.new() + return EXRoom.new() +end + +function M:GetGameRule() + return EXRuleView.new() end function M:GetIconUrl() - return "ui://Extend_Poker_RunFastNew/icon" + return "ui://Extend_Poker_SuoHa/icon" -- end function M:FillRoomConfig(room, _config) - room.room_config = ExRoomConfig.new(_config) + room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) @@ -81,7 +85,7 @@ function M:FillRoomData(s2croom) room.xipaiScore = _tableInfo["xipai_score"] local _config = _tableInfo["config"] - room.room_config = ExRoomConfig.new(_config) + room.room_config = EXRoomConfig.new(_config) room.curren_round = _tableInfo["round"] if room.curren_round == 0 and reload then @@ -92,7 +96,7 @@ function M:FillRoomData(s2croom) for i = 1, #playerList do local _jp = playerList[i] - local p = ExPlayer.new() + local p = EXPlayer.new() p.seat = _jp["seat"] local online = _jp["online"] p.line_state = online @@ -210,7 +214,7 @@ function M:FillPlayBackData(pd_data) local _config = _tableInfo["config"] room.room_id = _tableInfo.room_id - room.room_config = ExRoomConfig.new(_config) + room.room_config = EXRoomConfig.new(_config) room.owner_id = _config["ownerid"] local active_seat = _tableInfo["active_seat"] local bank_seat = _tableInfo["banker_seat"] @@ -220,7 +224,7 @@ function M:FillPlayBackData(pd_data) local _info_list = _tableInfo["playerData"] for i = 1, #_info_list do local _jp = _info_list[i] - local p = ExPlayer.new() + local p = EXPlayer.new() p.seat = _jp["seat"] p.aid = _jp["aid"] local pid = _jp["aid"] diff --git a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua index c01a68e2..957c3d72 100644 --- a/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua +++ b/lua_probject/main_project/main/majiang/MJPlayerCardInfoView_jiangxi.lua @@ -45,6 +45,8 @@ end function M:FillData(begin) if (begin) then + print("lingmengResetFzList2") + pt(self._player) for i = 1, #self._player.fz_list do self:UpdateFzList(self._player.fz_list[i], -1) end @@ -218,11 +220,11 @@ local function getPos(my_seat, other_seat, total) end function M:UpdateFzList(fz, index, show_card, seat) + print("lingmengUpdateFzList", fz, index, show_card, seat) local FZame = self._viewText_cardInfo['FZ_Card'] index = index or 0 show_card = show_card or nil - local outCard = self._view_FZList:AddItemFromPool() outCard:GetController("seat").selectedIndex = seat or 0 if fz.type == FZType.Chi then @@ -252,6 +254,8 @@ function M:UpdateFzList(fz, index, show_card, seat) elseif fz.type == FZType.Gang_Peng then for i = 1, self._view_FZList.numItems do if self._view_FZList:GetChildAt(i - 1).data and self._view_FZList:GetChildAt(i - 1).data == fz.card then + outCard:GetController("seat").selectedIndex = self._view_FZList:GetChildAt(i - 1):GetController( + "seat").selectedIndex self._view_FZList:RemoveChildrenToPool(i - 1, i - 1) return end @@ -279,6 +283,8 @@ end function M:ResetFzList() for i = 1, #self._player.fz_list do + print("lingmengResetFzList") + pt(self._player) local fz = self._player.fz_list[i] -- if fz.type ~= FZType.Gang_Peng then self:UpdateFzList(fz, -1) diff --git a/lua_probject/main_project/main/poker2/PKMainView.lua b/lua_probject/main_project/main/poker2/PKMainView.lua index 9bddec8b..4ae62b27 100644 --- a/lua_probject/main_project/main/poker2/PKMainView.lua +++ b/lua_probject/main_project/main/poker2/PKMainView.lua @@ -77,6 +77,13 @@ function M:InitView(url, isHideIpAdds, settingViewType, ex_defaultbg, ex_bgconfi end self:InitXiPai() self:InitXiPai1() + + local Btn_Ready = _view:GetChild('Btn_Ready') + if Btn_Ready ~= nil then + Btn_Ready.onClick:Set(function() + self._gamectr:PlayerReady() + end) + end end function M:InitXiPai() diff --git a/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes b/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes index f431663b..5b11fedd 100644 Binary files a/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes and b/wb_unity_pro/Assets/ART/base/Family/ui/Family_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png b/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png deleted file mode 100644 index 5e2f4c74..00000000 Binary files a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png and /dev/null differ diff --git a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_fui.bytes b/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_fui.bytes index 615b20e9..6527a6c7 100644 Binary files a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_fui.bytes and b/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/poker2.meta b/wb_unity_pro/Assets/ART/extend/poker2.meta new file mode 100644 index 00000000..26a4c91e --- /dev/null +++ b/wb_unity_pro/Assets/ART/extend/poker2.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b017686c13763de4884a002b00999158 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha.meta b/wb_unity_pro/Assets/ART/extend/poker2/suoha.meta new file mode 100644 index 00000000..352df9a8 --- /dev/null +++ b/wb_unity_pro/Assets/ART/extend/poker2/suoha.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e2ff47366ab50d3458b6acd751b404bc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui.meta b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui.meta new file mode 100644 index 00000000..b3bbbc62 --- /dev/null +++ b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09c85cd6409c1224ba5057c80042bf88 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png new file mode 100644 index 00000000..3648fd4d Binary files /dev/null and b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png differ diff --git a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png.meta b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png.meta similarity index 94% rename from wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png.meta rename to wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png.meta index 59323c33..0e7e57af 100644 --- a/wb_unity_pro/Assets/ART/extend/poker/suoha/ui/Info_Poker_SuoHa_atlas0.png.meta +++ b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_atlas0.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 90b7612eae62bb949b77c5984e16ea76 +guid: eee093667666622428a5ecf81ea2bfda TextureImporter: internalIDToNameTable: [] externalObjects: {} @@ -88,5 +88,5 @@ TextureImporter: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 userData: - assetBundleName: extend/poker/suoha/1dd27af6cf16f29dd351e9912088b1d5 + assetBundleName: assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes new file mode 100644 index 00000000..2ab82b50 Binary files /dev/null and b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes.meta b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes.meta new file mode 100644 index 00000000..a5ad9c7e --- /dev/null +++ b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Extend_Poker_SuoHa_fui.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9cf040078a8b4b1468dad9cc95784ed8 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes new file mode 100644 index 00000000..1fbf8fdf Binary files /dev/null and b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes.meta b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes.meta new file mode 100644 index 00000000..b90d458f --- /dev/null +++ b/wb_unity_pro/Assets/ART/extend/poker2/suoha/ui/Info_Poker_SuoHa_fui.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 22180c3e6d0d26848a8ca65c0c1ff971 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: