You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
package model
|
|
|
|
// Gear vendor NPC types (town shop stock is restricted by slot set).
|
|
const (
|
|
NPCTypeMerchant = "merchant" // feet, hands, cloak
|
|
NPCTypeArmorer = "armorer" // legs, wrist, chest, head
|
|
NPCTypeWeapon = "weapon" // main_hand
|
|
NPCTypeJeweler = "jeweler" // finger, neck
|
|
NPCTypeHealer = "healer"
|
|
NPCTypeBounty = "bounty_hunter"
|
|
NPCTypeElder = "elder"
|
|
NPCTypeQuestGiver = "quest_giver" // legacy; not used after DB migration
|
|
)
|
|
|
|
var gearVendorTypes = map[string]struct{}{
|
|
NPCTypeMerchant: {},
|
|
NPCTypeArmorer: {},
|
|
NPCTypeWeapon: {},
|
|
NPCTypeJeweler: {},
|
|
}
|
|
|
|
// IsGearVendorType is true for town NPCs that sell rolled gear rows.
|
|
func IsGearVendorType(t string) bool {
|
|
_, ok := gearVendorTypes[t]
|
|
return ok
|
|
}
|
|
|
|
// GearVendorSlots returns allowed equipment slots for this vendor type, or nil if not a gear vendor.
|
|
func GearVendorSlots(npcType string) []EquipmentSlot {
|
|
switch npcType {
|
|
case NPCTypeMerchant:
|
|
return []EquipmentSlot{SlotFeet, SlotHands, SlotCloak}
|
|
case NPCTypeArmorer:
|
|
return []EquipmentSlot{SlotLegs, SlotWrist, SlotChest, SlotHead}
|
|
case NPCTypeWeapon:
|
|
return []EquipmentSlot{SlotMainHand}
|
|
case NPCTypeJeweler:
|
|
return []EquipmentSlot{SlotFinger, SlotNeck}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// IsQuestOfferNPCType is true for NPCs that can offer quest templates from the catalog.
|
|
func IsQuestOfferNPCType(t string) bool {
|
|
return t == NPCTypeBounty || t == NPCTypeElder || t == NPCTypeQuestGiver
|
|
}
|
|
|
|
// QuestTemplateAllowedForNPCType returns whether a quest template type may be offered by this NPC role.
|
|
func QuestTemplateAllowedForNPCType(npcType, questType string) bool {
|
|
switch npcType {
|
|
case NPCTypeBounty:
|
|
return questType == "kill_count" || questType == "collect_item"
|
|
case NPCTypeElder:
|
|
return questType == "visit_town" || questType == "collect_item"
|
|
case NPCTypeQuestGiver:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// FilterQuestTemplatesByNPCType keeps only quests valid for the NPC role (no-op if not a quest NPC type).
|
|
func FilterQuestTemplatesByNPCType(quests []Quest, npcType string) []Quest {
|
|
if !IsQuestOfferNPCType(npcType) || npcType == NPCTypeQuestGiver {
|
|
return quests
|
|
}
|
|
out := make([]Quest, 0, len(quests))
|
|
for _, q := range quests {
|
|
if QuestTemplateAllowedForNPCType(npcType, q.Type) {
|
|
out = append(out, q)
|
|
}
|
|
}
|
|
return out
|
|
}
|