feat(pet): 添加精灵进化功能并优化融合系统

- 新增PetELV方法实现精灵进化功能,支持分支进化选择
- 添加进化相关的数据结构定义
- 实现进化材料检查和扣除逻辑
- 优化宠物融合失败处理机制

fix(fight): 修复战斗系统和效果计算问题

- 修复NewSeIdx_11和effect_60中的伤害计算逻辑
- 修复战斗状态判断条件,避免非PVP模式下的错误处理
- 优化战斗回合处理流程,修复效果缓存清空时机
- 修复effect_69
This commit is contained in:
2026-01-03 01:35:32 +08:00
parent c056fdcebc
commit a62b94446a
17 changed files with 323 additions and 66 deletions

View File

@@ -36,7 +36,15 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
for _, v := range c.HavePVPinfo {
if v.GetInfo().UserID == data.UserID && v.Getfightinfo().Mode == data.Mode {
resp.Result = data.Flag
if resp.Result == 0 {
v.SendPackCmd(2502, &resp)
atomic.StoreUint32(&c.Fightinfo.Mode, 0)
return
}
// 检查邀请者的邀请是否有效(对方已取消邀请)
if v.Getfightinfo().Status == 0 {
resp.Result = 4 // 邀请已取消

View File

@@ -189,7 +189,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
switch data.Head.CMD {
case 2429: //试炼之塔
for _, v := range boss.TaskIds {
c.CompletedTask(int(v), 500)
c.CompletedTask(int(v), 600)
}
c.Info.CurrentFreshStage++
if c.Info.CurrentFreshStage >= c.Info.MaxFreshStage {
@@ -198,7 +198,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
case 2415: //勇者之塔
for _, v := range boss.TaskIds {
c.CompletedTask(int(v), 600)
c.CompletedTask(int(v), 500)
}
c.Info.CurrentStage++
if c.Info.CurrentStage >= c.Info.MaxStage {

View File

@@ -1 +1,52 @@
package controller
import (
"blazing/common/data/xmlres"
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/logic/service/pet"
"blazing/logic/service/player"
"github.com/jinzhu/copier"
)
// PetEVDiy 自定义分配宠物努力值EV
// data: 包含宠物捕获时间和EV分配数据的输入信息
// c: 当前玩家对象
// 返回: 分配结果和错误码
func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
_, currentPet, found := c.FindPet(data.CacthTime)
if !found {
return nil, errorcode.ErrorCodes.Err10401
}
flag := xmlres.PetMAP[int(currentPet.ID)].EvolvFlag
if flag == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
}
evinfo := xmlres.EVOLVMAP[flag].Branches[data.Index-1]
if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < uint32(evinfo.EvolvItemCount) {
return nil, errorcode.ErrorCodes.ErrInsufficientItemsMulti
}
if evinfo.EvolvItem != 0 {
c.Service.Item.UPDATE(uint32(evinfo.EvolvItem), -evinfo.EvolvItemCount)
}
currentPet.ID = uint32(xmlres.EVOLVMAP[flag].Branches[data.Index-1].MonTo)
currentPet.Update(true)
currentPet.CalculatePetPane(false)
currentPet.Update(true)
updateOutbound := &info.PetUpdateOutboundInfo{}
var petUpdateInfo info.UpdatePropInfo
copier.Copy(&petUpdateInfo, currentPet)
updateOutbound.Data = append(updateOutbound.Data, petUpdateInfo)
c.SendPackCmd(2508, updateOutbound) //准备包由各自发,因为协议不一样
return nil, -1
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/alpacahq/alpacadecimal"
"github.com/gogf/gf/v2/util/grand"
"github.com/samber/lo"
)
func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result *pet.PetFusionInfo, err errorcode.ErrorCode) {
@@ -49,11 +50,34 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result
resid := int(service.NewPetFusionService().Data(Mcatchpetinfo.ID, Auxpetinfo.ID, Mcatchpetinfo.Level+Auxpetinfo.Level))
if resid == 0 {
//todo失败降低等级
_, ok := lo.Find(data.GoldItem1[:], func(item uint32) bool {
return item == 300044
})
if c.Service.Item.CheakItem(300044) > 0 && ok {
c.Service.Item.UPDATE(300044, -1)
} else {
if Auxpetinfo.Level > 5 {
Auxpetinfo.Level = Auxpetinfo.Level - 5
} else {
Auxpetinfo.Level = 1
}
}
return &pet.PetFusionInfo{}, 0
}
for _, v := range data.Item1 {
if c.Service.Item.CheakItem(v) == 0 {
return &pet.PetFusionInfo{}, 0
}
}
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
if effect == 0 {
return &pet.PetFusionInfo{}, 0
}
@@ -77,9 +101,23 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result
}
c.Service.Pet.PetAdd(r)
println(c.Info.UserID, "进行融合", len(c.Info.PetList), Mcatchpetinfo.ID, Auxpetinfo.ID, r.ID)
c.PetDel(data.Auxcatchtime)
c.PetDel(data.Mcatchtime)
c.PetDel(data.Mcatchtime)
_, ok2 := lo.Find(data.GoldItem1[:], func(item uint32) bool {
return item == 300043
})
if c.Service.Item.CheakItem(300043) > 0 && ok2 {
c.Service.Item.UPDATE(300044, -1)
} else {
c.PetDel(data.Auxcatchtime)
}
for _, v := range data.Item1 {
c.Service.Item.UPDATE(v, -1)
}
//todo材料扣除
return &pet.PetFusionInfo{
ObtainTime: r.CatchTime,