上传星座图代码

This commit is contained in:
liwei1dao 2022-11-01 16:45:51 +08:00
parent bb5a8ca643
commit 67759e6bbe
7 changed files with 394 additions and 327 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,17 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.HoroscopeInfoR
///获取自己的排行榜信息
func (this *apiComp) Info(session comm.IUserSession, req *pb.HoroscopeInfoReq) (code pb.ErrorCode, data proto.Message) {
var ()
var (
info *pb.DBHoroscope
err error
)
if code = this.InfoCheck(session, req); code != pb.ErrorCode_Success {
return
}
session.SendMsg(string(this.module.GetType()), "info", &pb.HoroscopeInfoResp{})
if info, err = this.module.modelHoroscope.queryInfo(session.GetUserId()); err != nil {
code = pb.ErrorCode_DBError
return
}
session.SendMsg(string(this.module.GetType()), "info", &pb.HoroscopeInfoResp{Info: info})
return
}

View File

@ -3,6 +3,7 @@ package horoscope
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
@ -15,11 +16,46 @@ func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.HoroscopeUp
///获取自己的排行榜信息
func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.HoroscopeUpgradeReq) (code pb.ErrorCode, data proto.Message) {
var ()
var (
info *pb.DBHoroscope
conf *cfg.GameHoroscopeData
front *cfg.GameHoroscopeData
err error
)
if code = this.UpgradeCheck(session, req); code != pb.ErrorCode_Success {
return
}
if info, err = this.module.modelHoroscope.queryInfo(session.GetUserId()); err != nil {
code = pb.ErrorCode_DBError
return
}
if conf, err = this.module.configure.getHoroscope(req.Nid); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if conf.CostItem != nil && len(conf.CostItem) > 0 { //可有升级
if conf.Front > 0 {
if front, err = this.module.configure.getHoroscope(conf.Front); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if v, ok := info.Nodes[front.GrowType]; !ok || v < front.Lv {
code = pb.ErrorCode_HoroscopeNotTurnedOn
return
}
}
} else {
code = pb.ErrorCode_ReqParameterError
return
}
if code = this.module.ConsumeRes(session, conf.CostItem, true); code != pb.ErrorCode_Success {
return
}
info.Nodes[conf.GrowType] = conf.Lv
if err = this.module.modelHoroscope.updateInfo(info); err != nil {
code = pb.ErrorCode_DBError
return
}
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.HoroscopeUpgradeResp{})
return
}

View File

@ -23,11 +23,19 @@ func (this *modelHoroscope) Init(service core.IService, module core.IModule, com
}
//查询用户装备数据
func (this *modelHoroscope) queryInfo(uId string) (result *pb.DBArenaUser, err error) {
result = &pb.DBArenaUser{}
func (this *modelHoroscope) queryInfo(uId string) (result *pb.DBHoroscope, err error) {
result = &pb.DBHoroscope{}
if err = this.Get(uId, result); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err)
return
}
return
}
///保存用户竞技场信息
func (this *modelHoroscope) updateInfo(info *pb.DBHoroscope) (err error) {
err = this.Change(info.Uid, map[string]interface{}{
"nodes": info.Nodes,
})
return
}

View File

@ -22,6 +22,9 @@ type Horoscope struct {
modules.ModuleBase
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
options *Options
api_comp *apiComp
configure *configureComp
modelHoroscope *modelHoroscope
}
//模块名
@ -41,6 +44,14 @@ func (this *Horoscope) Start() (err error) {
return
}
//装备组件
func (this *Horoscope) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
this.modelHoroscope = this.RegisterComp(new(modelHoroscope)).(*modelHoroscope)
}
//计算英雄数值
func (this *Horoscope) ComputeHeroNumeric(hero *pb.DBHero) (code pb.ErrorCode) {
return

View File

@ -240,6 +240,8 @@ const (
ErrorCode_TrollSellMax ErrorCode = 3302 // 卖出上限
ErrorCode_TrollMaxSellCount ErrorCode = 3303 // 单日最大交易次数
ErrorCode_TrollMaxItemCount ErrorCode = 3304 //背包格子达到上限
// horoscope
ErrorCode_HoroscopeNotTurnedOn ErrorCode = 3401 //未开启
)
// Enum value maps for ErrorCode.
@ -440,6 +442,7 @@ var (
3302: "TrollSellMax",
3303: "TrollMaxSellCount",
3304: "TrollMaxItemCount",
3401: "HoroscopeNotTurnedOn",
}
ErrorCode_value = map[string]int32{
"Success": 0,
@ -637,6 +640,7 @@ var (
"TrollSellMax": 3302,
"TrollMaxSellCount": 3303,
"TrollMaxItemCount": 3304,
"HoroscopeNotTurnedOn": 3401,
}
)
@ -671,7 +675,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0x96, 0x22, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xb1, 0x22, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -944,8 +948,10 @@ var file_errorcode_proto_rawDesc = []byte{
0x53, 0x65, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x10, 0xe6, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72,
0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x6c, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10,
0xe7, 0x19, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x78, 0x49, 0x74,
0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f,
0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64,
0x4f, 0x6e, 0x10, 0xc9, 0x1a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -26,7 +26,7 @@ type GameHoroscopeData struct {
Text string
Upgrade []*Gameatr
Position string
Front string
Front int32
Behind string
}
@ -78,7 +78,7 @@ func (_v *GameHoroscopeData)Deserialize(_buf map[string]interface{}) (err error)
}
{ var _ok_ bool; if _v.Position, _ok_ = _buf["position"].(string); !_ok_ { err = errors.New("position error"); return } }
{ var _ok_ bool; if _v.Front, _ok_ = _buf["front"].(string); !_ok_ { err = errors.New("front error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["front"].(float64); !_ok_ { err = errors.New("front error"); return }; _v.Front = int32(_tempNum_) }
{ var _ok_ bool; if _v.Behind, _ok_ = _buf["behind"].(string); !_ok_ { err = errors.New("behind error"); return } }
return
}