属性推送合并,增加一些错误码

This commit is contained in:
meixiongfeng 2022-07-21 19:13:52 +08:00
parent fe5fae9ca8
commit 21e6225520
18 changed files with 371 additions and 310 deletions

View File

@ -21,9 +21,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -64,9 +64,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -112,9 +112,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -165,9 +165,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -223,9 +223,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -286,9 +286,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -349,9 +349,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -412,9 +412,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -475,9 +475,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -538,9 +538,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -601,9 +601,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -664,9 +664,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -727,9 +727,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -790,9 +790,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -853,9 +853,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -916,9 +916,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -979,9 +979,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1042,9 +1042,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1105,9 +1105,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1168,9 +1168,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1231,9 +1231,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1294,9 +1294,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1357,9 +1357,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1420,9 +1420,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1483,9 +1483,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1546,9 +1546,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1609,9 +1609,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1672,9 +1672,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1735,9 +1735,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1798,9 +1798,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1861,9 +1861,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1924,9 +1924,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -1987,9 +1987,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2050,9 +2050,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2113,9 +2113,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2176,9 +2176,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2239,9 +2239,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2302,9 +2302,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2365,9 +2365,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2428,9 +2428,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2491,9 +2491,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2554,9 +2554,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2617,9 +2617,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2680,9 +2680,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2743,9 +2743,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2806,9 +2806,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2869,9 +2869,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2932,9 +2932,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -2995,9 +2995,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3058,9 +3058,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3121,9 +3121,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3184,9 +3184,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3247,9 +3247,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3310,9 +3310,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3373,9 +3373,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3436,9 +3436,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3499,9 +3499,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3562,9 +3562,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3625,9 +3625,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3688,9 +3688,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3751,9 +3751,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3814,9 +3814,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3877,9 +3877,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -3940,9 +3940,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4003,9 +4003,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4066,9 +4066,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4129,9 +4129,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4192,9 +4192,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4255,9 +4255,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",
@ -4318,9 +4318,9 @@
],
"award": [
{
"a": "attr",
"t": "gold",
"n": 10000
"a": "item",
"t": "1",
"n": 1
},
{
"a": "attr",

View File

@ -88,9 +88,9 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
property[awakenData.Phasebonus[0]] += int32(value)
}
this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero.Id, property)
_hero.JuexingLv += 1
_heroMap := map[string]interface{}{
"juexingLv": _hero.JuexingLv + 1,
"juexingLv": _hero.JuexingLv,
"isOverlying": false,
}
// 保存数据
@ -102,10 +102,12 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
}
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
session.SendMsg(string(this.module.GetType()), Awaken, &pb.HeroAwakenResp{Hero: _hero})
return
}

View File

@ -101,10 +101,11 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
if code != pb.ErrorCode_Success {
return
}
_hero.ResonateNum += 1
_hero.DistributionResonate += resonConfig.Energy
_heroMap := map[string]interface{}{
"resonateNum": _hero.ResonateNum + 1,
"distributionResonate": _hero.DistributionResonate + resonConfig.Energy,
"resonateNum": _hero.ResonateNum,
"distributionResonate": _hero.DistributionResonate,
"isOverlying": false,
}
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
@ -127,11 +128,12 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
}
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m
changeHero = append(changeHero, _hero)
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: changeHero})
session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
return

View File

@ -68,8 +68,9 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
for k := range _hero.Energy { // 清除玩家选择的共鸣属性
delete(_hero.Energy, k)
}
_hero.ResonateNum *= resonConfig.Energy
_heroMap := map[string]interface{}{
"DistributionResonate": _hero.ResonateNum * resonConfig.Energy,
"DistributionResonate": _hero.ResonateNum,
"Energy": _hero.Energy,
"isOverlying": false,
}
@ -80,10 +81,12 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
code = pb.ErrorCode_DBError
return
}
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
return
}

View File

@ -67,10 +67,11 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
}
this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero.Id, property)
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m
session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
return
}

View File

@ -131,11 +131,12 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
return
}
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{delcard}})
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
return
}

View File

