diff --git a/modules/dragon/configure_comp.go b/modules/dragon/configure_comp.go index 35e97c5c5..d30025f4e 100644 --- a/modules/dragon/configure_comp.go +++ b/modules/dragon/configure_comp.go @@ -15,8 +15,9 @@ import ( const moduleName = "dragon" const ( - dragon_trainlv = "game_trainlv.json" - dragon_play = "game_dragonplay.json" + dragon_trainlv = "game_trainlv.json" + dragon_play = "game_dragonplay.json" + game_buzkashimount = "game_buzkashimount.json" ) // /配置管理组件 @@ -26,6 +27,7 @@ type configureComp struct { hlock sync.RWMutex dragon map[string]*cfg.GameTrainlvData play map[string]*cfg.GameDragonPlayData + mount map[string]*cfg.GameBuzkashiMountData } // 组件初始化接口 @@ -38,6 +40,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp }) configure.RegisterConfigure(dragon_trainlv, cfg.NewGameTrainlv, this.LoadDragon) configure.RegisterConfigure(dragon_play, cfg.NewGameDragonPlay, this.LoadDragonPlay) + configure.RegisterConfigure(game_buzkashimount, cfg.NewGameBuzkashiMount, this.LoadDragonMount) + + this.GetDragonMount("20030001", 3) return } @@ -72,6 +77,22 @@ func (this *configureComp) LoadDragonPlay() { } } +func (this *configureComp) LoadDragonMount() { + if v, err := this.GetConfigure(game_buzkashimount); err == nil { + this.hlock.Lock() + defer this.hlock.Unlock() + this.mount = make(map[string]*cfg.GameBuzkashiMountData) + if _configure, ok := v.(*cfg.GameBuzkashiMount); ok { + for _, v := range _configure.GetDataList() { + this.mount[v.Id+"-"+strconv.Itoa(int(v.Type))] = v + } + return + } + } else { + err = fmt.Errorf("%T no is *cfg.GameBuzkashiMountData", v) + } +} + //加载多个配置文件 func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) { for k, v := range confs { @@ -125,3 +146,15 @@ func (this *configureComp) GetDragonPlayConfById(id string, grow int32, itype in err = comm.NewNotFoundConfErr(moduleName, dragon_trainlv, fmt.Sprintf("id:%s,grow:%d,itype:%d", id, grow, itype)) return } + +func (this *configureComp) GetDragonMount(id string, itype int32) (conf *cfg.GameBuzkashiMountData, err error) { + key := id + "-" + strconv.Itoa(int(itype)) + this.hlock.RLock() + defer this.hlock.RUnlock() + ok := false + if conf, ok = this.mount[key]; ok { + return + } + err = comm.NewNotFoundConfErr(moduleName, dragon_trainlv, fmt.Sprintf("id:%s,lv:%d", id, itype)) + return +} diff --git a/modules/dragon/model_dragon.go b/modules/dragon/model_dragon.go index 4b0ebc2ad..f580d1a8f 100644 --- a/modules/dragon/model_dragon.go +++ b/modules/dragon/model_dragon.go @@ -104,7 +104,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str Dragonid: dragonCfgId, Lv: lv, Exp: 0, - Property: map[int32]int32{}, + Property: map[string]int32{}, Play: map[int32]int32{}, Rtime: 0, } diff --git a/modules/dragon/module.go b/modules/dragon/module.go index d7f24e593..0d2ea2e22 100644 --- a/modules/dragon/module.go +++ b/modules/dragon/module.go @@ -5,6 +5,8 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" ) func NewModule() core.IModule { @@ -56,5 +58,34 @@ func (this *Dragon) CreateDragon(session comm.IUserSession, dragons map[string]i } func (this *Dragon) CreateRobotDragon(dragonid string, lv int32) (dragon *pb.DBDragon, err error) { - return this.modelDragon.CreateAiDragon(dragonid, lv) + var ( + conf *cfg.GameTrainlvData + ) + dragon = &pb.DBDragon{ + Id: "", + Uid: "", + Dragonid: dragonid, + Lv: lv, + Exp: 0, + Property: map[string]int32{}, + Play: map[int32]int32{}, + Rtime: configure.Now().Unix(), + } + + if conf, err = this.configure.GetDragonConfById(dragonid, lv); err != nil { + return + } + if c, err := this.configure.GetDragonMount(dragonid, conf.Type); err == nil { + dragon.Property["stime"] = c.Stime + dragon.Property["etime"] = c.Etime + dragon.Property["hp"] = c.Hp + dragon.Property["moderate"] = c.Moderate + dragon.Property["sprint"] = c.Sprint + dragon.Property["acceleration"] = c.Acceleration + dragon.Property["deceleration"] = c.Deceleration + dragon.Property["itemsprint"] = c.Itemsprint + dragon.Property["caddtime"] = c.Caddtime + dragon.Property["csubtime"] = c.Csubtime + } + return } diff --git a/modules/modulebase.go b/modules/modulebase.go index a57520d35..43e7d0af9 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -510,7 +510,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat this.Debugf("发放武馆资源: %v errdata: %v", panda, errdata) } if len(mts) > 0 { - if errdata = this.ModuleDragon.CreateDragon(session, per, bPush); errdata != nil { + if errdata = this.ModuleDragon.CreateDragon(session, mts, bPush); errdata != nil { return } //errdata = this.ModuleParkour.AddMounts(session, mts, bPush) diff --git a/pb/dragon_db.pb.go b/pb/dragon_db.pb.go index 5c76deeea..6664719a0 100644 --- a/pb/dragon_db.pb.go +++ b/pb/dragon_db.pb.go @@ -25,14 +25,14 @@ type DBDragon struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` - Dragonid string `protobuf:"bytes,3,opt,name=dragonid,proto3" json:"dragonid"` // 坐骑配置id - Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` //等级 - Exp int32 `protobuf:"varint,5,opt,name=exp,proto3" json:"exp"` // 经验 - Property map[int32]int32 `protobuf:"bytes,6,rep,name=property,proto3" json:"property" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 坐骑属性 - Play map[int32]int32 `protobuf:"bytes,7,rep,name=play,proto3" json:"play" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 坐骑训练次数 - Rtime int64 `protobuf:"varint,8,opt,name=rtime,proto3" json:"rtime"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` + Dragonid string `protobuf:"bytes,3,opt,name=dragonid,proto3" json:"dragonid"` // 坐骑配置id + Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` //等级 + Exp int32 `protobuf:"varint,5,opt,name=exp,proto3" json:"exp"` // 经验 + Property map[string]int32 `protobuf:"bytes,6,rep,name=property,proto3" json:"property" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 坐骑属性 + Play map[int32]int32 `protobuf:"bytes,7,rep,name=play,proto3" json:"play" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 坐骑训练次数 + Rtime int64 `protobuf:"varint,8,opt,name=rtime,proto3" json:"rtime"` } func (x *DBDragon) Reset() { @@ -102,7 +102,7 @@ func (x *DBDragon) GetExp() int32 { return 0 } -func (x *DBDragon) GetProperty() map[int32]int32 { +func (x *DBDragon) GetProperty() map[string]int32 { if x != nil { return x.Property } @@ -143,7 +143,7 @@ var file_dragon_dragon_db_proto_rawDesc = []byte{ 0x6c, 0x61, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x50, 0x6c, 0x61, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,