This commit is contained in:
liwei1dao 2022-06-30 13:48:11 +08:00
commit 10dfa52f8c
17 changed files with 165 additions and 77 deletions

View File

@ -1,9 +1,12 @@
package robot package robot
import ( import (
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules/hero" "go_dreamfactory/modules/hero"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
) )
var ( var (
@ -14,6 +17,12 @@ var (
subType: hero.HeroSubTypeList, subType: hero.HeroSubTypeList,
req: &pb.HeroListReq{}, req: &pb.HeroListReq{},
rsp: &pb.HeroListRsp{}, rsp: &pb.HeroListRsp{},
print: func(rsp proto.Message) {
out := rsp.(*pb.HeroListRsp)
for i, v := range out.List {
fmt.Printf("%d- %v\n", (i + 1), v)
}
},
// enabled: true, // enabled: true,
}, { }, {
mainType: string(comm.ModuleHero), mainType: string(comm.ModuleHero),
@ -26,8 +35,33 @@ var (
}, { }, {
mainType: string(comm.ModuleHero), mainType: string(comm.ModuleHero),
subType: hero.HeroSubTypeChouka, subType: hero.HeroSubTypeChouka,
req: &pb.HeroChoukaReq{}, req: &pb.HeroChoukaReq{
HeroIds: []int32{42911},
},
rsp: &pb.HeroChoukaResp{}, rsp: &pb.HeroChoukaResp{},
// enabled: true,
}, {
mainType: string(comm.ModuleHero),
subType: hero.StrengthenUpStar,
req: &pb.HeroStrengthenUpStarReq{
HeroObjID: "62bd0489ff6632434a7d0d1f",
Hero: []*pb.CostCardData{
{
CostCardObj: "",
},
},
},
rsp: &pb.HeroStrengthenUpStarResp{},
// enabled: true,
}, {
mainType: string(comm.ModuleHero),
subType: hero.StrengthenUplv,
req: &pb.HeroStrengthenUplvReq{
HeroObjID: "62bd0489ff6632434a7d0d1f",
ExpCardID: "62bd0b4eca37634b8230d4be",
Amount: 1,
},
rsp: &pb.HeroStrengthenUplvResp{},
enabled: true, enabled: true,
}, },
} }

View File

@ -75,6 +75,7 @@ type builder struct {
enabled bool enabled bool
start time.Time start time.Time
requested bool //请求标识 true已发 requested bool //请求标识 true已发
print func(rsp proto.Message)
} }
func (r *Robot) addBuilders(builders []*builder) { func (r *Robot) addBuilders(builders []*builder) {
@ -109,7 +110,13 @@ func (r *Robot) handleRsp(msg *pb.UserMessage) {
if !comm.ProtoUnmarshal(msg, b.rsp) { if !comm.ProtoUnmarshal(msg, b.rsp) {
return return
} }
if b.print == nil {
printReply(msg, b) printReply(msg, b)
} else {
fmt.Printf("===== rsp [%s.%s] =====\n", msg.MainType, msg.SubType)
b.print(b.rsp)
fmt.Println("==============================")
}
if msg.MainType == "user" && msg.SubType == "login" { if msg.MainType == "user" && msg.SubType == "login" {
r.loginCallback(b.rsp) r.loginCallback(b.rsp)

View File

@ -13,7 +13,7 @@ var user_builders = []*builder{
mainType: string(comm.ModuleUser), mainType: string(comm.ModuleUser),
subType: user.UserSubTypeCreate, subType: user.UserSubTypeCreate,
req: &pb.UserCreateReq{ //设置请求参数 req: &pb.UserCreateReq{ //设置请求参数
NickName: "乐谷62911", NickName: "乐谷6301",
}, },
rsp: &pb.UserCreateRsp{}, rsp: &pb.UserCreateRsp{},
// enabled: true, // enabled: true,

View File

@ -113,10 +113,10 @@ func (this *MCompModel) Add(uid string, data interface{}, attrs ...*cache.Operat
return return
} }
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil { if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
this.Redis.Expire(this.ukey(uid), ret.(time.Duration)) err = this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
} }
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil { if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
err = this.InsertModelLogs(this.TableName, uid, data) err = this.InsertModelLogs(this.TableName, uid, []interface{}{data})
} }
return return
} }
@ -131,7 +131,7 @@ func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs .
return return
} }
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil { if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
this.Redis.Expire(this.ukey(uid), ret.(time.Duration)) err = this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
} }
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil { if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
err = this.InsertModelLogs(this.TableName, uid, []interface{}{data}) err = this.InsertModelLogs(this.TableName, uid, []interface{}{data})

View File

@ -14,10 +14,15 @@ type apiComp struct {
} }
const ( //消息回复的头名称 const ( //消息回复的头名称
StrengthenUplv = "strengthenherolv" StrengthenUplv = "strengthenuplv"
HeroSubTypeInfo = "info" //英雄卡片信息 HeroSubTypeInfo = "info" //英雄卡片信息
HeroSubTypeList = "list" //英雄列表 HeroSubTypeList = "list" //英雄列表
HeroSubTypeChouka = "chouka" //抽卡 HeroSubTypeChouka = "chouka" //抽卡
ResonanceUseEnergy = "resonanceuseenergy" // 使用共鸣能量
Resonance = "resonance" // 英雄共鸣属性
ResonanceReset = "resonancereset" // 共鸣重置
StrengthenUpSkill = "strengthenupskill" // 技能强化
StrengthenUpStar = "strengthensupstar" // 英雄升星
) )
//组件初始化接口 //组件初始化接口