@ -4,7 +4,6 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"math"
"google.golang.org/protobuf/proto"
)
@ -153,39 +152,26 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
}
chanegCard = append(chanegCard, _delcard)
}
_hero.Star += 1
_heroMap := map[string]interface{}{
"star": _hero.Star + 1,
"star": _hero.Star,
"isOverlying": false,
}
// 触发星级任务
this.module.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: _hero.Star + 1})
this.module.ModuleTask.SendToTask(session.GetUserId(), comm.TaskTypeGetHero, &pb.TaskParam{First: _hero.Star})
// 保存数据
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil {
code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1)
}
// 计算属性
data1 := make(map[string]int32, 0)
newConfig := this.module.configure.GetHeroStar(_hero.Star - 1)
if newConfig == nil {
code = pb.ErrorCode_ConfigurationException
return
}
data1[comm.Hp] = int32(math.Floor((1.0 + float64(newConfig.StarupHp)) * float64(_hero.Property[comm.Hp]) / 100))
data1[comm.Atk] = int32(math.Floor((1.0 + float64(newConfig.StarupAtk)) * float64(_hero.Property[comm.Atk]) / 100))
data1[comm.Def] = int32(math.Floor((1.0 + float64(newConfig.StarupDef)) * float64(_hero.Property[comm.Def]) / 100))
data1[comm.Speed] = int32(math.Floor((1.0 + float64(newConfig.StarupSpeed)) * float64(_hero.Property[comm.Speed]) / 100))
this.module.modelHero.mergeMainProperty(session.GetUserId(), _hero.Id, data1)
err1 = this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
code = pb.ErrorCode_Unknown
this.module.Errorf("PushHeroProperty err!")
}
_hero.Property = m // 更新属性变化
chanegCard = append(chanegCard, _hero)
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
session.SendMsg(string(this.module.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero})
return

View File

@ -170,13 +170,14 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
_costHero = append(_costHero, costHero)
}
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: _costHero})
err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
m, err1 := this.module.modelHero.PushHeroProperty(session, _hero.Id) // 推送属性变化
if err1 != nil {
this.module.Errorf("PushHeroProperty err!")
}
_hero.Lv = curLv
_hero.Exp = curExp
_hero.Property = m
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: []*pb.DBHero{_hero}})
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
return
}

View File

@ -402,8 +402,8 @@ func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 {
}
//推送用户指定英雄属性
func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string) (err error) {
m := this.PropertyCompute(session.GetUserId(), heroId)
func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string) (m map[string]int32, err error) {
m = this.PropertyCompute(session.GetUserId(), heroId)
update := map[string]interface{}{
"property": m,
}
@ -412,7 +412,8 @@ func (this *ModelHero) PushHeroProperty(session comm.IUserSession, heroId string
this.moduleHero.Errorf("PushHeroProperty err:%v", err)
return
}
return session.SendMsg("hero", "property", &pb.HeroPropertyPush{Property: m})
return //session.SendMsg("hero", "property", &pb.HeroPropertyPush{Property: m})
}
func (this *ModelHero) cleanData(uid string) {
userList := this.moduleHero.GetHeroList(uid)

View File

@ -63,24 +63,24 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq
code = pb.ErrorCode_HeroNoExist
return
}
list := make([]*pb.DBHero, 0)
if newHero, err := this.modelHero.setEquipment(hero); err != nil {
code = pb.ErrorCode_HeroEquipUpdate
return
} else {
list := make([]*pb.DBHero, 0)
if newHero != nil {
list = append(list, newHero)
}
list = append(list, hero)
session.SendMsg("hero", "change", &pb.HeroChangePush{List: list})
}
err1 := this.modelHero.PushHeroProperty(session, hero.Id) // 推送属性变化
m, err1 := this.modelHero.PushHeroProperty(session, hero.Id) // 推送属性变化
if err1 != nil {
code = pb.ErrorCode_Unknown
this.Errorf("PushHeroProperty err!")
}
hero.Property = m
list = append(list, hero)
session.SendMsg("hero", "change", &pb.HeroChangePush{List: list})
this.modelHero.setEquipProperty(hero, equip)
return
}

View File

