diff --git a/comm/imodule.go b/comm/imodule.go index 509829759..5bdad5ca5 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -56,6 +56,9 @@ type ( AddHeroExp(session IUserSession, heroObjID string, exp int32) (code pb.ErrorCode) // 英雄练功 KungFuHero(session IUserSession, heroObjID string, bKongfu bool) (code pb.ErrorCode) + + //Create Monster + CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero) } //玩家 diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 34749c7d8..9136a635f 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -35,7 +35,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor } //初始化英雄 -func (this *ModelHero) initHero(uid string, heroCfgId string) *pb.DBHero { +func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero { heroCfg := this.moduleHero.configure.GetHero(heroCfgId) if heroCfg == nil { this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId) @@ -93,7 +93,7 @@ func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData { //创建一个指定的英雄 func (this *ModelHero) createOneHero(uid string, heroCfgId string) (hero *pb.DBHero, err error) { - hero = this.initHero(uid, heroCfgId) + hero = this.InitHero(uid, heroCfgId) if hero != nil { if err = this.AddList(uid, hero.Id, hero); err != nil { this.moduleHero.Errorf("%v", err) @@ -114,7 +114,7 @@ func (this *ModelHero) CloneNewHero(hero *pb.DBHero) (newHero *pb.DBHero) { //初始化可叠加的英雄 func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int32) (hero *pb.DBHero, err error) { - hero = this.initHero(uid, heroCfgId) + hero = this.InitHero(uid, heroCfgId) if hero != nil { hero.SameCount = count @@ -580,3 +580,31 @@ func (this *ModelHero) GetRandHeroIdBypool(sz []int32) int32 { } return 0 } + +func (this *ModelHero) InitTempHero(heroCfgId string, star, lv int32) *pb.DBHero { + heroCfg := this.moduleHero.configure.GetHero(heroCfgId) + if heroCfg == nil { + this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId) + return nil + } + + newHero := &pb.DBHero{ + HeroID: heroCfg.Hid, + Star: star, //初始星级 + Lv: lv, //初始等级 + IsOverlying: true, //是否允许叠加, + Block: false, //未锁定 + CardType: heroCfg.Type, //卡片类型 + Skins: []int32{}, + EquipID: make([]string, 6), //初始装备 + SameCount: 1, //默认叠加数量 + AddProperty: make(map[string]int32), + Energy: make(map[string]int32), + Property: make(map[string]int32), + EnergyProperty: make(map[string]int32), + JuexProperty: make(map[string]int32), + } + this.PropertyCompute(newHero) + this.initHeroSkill(newHero) + return newHero +} diff --git a/modules/hero/module.go b/modules/hero/module.go index 8faa13f9e..c73f2d256 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -356,3 +356,9 @@ func (this *Hero) KungFuHero(session comm.IUserSession, heroObjID string, bKongf session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero}) return } + +// 创建怪物英雄 +func (this *Hero) CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero) { + hero = this.modelHero.InitTempHero(heroCid, star, lv) + return +} diff --git a/modules/smithy/api_stoveskilllv.go b/modules/smithy/api_stoveskilllv.go index b408808f9..90254df9f 100644 --- a/modules/smithy/api_stoveskilllv.go +++ b/modules/smithy/api_stoveskilllv.go @@ -58,6 +58,6 @@ func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStove _smithy.StoveLv += 1 this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv) } - session.SendMsg(string(this.module.GetType()), SmithyDeskSkillLvResp, &pb.SmithyDeskSkillLvResp{Data: _smithy}) + session.SendMsg(string(this.module.GetType()), SmithyStoveSkillLvResp, &pb.SmithyStoveSkillLvResp{Data: _smithy}) return } diff --git a/modules/timer/module.go b/modules/timer/module.go index ccc2cea8b..a81d9cb86 100644 --- a/modules/timer/module.go +++ b/modules/timer/module.go @@ -24,6 +24,7 @@ type Timer struct { modules.MCompModel service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 rank *PagodaRank + rank2 *VikingRank } //模块名 @@ -52,5 +53,6 @@ func (this *Timer) Start() (err error) { func (this *Timer) OnInstallComp() { this.ModuleBase.OnInstallComp() this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank) + this.rank2 = this.RegisterComp(new(VikingRank)).(*VikingRank) } diff --git a/modules/timer/vikingrank.go b/modules/timer/vikingrank.go index 5ede63c64..94ccf9b40 100644 --- a/modules/timer/vikingrank.go +++ b/modules/timer/vikingrank.go @@ -38,7 +38,7 @@ func (this *VikingRank) Start() (err error) { func (this *VikingRank) Timer() { data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList) for i := 1; i <= 3; i++ { // boss 类型 1 2 3 后面封装 // 时间参数战斗调完后再加进来 - if _data, err := this.DB.Find(comm.TablePagodaRank, bson.M{"bosstype": i}, options.Find().SetSort(bson.M{"difficulty": -1}).SetLimit(comm.MaxRankList)); err == nil { + if _data, err := this.DB.Find(comm.TableVikingRank, bson.M{"bosstype": i}, options.Find().SetSort(bson.M{"difficulty": -1}).SetLimit(comm.MaxRankList)); err == nil { for _data.Next(context.TODO()) { temp := &pb.DBPagodaRank{} if err = _data.Decode(temp); err == nil { diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index 623ea307b..42ef620be 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -73,6 +73,17 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { return } + + // + mapRankData := make(map[string]interface{}, 0) + mapRankData["difficulty"] = req.Difficulty + mapRankData["bosstype"] = req.BossType + mapRankData["uid"] = session.GetUserId() + userinfo := this.module.ModuleUser.GetUser(session.GetUserId()) + mapRankData["nickname"] = userinfo.Name + mapRankData["lv"] = userinfo.Lv + mapRankData["costTime"] = 120 + this.module.modulerank.ChangeUserRank(session.GetUserId(), mapRankData) session.SendMsg(string(this.module.GetType()), VikingChallengeResp, &pb.VikingChallengeResp{Data: viking}) return }