Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-11-04 16:50:43 +08:00
commit d42d6d217f
2 changed files with 157 additions and 77 deletions

View File

@ -3,7 +3,6 @@ package hero
import ( import (
"crypto/rand" "crypto/rand"
"errors" "errors"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -15,7 +14,6 @@ import (
"math/big" "math/big"
"reflect" "reflect"
mengine "github.com/dengsgo/math-engine/engine"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx" "go.mongodb.org/mongo-driver/x/bsonx"
@ -413,65 +411,28 @@ func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[st
//属性计算 基础属性 //属性计算 基础属性
//英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数 //英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数
func (this *ModelHero) PropertyCompute(hero *pb.DBHero) { func (this *ModelHero) PropertyCompute(hero *pb.DBHero) {
growCfg := this.moduleHero.configure.GetHeroLvgrow(hero.HeroID)
//英雄等级基础属性levelup
heroLvCfg := this.moduleHero.configure.GetHeroLv(hero.Lv)
if heroLvCfg == nil {
return
}
//英雄基础配置 newhero
heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID) heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID)
if heroCfg == nil { lvCfg := this.moduleHero.configure.GetHeroLv(hero.Lv)
starCfg := this.moduleHero.configure.GetHeroStar(heroCfg.Star)
starLvfg := this.moduleHero.configure.GetHeroLv(starCfg.Level)
if growCfg == nil || heroCfg == nil || lvCfg == nil || starCfg == nil || starLvfg == nil {
return return
} }
atk := (starLvfg.Atk*(1+(starCfg.StarupAtk/1000)) + lvCfg.Atk + float32(growCfg.Atk)) * (growCfg.Atkgrow / 1000)
def := (starLvfg.Def*(1+(starCfg.StarupDef/1000)) + lvCfg.Def + float32(growCfg.Def)) * (growCfg.Defgrow / 1000)
hp := (starLvfg.Hp*(1+(starCfg.StarupHp/1000)) + lvCfg.Hp + float32(growCfg.Hp)) * (growCfg.Hpgrow / 1000)
speed := growCfg.Speed
//品质系数
stargrowCfg := this.moduleHero.configure.GetHeroStar(heroCfg.Star)
if stargrowCfg == nil {
return
}
//英雄星级对应等级属性
heroStarCfg := this.moduleHero.configure.GetHeroLv(heroCfg.Star * comm.HeroStarLvRatio)
if heroStarCfg == nil {
return
}
//成长系数
lvGrow := this.moduleHero.configure.GetHeroLvgrow(hero.HeroID)
if lvGrow == nil {
return
}
//血量
exprHp := fmt.Sprintf("%v + %v * %v/1000 + %v * %v/1000",
lvGrow.Hp, heroLvCfg.Hp, lvGrow.Hpgrow, heroStarCfg.Hp, stargrowCfg.StarupHp)
hp, _ := mengine.ParseAndExec(exprHp)
// 攻击
exprAtk := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
lvGrow.Atk, heroLvCfg.Atk, lvGrow.Atkgrow, heroStarCfg.Atk, stargrowCfg.StarupAtk)
atk, _ := mengine.ParseAndExec(exprAtk)
// 防御
exprDef := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
lvGrow.Def, heroLvCfg.Def, lvGrow.Defgrow, heroStarCfg.Def, stargrowCfg.StarupDef)
def, _ := mengine.ParseAndExec(exprDef)
// 速度
exprSpeed := fmt.Sprintf("%v +%v * %v/1000 + %v * %v/1000",
lvGrow.Speed, 0, 0, 0, stargrowCfg.StarupSpeed)
speed, _ := mengine.ParseAndExec(exprSpeed)
hero.Property = map[string]int32{ hero.Property = map[string]int32{
comm.Hp: int32(math.Floor(hp)), comm.Hp: int32(math.Floor(float64(hp))),
comm.Atk: int32(math.Floor(atk)), comm.Atk: int32(math.Floor(float64(atk))),
comm.Def: int32(math.Floor(def)), comm.Def: int32(math.Floor(float64(def))),
comm.Speed: int32(math.Floor(speed)), comm.Speed: int32(math.Floor(float64(speed))),
comm.Cri: int32(lvGrow.Cri), //暴击 comm.Cri: int32(growCfg.Cri), //暴击
comm.Effhit: int32(lvGrow.Effhit), //效果命中 comm.Effhit: int32(growCfg.Effhit), //效果命中
comm.Cridam: int32(lvGrow.Cridam), //暴击伤害 comm.Cridam: int32(growCfg.Cridam), //暴击伤害
comm.Effre: int32(lvGrow.Effre), //效果抵抗 comm.Effre: int32(growCfg.Effre), //效果抵抗
} }
this.resetTalentProperty(hero) this.resetTalentProperty(hero)
} }

View File

