上传捉虫子代码

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
handleplayer string
handleplayers int32
aihandlecards []int32
aihandlenumber int32
}
func (this *Room) GameStart() (err error) {
@ -284,17 +286,16 @@ func (this *Room) AiHanle(stype string) {
random = int32(len(cardsSlice))
}
indexs := comm.RandShuffle(len(cardsSlice))
for i, v := range indexs[0:random] {
this.PlayerHandle(this.data.Blue.Info.Uid, &pb.CatchbugsHandleReq{
Roomid: this.data.Rid,
Index: cardsSlice[v],
Number: int32(i % 2),
})
this.aihandlecards = make([]int32, 0)
this.aihandlenumber = 0
for _, v := range indexs[0:random] {
this.aihandlecards = append(this.aihandlecards, cardsSlice[v])
}
this.PlayerHandleEnd(this.data.Blue.Info.Uid, &pb.CatchbugsHandleEndReq{
Roomid: this.data.Rid,
})
this.AiHandleByOpenCard()
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的区域 旋转
func Skill1Effect(cards []*pb.DBCatchBugsCard) (cardsTemp []*pb.DBCatchBugsCard) {
var (