70 lines
1.9 KiB
Go
70 lines
1.9 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/blazing/service"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
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 {
|
|
return result, errorcode.ErrorCodes.ErrSystemBusy
|
|
}
|
|
|
|
_, Mcatchpetinfo, ok := c.FindPet(data.Mcatchtime)
|
|
if !ok {
|
|
return result, errorcode.ErrorCodes.ErrSystemBusy
|
|
}
|
|
|
|
if xmlres.PetMAP[int(Mcatchpetinfo.ID)].FuseMaster == 0 {
|
|
return result, errorcode.ErrorCodes.ErrSystemBusy
|
|
}
|
|
_, Auxpetinfo, ok := c.FindPet(data.Auxcatchtime)
|
|
if !ok {
|
|
return result, errorcode.ErrorCodes.ErrSystemBusy
|
|
}
|
|
|
|
if xmlres.PetMAP[int(Auxpetinfo.ID)].FuseSub == 0 {
|
|
return result, errorcode.ErrorCodes.ErrSystemBusy
|
|
}
|
|
|
|
///性格生成
|
|
var natureId int32 = -1
|
|
if Auxpetinfo.Nature == Mcatchpetinfo.Nature {
|
|
natureId = int32(Auxpetinfo.Nature)
|
|
}
|
|
|
|
resid := int(service.NewPetFusionService().Data(Mcatchpetinfo.ID, Auxpetinfo.ID))
|
|
|
|
if resid == 0 {
|
|
//todo失败降低等级
|
|
return &pet.PetFusionInfo{}, 0
|
|
}
|
|
|
|
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
|
|
dv1 := decimal.NewFromInt(2).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Mcatchpetinfo.Dv)))
|
|
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)
|
|
c.Service.Pet.PetAdd(*r)
|
|
c.Pet_del(Auxpetinfo.CatchTime)
|
|
c.Pet_del(Mcatchpetinfo.CatchTime)
|
|
//todo材料扣除
|
|
return &pet.PetFusionInfo{
|
|
ObtainTime: r.CatchTime,
|
|
SoulID: 1000017,
|
|
StarterCpTm: r.ID,
|
|
CostItemFlag: 0,
|
|
}, 0
|
|
}
|