feat: 添加炫彩碎片道具处理逻辑并优化闪光信息存储
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

修改道具处理逻辑,新增炫彩碎片道具(300212)的使用功能
优化宠物闪光信息存储方式,改为直接赋值而非追加
This commit is contained in:
xinian
2026-02-23 07:30:30 +08:00
committed by cnb
parent fc0842e388
commit 84768e3406
3 changed files with 26 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
package controller
import (
element "blazing/common/data/Element"
"blazing/common/data/xmlres"
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/item"
@@ -13,8 +15,6 @@ import (
const (
// ItemDefaultLeftTime 道具默认剩余时间(毫秒)
ItemDefaultLeftTime = 360000
// ItemNeuronID 神经元道具ID
ItemNeuronID = 300036
)
// GetUserItemList 获取用户道具列表
@@ -54,11 +54,15 @@ func (h Controller) UsePetItemOutOfFight(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGH
}
var errcode errorcode.ErrorCode
if data.ItemID == ItemNeuronID {
switch data.ItemID {
case 300036:
errcode = h.handleNeuronItem(currentPet, c)
} else {
case 300212:
errcode = h.handlexuancaiItem(currentPet, c)
default:
errcode = h.handleRegularPetItem(uint32(data.ItemID), currentPet)
}
if errcode != 0 {
return nil, errcode
}
@@ -91,6 +95,21 @@ func (h Controller) handleNeuronItem(currentPet *model.PetInfo, c *player.Player
return 0
}
// 炫彩碎片 处理神300212
func (h Controller) handlexuancaiItem(currentPet *model.PetInfo, c *player.Player) errorcode.ErrorCode {
r, _ := element.Calculator.GetCombination(int(currentPet.ID))
if r.Secondary != nil {
return errorcode.ErrorCodes.ErrItemUnusable
}
items := c.Service.Item.CheakItem(uint32(xmlres.PetMAP[int(currentPet.ID)].Type) + 400686)
if items <= 0 {
return errorcode.ErrorCodes.ErrInsufficientItems
}
c.Service.Item.UPDATE(uint32(items), -100)
currentPet.FixShiny()
return 0
}
// handleRegularPetItem 处理普通宠物道具
func (h Controller) handleRegularPetItem(itemID uint32, currentPet *model.PetInfo) errorcode.ErrorCode {
handler := item.PetItemRegistry.GetHandler(itemID)