diff --git a/comm/imodule.go b/comm/imodule.go index d3255da7c..9804b440e 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -27,7 +27,11 @@ type ( IHero interface { // 获取英雄 // heroId 英雄ID - GetHero(heroId int32) *pb.DB_HeroData + GetHero(heroId string) (*pb.DB_HeroData, pb.ErrorCode) + // 佩戴装备 + InstallEquip(heroId, equipId string) pb.ErrorCode + // 卸载装备 + UninstallEquip(heroId, equipId string) pb.ErrorCode } //玩家 diff --git a/modules/hero/hero_comp.go b/modules/hero/hero_comp.go deleted file mode 100644 index db98f610e..000000000 --- a/modules/hero/hero_comp.go +++ /dev/null @@ -1,20 +0,0 @@ -package hero - -import ( - "go_dreamfactory/modules" - - "go_dreamfactory/lego/core" -) - -///英雄配置管理组件 -type Model_Hero_Comp struct { - modules.Model_Comp - module *Hero -} - -//组件初始化接口 -func (this *Model_Hero_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.ModuleCompBase.Init(service, module, comp, options) - this.module = module.(*Hero) - return -} diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 2d384848f..1b8791e13 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -2,18 +2,58 @@ package hero import ( "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" + "go_dreamfactory/pb" ) type ModelHero struct { modules.Model_Comp + moduleHero *Hero } func (this *ModelHero) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.Model_Comp.Init(service, module, comp, options) + this.moduleHero = module.(*Hero) this.TableName = "hero" return } -//初始英雄 +//创建一个指定的英雄 +func (this *ModelHero) createOneHero(uid string, heroId int32) error { + heroCfg, err := this.moduleHero.configure_comp.GetHeroConfigure() + if err != nil { + log.Errorf("%v", err) + return err + } + if heroCfg != nil { + oneHeroCfg := heroCfg.Get(heroId) + if oneHeroCfg != nil { + newHero := &pb.DB_HeroData{ + Uid: uid, + HeroID: oneHeroCfg.Id, + Star: oneHeroCfg.Star, + Lv: 1, //初始等级 + } + return this.moduleHero.model_hero.Add(uid, newHero) + } + } + return nil +} + +//指定英雄升级 +func (this *ModelHero) levelUp(uid string, heroId int32) error { + var heroes []*pb.DB_HeroData + err := this.moduleHero.model_hero.GetList(uid, heroes) + if err != nil { + log.Errorf("levelUp err:%v", err) + return err + } + return nil +} + +//升星 +func (this *ModelHero) starUp() { + +} diff --git a/modules/hero/module.go b/modules/hero/module.go index 4f309c6df..4676d0fa2 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "go_dreamfactory/pb" ) func NewModule() core.IModule { @@ -13,9 +14,9 @@ func NewModule() core.IModule { type Hero struct { modules.ModuleBase - api_comp *Api_Comp - configure_comp *Configure_Comp - model_hero_comp *Model_Hero_Comp + api_comp *Api_Comp + configure_comp *Configure_Comp + model_hero *ModelHero } //模块名 @@ -33,6 +34,22 @@ func (this *Hero) Init(service core.IService, module core.IModule, options core. func (this *Hero) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp) - this.model_hero_comp = this.RegisterComp(new(Model_Hero_Comp)).(*Model_Hero_Comp) + this.model_hero = this.RegisterComp(new(ModelHero)).(*ModelHero) this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) } + +//获取英雄 +func (this *Hero) GetHero(heroId int32) (*pb.DB_HeroData, pb.ErrorCode) { + + return nil, pb.ErrorCode_HeroNoExist +} + +//佩戴装备 +func (this *Hero) InstallEquip(heroId, equipId string) pb.ErrorCode { + return pb.ErrorCode_Success +} + +// 卸载装备 +func (this *Hero) UninstallEquip(heroId, equipId string) pb.ErrorCode { + return pb.ErrorCode_Success +} diff --git a/modules/user/module.go b/modules/user/module.go index 5f6577e08..94b15ac72 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -3,6 +3,7 @@ package user import ( "go_dreamfactory/comm" "go_dreamfactory/modules" + "go_dreamfactory/pb" "go_dreamfactory/lego/core" ) @@ -35,3 +36,9 @@ func (this *User) OnInstallComp() { this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser) this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession) } + +//获取英雄列表 +func (this *User) GetHeroList(uid string) []*pb.DB_HeroData { + return nil +} + diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 4314575f9..39c34877e 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -56,11 +56,13 @@ const ( ErrorCode_FriendApplyError ErrorCode = 1109 //申请失败 ErrorCode_FriendBlackMax ErrorCode = 1110 //黑名单最大数量 ErrorCode_FriendSearchNameEmpty ErrorCode = 1111 //查询昵称为空 - //pack + // pack ErrorCode_PackNoEnough ErrorCode = 1200 //背包物品不足 ErrorCode_PackNoFoundGird ErrorCode = 1201 //背包未找到物品格子 ErrorCode_PackGridNumUpper ErrorCode = 1202 //背包格子数量已达上限 ErrorCode_PackGirdAmountUpper ErrorCode = 1203 //背包格子容量已达上限 + // hero + ErrorCode_HeroNoExist ErrorCode = 1300 //英雄不存在 ) // Enum value maps for ErrorCode. @@ -101,6 +103,7 @@ var ( 1201: "PackNoFoundGird", 1202: "PackGridNumUpper", 1203: "PackGirdAmountUpper", + 1300: "HeroNoExist", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -138,6 +141,7 @@ var ( "PackNoFoundGird": 1201, "PackGridNumUpper": 1202, "PackGirdAmountUpper": 1203, + "HeroNoExist": 1300, } ) @@ -172,7 +176,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xdb, 0x05, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xed, 0x05, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -217,8 +221,10 @@ var file_errorcode_proto_rawDesc = []byte{ 0x4e, 0x6f, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x69, 0x72, 0x64, 0x10, 0xb1, 0x09, 0x12, 0x15, 0x0a, 0x10, 0x50, 0x61, 0x63, 0x6b, 0x47, 0x72, 0x69, 0x64, 0x4e, 0x75, 0x6d, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb2, 0x09, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x61, 0x63, 0x6b, 0x47, 0x69, 0x72, - 0x64, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb3, 0x09, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x55, 0x70, 0x70, 0x65, 0x72, 0x10, 0xb3, 0x09, 0x12, + 0x10, 0x0a, 0x0b, 0x48, 0x65, 0x72, 0x6f, 0x4e, 0x6f, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x94, + 0x0a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index f41e041f8..673ff050f 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -38,12 +38,15 @@ enum ErrorCode { FriendBlackMax = 1110; //黑名单最大数量 FriendSearchNameEmpty = 1111; //查询昵称为空 - //pack - PackNoEnough = 1200; //背包物品不足 - PackNoFoundGird = 1201; //背包未找到物品格子 - PackGridNumUpper = 1202; //背包格子数量已达上限 - PackGirdAmountUpper = 1203; //背包格子容量已达上限 + // pack + PackNoEnough = 1200; //背包物品不足 + PackNoFoundGird = 1201; //背包未找到物品格子 + PackGridNumUpper = 1202; //背包格子数量已达上限 + PackGirdAmountUpper = 1203; //背包格子容量已达上限 + + // hero + HeroNoExist = 1300; //英雄不存在 //equipment - EquipmentOnFoundEquipment = 1300; // 未找到武器 + EquipmentOnFoundEquipment = 1400; // 未找到武器 } \ No newline at end of file