AI 积分波动处理

This commit is contained in:
meixiongfeng 2023-11-10 16:01:30 +08:00
parent 6715575176
commit dd3a0a9dbb

View File

@ -2,9 +2,11 @@ package entertainment
import (
"context"
"crypto/rand"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"math/big"
"go_dreamfactory/lego/core"
@ -89,17 +91,18 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) {
if robots, err := this.module.ModuleTools.RandRobotConfig(1); err == nil {
if len(robots) > 0 {
p2 = &pb.PlayerData{
Userinfo: &pb.BaseUserInfo{
Uid: "999",
Sid: "",
Name: robots[0].Name,
Gender: robots[0].Sex,
Skin: robots[0].Showid,
Aframe: "",
Title: "",
Lv: robots[0].Lvshow,
},
Cardid: this.module.configure.GetRobotGameConsumeHero(),
Userinfo: &pb.BaseUserInfo{Uid: "999", Sid: "", Name: robots[0].Name, Gender: robots[0].Sex, Skin: robots[0].Showid, Aframe: "", Title: "", Lv: robots[0].Lvshow},
Cardid: this.module.configure.GetRobotGameConsumeHero(),
}
n1, _ := rand.Int(rand.Reader, big.NewInt(100)) // AI 玩家积分波动
if n1.Int64()%2 == 0 {
p2.Consumeexp = p1.Consumeexp + int32(n1.Int64())
} else {
p2.Consumeexp = p1.Consumeexp - int32(n1.Int64())
if p2.Consumeexp < 0 { // 负数过滤
n1, _ := rand.Int(rand.Reader, big.NewInt(100))
p2.Consumeexp = int32(n1.Int64())
}
}
}
}