View File

@ -25,7 +25,7 @@ func (this *apiComp) Chouka(session comm.IUserSession, result map[string]interfa
utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeChouka, req, rsp) utils.TraceFunc(session.GetUserId(), string(this.moduleHero.GetType()), HeroSubTypeChouka, req, rsp)
}() }()
heroCfgIds := []int32{15001, 25001} heroCfgIds := req.HeroIds
if err := this.moduleHero.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil { if err := this.moduleHero.modelHero.createMultiHero(session.GetUserId(), heroCfgIds...); err != nil {
code = pb.ErrorCode_HeroCreate code = pb.ErrorCode_HeroCreate
return return

View File

@ -17,12 +17,12 @@ func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroReson
bCheckOk bool bCheckOk bool
) )
bCheckOk = false bCheckOk = false
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
} }
_costHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.CostObjID) // 查询消耗卡是否存在 _costHero, err := this.moduleHero.GetHero(session.GetUserId(), req.CostObjID) // 查询消耗卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
@ -88,7 +88,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
} }
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroResonanceResp{Hero: _hero}) session.SendMsg(string(this.moduleHero.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
} }
}() }()
@ -135,6 +135,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, agrs map[string]interf
} }
} }
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -13,7 +13,7 @@ func (this *apiComp) ResonanceResetCheck(session comm.IUserSession, req *pb.Hero
code.Code = pb.ErrorCode_ReqParameterError code.Code = pb.ErrorCode_ReqParameterError
return return
} }
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
@ -66,7 +66,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, agrs map[string]i
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), "ResonanceReset", &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum}) session.SendMsg(string(this.moduleHero.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
} }
}() }()
@ -88,6 +88,9 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, agrs map[string]i
if err != nil { if err != nil {
log.Errorf("update hero skill failed:%v", err) log.Errorf("update hero skill failed:%v", err)
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -12,7 +12,7 @@ func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.
code.Code = pb.ErrorCode_ReqParameterError code.Code = pb.ErrorCode_ReqParameterError
return return
} }
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
@ -32,7 +32,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[stri
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroResonanceUseEnergyResp{Hero: _hero}) session.SendMsg(string(this.moduleHero.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
} }
}() }()
@ -53,5 +53,9 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, agrs map[stri
log.Errorf("update hero skill failed:%v", err) log.Errorf("update hero skill failed:%v", err)
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -19,12 +19,12 @@ func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.H
tagColor int32 tagColor int32
costColor int32 costColor int32
) )
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在 _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
} }
_costHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在 _costHero, err := this.moduleHero.GetHero(session.GetUserId(), req.CostCardObj) // 查询消耗卡是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
@ -74,7 +74,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
} }
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUpSkillResp{Hero: _hero}) session.SendMsg(string(this.moduleHero.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
} }
}() }()
log.Debugf("英雄:%d 技能升级", tagHero) log.Debugf("英雄:%d 技能升级", tagHero)
@ -139,5 +139,9 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, agrs map[strin
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -20,7 +20,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
costRaceCount int32 costRaceCount int32
curGold int32 curGold int32
) )
tagHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) tagHero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID)
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
@ -42,7 +42,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
} }
// 指定英雄消耗校验 // 指定英雄消耗校验
for _, v := range req.Hero { for _, v := range req.Hero {
if tagHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 { if tagHero, err := this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
code.Code = pb.ErrorCode_ReqParameterError code.Code = pb.ErrorCode_ReqParameterError
return return
} else { } else {
@ -59,7 +59,7 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
} }
// 校验阵容英雄消耗 // 校验阵容英雄消耗
for _, v := range req.HeroRace { for _, v := range req.HeroRace {
if raceHero, err = this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 { if raceHero, err = this.moduleHero.GetHero(session.GetUserId(), v.CostCardObj); err != 0 {
code.Code = pb.ErrorCode_ReqParameterError code.Code = pb.ErrorCode_ReqParameterError
return return
} else { } else {
@ -112,7 +112,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
} }
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUpStarResp{Hero: _hero}) session.SendMsg(string(this.moduleHero.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero})
} }
}() }()
@ -151,5 +151,9 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, agrs map[string
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
log.Errorf("update hero skill failed:%v", err) log.Errorf("update hero skill failed:%v", err)
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -21,13 +21,13 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
//atn = map[string]interface{}{} //atn = map[string]interface{}{}
) )
_hero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在 _hero, err := this.moduleHero.GetHero(session.GetUserId(), req.HeroObjID) // 校验升级的对象是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
return return
} }
_expHero, err := this.moduleHero.modelHero.moduleHero.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在 _expHero, err := this.moduleHero.GetHero(session.GetUserId(), req.ExpCardID) // 校验需要消耗经验卡牌的对象是否存在
if err != 0 { if err != 0 {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
@ -45,7 +45,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
if expConf != nil { if expConf != nil {
addExp = expConf.Heroexp * req.Amount addExp = expConf.Heroexp * req.Amount
} }
if _expHero.SameCount <= req.Amount { // 消耗经验卡片数量不足 if _expHero.SameCount < req.Amount { // 消耗经验卡片数量不足
code.Code = pb.ErrorCode_HeroNoEnough code.Code = pb.ErrorCode_HeroNoEnough
return return
} }
@ -60,14 +60,14 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
maxLv = _hero.Star * comm.HeroStarLvRatio maxLv = _hero.Star * comm.HeroStarLvRatio
_data := this.moduleHero.configure.GetHeroLv(curLv) _data := this.moduleHero.configure.GetHeroLv(curLv)
if _data != nil { if _data != nil {
if maxLv >= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级 if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级
code.Code = pb.ErrorCode_HeroMaxLv code.Code = pb.ErrorCode_HeroMaxLv
return return
} }
curExp += addExp // 先把经验加上 curExp += addExp // 先把经验加上
for { // 死循环判断一键升级 for { // 死循环判断一键升级
if maxLv >= _hero.Lv && curExp >= _data.Heroexp[0].N { // 设置最大经验和等级 if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 设置最大经验和等级
curLv = maxLv curLv = maxLv
curExp = _data.Heroexp[0].N curExp = _data.Heroexp[0].N
break break
@ -88,7 +88,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
// 金币消耗判断 // 金币消耗判断
curGold = this.user.QueryAttributeValue(session.GetUserId(), "gold") curGold = this.user.QueryAttributeValue(session.GetUserId(), "gold")
if curGold < costGold { if curGold < costGold {
code.Code = pb.ErrorCode_GoldNoEnough // code.Code = pb.ErrorCode_GoldNoEnough
} }
} else { } else {
code.Code = pb.ErrorCode_HeroNoExist code.Code = pb.ErrorCode_HeroNoExist
@ -101,6 +101,7 @@ func (this *apiComp) StrengthenUplvCheck(session comm.IUserSession, req *pb.Hero
"curExp": curExp, "curExp": curExp,
"curLv": curLv, "curLv": curLv,
"addExp": addExp, "addExp": addExp,
"heroObj": _hero,
//"atn": atn, //"atn": atn,
} }
return return
@ -115,18 +116,24 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, agrs map[string]i
addExp int32 // 需要增加的经验 addExp int32 // 需要增加的经验
//atn = map[string]interface{}{} //atn = map[string]interface{}{}
) )
defer func() {
if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{})
}
}()
costGold = agrs["costGold"].(int32) costGold = agrs["costGold"].(int32)
curLv = agrs["curLv"].(int32) curLv = agrs["curLv"].(int32)
curExp = agrs["curExp"].(int32) curExp = agrs["curExp"].(int32)
addExp = agrs["addExp"].(int32) addExp = agrs["addExp"].(int32)
_hero := agrs["heroObj"].(*pb.DBHero)
if _hero == nil {
code = pb.ErrorCode_HeroNoExist
return
}
defer func() {
if code == pb.ErrorCode_Success {
session.SendMsg(string(this.moduleHero.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
}
}()
log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costGold, addExp) log.Debugf("升级后当前等级: %d,经验: %d,需要消耗的金币: %d,增加的经验: %d", curLv, curExp, costGold, addExp)
// 执行升级逻辑 // 执行升级逻辑
code = this.moduleHero.modelHero.moduleHero.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验 code = this.moduleHero.AddCardExp(session.GetUserId(), req.HeroObjID, addExp) // 加经验
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
@ -136,10 +143,18 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, agrs map[string]i
return return
} }
// 删除经验卡 // 删除经验卡
code = this.moduleHero.modelHero.moduleHero.DelCard(req.ExpCardID, req.Amount) err := this.moduleHero.modelHero.DelListlds(session.GetUserId(), req.ExpCardID)
if err != nil {
log.Errorf("delete err failed err:%T!", err)
return
}
//code = this.moduleHero.modelHero.moduleHero.DelCard(req.ExpCardID, req.Amount)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
err = this.moduleHero.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err != nil {
log.Errorf("PushHeroProperty err!")
}
return return
} }

