diff --git a/comm/imodule.go b/comm/imodule.go index 12ed1b31a..9c03a12d8 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -37,7 +37,7 @@ type ( QueryCardAmount(uId string, cardId int32) (amount uint32) //添加/减少卡片 AddCard(uId string, cardId int32, add int32) (code pb.ErrorCode) - //创建一个新英雄 + //创建新英雄 CreatMultiHero(uid string, heroCfgId ...int32) error // 获取英雄 @@ -47,7 +47,6 @@ type ( UpdateEquipment(hero *pb.DB_HeroData, equip []*pb.DB_Equipment) (code pb.ErrorCode) //获取玩家英雄列表 GetHeroList(uid string) []*pb.DB_HeroData - } //玩家 @@ -56,7 +55,6 @@ type ( QueryAttributeValue(uid string, attr string) (value int32) //添加/减少属性值 AddAttributeValue(uid string, attr string, add int32) (code pb.ErrorCode) - } //武器模块 IEquipment interface { diff --git a/modules/hero/module.go b/modules/hero/module.go index a96e8a470..5f0927f7d 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -44,10 +44,18 @@ func (this *Hero) GetHeroInfoByObjID(id string) (*pb.DB_HeroData, pb.ErrorCode) return nil, pb.ErrorCode_HeroNoExist } -//获取英雄 -func (this *Hero) GetHero(heroId int32) (*pb.DB_HeroData, pb.ErrorCode) { +//创建新英雄 +func (this *Hero) CreatMultiHero(uid string, heroCfgId ...int32) error { + return this.model_hero.createMultiHero(uid, heroCfgId...) +} - return nil, pb.ErrorCode_HeroNoExist +//获取英雄 +func (this *Hero) GetHero(uid, heroId string) (*pb.DB_HeroData, pb.ErrorCode) { + hero := this.model_hero.getOneHero(uid, heroId) + if hero == nil { + return nil, pb.ErrorCode_HeroNoExist + } + return hero, pb.ErrorCode_Success } func (this *Hero) ModifyHero(heroId *pb.DB_HeroData) (*pb.DB_HeroData, pb.ErrorCode) { @@ -56,11 +64,19 @@ func (this *Hero) ModifyHero(heroId *pb.DB_HeroData) (*pb.DB_HeroData, pb.ErrorC } //佩戴装备 -func (this *Hero) InstallEquip(heroId, equipId string) pb.ErrorCode { - return pb.ErrorCode_Success +func (this *Hero) UpdateEquipment(hero *pb.DB_HeroData, equip []*pb.DB_Equipment) (code pb.ErrorCode) { + equipIds := make([]string, 4) + for _, v := range equip { + equipIds = append(equipIds, v.Id) + } + return this.model_hero.setEquipment(hero.Uid, hero.Id, equipIds) } -// 卸载装备 -func (this *Hero) UninstallEquip(heroId, equipId string) pb.ErrorCode { - return pb.ErrorCode_Success +//英雄列表 +func (this *Hero) GetHeroList(uid string) []*pb.DB_HeroData { + list, err := this.model_hero.getHeroList(uid) + if err != nil { + return nil + } + return list }