From b76b1f5ab2fdeb350b359943602cd6b6469e3535 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 8 Dec 2023 22:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=81=9A=E8=99=AB=E5=AD=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/catchbugs/module.go | 10 +++++++++- modules/catchbugs/room.go | 26 +++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/catchbugs/module.go b/modules/catchbugs/module.go index 40124ab2e..e6e5362f2 100644 --- a/modules/catchbugs/module.go +++ b/modules/catchbugs/module.go @@ -116,6 +116,7 @@ func (this *CatchBugs) createRoom(rules *pb.DBCatchBugsRules, red, blue *pb.DBCa confs []*cfg.GameCatchbugLllustratedData cardsTemp []*pb.DBCatchBugsCard cards []*pb.DBCatchBugsCard + backup []*pb.DBCatchBugsCard weights []int32 room *Room ) @@ -146,13 +147,20 @@ func (this *CatchBugs) createRoom(rules *pb.DBCatchBugsRules, red, blue *pb.DBCa cards[i].Index = int32(i) } + indexs = comm.RandShuffle(24) + backup = make([]*pb.DBCatchBugsCard, 24) + for i, v := range indexs { + backup[i] = cardsTemp[24+v] + backup[i].Index = int32(i) + } + roomid = primitive.NewObjectID().Hex() if room, err = this.rooms.newRoom(&pb.DBCatchBugsRoom{ Rid: roomid, Rules: rules, Red: red, Blue: blue, - Backup: cardsTemp[24:], + Backup: backup, Card: cards, }, sessions); err != nil { this.Error("创建房间错误", log.Field{Key: "err", Value: err.Error()}) diff --git a/modules/catchbugs/room.go b/modules/catchbugs/room.go index db68eaa2a..2302b6c7d 100644 --- a/modules/catchbugs/room.go +++ b/modules/catchbugs/room.go @@ -168,15 +168,19 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq) Changetype: 1, Card: card, }) - // this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{ - // Changetype: 1, - // Card: card, - // }) - // this.SendAllSessions("roundend", &pb.CatchbugsRoundEndPush{}) } if this.handleplayers == 2 { this.round++ this.handleplayers = 0 + if this.round == 4 { + this.ReplenishCard() + card = this.data.Card + roundendpush.Changes = append(roundendpush.Changes, &pb.CatchbugsTablesChangePush{ + Changetype: 1, + Card: card, + }) + } + if this.round <= 6 { if this.round%this.conf.Round == 0 { //触发技能 switch this.data.Rules.Skill { @@ -246,12 +250,12 @@ func (this *Room) ReplenishCard() { var index = 0 this.round = 4 for _, v := range this.data.Card { - if v.Isopen { - v.Isopen = false - v.Cid = this.data.Backup[index].Cid - v.Id = this.data.Backup[index].Id - index++ - } + // if v.Isopen { + v.Isopen = false + v.Cid = this.data.Backup[index].Cid + v.Id = this.data.Backup[index].Id + index++ + // } } this.isReplenish = true if this.data.Rules.Headstart == 0 {