package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) //参数校验 func (this *apiComp) TalentResetCheck(session comm.IUserSession, req *pb.HeroTalentResetReq) (code pb.ErrorCode) { return } func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentResetReq) (code pb.ErrorCode, data proto.Message) { var ( heroList []*pb.DBHero chanegCard []*pb.DBHero // 推送属性变化 ) chanegCard = make([]*pb.DBHero, 0) heroList = this.module.GetHeroList(session.GetUserId()) rsp := &pb.HeroTalentResetResp{} globalCnf := this.module.configure.GetGlobalAtnConf("talent_reset") // 获取重置消耗 if globalCnf == nil { code = pb.ErrorCode_ConfigNoFound return } // 检查消耗够不够 if code = this.module.CheckRes(session, globalCnf.Var); code != pb.ErrorCode_Success { return } if code = this.module.ConsumeRes(session, globalCnf.Var, true); code != pb.ErrorCode_Success { return } list, _ := this.module.modelTalent.GetHerotalent(session.GetUserId()) for _, v := range list { if len(v.Talent) > 0 { update := make(map[string]interface{}, 0) szTalent := map[int32]int32{} update["talent"] = szTalent this.module.modelTalent.ChangeHeroTalent(v, update) for _, hero := range heroList { if hero.HeroID == v.HeroId { this.module.modelHero.cleanTalentProperty(hero) chanegCard = append(chanegCard, hero) // 添加推送属性变化信息 } } } } session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard}) session.SendMsg(string(this.module.GetType()), HeroTalentResetResp, rsp) return }