diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 14d4288a4..e4ec05417 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -410,6 +410,7 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen }) } } + } for _, v := range hero.Suits { diff --git a/modules/plunder/api_getlist.go b/modules/plunder/api_getlist.go index 60e178f36..55acb6ae1 100644 --- a/modules/plunder/api_getlist.go +++ b/modules/plunder/api_getlist.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/sys/redis" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" "reflect" @@ -25,6 +26,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe land *pb.DBPlunderLand update map[string]interface{} ) + if errdata = this.GetListCheck(session, req); errdata != nil { return } @@ -58,6 +60,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe var uids []string // 清理岛数据 if land.Etime < configure.Now().Unix() { + // 清理之前先发奖 + this.sendRankReward(land.Score) for _, v := range land.Uinfo { // 重置成员信息 uids = append(uids, v.Uid) } @@ -73,6 +77,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe } return } + list.Landid = land.Id update["landid"] = land.Id list.Etime = land.Etime @@ -144,3 +149,45 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe }) return } + +func (this *apiComp) sendRankReward(data map[string]int32) (err error) { + var ( + list []Pair + rewardConf []*cfg.GamePlunderRankData + uid []string // + reward []*pb.UserAssets + ) + + list = sortMap(data) + for _, v := range list { + if v.Value > 0 { // 只算 分数大于0 的玩家 + uid = append(uid, v.Key) + } + } + if rewardConf, err = this.module.configure.getPlunderRandConf(); err != nil { + return + } + for _, v := range rewardConf { + var sz []string + if true { + for i := v.ScoreLow; i <= v.ScoreUp; i++ { + sz = append(sz, uid[i-1]) + } + + } + for _, v := range v.Reward { + reward = append(reward, &pb.UserAssets{ + A: v.A, + T: v.T, + N: v.N, + }) + } + this.module.mail.SendNewMail(&pb.DBMailData{ + Cid: "XXLRankingReward", + Param: []string{fmt.Sprintf("%d-%d", v.ScoreLow, v.ScoreUp)}, // 参数 分数下线和分数上限之间 + CreateTime: uint64(configure.Now().Unix()), + Items: reward, + }, sz...) + } + return +} diff --git a/modules/plunder/configure.go b/modules/plunder/configure.go index cce394d36..25ebeb04d 100644 --- a/modules/plunder/configure.go +++ b/modules/plunder/configure.go @@ -11,6 +11,7 @@ const ( game_plunder = "game_plunder.json" game_plunderbattle = "game_plunderbattle.json" game_plunderdevelop = "game_plunderdevelop.json" + game_plunderrank = "game_plunderrank.json" ) type configureComp struct { @@ -26,6 +27,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp game_plunder: cfg.NewGamePlunder, game_plunderbattle: cfg.NewGamePlunderBattle, game_plunderdevelop: cfg.NewGamePlunderDevelop, + game_plunderrank: cfg.NewGamePlunderRank, }) return } @@ -93,3 +95,18 @@ func (this *configureComp) getPlunderDevelopById(id int32) (result *cfg.GamePlun err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_plunderdevelop, id) return } + +func (this *configureComp) getPlunderRandConf() (result []*cfg.GamePlunderRankData, err error) { + var ( + v interface{} + ) + if v, err = this.GetConfigure(game_plunderrank); err == nil { + if configure, ok := v.(*cfg.GamePlunderRank); ok { + if result = configure.GetDataList(); result != nil { + return + } + } + } + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_plunderdevelop, "") + return +} diff --git a/modules/plunder/module.go b/modules/plunder/module.go index 45947bb32..ce291e779 100644 --- a/modules/plunder/module.go +++ b/modules/plunder/module.go @@ -24,6 +24,7 @@ type Plunder struct { battle comm.IBattle modelRecord *modelRecord battlerecord comm.IBattleRecord // 战报模块 + mail comm.Imail } // 模块名 @@ -53,6 +54,11 @@ func (this *Plunder) Start() (err error) { return } this.battlerecord = module.(comm.IBattleRecord) + + if module, err = this.service.GetModule(comm.ModuleMail); err != nil { + return + } + this.mail = module.(comm.Imail) return } diff --git a/modules/plunder/plunder_test.go b/modules/plunder/plunder_sort.go similarity index 74% rename from modules/plunder/plunder_test.go rename to modules/plunder/plunder_sort.go index d17f6795a..6261a13c6 100644 --- a/modules/plunder/plunder_test.go +++ b/modules/plunder/plunder_sort.go @@ -5,16 +5,16 @@ import "sort" //根据value排序 type Pair struct { Key string - Value int + Value int32 } type PairList []Pair func (p PairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p PairList) Len() int { return len(p) } -func (p PairList) Less(i, j int) bool { return p[i].Value < p[j].Value } +func (p PairList) Less(i, j int) bool { return p[i].Value > p[j].Value } -func sortMap(m map[string]int) PairList { +func sortMap(m map[string]int32) PairList { p := make(PairList, len(m)) i := 0 for k, v := range m {