服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
95 lines
3.1 KiB
Go
95 lines
3.1 KiB
Go
package equip
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
dnfrepo "longheng.io/server/internal/modules/dnf/repository"
|
|
)
|
|
|
|
// syncPetArtifactEquipmentMove projects the already-persisted list-7 / actor
|
|
// target 27..29 mutation into PetRecord.Artifacts before the surrounding
|
|
// CharacterPetUnitOfWork commits. The actor EquipmentRecord remains the worn
|
|
// endpoint authority; PetRecord is its durable pet-status projection.
|
|
func (o *Owner) syncPetArtifactEquipmentMove(ctx context.Context, characterID string, result MoveResult) error {
|
|
if o == nil || o.pets == nil {
|
|
return ErrPetRepositoryRequired
|
|
}
|
|
target, ok := petArtifactTargetFromMoveResult(result)
|
|
if !ok {
|
|
return fmt.Errorf("%w: artifact result endpoints=(%d,%d)->(%d,%d)",
|
|
ErrPetOwnershipMismatch,
|
|
result.SourceListType,
|
|
result.SourceSlotIndex,
|
|
result.DestinationListType,
|
|
result.DestinationSlotIndex,
|
|
)
|
|
}
|
|
kind, ok := petArtifactProjectionKey(target)
|
|
if !ok {
|
|
return fmt.Errorf("%w: artifact target=%d", ErrPetOwnershipMismatch, target)
|
|
}
|
|
|
|
_, equipment, err := o.loadMoveRecords(ctx, characterID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
record, found, err := o.pets.Load(ctx, characterID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !found {
|
|
record = dnfrepo.PetRecord{CharacterID: characterID}
|
|
}
|
|
record = dnfrepo.ClonePet(record)
|
|
record.CharacterID = characterID
|
|
if record.Artifacts == nil {
|
|
record.Artifacts = make(map[string]dnfrepo.ItemStack)
|
|
}
|
|
|
|
equipped, equippedFound := equipment.Entries[entryKey(target)]
|
|
if equippedFound {
|
|
if equipped.SlotIndex != target || equipped.ItemID <= 0 || len(equipped.RawEntry) == 0 {
|
|
return fmt.Errorf("%w: artifact target=%d entry=%+v", ErrPetOwnershipMismatch, target, equipped)
|
|
}
|
|
if result.Mode != "equip" && result.Mode != "equip_swap" && result.Mode != "unequip_swap" {
|
|
return fmt.Errorf("%w: artifact target=%d mode=%s remains occupied", ErrPetOwnershipMismatch, target, result.Mode)
|
|
}
|
|
if equipped.ItemID != result.ItemID && equipped.ItemID != result.SwappedItemID {
|
|
return fmt.Errorf("%w: artifact target=%d item=%d result=(%d,%d)", ErrPetOwnershipMismatch, target, equipped.ItemID, result.ItemID, result.SwappedItemID)
|
|
}
|
|
record.Artifacts[kind] = stackFromEntry(equipped)
|
|
} else {
|
|
if result.Mode != "unequip" {
|
|
return fmt.Errorf("%w: artifact target=%d mode=%s is empty", ErrPetOwnershipMismatch, target, result.Mode)
|
|
}
|
|
delete(record.Artifacts, kind)
|
|
}
|
|
record.UpdatedAt = time.Now()
|
|
return dnfrepo.SavePetFields(ctx, o.pets, record, dnfrepo.PetFieldEntries)
|
|
}
|
|
|
|
func petArtifactTargetFromMoveResult(result MoveResult) (int16, bool) {
|
|
if result.SourceListType == wireListEquipment && isPetArtifactTarget(result.SourceSlotIndex) && result.DestinationListType == wireListPet {
|
|
return result.SourceSlotIndex, true
|
|
}
|
|
if result.SourceListType == wireListPet && result.DestinationListType == wireListEquipment && isPetArtifactTarget(result.DestinationSlotIndex) {
|
|
return result.DestinationSlotIndex, true
|
|
}
|
|
return 0, false
|
|
}
|
|
|
|
func petArtifactProjectionKey(target int16) (string, bool) {
|
|
switch target {
|
|
case 27:
|
|
return "red", true
|
|
case 28:
|
|
return "blue", true
|
|
case 29:
|
|
return "green", true
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|