@ -6,10 +6,10 @@ import (
)
const (
MainlineGetListResp = "getlist"
MainlineChallengeResp = "challenge"
MainlineGetRewardResp = "getreward"
PushNewChapterPush = "newchapter"
MainlineGetListResp = "getlist"
MainlineChallengeResp = "challenge"
MainlineGetRewardResp = "getreward"
MainlineNewChapterPush = "newchapter"
)
type apiComp struct {

View File

@ -4,6 +4,8 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
@ -23,7 +25,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
curChapter *pb.DBMainline // 当前章节信息
bBranch bool // 当前挑战关卡是不是分支
bCheck bool
res []*cfg.Game_atn // 小章节奖励
)
res = make([]*cfg.Game_atn, 0)
bBranch = false
code = this.ChallengeCheck(session, req)
if code != pb.ErrorCode_Success {
@ -62,6 +66,12 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
}
if con.Route == 1 {
if con.Previoustage != curChapter.MainlineId { // 前置关卡校验
// 分支关卡也校验一下
for _, v := range curChapter.BranchID {
if v == con.Previoustage {
break
}
}
code = pb.ErrorCode_MainlinePreNotFound
}
} else if con.Route == 2 { //分支
@ -72,6 +82,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
// return
//}
}
res = append(res, con.Award...)
}
// TODO 调用战斗逻辑
@ -91,21 +102,34 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
code = pb.ErrorCode_DBError
return
}
// 如果本章节打完 则创建新的章节
if chaptConfig.Episode[len(chaptConfig.Episode)-1] == int32(req.MainlineId) {
_data := &pb.DBMainline{}
_data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = curChapter.ChapterId + 1
_mData := make(map[string]interface{}, 0)
_data.Uid = session.GetUserId()
_mData[_data.Id] = _data
newChaptConfig := this.module.configure.GetMainlineChapter(int32(curChapter.ChapterId + 1)) // 查下一章节
if newChaptConfig != nil {
if len(newChaptConfig.Episode) <= 0 {
return
}
mainLineID := newChaptConfig.Episode[0]
// 如果本章节打完 则创建新的章节
if chaptConfig.Episode[len(chaptConfig.Episode)-1] == int32(req.MainlineId) {
_data := &pb.DBMainline{}
_data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = curChapter.ChapterId + 1
_data.MainlineId = mainLineID
_mData := make(map[string]interface{}, 0)
_data.Uid = session.GetUserId()
_mData[_data.Id] = _data
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
// 推送新的章节
session.SendMsg(string(this.module.GetType()), PushNewChapterPush, &pb.PushNewChapterPush{Data: _data})
this.module.modelMainline.addNewChapter(session.GetUserId(), _mData)
// 推送新的章节
session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data})
}
}
// 发奖 (奖励数据还没配置,后续补充)
code = this.module.DispenseRes(session, res, true)
if code != pb.ErrorCode_Success {
return
}
session.SendMsg(string(this.module.GetType()), MainlineChallengeResp, &pb.MainlineChallengeResp{Data: curChapter})
return
}

View File

@ -29,6 +29,35 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.MainlineGetRew
code = pb.ErrorCode_DBError
return
}
if _obj.AwaredID >= 0 {
code = pb.ErrorCode_MainlineRepeatReward // 重复领奖
return
}
// 校验是不是通关了
chaptConfig := this.module.configure.GetMainlineChapter(int32(_obj.ChapterId)) // 根据配置文件找
if chaptConfig == nil {
code = pb.ErrorCode_ConfigNoFound
return
}
if chaptConfig.Episode[len(chaptConfig.Episode)-1] != _obj.MainlineId {
code = pb.ErrorCode_MainlineCompleteReward // 通关才能领奖
return
}
_obj.AwaredID = 1
update := map[string]interface{}{
"awaredID": _obj.AwaredID,
}
// 发奖
code = this.module.DispenseRes(session, chaptConfig.Award, true)
if code != pb.ErrorCode_Success {
return
}
err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), _obj.Id, update)
if err != nil {
code = pb.ErrorCode_DBError
return
}
rsp.Data = _obj
session.SendMsg(string(this.module.GetType()), MainlineGetRewardResp, rsp)
return

View File

@ -120,7 +120,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
ObjId: primitive.NewObjectID().Hex(),
Uid: user.Uid,
Title: "系统邮件",
Contex: "恭喜获得专属礼包一份",
Contex: "恭喜获得登录专属礼包一份",
CreateTime: uint64(time.Now().Unix()),
DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
Check: false,

View File

