羁绊属性计算
This commit is contained in:
parent
702375e8b3
commit
8811db5c1b
@ -107,6 +107,8 @@ type (
|
|||||||
|
|
||||||
// 跨服查询英雄详细信息
|
// 跨服查询英雄详细信息
|
||||||
QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error)
|
QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error)
|
||||||
|
|
||||||
|
AddHeroFetterAttribute(session IUserSession, attr map[string][]*cfg.Gameatr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//玩家
|
//玩家
|
||||||
|
@ -959,3 +959,32 @@ func (this *ModelHero) checkHeroAllSkillMax(hero *pb.DBHero) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
func (this *ModelHero) SetHeroFetterProperty(hero *pb.DBHero, attr []*cfg.Gameatr) {
|
||||||
|
if hero == nil || len(attr) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if hero.Fetters == nil {
|
||||||
|
hero.Fetters = make(map[string]int32, 0)
|
||||||
|
}
|
||||||
|
for _, key := range attr {
|
||||||
|
value := key.N
|
||||||
|
switch key.A {
|
||||||
|
case comm.Hp:
|
||||||
|
hero.Fetters[comm.Hp] += int32(value)
|
||||||
|
case comm.Def:
|
||||||
|
hero.Fetters[comm.Def] += int32(value)
|
||||||
|
case comm.Atk:
|
||||||
|
hero.Fetters[comm.Atk] += int32(value)
|
||||||
|
case comm.Speed:
|
||||||
|
hero.Fetters[comm.Speed] += int32(value)
|
||||||
|
case comm.HpPro:
|
||||||
|
hero.Fetters[comm.Hp] += int32(math.Floor((float64(value) / 1000) * float64(hero.Property[comm.Hp])))
|
||||||
|
case comm.AtkPro:
|
||||||
|
hero.Fetters[comm.Atk] += int32(math.Floor((float64(value) / 1000) * float64(hero.Property[comm.Atk])))
|
||||||
|
case comm.DefPro:
|
||||||
|
hero.Fetters[comm.Def] += int32(math.Floor((float64(value) / 1000) * float64(hero.Property[comm.Def])))
|
||||||
|
default:
|
||||||
|
this.moduleHero.Errorf("unkonw hero fetter property:%v", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -977,3 +977,24 @@ func (this *Hero) QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, e
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Hero) AddHeroFetterAttribute(session comm.IUserSession, attr map[string][]*cfg.Gameatr) {
|
||||||
|
chanegCard := make([]*pb.DBHero, 0)
|
||||||
|
heroList := this.GetHeroList(session.GetUserId())
|
||||||
|
for _, v := range heroList {
|
||||||
|
if v1, ok := attr[v.HeroID]; ok { // 找到对应的英雄ID
|
||||||
|
_heroMap := make(map[string]interface{}, 0)
|
||||||
|
this.modelHero.SetHeroFetterProperty(v, v1)
|
||||||
|
_heroMap["fetters"] = v.Fetters
|
||||||
|
// 保存数据
|
||||||
|
err := this.modelHero.ChangeList(session.GetUserId(), v.Id, _heroMap)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
this.Errorf("SetHeroFetterProperty failed:%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
chanegCard = append(chanegCard, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ package library
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
@ -28,7 +29,8 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.LibraryGetRewa
|
|||||||
code = pb.ErrorCode_LibraryNoData
|
code = pb.ErrorCode_LibraryNoData
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if conf := this.module.configure.GetFriendData(fetter.Fid, req.Fetterlv); len(conf) == 0 {
|
conf := this.module.configure.GetFriendData(fetter.Fid, req.Fetterlv)
|
||||||
|
if len(conf) == 0 {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@ -49,6 +51,19 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.LibraryGetRewa
|
|||||||
fetter.Prize[req.Fetterlv] = 1
|
fetter.Prize[req.Fetterlv] = 1
|
||||||
// 发奖
|
// 发奖
|
||||||
|
|
||||||
|
h := make(map[string][]*cfg.Gameatr, 0)
|
||||||
|
for _, v := range conf {
|
||||||
|
var sz []*cfg.Gameatr
|
||||||
|
for _, v1 := range v.Attribute {
|
||||||
|
b := &cfg.Gameatr{
|
||||||
|
A: v1.A,
|
||||||
|
N: v1.N,
|
||||||
|
}
|
||||||
|
sz = append(sz, b)
|
||||||
|
}
|
||||||
|
h[v.Hid] = sz
|
||||||
|
}
|
||||||
|
this.module.ModuleHero.AddHeroFetterAttribute(session, h)
|
||||||
mapData := make(map[string]interface{}, 0)
|
mapData := make(map[string]interface{}, 0)
|
||||||
mapData["prize"] = fetter.Prize
|
mapData["prize"] = fetter.Prize
|
||||||
this.module.ModifyLibraryData(session.GetUserId(), fetter.Id, mapData) // 更新内存信息
|
this.module.ModifyLibraryData(session.GetUserId(), fetter.Id, mapData) // 更新内存信息
|
||||||
|
@ -19,7 +19,6 @@ func (this *apiComp) UseGiftCheck(session comm.IUserSession, req *pb.LibraryUseG
|
|||||||
func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
res []*cfg.Gameatn
|
res []*cfg.Gameatn
|
||||||
totalExp int32
|
|
||||||
maxLv int32 // 羁绊最大等级
|
maxLv int32 // 羁绊最大等级
|
||||||
upLv int32
|
upLv int32
|
||||||
attenuation map[int32]int32
|
attenuation map[int32]int32
|
||||||
@ -97,14 +96,19 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
|
|||||||
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
|
if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
itemConf, err1 := this.module.configure.GetItemConfigureData(req.Items) // 获取食物的
|
||||||
|
if err1 != nil {
|
||||||
|
this.module.Errorf("赠送菜品配置没找到:%s", req.Items)
|
||||||
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
|
return
|
||||||
|
}
|
||||||
// 100*1 + 100*0.25 + 100*0.5
|
// 100*1 + 100*0.25 + 100*0.5
|
||||||
totalExp = add
|
_heroObj.Favorexp += add * itemConf.SpecialType / 1000
|
||||||
_heroObj.Favorexp += totalExp
|
|
||||||
|
|
||||||
// 折算出等级
|
// 折算出等级
|
||||||
for {
|
for {
|
||||||
if _heroObj.Favorlv >= maxLv { // 达到最大等级不让继续升级
|
if _heroObj.Favorlv >= maxLv { // 达到最大等级不让继续升级
|
||||||
code = pb.ErrorCode_LibraryMaxLv
|
_heroObj.Favorexp = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if _exp[_heroObj.Favorlv] <= _heroObj.Favorexp {
|
if _exp[_heroObj.Favorlv] <= _heroObj.Favorexp {
|
||||||
|
@ -120,7 +120,6 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr
|
|||||||
}
|
}
|
||||||
dbLibrary = append(dbLibrary, tmp)
|
dbLibrary = append(dbLibrary, tmp)
|
||||||
} else { // 有这条羁绊数据
|
} else { // 有这条羁绊数据
|
||||||
dbLibrary = append(dbLibrary, list)
|
|
||||||
for _, v := range conf {
|
for _, v := range conf {
|
||||||
if _, ok := list.Herofetter[v.Hid]; !ok {
|
if _, ok := list.Herofetter[v.Hid]; !ok {
|
||||||
if _d := this.CheckHeroFetter(uid, v.Hid); _d == nil {
|
if _d := this.CheckHeroFetter(uid, v.Hid); _d == nil {
|
||||||
@ -130,6 +129,7 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr
|
|||||||
mapData := make(map[string]interface{}, 0)
|
mapData := make(map[string]interface{}, 0)
|
||||||
mapData["herofetter"] = list.Herofetter
|
mapData["herofetter"] = list.Herofetter
|
||||||
this.modelLibrary.modifyLibraryDataByObjId(uid, list.Id, mapData) // 更新新的羁绊信息
|
this.modelLibrary.modifyLibraryDataByObjId(uid, list.Id, mapData) // 更新新的羁绊信息
|
||||||
|
dbLibrary = append(dbLibrary, list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ func (this *Library) CheckHeroFetter(uid string, hid string) (obj *pb.DBHeroFett
|
|||||||
|
|
||||||
// 创建一条英雄羁绊信息
|
// 创建一条英雄羁绊信息
|
||||||
func (this *Library) createHeroFetter(uid string, heroConfId string) (obj *pb.DBHeroFetter, err error) {
|
func (this *Library) createHeroFetter(uid string, heroConfId string) (obj *pb.DBHeroFetter, err error) {
|
||||||
this.modelFetter.getHeroFetterList(uid)
|
|
||||||
obj = &pb.DBHeroFetter{
|
obj = &pb.DBHeroFetter{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
|
@ -9,26 +9,32 @@
|
|||||||
package cfg
|
package cfg
|
||||||
|
|
||||||
type GameEquipAttrlibrary struct {
|
type GameEquipAttrlibrary struct {
|
||||||
_dataList []*GameEquipAttrlibraryData
|
_dataMap map[int32]*GameEquipAttrlibraryData
|
||||||
|
_dataList []*GameEquipAttrlibraryData
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGameEquipAttrlibrary(_buf []map[string]interface{}) (*GameEquipAttrlibrary, error) {
|
func NewGameEquipAttrlibrary(_buf []map[string]interface{}) (*GameEquipAttrlibrary, error) {
|
||||||
_dataList := make([]*GameEquipAttrlibraryData, 0, len(_buf))
|
_dataList := make([]*GameEquipAttrlibraryData, 0, len(_buf))
|
||||||
|
dataMap := make(map[int32]*GameEquipAttrlibraryData)
|
||||||
for _, _ele_ := range _buf {
|
for _, _ele_ := range _buf {
|
||||||
if _v, err2 := DeserializeGameEquipAttrlibraryData(_ele_); err2 != nil {
|
if _v, err2 := DeserializeGameEquipAttrlibraryData(_ele_); err2 != nil {
|
||||||
return nil, err2
|
return nil, err2
|
||||||
} else {
|
} else {
|
||||||
_dataList = append(_dataList, _v)
|
_dataList = append(_dataList, _v)
|
||||||
|
dataMap[_v.Key] = _v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &GameEquipAttrlibrary{_dataList:_dataList}, nil
|
return &GameEquipAttrlibrary{_dataList: _dataList, _dataMap: dataMap}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *GameEquipAttrlibrary) GetDataMap() map[int32]*GameEquipAttrlibraryData {
|
||||||
|
return table._dataMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (table *GameEquipAttrlibrary) GetDataList() []*GameEquipAttrlibraryData {
|
func (table *GameEquipAttrlibrary) GetDataList() []*GameEquipAttrlibraryData {
|
||||||
return table._dataList
|
return table._dataList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (table *GameEquipAttrlibrary) Get(index int) *GameEquipAttrlibraryData {
|
func (table *GameEquipAttrlibrary) Get(key int32) *GameEquipAttrlibraryData {
|
||||||
return table._dataList[index]
|
return table._dataMap[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user