@ -628,6 +628,92 @@ func (x *PagodaQueryRecordResp) GetData() *DBPagodaRecord {
return nil return nil
} }
// 激活赛季塔
type PagodaActivateReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PagodaActivateReq) Reset() {
*x = PagodaActivateReq{}
if protoimpl.UnsafeEnabled {
mi := &file_pagoda_pagoda_msg_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PagodaActivateReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PagodaActivateReq) ProtoMessage() {}
func (x *PagodaActivateReq) ProtoReflect() protoreflect.Message {
mi := &file_pagoda_pagoda_msg_proto_msgTypes[12]
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 PagodaActivateReq.ProtoReflect.Descriptor instead.
func (*PagodaActivateReq) Descriptor() ([]byte, []int) {
return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{12}
}
type PagodaActivateResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *DBSeasonPagoda `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
}
func (x *PagodaActivateResp) Reset() {
*x = PagodaActivateResp{}
if protoimpl.UnsafeEnabled {
mi := &file_pagoda_pagoda_msg_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PagodaActivateResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PagodaActivateResp) ProtoMessage() {}
func (x *PagodaActivateResp) ProtoReflect() protoreflect.Message {
mi := &file_pagoda_pagoda_msg_proto_msgTypes[13]
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 PagodaActivateResp.ProtoReflect.Descriptor instead.
func (*PagodaActivateResp) Descriptor() ([]byte, []int) {
return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{13}
}
func (x *PagodaActivateResp) GetData() *DBSeasonPagoda {
if x != nil {
return x.Data
}
return nil
}
var File_pagoda_pagoda_msg_proto protoreflect.FileDescriptor var File_pagoda_pagoda_msg_proto protoreflect.FileDescriptor
var file_pagoda_pagoda_msg_proto_rawDesc = []byte{ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{
@ -685,7 +771,12 @@ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{
0x61, 0x67, 0x6f, 0x64, 0x61, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x6f, 0x72, 0x64, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x13, 0x0a, 0x11, 0x50, 0x61, 0x67,
0x6f, 0x64, 0x61, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x22, 0x39,
0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65,
0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x53, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x50, 0x61, 0x67,
0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
@ -701,7 +792,7 @@ func file_pagoda_pagoda_msg_proto_rawDescGZIP() []byte {
return file_pagoda_pagoda_msg_proto_rawDescData return file_pagoda_pagoda_msg_proto_rawDescData
} }
var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{ var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{
(*PagodaGetListReq)(nil), // 0: PagodaGetListReq (*PagodaGetListReq)(nil), // 0: PagodaGetListReq
(*PagodaGetListResp)(nil), // 1: PagodaGetListResp (*PagodaGetListResp)(nil), // 1: PagodaGetListResp
@ -715,26 +806,30 @@ var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{
(*PagodaRankListResp)(nil), // 9: PagodaRankListResp (*PagodaRankListResp)(nil), // 9: PagodaRankListResp
(*PagodaQueryRecordReq)(nil), // 10: PagodaQueryRecordReq (*PagodaQueryRecordReq)(nil), // 10: PagodaQueryRecordReq
(*PagodaQueryRecordResp)(nil), // 11: PagodaQueryRecordResp (*PagodaQueryRecordResp)(nil), // 11: PagodaQueryRecordResp
(*DBPagoda)(nil), // 12: DBPagoda (*PagodaActivateReq)(nil), // 12: PagodaActivateReq
(*BattleFormation)(nil), // 13: BattleFormation (*PagodaActivateResp)(nil), // 13: PagodaActivateResp
(*BattleInfo)(nil), // 14: BattleInfo (*DBPagoda)(nil), // 14: DBPagoda
(*BattleReport)(nil), // 15: BattleReport (*BattleFormation)(nil), // 15: BattleFormation
(*DBPagodaRecord)(nil), // 16: DBPagodaRecord (*BattleInfo)(nil), // 16: BattleInfo
(*BattleReport)(nil), // 17: BattleReport
(*DBPagodaRecord)(nil), // 18: DBPagodaRecord
(*DBSeasonPagoda)(nil), // 19: DBSeasonPagoda
} }
var file_pagoda_pagoda_msg_proto_depIdxs = []int32{ var file_pagoda_pagoda_msg_proto_depIdxs = []int32{
12, // 0: PagodaGetListResp.data:type_name -> DBPagoda 14, // 0: PagodaGetListResp.data:type_name -> DBPagoda
12, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda 14, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda
13, // 2: PagodaChallengeReq.battle:type_name -> BattleFormation 15, // 2: PagodaChallengeReq.battle:type_name -> BattleFormation
14, // 3: PagodaChallengeResp.info:type_name -> BattleInfo 16, // 3: PagodaChallengeResp.info:type_name -> BattleInfo
15, // 4: PagodaChallengeOverReq.report:type_name -> BattleReport 17, // 4: PagodaChallengeOverReq.report:type_name -> BattleReport
12, // 5: PagodaChallengeOverResp.data:type_name -> DBPagoda 14, // 5: PagodaChallengeOverResp.data:type_name -> DBPagoda
16, // 6: PagodaRankListResp.ranks:type_name -> DBPagodaRecord 18, // 6: PagodaRankListResp.ranks:type_name -> DBPagodaRecord
16, // 7: PagodaQueryRecordResp.data:type_name -> DBPagodaRecord 18, // 7: PagodaQueryRecordResp.data:type_name -> DBPagodaRecord
8, // [8:8] is the sub-list for method output_type 19, // 8: PagodaActivateResp.data:type_name -> DBSeasonPagoda
8, // [8:8] is the sub-list for method input_type 9, // [9:9] is the sub-list for method output_type
8, // [8:8] is the sub-list for extension type_name 9, // [9:9] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension extendee 9, // [9:9] is the sub-list for extension type_name
0, // [0:8] is the sub-list for field type_name 9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
} }
func init() { file_pagoda_pagoda_msg_proto_init() } func init() { file_pagoda_pagoda_msg_proto_init() }
@ -889,6 +984,30 @@ func file_pagoda_pagoda_msg_proto_init() {
return nil return nil
} }
} }
file_pagoda_pagoda_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PagodaActivateReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pagoda_pagoda_msg_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PagodaActivateResp); 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{
@ -896,7 +1015,7 @@ func file_pagoda_pagoda_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pagoda_pagoda_msg_proto_rawDesc, RawDescriptor: file_pagoda_pagoda_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 12, NumMessages: 14,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },