坐骑属性
This commit is contained in:
parent
5c3768034d
commit
e29b744153
@ -17,6 +17,7 @@ const moduleName = "dragon"
|
|||||||
const (
|
const (
|
||||||
dragon_trainlv = "game_trainlv.json"
|
dragon_trainlv = "game_trainlv.json"
|
||||||
dragon_play = "game_dragonplay.json"
|
dragon_play = "game_dragonplay.json"
|
||||||
|
game_buzkashimount = "game_buzkashimount.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// /配置管理组件
|
// /配置管理组件
|
||||||
@ -26,6 +27,7 @@ type configureComp struct {
|
|||||||
hlock sync.RWMutex
|
hlock sync.RWMutex
|
||||||
dragon map[string]*cfg.GameTrainlvData
|
dragon map[string]*cfg.GameTrainlvData
|
||||||
play map[string]*cfg.GameDragonPlayData
|
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_trainlv, cfg.NewGameTrainlv, this.LoadDragon)
|
||||||
configure.RegisterConfigure(dragon_play, cfg.NewGameDragonPlay, this.LoadDragonPlay)
|
configure.RegisterConfigure(dragon_play, cfg.NewGameDragonPlay, this.LoadDragonPlay)
|
||||||
|
configure.RegisterConfigure(game_buzkashimount, cfg.NewGameBuzkashiMount, this.LoadDragonMount)
|
||||||
|
|
||||||
|
this.GetDragonMount("20030001", 3)
|
||||||
return
|
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) {
|
func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) {
|
||||||
for k, v := range confs {
|
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))
|
err = comm.NewNotFoundConfErr(moduleName, dragon_trainlv, fmt.Sprintf("id:%s,grow:%d,itype:%d", id, grow, itype))
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
|||||||
Dragonid: dragonCfgId,
|
Dragonid: dragonCfgId,
|
||||||
Lv: lv,
|
Lv: lv,
|
||||||
Exp: 0,
|
Exp: 0,
|
||||||
Property: map[int32]int32{},
|
Property: map[string]int32{},
|
||||||
Play: map[int32]int32{},
|
Play: map[int32]int32{},
|
||||||
Rtime: 0,
|
Rtime: 0,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/configure"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
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) {
|
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
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
|
|||||||
this.Debugf("发放武馆资源: %v errdata: %v", panda, errdata)
|
this.Debugf("发放武馆资源: %v errdata: %v", panda, errdata)
|
||||||
}
|
}
|
||||||
if len(mts) > 0 {
|
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
|
return
|
||||||
}
|
}
|
||||||
//errdata = this.ModuleParkour.AddMounts(session, mts, bPush)
|
//errdata = this.ModuleParkour.AddMounts(session, mts, bPush)
|
||||||
|
@ -30,7 +30,7 @@ type DBDragon struct {
|
|||||||
Dragonid string `protobuf:"bytes,3,opt,name=dragonid,proto3" json:"dragonid"` // 坐骑配置id
|
Dragonid string `protobuf:"bytes,3,opt,name=dragonid,proto3" json:"dragonid"` // 坐骑配置id
|
||||||
Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` //等级
|
Lv int32 `protobuf:"varint,4,opt,name=lv,proto3" json:"lv"` //等级
|
||||||
Exp int32 `protobuf:"varint,5,opt,name=exp,proto3" json:"exp"` // 经验
|
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"` // 坐骑属性
|
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"` // 坐骑训练次数
|
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"`
|
Rtime int64 `protobuf:"varint,8,opt,name=rtime,proto3" json:"rtime"`
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ func (x *DBDragon) GetExp() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBDragon) GetProperty() map[int32]int32 {
|
func (x *DBDragon) GetProperty() map[string]int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Property
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||||
|
Loading…
Reference in New Issue
Block a user