修复做虫子代码

This commit is contained in:
liwei1dao 2023-12-08 22:27:36 +08:00
parent 1baf868df3
commit b76b1f5ab2
2 changed files with 24 additions and 12 deletions

View File

@ -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()})

View File

@ -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 {