This commit is contained in:
wh_zcy 2023-06-28 17:53:40 +08:00
commit 7437087b27

View File

@ -23,13 +23,13 @@ import (
"go.mongodb.org/mongo-driver/x/bsonx" "go.mongodb.org/mongo-driver/x/bsonx"
) )
///竞技场 数据组件 // /竞技场 数据组件
type modelArena struct { type modelArena struct {
modules.MCompModel modules.MCompModel
module *Arena module *Arena
} }
//组件初始化接口 // 组件初始化接口
func (this *modelArena) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { func (this *modelArena) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.TableName = comm.TableArena this.TableName = comm.TableArena
this.MCompModel.Init(service, module, comp, opt) this.MCompModel.Init(service, module, comp, opt)
@ -48,7 +48,7 @@ func (this *modelArena) Init(service core.IService, module core.IModule, comp co
return return
} }
//查询用户装备数据 // 查询用户装备数据
func (this *modelArena) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err error) { func (this *modelArena) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err error) {
result = &pb.DBArenaUser{} result = &pb.DBArenaUser{}
if err = this.Get(uId, result); err != nil && err != mgo.MongodbNil { if err = this.Get(uId, result); err != nil && err != mgo.MongodbNil {
@ -58,7 +58,7 @@ func (this *modelArena) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err
return return
} }
//查询用户装备数据 // 查询用户装备数据
func (this *modelArena) queryPlayers(uIds []string) (result []*pb.DBArenaUser, err error) { func (this *modelArena) queryPlayers(uIds []string) (result []*pb.DBArenaUser, err error) {
result = make([]*pb.DBArenaUser, 0) result = make([]*pb.DBArenaUser, 0)
if _, err = this.Gets(uIds, &result); err != nil && err != mgo.MongodbNil { if _, err = this.Gets(uIds, &result); err != nil && err != mgo.MongodbNil {
@ -68,7 +68,7 @@ func (this *modelArena) queryPlayers(uIds []string) (result []*pb.DBArenaUser, e
return return
} }
//查询用户装备数据 // 查询用户装备数据
func (this *modelArena) queryArenaPlayer(uId string) (result *pb.ArenaPlayer, err error) { func (this *modelArena) queryArenaPlayer(uId string) (result *pb.ArenaPlayer, err error) {
temp := &pb.DBArenaUser{} temp := &pb.DBArenaUser{}
if err = this.Get(uId, temp); err != nil { if err = this.Get(uId, temp); err != nil {
@ -88,7 +88,7 @@ func (this *modelArena) queryArenaPlayer(uId string) (result *pb.ArenaPlayer, er
return return
} }
//查询用户英雄数据 // 查询用户英雄数据
func (this *modelArena) queryUserHeros(uid string, heroids []string) (results []*pb.DBHero, err error) { func (this *modelArena) queryUserHeros(uid string, heroids []string) (results []*pb.DBHero, err error) {
var ( var (
model *db.DBModel model *db.DBModel
@ -105,7 +105,7 @@ func (this *modelArena) queryUserHeros(uid string, heroids []string) (results []
return return
} }
///保存用户竞技场信息 // /保存用户竞技场信息
func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) { func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
var ( var (
dan int32 dan int32
@ -131,6 +131,8 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) {
"defendtotaluum": info.Defendtotaluum, "defendtotaluum": info.Defendtotaluum,
"loc": []float64{float64(dan), float64(rand.Int31n(100)) / 1000.0}, "loc": []float64{float64(dan), float64(rand.Int31n(100)) / 1000.0},
"isdef": info.Isdef, "isdef": info.Isdef,
"name": info.Name,
"avatar": info.Avatar,
"lv": info.Lv, "lv": info.Lv,
}) })
return return
@ -195,7 +197,7 @@ func (this *modelArena) computedan(integral int32) (dan int32, err error) {
// return // return
// } // }
//匹配机器人 // 匹配机器人
func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err error) { func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err error) {
var ( var (
active *cfg.GameArenaActiveRewardData active *cfg.GameArenaActiveRewardData
@ -276,7 +278,7 @@ func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err
return return
} }
//获取目标去陪数据 // 获取目标去陪数据
func (this *modelArena) matchePlayer(uid string, dan, num int32) (results []*pb.ArenaPlayer, err error) { func (this *modelArena) matchePlayer(uid string, dan, num int32) (results []*pb.ArenaPlayer, err error) {
var ( var (
cursor *mongo.Cursor cursor *mongo.Cursor
@ -317,7 +319,7 @@ func (this *modelArena) matchePlayer(uid string, dan, num int32) (results []*pb.
return return
} }
//随机用户名 // 随机用户名
func (this *modelArena) randUserName() string { func (this *modelArena) randUserName() string {
var s = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*") var s = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*")
r := rand.New(rand.NewSource(configure.Now().UnixNano() + rand.Int63n(10000))) r := rand.New(rand.NewSource(configure.Now().UnixNano() + rand.Int63n(10000)))
@ -377,7 +379,7 @@ func (this *modelArena) getAI(mformatId int32) (ai *pb.ArenaPlayer, err error) {
return return
} }
//积分计算 // 积分计算
func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) { func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) {
var ( var (
redactive *cfg.GameArenaActiveRewardData redactive *cfg.GameArenaActiveRewardData