diff --git a/comm/imodule.go b/comm/imodule.go index 11cf85e31..1d8f7b122 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -167,9 +167,9 @@ type ( //查询用户属性值 例如 金币 经验 QueryAttributeValue(uid string, attr string) (value int64) //添加/减少属性值 第四个参数控制是否推送给前端 - AddAttributeValue(session IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData) + // AddAttributeValue(session IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData) // 批量处理 - AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) + AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData) //用户改变事件 // EventUserChanged(session IUserSession) // EventUserVipChanged(session IUserSession) diff --git a/modules/modulebase.go b/modules/modulebase.go index 5bd4ed0cd..d40f71271 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -412,7 +412,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn } // 真正消耗 if len(attrs) > 0 { - errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush) + _, errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush) if errdata != nil { return } @@ -480,7 +480,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat } if len(attrs) > 0 { //用户属性资源 - errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush) + _, errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush) this.Debugf("发放用户资源: %v errdata: %v", attrs, errdata) } if len(items) > 0 { //道具资源 @@ -702,16 +702,16 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea } if len(attrs) > 0 { //用户属性资源 - if errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush); errdata != nil { + if atno, errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush); errdata != nil { return } - for k, v := range attrs { - atno = append(atno, &pb.UserAtno{ - A: comm.AttrType, - T: k, - N: v, - }) - } + // for k, v := range attrs { + // atno = append(atno, &pb.UserAtno{ + // A: comm.AttrType, + // T: k, + // N: v, + // }) + // } this.Debugf("发放用户资源: %v errdata: %v", attrs, errdata) } diff --git a/modules/robot/configure.go b/modules/robot/configure.go index 8d351d5f2..886f416e7 100644 --- a/modules/robot/configure.go +++ b/modules/robot/configure.go @@ -18,13 +18,7 @@ const ( game_equipintensify = "game_equipintensify.json" //装备等级消耗表 game_equipenchanting = "game_equipenchanting.json" //装备附魔 equip_suit = "game_equipsuit.json" //装备套装表 - // gameWorldAll = "game_worldall.json" - // gameburiedCond = "game_buriedcondi.json" - // gamerdtasknpc = "game_rdtasknpc.json" - // gamesearchitemall = "game_searchitemall.json" - // gamesearchitembox = "game_searchitembox.json" - // game_worlddeal = "game_worlddeal.json" - // game_worldrd = "game_worldrd.json" + game_pagoda = "game_pagoda.json" hero_talent = "game_herotalent.json" // 天赋详细数据 game_playerlv = "game_playerlv.json" @@ -32,6 +26,8 @@ const ( hero_awaken = "game_heroawaken.json" game_horoscope = "game_horoscope.json" //星阵图 + + game_combatlevel = "game_combatlevel.json" //关卡编辑器 ) type configureComp struct { @@ -54,6 +50,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil) configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, nil) // 觉醒 configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil) + configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil) + configure.RegisterConfigure(game_combatlevel, cfg.NewGameCombatLevel, nil) return } diff --git a/modules/robot/modulerobot_combat.go b/modules/robot/modulerobot_combat.go new file mode 100644 index 000000000..2facb075e --- /dev/null +++ b/modules/robot/modulerobot_combat.go @@ -0,0 +1,64 @@ +package robot + +import ( + "errors" + "fmt" + "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + + "google.golang.org/protobuf/proto" +) + +//用户模块 机器人 +type ModuleRobot_Combat struct { +} + +func (this *ModuleRobot_Combat) Init() (err error) { + + return +} + +//接收到消息 +func (this *ModuleRobot_Combat) Receive(robot IRobot, stype string, message proto.Message) (err error) { + + return +} + +func (this *ModuleRobot_Combat) OncePipeline(robot IRobot) (err error) { + var ( + errdata *pb.ErrorData + conf *cfg.GameCombatLevelData + ) + conf = this.GetCombatLevelData()[0] + if _, errdata = robot.SendMessage("combat", "ask", &pb.CombatAskReq{Level: conf.Id}); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + + return +} + +//机器人执行流 +func (this *ModuleRobot_Combat) DoPipeline(robot IRobot) (err error) { + + return +} + +//做任务 +func (this *ModuleRobot_Combat) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { + + return +} + +func (this *ModuleRobot_Combat) GetCombatLevelData() (data []*cfg.GameCombatLevelData) { + data = make([]*cfg.GameCombatLevelData, 0) + if v, err := configure.GetConfigure(game_combatlevel); err == nil { + if _configure, ok := v.(*cfg.GameCombatLevel); ok { + for _, v := range _configure.GetDataList() { + data = append(data, v) + } + } + } + return +} diff --git a/modules/robot/robot.go b/modules/robot/robot.go index f21af9cf6..922b62aa5 100644 --- a/modules/robot/robot.go +++ b/modules/robot/robot.go @@ -77,6 +77,8 @@ func (this *Robot) Init(addr string, client IClient) (err error) { this.modules[comm.ModuleShop] = new(ModuleRobot_Shop) this.modules[comm.ModuleCaravan] = new(ModuleRobot_Caravan) this.modules[comm.ModuleHoroscope] = new(ModuleRobot_Horoscope) + this.modules[comm.ModuleCombat] = new(ModuleRobot_Combat) + for _, v := range this.modules { v.Init() } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index e463d7f08..36688955e 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -215,45 +215,41 @@ func (this *ModelUser) changeVipExp(change *pb.UserResChangedPush) (lvchange boo } // change level -func (this *ModelUser) computeLevel(change *pb.UserResChangedPush) (lvchange bool, rewards []*cfg.Gameatn) { +func (this *ModelUser) computeLevel(change *pb.UserResChangedPush) (lvchange bool, loseexp int32, rewards []*cfg.Gameatn) { var ( curLv int32 = change.Lv nextLvConf *cfg.GamePlayerlvData curExp int64 = change.Exp res int64 ) - //下一等级配置 - nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1) - if nextLvConf == nil { - curLvConf := this.module.configure.GetPlayerlvConf(curLv) - reward := this.module.globalConf.OverexpReward - if curExp < int64(curLvConf.Exp) { - res = curExp * int64(reward.N) - } else { - yu := int32(curExp) - curLvConf.Exp - res = int64(yu * reward.N) - } - curExp = int64(curLvConf.Exp) - } else { - for nextLvConf != nil && curExp >= int64(nextLvConf.Exp) { + + for nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1); nextLvConf != nil; { + if curExp >= int64(nextLvConf.Exp) { curExp = curExp - int64(nextLvConf.Exp) curLv++ //叠加奖励 rewards = append(rewards, nextLvConf.Reward...) - nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1) + } else { + break } } + if nextLvConf == nil { //满级了 + curLvConf := this.module.configure.GetPlayerlvConf(curLv) + reward := this.module.globalConf.OverexpReward + if curExp > int64(curLvConf.Exp) { + loseexp = int32(curExp) - curLvConf.Exp + res = int64(loseexp * reward.N) + curExp = int64(curLvConf.Exp) + change.Deposit += res + change.Exp = curExp + } + } // 等级有递增时再更新 if curLv > change.Lv { lvchange = true change.Lv = curLv change.Exp = curExp - } else { - if nextLvConf == nil { - change.Deposit += res - change.Exp = curExp - } } return } diff --git a/modules/user/module.go b/modules/user/module.go index fb94a58fd..624971072 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -381,22 +381,14 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { return } -func (this *User) change(session comm.IUserSession, attr string, add int32) (change *pb.UserResChangedPush, errdata *pb.ErrorData) { - if add == 0 { - log.Warn("attr no changed", - log.Field{Key: "uid", Value: session.GetUserId()}, - log.Field{Key: "attr", Value: attr}, - log.Field{Key: "add", Value: add}, - ) - return - } - +func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atno []*pb.UserAtno, change *pb.UserResChangedPush, errdata *pb.ErrorData) { uid := session.GetUserId() var ( - user *pb.DBUser - userEx *pb.DBUserExpand - lvexpchange, vipexpchange bool - err error + user *pb.DBUser + userEx *pb.DBUserExpand + vipexpchange bool + temp *pb.UserAtno + err error ) user, err = this.GetUser(uid) @@ -447,224 +439,242 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha Integral: user.Integral, Profit: user.Profit, } + atno = make([]*pb.UserAtno, 0, len(attrs)) + for attr, add := range attrs { + if add == 0 { + log.Warn("attr no changed", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "attr", Value: attr}, + log.Field{Key: "add", Value: add}, + ) + continue + } + temp = &pb.UserAtno{ + A: comm.AttrType, + T: attr, + N: add, + } + switch attr { + case comm.ResGold: + if add < 0 { + if user.Gold+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_GoldNoEnough, + Title: pb.ErrorCode_GoldNoEnough.ToString(), + } + return + } + } + change.Gold += int64(add) + case comm.ResExp: + var ( + lvchange bool + loseexp int32 + rewards []*cfg.Gameatn + ) + if add < 0 { + if user.Exp+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserExpNoEnough, + Title: pb.ErrorCode_UserExpNoEnough.ToString(), + } + return + } + } + change.Exp += int64(add) + if lvchange, loseexp, rewards = this.modelUser.computeLevel(change); lvchange { + go this.modelUser.changelv(session.Clone(), change.Lv, change.Exp, user.Name, rewards) + } + temp.N = temp.N - loseexp + case comm.VipExp: + if add < 0 { + if user.Vipexp+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserExpNoEnough, + Title: pb.ErrorCode_UserExpNoEnough.ToString(), + } + return + } + } + change.Vipexp += int64(add) + vipexpchange = true + case comm.ResDiamond: + if add < 0 { + if user.Diamond+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DiamondNoEnough, + Title: pb.ErrorCode_DiamondNoEnough.ToString(), + } + return + } + } + change.Diamond += int64(add) + case comm.Moongold: + if add < 0 { + if user.Moongold+int32(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserMoongoldNoEnough, + Title: pb.ErrorCode_UserMoongoldNoEnough.ToString(), + } + pb.ErrorCode_PayRenewTimeErr.Enum().Descriptor().ReservedNames() + } + } + change.Moongold += int32(add) + case comm.ResFriend: + if add < 0 { + if userEx.FriendPoint+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserFriendNoEnough, + Title: pb.ErrorCode_UserFriendNoEnough.ToString(), + } + return + } + } + change.Friend += add + case comm.StarCoin: + if add < 0 { + if user.Starcoin+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserStarCoinNoEnough, + Title: pb.ErrorCode_UserStarCoinNoEnough.ToString(), + } + return + } + } + change.Starcoin += int64(add) + case comm.SociatyCoin: + if add < 0 { + if userEx.Guildcoin+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserSociatyCoinNoEnough, + Title: pb.ErrorCode_UserSociatyCoinNoEnough.ToString(), + } + return + } + } + change.Guildcoin += add + case comm.ArenaCoin: + if add < 0 { + if userEx.Arenacoin+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserArenaCoinNoEnough, + Title: pb.ErrorCode_UserArenaCoinNoEnough.ToString(), + } + return + } + } + change.Arenacoin += add + case comm.ResPs: + ggd := this.ModuleTools.GetGlobalConf() + if ggd == nil { + return + } + if add < 0 { + if user.Ps+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserVitNoEnough, + Title: pb.ErrorCode_UserVitNoEnough.ToString(), + } + return + } + change.Ps += add + userEx.ConsumPs += -add + this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userEx.ConsumPs) + } else { + if change.Ps+add > ggd.PsUl { + change.Ps = ggd.PsUl + } else { + change.Ps += add + } + } - switch attr { - case comm.ResGold: - if add < 0 { - if user.Gold+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_GoldNoEnough, - Title: pb.ErrorCode_GoldNoEnough.ToString(), + case comm.Talent1: + if add < 0 { + if user.Talent1+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserTalent1NoEnough, + Title: pb.ErrorCode_UserTalent1NoEnough.ToString(), + } + return } - return } - } - change.Gold += int64(add) - case comm.ResExp: - if add < 0 { - if user.Exp+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserExpNoEnough, - Title: pb.ErrorCode_UserExpNoEnough.ToString(), + change.Talent1 += add + case comm.Talent2: + if add < 0 { + if user.Talent2+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserTalent2NoEnough, + Title: pb.ErrorCode_UserTalent2NoEnough.ToString(), + } + + return } - return } - } - change.Exp += int64(add) - lvexpchange = true - case comm.VipExp: - if add < 0 { - if user.Vipexp+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserExpNoEnough, - Title: pb.ErrorCode_UserExpNoEnough.ToString(), + change.Talent2 += add + case comm.Talent3: + if add < 0 { + if user.Talent3+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserTalent3NoEnough, + Title: pb.ErrorCode_UserTalent3NoEnough.ToString(), + } + + return } - return } - } - change.Vipexp += int64(add) - vipexpchange = true - case comm.ResDiamond: - if add < 0 { - if user.Diamond+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_DiamondNoEnough, - Title: pb.ErrorCode_DiamondNoEnough.ToString(), + change.Talent3 += add + case comm.Talent4: + if add < 0 { + if user.Talent4+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserTalent4NoEnough, + Title: pb.ErrorCode_UserTalent4NoEnough.ToString(), + } + + return } - return } - } - change.Diamond += int64(add) - case comm.Moongold: - if add < 0 { - if user.Moongold+int32(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserMoongoldNoEnough, - Title: pb.ErrorCode_UserMoongoldNoEnough.ToString(), + change.Talent4 += add + case comm.Merchantmoney: + if add < 0 { + if user.Merchantmoney+add < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserMerchantNoEnough, + Title: pb.ErrorCode_UserMerchantNoEnough.ToString(), + } + + return } - pb.ErrorCode_PayRenewTimeErr.Enum().Descriptor().ReservedNames() } - } - change.Moongold += int32(add) - case comm.ResFriend: - if add < 0 { - if userEx.FriendPoint+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserFriendNoEnough, - Title: pb.ErrorCode_UserFriendNoEnough.ToString(), + change.Merchantmoney += add + case comm.Integral: + if add < 0 { + if user.Integral+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserMerchantNoEnough, + Title: pb.ErrorCode_UserMerchantNoEnough.ToString(), + } + + return } - return } - } - change.Friend += add - case comm.StarCoin: - if add < 0 { - if user.Starcoin+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserStarCoinNoEnough, - Title: pb.ErrorCode_UserStarCoinNoEnough.ToString(), + change.Integral += int64(add) + case comm.Profit: + if add < 0 { + if user.Profit+int64(add) < 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_UserProfitNoEnough, + Title: pb.ErrorCode_UserProfitNoEnough.ToString(), + } + return } - return } - } - change.Starcoin += int64(add) - case comm.SociatyCoin: - if add < 0 { - if userEx.Guildcoin+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserSociatyCoinNoEnough, - Title: pb.ErrorCode_UserSociatyCoinNoEnough.ToString(), - } - return - } - } - change.Guildcoin += add - case comm.ArenaCoin: - if add < 0 { - if userEx.Arenacoin+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserArenaCoinNoEnough, - Title: pb.ErrorCode_UserArenaCoinNoEnough.ToString(), - } - return - } - } - change.Arenacoin += add - case comm.ResPs: - ggd := this.ModuleTools.GetGlobalConf() - if ggd == nil { + change.Profit += int64(add) + default: + err = errors.New(fmt.Sprintf("%s no supported", attr)) return } - if add < 0 { - if user.Ps+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserVitNoEnough, - Title: pb.ErrorCode_UserVitNoEnough.ToString(), - } - return - } - change.Ps += add - userEx.ConsumPs += -add - this.ModuleUiGame.HDPSTodayConsum(session.GetUserId(), userEx.ConsumPs) - } else { - if change.Ps+add > ggd.PsUl { - change.Ps = ggd.PsUl - } else { - change.Ps += add - } - } - - case comm.Talent1: - if add < 0 { - if user.Talent1+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserTalent1NoEnough, - Title: pb.ErrorCode_UserTalent1NoEnough.ToString(), - } - return - } - } - change.Talent1 += add - case comm.Talent2: - if add < 0 { - if user.Talent2+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserTalent2NoEnough, - Title: pb.ErrorCode_UserTalent2NoEnough.ToString(), - } - - return - } - } - change.Talent2 += add - case comm.Talent3: - if add < 0 { - if user.Talent3+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserTalent3NoEnough, - Title: pb.ErrorCode_UserTalent3NoEnough.ToString(), - } - - return - } - } - change.Talent3 += add - case comm.Talent4: - if add < 0 { - if user.Talent4+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserTalent4NoEnough, - Title: pb.ErrorCode_UserTalent4NoEnough.ToString(), - } - - return - } - } - change.Talent4 += add - case comm.Merchantmoney: - if add < 0 { - if user.Merchantmoney+add < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserMerchantNoEnough, - Title: pb.ErrorCode_UserMerchantNoEnough.ToString(), - } - - return - } - } - change.Merchantmoney += add - case comm.Integral: - if add < 0 { - if user.Integral+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserMerchantNoEnough, - Title: pb.ErrorCode_UserMerchantNoEnough.ToString(), - } - - return - } - } - change.Integral += int64(add) - case comm.Profit: - if add < 0 { - if user.Profit+int64(add) < 0 { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_UserProfitNoEnough, - Title: pb.ErrorCode_UserProfitNoEnough.ToString(), - } - return - } - } - change.Profit += int64(add) - default: - err = errors.New(fmt.Sprintf("%s no supported", attr)) - return - } - - if lvexpchange { - if ok, rewards := this.modelUser.computeLevel(change); ok { - go this.modelUser.changelv(session.Clone(), change.Lv, change.Exp, user.Name, rewards) - } + atno = append(atno, temp) } if vipexpchange { @@ -729,37 +739,37 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } -// 用户资源 -func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData) { - var _change *pb.UserResChangedPush +// // 用户资源 +// func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData) { +// var _change *pb.UserResChangedPush - _change, errdata = this.change(session, attr, add) - if errdata != nil { - return - } +// _change, errdata = this.change(session, attr, add) +// if errdata != nil { +// return +// } - if _change == nil { - return - } +// if _change == nil { +// return +// } - if bPush { //推送玩家账号信息变化消息 - session.SendMsg(string(this.GetType()), "reschanged", _change) - } - return -} +// if bPush { //推送玩家账号信息变化消息 +// session.SendMsg(string(this.GetType()), "reschanged", _change) +// } +// return +// } // 用户资源 -func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData) { +func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string]int32, bPush bool) (atno []*pb.UserAtno, errdata *pb.ErrorData) { var ( tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0) _change *pb.UserResChangedPush ) - for key, add := range attrs { - _change, errdata = this.change(session, key, add) - if errdata != nil { - return - } + atno, _change, errdata = this.change(session, attrs) + if errdata != nil { + return + } + for key, add := range attrs { if key == comm.ResPs && add < 0 { //消耗体力 tasks = append(tasks, comm.GetBuriedParam(comm.Rtype213, -add)) } @@ -1219,7 +1229,8 @@ func (this *User) ConsumePsAddExp(session comm.IUserSession, ps int32) (addExp i attrs := make(map[string]int32, 0) attrs["exp"] = addExp - return addExp, this.AddAttributeValues(session, attrs, true) + _, errdata = this.AddAttributeValues(session, attrs, true) + return } // 剩余体力