71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package atlas
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/utils/codec/json"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.AtlasAwardReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
// 一键领取所有可以领取的奖励
|
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
var (
|
|
res []*cfg.Gameatn
|
|
respRes []*pb.UserAssets
|
|
)
|
|
list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
|
|
for {
|
|
conf, err := this.module.configure.GetPandoAtlasAwardConf(list.Award + 1)
|
|
if err != nil {
|
|
break
|
|
}
|
|
if list.Score < conf.AtlasScore { // 校验积分够不够
|
|
break
|
|
}
|
|
list.Award += 1
|
|
res = append(res, conf.ItemId...)
|
|
}
|
|
if len(res) == 0 { // 没有奖励可领取
|
|
code = pb.ErrorCode_MartialhallAtlasNoReward
|
|
return
|
|
}
|
|
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
|
buff, _ := json.Marshal(res)
|
|
data = &pb.ErrorData{Title: "图鉴奖励领取失败!", Datastring: string(buff)}
|
|
return
|
|
}
|
|
|
|
for _, v := range res {
|
|
bFind := false
|
|
for _, v1 := range respRes {
|
|
|
|
if v1.A == v.A && v1.T == v.T {
|
|
v1.N += v.N
|
|
bFind = true
|
|
}
|
|
|
|
}
|
|
if !bFind {
|
|
respRes = append(respRes, &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
})
|
|
}
|
|
}
|
|
update := make(map[string]interface{})
|
|
update["award"] = list.Award
|
|
this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update)
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.AtlasAwardResp{
|
|
Data: list,
|
|
Res: respRes,
|
|
})
|
|
return
|
|
}
|