#33705 子任务 【梦工场系统】 <-后端-> 【铁匠破】图鉴需要一键激活
This commit is contained in:
parent
4871c79f75
commit
bf96d301b0
@ -7,12 +7,7 @@ import (
|
||||
|
||||
// 参数校验
|
||||
func (this *apiComp) AtlasActivateCheck(session comm.IUserSession, req *pb.SmithyAtlasActivateReq) (errdata *pb.ErrorData) {
|
||||
if req.Id == "" {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -21,7 +16,9 @@ func (this *apiComp) AtlasActivate(session comm.IUserSession, req *pb.SmithyAtla
|
||||
var (
|
||||
addScore int32 // 更新图鉴增加的积分
|
||||
szTask []*pb.BuriedParam
|
||||
update map[string]interface{}
|
||||
)
|
||||
update = make(map[string]interface{}, 0)
|
||||
if errdata = this.AtlasActivateCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
@ -34,67 +31,89 @@ func (this *apiComp) AtlasActivate(session comm.IUserSession, req *pb.SmithyAtla
|
||||
}
|
||||
return
|
||||
}
|
||||
conf, err := this.module.configure.GetSmithyAtlasConf(req.Id)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if conf.TypeId == 1 {
|
||||
if v, ok := atlas.Atlas[req.Id]; ok {
|
||||
if !v.Activate { // 激活
|
||||
|
||||
if req.Id == "" { // 一键激活
|
||||
for _, v := range atlas.Atlas {
|
||||
if !v.Activate {
|
||||
v.Activate = true
|
||||
addScore = v.Data1.Score
|
||||
} else { //更新操作
|
||||
if v.Data2 != nil {
|
||||
addScore = v.Data2.Score - v.Data1.Score
|
||||
if addScore < 0 { // 异常校验 防止配置修改导致分数减少
|
||||
addScore = 0
|
||||
}
|
||||
v.Data1 = v.Data2
|
||||
v.Data2 = nil
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoActivateAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoActivateAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if v.Data2 != nil {
|
||||
addScore = v.Data2.Score - v.Data1.Score
|
||||
if addScore < 0 { // 异常校验 防止配置修改导致分数减少
|
||||
addScore = 0
|
||||
}
|
||||
v.Data1 = v.Data2
|
||||
v.Data2 = nil
|
||||
}
|
||||
update := make(map[string]interface{}, 0)
|
||||
update["atlas"] = atlas.Atlas
|
||||
atlas.Score += addScore
|
||||
update["score"] = atlas.Score
|
||||
this.module.modelAtlas.modifySmithyAtlasList(session.GetUserId(), update)
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
} else if conf.TypeId == 2 {
|
||||
if v, ok := atlas.Collect[req.Id]; ok {
|
||||
update["atlas"] = atlas.Atlas
|
||||
for _, v := range atlas.Collect {
|
||||
if !v.Activate { // 激活
|
||||
v.Activate = true
|
||||
|
||||
update := make(map[string]interface{}, 0)
|
||||
update["collect"] = atlas.Collect
|
||||
atlas.Score += v.Score
|
||||
update["score"] = atlas.Score
|
||||
this.module.modelAtlas.modifySmithyAtlasList(session.GetUserId(), update)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
conf, err := this.module.configure.GetSmithyAtlasConf(req.Id)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if conf.TypeId == 1 {
|
||||
if v, ok := atlas.Atlas[req.Id]; ok {
|
||||
if !v.Activate { // 激活
|
||||
v.Activate = true
|
||||
addScore = v.Data1.Score
|
||||
} else { //更新操作
|
||||
if v.Data2 != nil {
|
||||
addScore = v.Data2.Score - v.Data1.Score
|
||||
if addScore < 0 { // 异常校验 防止配置修改导致分数减少
|
||||
addScore = 0
|
||||
}
|
||||
v.Data1 = v.Data2
|
||||
v.Data2 = nil
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoActivateAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoActivateAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
update["atlas"] = atlas.Atlas
|
||||
atlas.Score += addScore
|
||||
update["score"] = atlas.Score
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
} else if conf.TypeId == 2 {
|
||||
if v, ok := atlas.Collect[req.Id]; ok {
|
||||
if !v.Activate { // 激活
|
||||
v.Activate = true
|
||||
atlas.Score += v.Score
|
||||
}
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
update["score"] = atlas.Score
|
||||
update["collect"] = atlas.Collect
|
||||
this.module.modelAtlas.modifySmithyAtlasList(session.GetUserId(), update)
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype165, 1))
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype166, int32(len(atlas.Collect))))
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype167, atlas.Score))
|
||||
|
@ -32,7 +32,7 @@ func (this *apiComp) AtlasAward(session comm.IUserSession, req *pb.SmithyAtlasAw
|
||||
return
|
||||
}
|
||||
for {
|
||||
conf, err := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1)
|
||||
conf, err := this.module.configure.GetSmithyAtlasLvConf(atlas.Award)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) {
|
||||
|
||||
atlas.Collect[id] = &pb.CollectData{
|
||||
Id: id,
|
||||
Score: 0,
|
||||
Score: atlasConf.AtlasScore,
|
||||
Time: configure.Now().Unix(),
|
||||
Activate: false,
|
||||
}
|
||||
@ -94,7 +94,7 @@ func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) {
|
||||
if _, ok := atlas.Collect[id]; !ok {
|
||||
atlas.Collect[id] = &pb.CollectData{
|
||||
Id: id,
|
||||
Score: 0,
|
||||
Score: atlasConf.AtlasScore,
|
||||
Time: configure.Now().Unix(),
|
||||
Activate: false,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user