From bdac067402b06c8dc7b54f87608e0166fdbe6265 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Mon, 2 Dec 2024 17:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=81=E4=B8=89=E5=BC=A0?= =?UTF-8?q?=E9=A2=84=E9=80=89=E7=89=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamerule/thirteen/constants.go | 1 + gamesrv/thirteen/player.go | 2 ++ gamesrv/thirteen/scenepolicy.go | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/gamerule/thirteen/constants.go b/gamerule/thirteen/constants.go index 64d4508..d3eb482 100644 --- a/gamerule/thirteen/constants.go +++ b/gamerule/thirteen/constants.go @@ -34,6 +34,7 @@ const ( ThirteenWaterPlayerOpTest = 3 // test ThirteenWaterPlayerOpReset = 4 // 重新选牌 ThirteenWaterPlayerJoin = 5 // 加入游戏 + ThirteenWaterPlayerOpSelect = 6 // 预选牌 ) const ( ThirteenWaterSceneWaitTimeout = time.Second * 2 //等待倒计时 diff --git a/gamesrv/thirteen/player.go b/gamesrv/thirteen/player.go index f3d5a70..d59c380 100644 --- a/gamesrv/thirteen/player.go +++ b/gamesrv/thirteen/player.go @@ -12,6 +12,7 @@ type PlayerEx struct { cards [13]int //手牌信息 allGroup map[int]*thirteen.Group //玩家所有牌型 cardsO *thirteen.Group //确定的牌型信息 + preCardsO *thirteen.Group //预确定的牌型 isDP bool // 是否倒排 gainCoin int64 //本局赢的金币 taxCoin int64 //本局税收 @@ -36,6 +37,7 @@ func (this *PlayerEx) Clear() { } this.allGroup = make(map[int]*thirteen.Group) this.cardsO = &thirteen.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1} + this.preCardsO = &thirteen.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1} this.isDP = false this.gainCoin = 0 this.taxCoin = 0 diff --git a/gamesrv/thirteen/scenepolicy.go b/gamesrv/thirteen/scenepolicy.go index 331c12f..05d9b36 100644 --- a/gamesrv/thirteen/scenepolicy.go +++ b/gamesrv/thirteen/scenepolicy.go @@ -870,6 +870,7 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param } else { sceneEx.SendSelectCards(playerEx, int(params[0]), int64(opcode)) } + playerEx.preCardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1} playerEx.Trusteeship = 0 playerEx.UnmarkFlag(base.PlayerState_Auto) playerEx.deterMine = true @@ -886,6 +887,34 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param //提前进入亮牌阶段 s.ChangeSceneState(rule.ThirteenWaterSceneStateShowCards) } + + case rule.ThirteenWaterPlayerOpSelect: + playerEx.deterMine = false + playerEx.cardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1} + playerEx.Trusteeship = 0 + playerEx.UnmarkFlag(base.PlayerState_Auto) + pack := &thirteen.SCThirteenPlayerOp{ + OpRetCode: thirteen.OpResultCode_OPRC_Sucess, + OpCode: int32(opcode), + OpParam: params, + Pos: int32(playerEx.GetPos()), + } + if len(params) == 13 { + //校验牌 + a := rule.DelCards(playerEx.cards[:], common.Int64Toint(params)) + if len(a) != 0 { + logger.Logger.Error("the cards is error.") + returnFunc(thirteen.OpResultCode_OPRC_Error) + return true + } + //牌赋值 + copy(playerEx.preCardsO.Head[:], common.Int64Toint(params[:3])) + copy(playerEx.preCardsO.Mid[:], common.Int64Toint(params[3:8])) + copy(playerEx.preCardsO.End[:], common.Int64Toint(params[8:])) + playerEx.preCardsO.PokerType = 0 + } + playerEx.SendToClient(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack) + case rule.ThirteenWaterPlayerOpReset: // 取消确认 playerEx.deterMine = false @@ -913,6 +942,11 @@ func (this *StateOp) OnLeave(s *base.Scene) { for _, player := range sceneEx.players { if player != nil && player.IsGameing() { + // 使用预选牌 + if player.preCardsO != nil && player.preCardsO.PokerType != -1 && (player.cardsO == nil || player.cardsO.PokerType == -1) { + player.cardsO = player.preCardsO + } + // 判断是否倒水 if player.cardsO != nil && player.cardsO.PokerType != -1 { if player.cardsO.PokerType < 1000000 { player.isDP = sceneEx.logic.IsDP(player.cardsO.Head, player.cardsO.Mid, player.cardsO.End)