上传代码
This commit is contained in:
parent
fcb577bb66
commit
56cd53a09c
@ -2,7 +2,11 @@ package arena
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/mgo"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -16,16 +20,44 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.ArenaInfoReq)
|
|||||||
///获取自己的排行榜信息
|
///获取自己的排行榜信息
|
||||||
func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
|
global *cfg.GameGlobalData
|
||||||
info *pb.DBArenaUser
|
info *pb.DBArenaUser
|
||||||
|
user *pb.DBUser
|
||||||
|
model *db.DBModel
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
|
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil {
|
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if err == mgo.MongodbNil {
|
||||||
|
global = this.module.configure.GetGlobalConf()
|
||||||
|
if model, err = this.module.GetDBNodule(session, comm.TableUser, time.Hour); err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user = &pb.DBUser{}
|
||||||
|
if err = model.Get(session.GetUserId(), user); err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info = &pb.DBArenaUser{
|
||||||
|
Uid: session.GetUserId(),
|
||||||
|
Name: user.Name,
|
||||||
|
Integral: global.ArenaInitiaIntegral,
|
||||||
|
Ticket: 10,
|
||||||
|
Record: make([]*pb.DBArenaBattleRecord, 0),
|
||||||
|
}
|
||||||
|
if err = this.module.modelArena.Add(session.GetUserId(), info); err != nil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), "info", &pb.ArenaInfoResp{Info: info})
|
session.SendMsg(string(this.module.GetType()), "info", &pb.ArenaInfoResp{Info: info})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -44,17 +44,6 @@ func (this *modelArena) queryPlayerInfo(uId string) (result *pb.DBArenaUser, err
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err == mgo.MongodbNil {
|
|
||||||
result = &pb.DBArenaUser{
|
|
||||||
Uid: uId,
|
|
||||||
Integral: 0,
|
|
||||||
Ticket: 10,
|
|
||||||
Record: make([]*pb.DBArenaBattleRecord, 0),
|
|
||||||
}
|
|
||||||
if err = this.Add(uId, result); err != nil {
|
|
||||||
this.module.Errorln(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,3 +270,8 @@ func (this *modelArena) getAI(mformatId int32) (ai *pb.ArenaPlayer, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//积分计算
|
||||||
|
func (this *modelArena) integralCompute(red, bule *pb.ArenaPlayer, iswin bool) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user