diff --git a/modules/library/api_getstoryreward.go b/modules/library/api_getstoryreward.go index 2a6289719..4c9cf0950 100644 --- a/modules/library/api_getstoryreward.go +++ b/modules/library/api_getstoryreward.go @@ -46,9 +46,9 @@ func (this *apiComp) GetStoryReward(session comm.IUserSession, req *pb.LibraryGe } } // 等级规则校验 - l := len(_heroFetter.History) - if len(favorConf.Favorlv) < l { - if favorConf.Favorlv[l] > _heroFetter.Favorlv { // 等级不够 + _len := len(_heroFetter.History) + if len(favorConf.Favorlv) < _len { + if favorConf.Favorlv[_len] > _heroFetter.Favorlv { // 等级不够 code = pb.ErrorCode_LibraryLvReward return } @@ -57,26 +57,25 @@ func (this *apiComp) GetStoryReward(session comm.IUserSession, req *pb.LibraryGe var res []*cfg.Gameatn if v == req.History { - switch iPos { - case 1: + if iPos == 0 { res = append(res, favorConf.BiographyReward1...) - case 2: + } else if iPos == 1 { res = append(res, favorConf.BiographyReward2...) - case 3: + } else if iPos == 2 { res = append(res, favorConf.BiographyReward3...) } + + if len(res) > 0 { + if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success { + return + } + } else { + this.module.Errorf("领取奖励配置错误:%d", req.History) + code = pb.ErrorCode_LibraryLvReward + return + } break } - if len(res) > 0 { - if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success { - return - } - } else { - this.module.Errorf("领取奖励配置错误:%d", req.History) - code = pb.ErrorCode_LibraryLvReward - return - } - } _heroFetter.History = append(_heroFetter.History, req.History) diff --git a/modules/sys/module.go b/modules/sys/module.go index 9f44605e6..8ba9adbcf 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -75,18 +75,19 @@ func (this *ModuleSys) AutoActivate(session comm.IUserSession, cids []string) bo break } } - for k, v := range list.Cond { if k == cid && v != 0 { + list.Cond[cid] = 1 + szOpen = append(szOpen, cid) break } } - list.Cond[cid] = 1 - szOpen = append(szOpen, cid) } - this.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{ - "cond": list.Cond, - }) + if len(szOpen) > 0 { + this.modelSys.ChangeOpenCondData(session.GetUserId(), map[string]interface{}{ + "cond": list.Cond, + }) + } // 推送变化 session.SendMsg(string(this.GetType()), "open", &pb.SysFuncOpnePush{ Cid: szOpen,