package reputation import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" ) // 天赋树升级 func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.ReputationUpgradeReq) (code pb.ErrorCode) { return } func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.ReputationUpgradeReq) (code pb.ErrorCode, data *pb.ErrorData) { // uid := session.GetUserId() rsp := &pb.ReputationUpgradeResp{} talentCfg := this.module.configure.getTalentNodeCfg(req.NodeId) if talentCfg == nil { code = pb.ErrorCode_ConfigNoFound return } reputation := this.module.modelReputation.getDBReputation(uid) if reputation == nil { code = pb.ErrorCode_DataNotFound return } camp, ok := reputation.Camps[talentCfg.Type] if !ok { code = pb.ErrorCode_DataNotFound this.module.Debug("未找到阵营数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "raceType", Value: talentCfg.Type}) return } if camp != nil { for _, v := range camp.Nodes { //判断是否满级 if req.NodeId == v.Nid && v.Status == 2 { code = pb.ErrorCode_ReputationTalentFull return } else if req.NodeId == v.Nid { //消耗 if c := this.module.ConsumeRes(session, talentCfg.IconCos, true); c == pb.ErrorCode_Success { v.Status = 1 camp.CampAttr = this.module.modelReputation.computeAttr(camp.CampAttr, talentCfg.Attribute) update := map[string]interface{}{ "camps": reputation.Camps, } this.module.modelReputation.updateDBReputation(uid, update) } else { code = pb.ErrorCode_ResNoEnough return } break } } } session.SendMsg(string(this.module.GetType()), "upgrade", rsp) return }