上传捉虫子代码

This commit is contained in:
liwei1dao 2023-11-13 14:53:24 +08:00
parent 569d9774db
commit f8822fc6be

View File

@ -21,6 +21,8 @@ type Room struct {
isReplenish bool isReplenish bool
handleplayer string handleplayer string
handleplayers int32 handleplayers int32
aihandlecards []int32
aihandlenumber int32
} }
func (this *Room) GameStart() (err error) { func (this *Room) GameStart() (err error) {
@ -284,17 +286,16 @@ func (this *Room) AiHanle(stype string) {
random = int32(len(cardsSlice)) random = int32(len(cardsSlice))
} }
indexs := comm.RandShuffle(len(cardsSlice)) indexs := comm.RandShuffle(len(cardsSlice))
for i, v := range indexs[0:random] { this.aihandlecards = make([]int32, 0)
this.PlayerHandle(this.data.Blue.Info.Uid, &pb.CatchbugsHandleReq{ this.aihandlenumber = 0
Roomid: this.data.Rid, for _, v := range indexs[0:random] {
Index: cardsSlice[v], this.aihandlecards = append(this.aihandlecards, cardsSlice[v])
Number: int32(i % 2),
})
} }
this.PlayerHandleEnd(this.data.Blue.Info.Uid, &pb.CatchbugsHandleEndReq{ this.AiHandleByOpenCard()
Roomid: this.data.Rid,
})
break break
case "opencard":
time.Sleep(time.Second)
this.AiHandleByOpenCard()
} }
} }
@ -312,6 +313,21 @@ func (this *Room) SendAllSessions(stype string, msg proto.Message, ispush bool)
} }
} }
func (this *Room) AiHandleByOpenCard() {
this.PlayerHandle(this.data.Blue.Info.Uid, &pb.CatchbugsHandleReq{
Roomid: this.data.Rid,
Index: this.aihandlecards[this.aihandlenumber],
Number: int32(this.aihandlenumber % 2),
})
this.aihandlenumber++
if this.aihandlenumber >= int32(len(this.aihandlecards)) {
this.PlayerHandleEnd(this.data.Blue.Info.Uid, &pb.CatchbugsHandleEndReq{
Roomid: this.data.Rid,
})
}
}
//技能效果1 随机2x2的区域 旋转 //技能效果1 随机2x2的区域 旋转
func Skill1Effect(cards []*pb.DBCatchBugsCard) (cardsTemp []*pb.DBCatchBugsCard) { func Skill1Effect(cards []*pb.DBCatchBugsCard) (cardsTemp []*pb.DBCatchBugsCard) {
var ( var (