@ -102,6 +102,8 @@ const (
ErrorCode_MainlineIDFailed ErrorCode = 1501 // 关卡ID 错误
ErrorCode_MainlineNotFound ErrorCode = 1502 // 主线关卡不存在
ErrorCode_MainlinePreNotFound ErrorCode = 1503 // 前置关卡不匹配
ErrorCode_MainlineRepeatReward ErrorCode = 1504 // 重复领奖
ErrorCode_MainlineCompleteReward ErrorCode = 1505 // 通关才能领奖
// task
ErrorCode_TaskInit ErrorCode = 1600 //初始化失败
ErrorCode_TaskReset ErrorCode = 1601 //重置任务失败
@ -190,6 +192,8 @@ var (
1501: "MainlineIDFailed",
1502: "MainlineNotFound",
1503: "MainlinePreNotFound",
1504: "MainlineRepeatReward",
1505: "MainlineCompleteReward",
1600: "TaskInit",
1601: "TaskReset",
1602: "TaskHandle",
@ -274,6 +278,8 @@ var (
"MainlineIDFailed": 1501,
"MainlineNotFound": 1502,
"MainlinePreNotFound": 1503,
"MainlineRepeatReward": 1504,
"MainlineCompleteReward": 1505,
"TaskInit": 1600,
"TaskReset": 1601,
"TaskHandle": 1602,
@ -317,7 +323,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, 0xb1, 0x0d, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xe9, 0x0d, 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,
@ -413,19 +419,22 @@ var file_errorcode_proto_rawDesc = []byte{
0x10, 0xdd, 0x0b, 0x12, 0x15, 0x0a, 0x10, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x4e,
0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xde, 0x0b, 0x12, 0x18, 0x0a, 0x13, 0x4d, 0x61,
0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x50, 0x72, 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e,
0x64, 0x10, 0xdf, 0x0b, 0x12, 0x0d, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74,
0x10, 0xc0, 0x0c, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74,
0x10, 0xc1, 0x0c, 0x12, 0x0f, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c,
0x65, 0x10, 0xc2, 0x0c, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65,
0x69, 0x76, 0x65, 0x64, 0x10, 0xc3, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41,
0x63, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc4, 0x0c, 0x12, 0x16, 0x0a, 0x11,
0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e,
0x64, 0x10, 0xc5, 0x0c, 0x12, 0x17, 0x0a, 0x12, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69,
0x76, 0x65, 0x4e, 0x6f, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0xc6, 0x0c, 0x12, 0x13, 0x0a,
0x0e, 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10,
0xc7, 0x0c, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68,
0x65, 0x64, 0x10, 0xc8, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x64, 0x10, 0xdf, 0x0b, 0x12, 0x19, 0x0a, 0x14, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65,
0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0xe0, 0x0b, 0x12,
0x1b, 0x0a, 0x16, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6c,
0x65, 0x74, 0x65, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0xe1, 0x0b, 0x12, 0x0d, 0x0a, 0x08,
0x54, 0x61, 0x73, 0x6b, 0x49, 0x6e, 0x69, 0x74, 0x10, 0xc0, 0x0c, 0x12, 0x0e, 0x0a, 0x09, 0x54,
0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x65, 0x74, 0x10, 0xc1, 0x0c, 0x12, 0x0f, 0x0a, 0x0a, 0x54,
0x61, 0x73, 0x6b, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x10, 0xc2, 0x0c, 0x12, 0x11, 0x0a, 0x0c,
0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, 0xc3, 0x0c, 0x12,
0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x69,
0x74, 0x10, 0xc4, 0x0c, 0x12, 0x16, 0x0a, 0x11, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69,
0x76, 0x65, 0x4e, 0x6f, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x10, 0xc5, 0x0c, 0x12, 0x17, 0x0a, 0x12,
0x54, 0x61, 0x73, 0x6b, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x4e, 0x6f, 0x65, 0x6e, 0x6f, 0x75,
0x67, 0x68, 0x10, 0xc6, 0x0c, 0x12, 0x13, 0x0a, 0x0e, 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x46,
0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xc7, 0x0c, 0x12, 0x11, 0x0a, 0x0c, 0x54, 0x61,
0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xc8, 0x0c, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -306,7 +306,7 @@ func (x *MainlineChallengeResp) GetData() *DBMainline {
}
// 推送新章节
type PushNewChapterPush struct {
type MainlineNewChapterPush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@ -314,8 +314,8 @@ type PushNewChapterPush struct {
Data *DBMainline `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
}
func (x *PushNewChapterPush) Reset() {
*x = PushNewChapterPush{}
func (x *MainlineNewChapterPush) Reset() {
*x = MainlineNewChapterPush{}
if protoimpl.UnsafeEnabled {
mi := &file_mainline_mainline_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -323,13 +323,13 @@ func (x *PushNewChapterPush) Reset() {
}
}
func (x *PushNewChapterPush) String() string {
func (x *MainlineNewChapterPush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PushNewChapterPush) ProtoMessage() {}
func (*MainlineNewChapterPush) ProtoMessage() {}
func (x *PushNewChapterPush) ProtoReflect() protoreflect.Message {
func (x *MainlineNewChapterPush) ProtoReflect() protoreflect.Message {
mi := &file_mainline_mainline_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -341,12 +341,12 @@ func (x *PushNewChapterPush) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use PushNewChapterPush.ProtoReflect.Descriptor instead.
func (*PushNewChapterPush) Descriptor() ([]byte, []int) {
// Deprecated: Use MainlineNewChapterPush.ProtoReflect.Descriptor instead.
func (*MainlineNewChapterPush) Descriptor() ([]byte, []int) {
return file_mainline_mainline_msg_proto_rawDescGZIP(), []int{6}
}
func (x *PushNewChapterPush) GetData() *DBMainline {
func (x *MainlineNewChapterPush) GetData() *DBMainline {
if x != nil {
return x.Data
}
@ -380,12 +380,12 @@ var file_mainline_mainline_msg_proto_rawDesc = []byte{
0x64, 0x22, 0x38, 0x0a, 0x15, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x68, 0x61,
0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61,
0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69,
0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x35, 0x0a, 0x12, 0x50,
0x75, 0x73, 0x68, 0x4e, 0x65, 0x77, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x50, 0x75, 0x73,
0x68, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x39, 0x0a, 0x16, 0x4d,
0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x65, 0x77, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65,
0x72, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x44, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x6c, 0x69, 0x6e, 0x65,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -402,20 +402,20 @@ func file_mainline_mainline_msg_proto_rawDescGZIP() []byte {
var file_mainline_mainline_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_mainline_mainline_msg_proto_goTypes = []interface{}{
(*MainlineGetListReq)(nil), // 0: MainlineGetListReq
(*MainlineGetListResp)(nil), // 1: MainlineGetListResp
(*MainlineGetRewardReq)(nil), // 2: MainlineGetRewardReq
(*MainlineGetRewardResp)(nil), // 3: MainlineGetRewardResp
(*MainlineChallengeReq)(nil), // 4: MainlineChallengeReq
(*MainlineChallengeResp)(nil), // 5: MainlineChallengeResp
(*PushNewChapterPush)(nil), // 6: PushNewChapterPush
(*DBMainline)(nil), // 7: DBMainline
(*MainlineGetListReq)(nil), // 0: MainlineGetListReq
(*MainlineGetListResp)(nil), // 1: MainlineGetListResp
(*MainlineGetRewardReq)(nil), // 2: MainlineGetRewardReq
(*MainlineGetRewardResp)(nil), // 3: MainlineGetRewardResp
(*MainlineChallengeReq)(nil), // 4: MainlineChallengeReq
(*MainlineChallengeResp)(nil), // 5: MainlineChallengeResp
(*MainlineNewChapterPush)(nil), // 6: MainlineNewChapterPush
(*DBMainline)(nil), // 7: DBMainline
}
var file_mainline_mainline_msg_proto_depIdxs = []int32{
7, // 0: MainlineGetListResp.data:type_name -> DBMainline
7, // 1: MainlineGetRewardResp.data:type_name -> DBMainline
7, // 2: MainlineChallengeResp.data:type_name -> DBMainline
7, // 3: PushNewChapterPush.data:type_name -> DBMainline
7, // 3: MainlineNewChapterPush.data:type_name -> DBMainline
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
@ -503,7 +503,7 @@ func file_mainline_mainline_msg_proto_init() {
}
}
file_mainline_mainline_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PushNewChapterPush); i {
switch v := v.(*MainlineNewChapterPush); i {
case 0:
return &v.state
case 1:

View File

@ -86,6 +86,8 @@ enum ErrorCode {
MainlineIDFailed = 1501; // ID
MainlineNotFound = 1502; // 线
MainlinePreNotFound = 1503; //
MainlineRepeatReward = 1504; //
MainlineCompleteReward = 1505; //
// task
TaskInit = 1600; //

View File

@ -31,6 +31,6 @@ message MainlineChallengeResp {
}
//
message PushNewChapterPush{
message MainlineNewChapterPush{
DBMainline data = 1;
}