Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
4d4b2f78d4
@ -660,5 +660,8 @@ type (
|
|||||||
QueryBigDragonList(uid string) (dragon []*pb.DBDragon, err error)
|
QueryBigDragonList(uid string) (dragon []*pb.DBDragon, err error)
|
||||||
// 通过ID 查询龙的信息
|
// 通过ID 查询龙的信息
|
||||||
QueryDragonById(uid string, dragonid string) (dragon *pb.DBDragon, err error)
|
QueryDragonById(uid string, dragonid string) (dragon *pb.DBDragon, err error)
|
||||||
|
|
||||||
|
// 跨服接口 通过 服务器标签和唯一id 获取坐骑信息
|
||||||
|
QueryDragonByTagAndOid(tag string, objId string) (dragon *pb.DBDragon, err error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -34,6 +34,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.DragonGetListReq
|
|||||||
this.module.modelDragon.UpdateDragonData(session.GetUserId(), v.Id, update)
|
this.module.modelDragon.UpdateDragonData(session.GetUserId(), v.Id, update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.Dragons = dragon
|
rsp.Dragons = dragon
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", rsp)
|
session.SendMsg(string(this.module.GetType()), "getlist", rsp)
|
||||||
return
|
return
|
||||||
|
@ -20,17 +20,18 @@ func (this *apiComp) TrainCheck(session comm.IUserSession, req *pb.DragonTrainRe
|
|||||||
|
|
||||||
func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
dragon *pb.DBDragon
|
dragon *pb.DBDragon
|
||||||
playConf *cfg.GameDragonPlayData
|
playConf *cfg.GameDragonPlayData
|
||||||
update map[string]interface{}
|
update map[string]interface{}
|
||||||
preType int32
|
preType int32
|
||||||
curType int32 // 当前阶段
|
curType int32 // 当前阶段
|
||||||
reward []*cfg.Gameatn
|
reward []*cfg.Gameatn
|
||||||
preLv int32 // 升级之前的等级
|
preLv int32 // 升级之前的等级
|
||||||
curLv int32 // 升级之后的等级
|
curLv int32 // 升级之后的等级
|
||||||
atno []*pb.UserAtno
|
atno []*pb.UserAtno
|
||||||
speed int32
|
speed int32
|
||||||
|
chanegList []*pb.DBDragon
|
||||||
)
|
)
|
||||||
update = make(map[string]interface{})
|
update = make(map[string]interface{})
|
||||||
rsp := &pb.DragonTrainResp{}
|
rsp := &pb.DragonTrainResp{}
|
||||||
@ -145,6 +146,11 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
|
|||||||
}
|
}
|
||||||
rsp.Dragons = dragon
|
rsp.Dragons = dragon
|
||||||
this.module.modelDragon.UpdateDragonData(session.GetUserId(), dragon.Id, update)
|
this.module.modelDragon.UpdateDragonData(session.GetUserId(), dragon.Id, update)
|
||||||
|
|
||||||
|
chanegList = append(chanegList, dragon)
|
||||||
|
session.SendMsg(string(this.module.GetType()), "change", &pb.DragonChangePush{
|
||||||
|
Dragons: chanegList,
|
||||||
|
})
|
||||||
session.SendMsg(string(this.module.GetType()), "train", rsp)
|
session.SendMsg(string(this.module.GetType()), "train", rsp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,10 @@ func (this *ModelDragon) Init(service core.IService, module core.IModule, comp c
|
|||||||
// 获取一个新的坐骑
|
// 获取一个新的坐骑
|
||||||
func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[string]int32) (errdata *pb.ErrorData) {
|
func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[string]int32) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
dbModel *db.DBModel
|
dbModel *db.DBModel
|
||||||
err error
|
err error
|
||||||
dragon *pb.DBDragon
|
dragon *pb.DBDragon
|
||||||
|
chanegList []*pb.DBDragon
|
||||||
)
|
)
|
||||||
dragonList := make([]*pb.DBDragon, 0)
|
dragonList := make([]*pb.DBDragon, 0)
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
@ -81,10 +82,19 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bFound := false
|
dragon = &pb.DBDragon{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
Uid: uid,
|
||||||
|
Dragonid: dragonCfgId,
|
||||||
|
Lv: lv,
|
||||||
|
Exp: 0,
|
||||||
|
Property: map[string]int32{},
|
||||||
|
Play: map[int32]*pb.PlayData{},
|
||||||
|
Rtime: configure.Now().Unix(),
|
||||||
|
}
|
||||||
for _, obj := range dragonList {
|
for _, obj := range dragonList {
|
||||||
if obj.Dragonid == dragonCfgId { // 重复获得 直接返回
|
if obj.Dragonid == dragonCfgId { // 重复获得 直接返回
|
||||||
bFound = true
|
dragon.Id = obj.Id
|
||||||
update := make(map[string]interface{}, 0)
|
update := make(map[string]interface{}, 0)
|
||||||
update["lv"] = lv // 更新等级
|
update["lv"] = lv // 更新等级
|
||||||
if err = this.UpdateDragonData(session.GetUserId(), obj.Id, update); err != nil {
|
if err = this.UpdateDragonData(session.GetUserId(), obj.Id, update); err != nil {
|
||||||
@ -98,42 +108,34 @@ func (this *ModelDragon) CreateDragon(session comm.IUserSession, dragons map[str
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bFound {
|
|
||||||
dragon = &pb.DBDragon{
|
|
||||||
Id: primitive.NewObjectID().Hex(),
|
|
||||||
Uid: uid,
|
|
||||||
Dragonid: dragonCfgId,
|
|
||||||
Lv: lv,
|
|
||||||
Exp: 0,
|
|
||||||
Property: map[string]int32{},
|
|
||||||
Play: map[int32]*pb.PlayData{},
|
|
||||||
Rtime: configure.Now().Unix(),
|
|
||||||
}
|
|
||||||
if conf, err := this.module.configure.GetDragonConfById(dragonCfgId, lv); err == nil {
|
|
||||||
if c, err := this.module.configure.GetDragonMount(dragonCfgId, 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if dbModel != nil {
|
if conf, err := this.module.configure.GetDragonConfById(dragonCfgId, lv); err == nil {
|
||||||
if dbModel, err1 := this.module.GetDBModelByUid(uid, this.TableName); err1 == nil {
|
if c, err := this.module.configure.GetDragonMount(dragonCfgId, conf.Type); err == nil {
|
||||||
err = dbModel.AddList(uid, dragonCfgId, dragon)
|
dragon.Property["stime"] = c.Stime
|
||||||
}
|
dragon.Property["etime"] = c.Etime
|
||||||
} else {
|
dragon.Property["hp"] = c.Hp
|
||||||
err = this.AddList(uid, dragonCfgId, dragon)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if dbModel != nil {
|
||||||
|
if dbModel, err1 := this.module.GetDBModelByUid(uid, this.TableName); err1 == nil {
|
||||||
|
err = dbModel.AddList(uid, dragonCfgId, dragon)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = this.AddList(uid, dragonCfgId, dragon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chanegList = append(chanegList, dragon)
|
||||||
|
session.SendMsg(string(this.module.GetType()), "change", &pb.DragonChangePush{
|
||||||
|
Dragons: chanegList,
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,8 +185,3 @@ func (this *ModelDragon) GetDragonByOid(uid string, oid string) (dragon *pb.DBDr
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelDragon) CreateAiDragon(dragonid string, lv int32) (dragon *pb.DBDragon, err error) {
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
@ -8,6 +8,10 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
@ -126,3 +130,21 @@ func (this *Dragon) QueryDragonById(uid string, dragonid string) (dragon *pb.DBD
|
|||||||
err = fmt.Errorf("not found dragon dragonid:%s", dragonid)
|
err = fmt.Errorf("not found dragon dragonid:%s", dragonid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通过区服id 和唯一id 查询坐骑信息
|
||||||
|
func (this *Dragon) QueryDragonByTagAndOid(tag string, objId string) (dragon *pb.DBDragon, err error) {
|
||||||
|
var (
|
||||||
|
conn *db.DBConn
|
||||||
|
model *db.DBModel
|
||||||
|
)
|
||||||
|
if conn, err = db.ServerDBConn(tag); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dragon = &pb.DBDragon{}
|
||||||
|
model = db.NewDBModel(this.modelDragon.TableName, time.Hour, conn)
|
||||||
|
if model.DB.FindOne(comm.TableHero, bson.M{"_id": objId}).Decode(dragon); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -469,7 +469,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
|
|||||||
case comm.PandaType:
|
case comm.PandaType:
|
||||||
panda[v.T] = 1
|
panda[v.T] = 1
|
||||||
case comm.MountsType:
|
case comm.MountsType:
|
||||||
mts[v.T] = 1
|
mts[v.T] = v.N // N 表示等级
|
||||||
case comm.PerType:
|
case comm.PerType:
|
||||||
per[v.T] = 1
|
per[v.T] = 1
|
||||||
default:
|
default:
|
||||||
@ -691,7 +691,7 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea
|
|||||||
case comm.PandaType:
|
case comm.PandaType:
|
||||||
panda[v.T] = 1
|
panda[v.T] = 1
|
||||||
case comm.MountsType:
|
case comm.MountsType:
|
||||||
mts[v.T] = 1
|
mts[v.T] += v.N
|
||||||
case comm.PerType:
|
case comm.PerType:
|
||||||
per[v.T] = 1
|
per[v.T] = 1
|
||||||
default:
|
default:
|
||||||
|
@ -218,6 +218,54 @@ func (x *DragonTrainResp) GetReward() []*UserAtno {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 坐骑变化推送
|
||||||
|
type DragonChangePush struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Dragons []*DBDragon `protobuf:"bytes,1,rep,name=dragons,proto3" json:"dragons"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DragonChangePush) Reset() {
|
||||||
|
*x = DragonChangePush{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_dragon_dragon_msg_proto_msgTypes[4]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DragonChangePush) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*DragonChangePush) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *DragonChangePush) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_dragon_dragon_msg_proto_msgTypes[4]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use DragonChangePush.ProtoReflect.Descriptor instead.
|
||||||
|
func (*DragonChangePush) Descriptor() ([]byte, []int) {
|
||||||
|
return file_dragon_dragon_msg_proto_rawDescGZIP(), []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DragonChangePush) GetDragons() []*DBDragon {
|
||||||
|
if x != nil {
|
||||||
|
return x.Dragons
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_dragon_dragon_msg_proto protoreflect.FileDescriptor
|
var File_dragon_dragon_msg_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_dragon_dragon_msg_proto_rawDesc = []byte{
|
var file_dragon_dragon_msg_proto_rawDesc = []byte{
|
||||||
@ -239,7 +287,11 @@ var file_dragon_dragon_msg_proto_rawDesc = []byte{
|
|||||||
0x61, 0x67, 0x6f, 0x6e, 0x52, 0x07, 0x64, 0x72, 0x61, 0x67, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a,
|
0x61, 0x67, 0x6f, 0x6e, 0x52, 0x07, 0x64, 0x72, 0x61, 0x67, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a,
|
||||||
0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e,
|
0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e,
|
||||||
0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64,
|
0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64,
|
||||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x22, 0x37, 0x0a, 0x10, 0x44, 0x72, 0x61, 0x67, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65,
|
||||||
|
0x50, 0x75, 0x73, 0x68, 0x12, 0x23, 0x0a, 0x07, 0x64, 0x72, 0x61, 0x67, 0x6f, 0x6e, 0x73, 0x18,
|
||||||
|
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x44, 0x72, 0x61, 0x67, 0x6f, 0x6e,
|
||||||
|
0x52, 0x07, 0x64, 0x72, 0x61, 0x67, 0x6f, 0x6e, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||||
|
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -254,24 +306,26 @@ func file_dragon_dragon_msg_proto_rawDescGZIP() []byte {
|
|||||||
return file_dragon_dragon_msg_proto_rawDescData
|
return file_dragon_dragon_msg_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_dragon_dragon_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_dragon_dragon_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_dragon_dragon_msg_proto_goTypes = []interface{}{
|
var file_dragon_dragon_msg_proto_goTypes = []interface{}{
|
||||||
(*DragonGetListReq)(nil), // 0: DragonGetListReq
|
(*DragonGetListReq)(nil), // 0: DragonGetListReq
|
||||||
(*DragonGetListResp)(nil), // 1: DragonGetListResp
|
(*DragonGetListResp)(nil), // 1: DragonGetListResp
|
||||||
(*DragonTrainReq)(nil), // 2: DragonTrainReq
|
(*DragonTrainReq)(nil), // 2: DragonTrainReq
|
||||||
(*DragonTrainResp)(nil), // 3: DragonTrainResp
|
(*DragonTrainResp)(nil), // 3: DragonTrainResp
|
||||||
(*DBDragon)(nil), // 4: DBDragon
|
(*DragonChangePush)(nil), // 4: DragonChangePush
|
||||||
(*UserAtno)(nil), // 5: UserAtno
|
(*DBDragon)(nil), // 5: DBDragon
|
||||||
|
(*UserAtno)(nil), // 6: UserAtno
|
||||||
}
|
}
|
||||||
var file_dragon_dragon_msg_proto_depIdxs = []int32{
|
var file_dragon_dragon_msg_proto_depIdxs = []int32{
|
||||||
4, // 0: DragonGetListResp.dragons:type_name -> DBDragon
|
5, // 0: DragonGetListResp.dragons:type_name -> DBDragon
|
||||||
4, // 1: DragonTrainResp.dragons:type_name -> DBDragon
|
5, // 1: DragonTrainResp.dragons:type_name -> DBDragon
|
||||||
5, // 2: DragonTrainResp.reward:type_name -> UserAtno
|
6, // 2: DragonTrainResp.reward:type_name -> UserAtno
|
||||||
3, // [3:3] is the sub-list for method output_type
|
5, // 3: DragonChangePush.dragons:type_name -> DBDragon
|
||||||
3, // [3:3] is the sub-list for method input_type
|
4, // [4:4] is the sub-list for method output_type
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
4, // [4:4] is the sub-list for method input_type
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
4, // [4:4] is the sub-list for extension type_name
|
||||||
0, // [0:3] is the sub-list for field type_name
|
4, // [4:4] is the sub-list for extension extendee
|
||||||
|
0, // [0:4] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_dragon_dragon_msg_proto_init() }
|
func init() { file_dragon_dragon_msg_proto_init() }
|
||||||
@ -330,6 +384,18 @@ func file_dragon_dragon_msg_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_dragon_dragon_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*DragonChangePush); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@ -337,7 +403,7 @@ func file_dragon_dragon_msg_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_dragon_dragon_msg_proto_rawDesc,
|
RawDescriptor: file_dragon_dragon_msg_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 4,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user