2025-11-25 21:10:52 +08:00
|
|
|
package controller
|
2025-11-26 01:33:48 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/data/xmlres"
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
"blazing/logic/service/pet"
|
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
"blazing/modules/blazing/model"
|
2025-12-02 03:59:28 +08:00
|
|
|
"blazing/modules/blazing/service"
|
2025-12-02 02:50:20 +00:00
|
|
|
|
2025-12-04 14:28:42 +00:00
|
|
|
"github.com/govalues/decimal"
|
2025-11-26 01:33:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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.ErrSystemBusy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//防止同一只
|
|
|
|
|
if data.Mcatchtime == data.Auxcatchtime {
|
2025-12-04 00:26:49 +08:00
|
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady
|
2025-11-26 01:33:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, Mcatchpetinfo, ok := c.FindPet(data.Mcatchtime)
|
|
|
|
|
if !ok {
|
2025-12-04 00:26:49 +08:00
|
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2
|
2025-11-26 01:33:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if xmlres.PetMAP[int(Mcatchpetinfo.ID)].FuseMaster == 0 {
|
2025-12-04 00:26:49 +08:00
|
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3
|
2025-11-26 01:33:48 +08:00
|
|
|
}
|
|
|
|
|
_, Auxpetinfo, ok := c.FindPet(data.Auxcatchtime)
|
|
|
|
|
if !ok {
|
2025-12-04 00:26:49 +08:00
|
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2
|
2025-11-26 01:33:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if xmlres.PetMAP[int(Auxpetinfo.ID)].FuseSub == 0 {
|
2025-12-04 00:26:49 +08:00
|
|
|
return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3
|
2025-11-26 01:33:48 +08:00
|
|
|
}
|
2025-12-02 03:59:28 +08:00
|
|
|
|
|
|
|
|
///性格生成
|
|
|
|
|
var natureId int32 = -1
|
|
|
|
|
if Auxpetinfo.Nature == Mcatchpetinfo.Nature {
|
|
|
|
|
natureId = int32(Auxpetinfo.Nature)
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 02:32:31 +08:00
|
|
|
resid := int(service.NewPetFusionService().Data(Mcatchpetinfo.ID, Auxpetinfo.ID, Mcatchpetinfo.Level+Auxpetinfo.Level))
|
2025-12-02 03:59:28 +08:00
|
|
|
|
|
|
|
|
if resid == 0 {
|
|
|
|
|
//todo失败降低等级
|
|
|
|
|
return &pet.PetFusionInfo{}, 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
|
2025-12-04 14:28:42 +00:00
|
|
|
dv1 := decimal.newf(2).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Mcatchpetinfo.Dv)))
|
2025-12-02 02:50:20 +00:00
|
|
|
dv2 := decimal.NewFromInt(1).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Auxpetinfo.Dv)))
|
|
|
|
|
dv := dv1.Add(dv2).Add(decimal.NewFromInt(1)).IntPart()
|
|
|
|
|
r := model.GenPetInfo(resid, int(dv), int(natureId), effect, -1, 1)
|
2025-12-04 00:26:49 +08:00
|
|
|
r.OldCatchTime = Mcatchpetinfo.CatchTime
|
2025-12-03 22:05:28 +08:00
|
|
|
c.Service.Pet.PetAdd(r)
|
2025-11-26 01:33:48 +08:00
|
|
|
c.Pet_del(Auxpetinfo.CatchTime)
|
|
|
|
|
c.Pet_del(Mcatchpetinfo.CatchTime)
|
2025-12-02 03:59:28 +08:00
|
|
|
//todo材料扣除
|
2025-11-26 01:33:48 +08:00
|
|
|
return &pet.PetFusionInfo{
|
|
|
|
|
ObtainTime: r.CatchTime,
|
|
|
|
|
SoulID: 1000017,
|
|
|
|
|
StarterCpTm: r.ID,
|
|
|
|
|
CostItemFlag: 0,
|
|
|
|
|
}, 0
|
|
|
|
|
}
|