feat(pet): 宠物系统新增异色功能 - 在蛋游戏中添加异色宠物生成逻辑 - 在 boss 战斗中加入捕获时异色概率判定 - 优化宠物融合系统,支持融合后异色继承 - 重构宠物删除方法命名,修复方法调用问题
92 lines
2.7 KiB
Go
92 lines
2.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/data/xmlres"
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/modules/blazing/model"
|
|
"blazing/modules/config/service"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
"github.com/gogf/gf/v2/util/grand"
|
|
)
|
|
|
|
func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result *pet.PetFusionInfo, err errorcode.ErrorCode) {
|
|
if !c.UseCoins(1000) {
|
|
return result, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
|
}
|
|
// g.Dump(c.Info.PetList)
|
|
|
|
//防止同一只
|
|
if data.Mcatchtime == data.Auxcatchtime {
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady
|
|
}
|
|
|
|
_, Mcatchpetinfo, ok := c.FindPet(data.Mcatchtime)
|
|
if !ok {
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2
|
|
}
|
|
|
|
if xmlres.PetMAP[int(Mcatchpetinfo.ID)].FuseMaster == 0 {
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3
|
|
}
|
|
_, Auxpetinfo, ok := c.FindPet(data.Auxcatchtime)
|
|
if !ok {
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2
|
|
}
|
|
|
|
if xmlres.PetMAP[int(Auxpetinfo.ID)].FuseSub == 0 {
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3
|
|
}
|
|
//println(len(c.Info.PetList), data.Mcatchtime, data.Auxcatchtime, Mcatchpetinfo.CatchTime, Auxpetinfo.CatchTime)
|
|
///性格生成
|
|
var natureId int32 = -1
|
|
if Auxpetinfo.Nature == Mcatchpetinfo.Nature {
|
|
natureId = int32(Auxpetinfo.Nature)
|
|
}
|
|
|
|
resid := int(service.NewPetFusionService().Data(Mcatchpetinfo.ID, Auxpetinfo.ID, Mcatchpetinfo.Level+Auxpetinfo.Level))
|
|
|
|
if resid == 0 {
|
|
//todo失败降低等级
|
|
|
|
return &pet.PetFusionInfo{}, 0
|
|
}
|
|
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
|
|
if effect == 0 {
|
|
return &pet.PetFusionInfo{}, 0
|
|
}
|
|
|
|
dv1 := alpacadecimal.NewFromInt(2).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Mcatchpetinfo.Dv)))
|
|
dv2 := alpacadecimal.NewFromInt(1).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Auxpetinfo.Dv)))
|
|
dv := dv1.Add(dv2).Add(alpacadecimal.NewFromInt(1)).IntPart()
|
|
r := model.GenPetInfo(resid, int(dv), int(natureId), effect, 1, nil)
|
|
r.OldCatchTime = Mcatchpetinfo.CatchTime
|
|
|
|
shinycont := 0
|
|
if Mcatchpetinfo.IsShiny() || Auxpetinfo.IsShiny() {
|
|
shinycont = 50
|
|
}
|
|
if Mcatchpetinfo.IsShiny() && Auxpetinfo.IsShiny() {
|
|
shinycont = 100
|
|
}
|
|
if grand.Meet(shinycont, 100) {
|
|
r.RandShiny()
|
|
|
|
}
|
|
c.Service.Pet.PetAdd(r)
|
|
println(len(c.Info.PetList), data.Mcatchtime, data.Auxcatchtime, Mcatchpetinfo.CatchTime, Auxpetinfo.CatchTime)
|
|
c.PetDel(data.Auxcatchtime)
|
|
c.PetDel(data.Mcatchtime)
|
|
//fmt.Println(len(c.Info.PetList))
|
|
// g.Dump(c.Info.PetList)
|
|
//todo材料扣除
|
|
return &pet.PetFusionInfo{
|
|
ObtainTime: r.CatchTime,
|
|
SoulID: 1000017,
|
|
StarterCpTm: r.ID,
|
|
CostItemFlag: 0,
|
|
}, 0
|
|
}
|