创建怪物英雄
This commit is contained in:
parent
d181be0334
commit
4f78b63c06
@ -56,6 +56,9 @@ type (
|
|||||||
AddHeroExp(session IUserSession, heroObjID string, exp int32) (code pb.ErrorCode)
|
AddHeroExp(session IUserSession, heroObjID string, exp int32) (code pb.ErrorCode)
|
||||||
// 英雄练功
|
// 英雄练功
|
||||||
KungFuHero(session IUserSession, heroObjID string, bKongfu bool) (code pb.ErrorCode)
|
KungFuHero(session IUserSession, heroObjID string, bKongfu bool) (code pb.ErrorCode)
|
||||||
|
|
||||||
|
//Create Monster
|
||||||
|
CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero)
|
||||||
}
|
}
|
||||||
|
|
||||||
//玩家
|
//玩家
|
||||||
|
@ -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)
|
heroCfg := this.moduleHero.configure.GetHero(heroCfgId)
|
||||||
if heroCfg == nil {
|
if heroCfg == nil {
|
||||||
this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId)
|
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) {
|
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 hero != nil {
|
||||||
if err = this.AddList(uid, hero.Id, hero); err != nil {
|
if err = this.AddList(uid, hero.Id, hero); err != nil {
|
||||||
this.moduleHero.Errorf("%v", err)
|
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) {
|
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 {
|
if hero != nil {
|
||||||
|
|
||||||
hero.SameCount = count
|
hero.SameCount = count
|
||||||
@ -580,3 +580,31 @@ func (this *ModelHero) GetRandHeroIdBypool(sz []int32) int32 {
|
|||||||
}
|
}
|
||||||
return 0
|
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
|
||||||
|
}
|
||||||
|
@ -356,3 +356,9 @@ func (this *Hero) KungFuHero(session comm.IUserSession, heroObjID string, bKongf
|
|||||||
session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero})
|
session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: _changeHero})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建怪物英雄
|
||||||
|
func (this *Hero) CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero) {
|
||||||
|
hero = this.modelHero.InitTempHero(heroCid, star, lv)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -58,6 +58,6 @@ func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStove
|
|||||||
_smithy.StoveLv += 1
|
_smithy.StoveLv += 1
|
||||||
this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ type Timer struct {
|
|||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
||||||
rank *PagodaRank
|
rank *PagodaRank
|
||||||
|
rank2 *VikingRank
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块名
|
//模块名
|
||||||
@ -52,5 +53,6 @@ func (this *Timer) Start() (err error) {
|
|||||||
func (this *Timer) OnInstallComp() {
|
func (this *Timer) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank)
|
this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank)
|
||||||
|
this.rank2 = this.RegisterComp(new(VikingRank)).(*VikingRank)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func (this *VikingRank) Start() (err error) {
|
|||||||
func (this *VikingRank) Timer() {
|
func (this *VikingRank) Timer() {
|
||||||
data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList)
|
data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList)
|
||||||
for i := 1; i <= 3; i++ { // boss 类型 1 2 3 后面封装 // 时间参数战斗调完后再加进来
|
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()) {
|
for _data.Next(context.TODO()) {
|
||||||
temp := &pb.DBPagodaRank{}
|
temp := &pb.DBPagodaRank{}
|
||||||
if err = _data.Decode(temp); err == nil {
|
if err = _data.Decode(temp); err == nil {
|
||||||
|
@ -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 {
|
if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success {
|
||||||
return
|
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})
|
session.SendMsg(string(this.module.GetType()), VikingChallengeResp, &pb.VikingChallengeResp{Data: viking})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user