xxl发奖校验 如果是AI胜利 不发将

This commit is contained in:
meixiongfeng 2023-10-26 09:58:48 +08:00
parent e5f95645e4
commit 58898f4d3f

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -473,22 +474,42 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
var (
atno []*pb.UserAtno
winindex int32
bReward bool
res []*cfg.Gameatn
)
if this.operatetimer != nil {
timewheel.Remove(this.operatetimer)
}
var winner string
winner = this.player1.Uid
bReward = true
if this.player1.Score < this.player2.Score {
winner = this.player2.Uid
winindex = 1
if len(this.szSession) == 1 { // 赢家是AI 的话不发奖
bReward = false
}
if conf, err := this.module.configure.GetGameConsumeintegral(this.player1.Score); err != nil {
if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], conf.Rewards, true); errdata != nil {
}
if conf, err := this.module.configure.GetGameConsumeintegral(this.player1.Score); err == nil {
res = append(res, conf.Onereward...)
res = append(res, conf.Rewards...)
if bReward { // 发奖
if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil {
return
}
} else { // AI 不发将 构建一个atno对象
for _, v := range res {
atno = append(atno, &pb.UserAtno{
A: v.A,
T: v.T,
N: v.N,
O: "",
})
}
}
}
this.module.SendMsgSyncToSession(string(this.module.GetType()), "gameover", &pb.EntertainGameOverPush{
User1: this.player1,
User2: this.player2,