View File

@ -124,14 +124,14 @@ func (this *Hero) AddCardExp(uid string, heroId string, exp int32) (code pb.Erro
maxLv = _hero.Star * comm.HeroStarLvRatio maxLv = _hero.Star * comm.HeroStarLvRatio
_data := this.configure.GetHeroLv(curLv) _data := this.configure.GetHeroLv(curLv)
if _data != nil { if _data != nil {
if maxLv >= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级 if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 加经验之前校验是否达到最大等级
code = pb.ErrorCode_HeroMaxLv code = pb.ErrorCode_HeroMaxLv
return return
} }
curExp += exp // 先把经验加上 curExp += exp // 先把经验加上
for { // 死循环判断一键升级 for { // 死循环判断一键升级
if maxLv >= _hero.Lv && curExp >= _data.Heroexp[0].N { // 设置最大经验和等级 if maxLv <= _hero.Lv && curExp >= _data.Heroexp[0].N { // 设置最大经验和等级
curLv = maxLv curLv = maxLv
curExp = _data.Heroexp[0].N curExp = _data.Heroexp[0].N
break break

View File

@ -37,8 +37,6 @@ func (this *apiComp) Login(session comm.IUserSession, result map[string]interfac
} }
}() }()
// user := decodeUserData(req.Sec)
//从mgo查询user //从mgo查询user
user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account) user, err = this.module.modelUser.User_FindByAccount(req.Sid, req.Account)
if err != nil { if err != nil {
@ -49,6 +47,7 @@ func (this *apiComp) Login(session comm.IUserSession, result map[string]interfac
if user == nil { if user == nil {
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面 //如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
user = &pb.DBUser{}
err = this.module.modelUser.User_Create(user) err = this.module.modelUser.User_Create(user)
if err != nil { if err != nil {
log.Errorf("User_CreateUser err %v", err) log.Errorf("User_CreateUser err %v", err)

View File

@ -44,8 +44,7 @@ func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id) user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
user.Uuid = uuid.NewV4().String() user.Uuid = uuid.NewV4().String()
user.Ctime = time.Now().Unix() user.Ctime = time.Now().Unix()
_, err = this.DB.InsertOne(TableUser, user) return this.Add(user.Uid,user)
return err
} }
//获取用户 //获取用户

View File

@ -1089,6 +1089,8 @@ type HeroChoukaReq struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
HeroIds []int32 `protobuf:"varint,1,rep,packed,name=heroIds,proto3" json:"heroIds"`
} }
func (x *HeroChoukaReq) Reset() { func (x *HeroChoukaReq) Reset() {
@ -1123,6 +1125,13 @@ func (*HeroChoukaReq) Descriptor() ([]byte, []int) {
return file_hero_hero_msg_proto_rawDescGZIP(), []int{20} return file_hero_hero_msg_proto_rawDescGZIP(), []int{20}
} }
func (x *HeroChoukaReq) GetHeroIds() []int32 {
if x != nil {
return x.HeroIds
}
return nil
}
type HeroChoukaResp struct { type HeroChoukaResp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -1332,31 +1341,33 @@ var file_hero_hero_msg_proto_rawDesc = []byte{
0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f,
0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68,
0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44,
0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x0f, 0x0a, 0x0d, 0x48, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x29, 0x0a, 0x0d, 0x48,
0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x0e, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x68,
0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x73, 0x22, 0x34, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68,
0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f,
0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42,
0x72, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a,
0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x70, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x16, 0x0a,
0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68,
0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72,
0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74,
0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x41, 0x79, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79,
0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f,
0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72,
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -108,7 +108,7 @@ message HeroJuexingResp {
} }
// //
message HeroChoukaReq {} message HeroChoukaReq { repeated int32 heroIds = 1; }
message HeroChoukaResp { repeated DBHero heroes = 1; } message HeroChoukaResp { repeated DBHero heroes = 1; }