aboutsummaryrefslogtreecommitdiff
path: root/internal/world/mob.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-25 15:40:48 -0400
committerhistoria <[not public]>2026-06-25 15:40:48 -0400
commitabd612c15799f604e671e83dc7c410ed2b44185f (patch)
tree0597ca92350de73aac2a7cf26b2f2d6595dac0cc /internal/world/mob.go
parent2725e2927a1595c7b100d942d1f14146252adeb7 (diff)
downloadthehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz
slop refactor
Diffstat (limited to 'internal/world/mob.go')
-rw-r--r--internal/world/mob.go161
1 files changed, 80 insertions, 81 deletions
diff --git a/internal/world/mob.go b/internal/world/mob.go
index 4864e5c..4c6becb 100644
--- a/internal/world/mob.go
+++ b/internal/world/mob.go
@@ -8,38 +8,37 @@ import (
"strings"
"sync"
- "thehouseoficarus/internal/action"
- "thehouseoficarus/internal/object"
"gopkg.in/yaml.v3"
+ "thehouseoficarus/internal/behavior"
)
type MobDropTable struct {
- Remains string `yaml:"remains"`
- Loot []action.DropEntry `yaml:"loot"`
+ Remains string `yaml:"remains"`
+ Loot []behavior.DropEntry `yaml:"loot"`
}
type MobDef struct {
- ID string `yaml:"id"`
- Name string `yaml:"name"`
- Description string `yaml:"description"`
- IdleDescriptions []string `yaml:"idle_descriptions"`
- CombatDescriptions []string `yaml:"combat_descriptions"`
- Attack int `yaml:"attack"`
- Strength int `yaml:"strength"`
- Defense int `yaml:"defense"`
- HP int `yaml:"hp"`
- Ranged int `yaml:"ranged"`
- Science int `yaml:"science"`
- Speed float64 `yaml:"speed"`
- Aggressive bool `yaml:"aggressive"`
- Protected bool `yaml:"protected"`
- Unique bool `yaml:"unique"`
- RespawnTicks float64 `yaml:"respawn_ticks"`
+ ID string `yaml:"id"`
+ Name string `yaml:"name"`
+ Description string `yaml:"description"`
+ IdleDescriptions []string `yaml:"idle_descriptions"`
+ CombatDescriptions []string `yaml:"combat_descriptions"`
+ Attack int `yaml:"attack"`
+ Strength int `yaml:"strength"`
+ Defense int `yaml:"defense"`
+ HP int `yaml:"hp"`
+ Ranged int `yaml:"ranged"`
+ Science int `yaml:"science"`
+ Speed float64 `yaml:"speed"`
+ Aggressive bool `yaml:"aggressive"`
+ Protected bool `yaml:"protected"`
+ Unique bool `yaml:"unique"`
+ RespawnTicks float64 `yaml:"respawn_ticks"`
Drops MobDropTable `yaml:"drops"`
- AttackBonus int `yaml:"attack_bonus"`
- StrengthBonus int `yaml:"strength_bonus"`
- AttackType string `yaml:"attack_type"`
+ AttackBonus int `yaml:"attack_bonus"`
+ StrengthBonus int `yaml:"strength_bonus"`
+ AttackType string `yaml:"attack_type"`
StabDefense int `yaml:"stab_defense"`
SlashDefense int `yaml:"slash_defense"`
@@ -47,11 +46,11 @@ type MobDef struct {
ScienceDefense int `yaml:"science_defense"`
RangedDefense int `yaml:"ranged_defense"`
- Weakness string `yaml:"weakness"`
- StealTable string `yaml:"steal_table"`
- StealLevel int `yaml:"steal_level"`
- StealXP int `yaml:"steal_xp"`
- StealSpeed float64 `yaml:"steal_speed"`
+ Weakness string `yaml:"weakness"`
+ StealTable string `yaml:"steal_table"`
+ StealLevel int `yaml:"steal_level"`
+ StealXP int `yaml:"steal_xp"`
+ StealSpeed float64 `yaml:"steal_speed"`
AssassinLevel int `yaml:"assassin_level"`
FinishingBlow string `yaml:"finishing_blow"`
@@ -68,7 +67,7 @@ type MobDef struct {
ProgressNoun string `yaml:"progress_noun"` // flavor noun, e.g. "construction"
CompleteMessage string `yaml:"complete_message"` // shown on completion
- Talk *action.TalkConfig `yaml:"talk,omitempty"`
+ Talk *behavior.TalkConfig `yaml:"talk,omitempty"`
}
func (d *MobDef) IsTalkable() bool { return d.Talk != nil }
@@ -100,9 +99,9 @@ type MobInstance struct {
WanderTickCounter int
regenerateTick int
- AttackBonus int
- StrengthBonus int
- AttackType string
+ AttackBonus int
+ StrengthBonus int
+ AttackType string
StabDefense int
SlashDefense int
@@ -110,11 +109,11 @@ type MobInstance struct {
ScienceDefense int
RangedDefense int
- Weakness string
- StealTable string
- StealLevel int
- StealXP int
- StealSpeed float64
+ Weakness string
+ StealTable string
+ StealLevel int
+ StealXP int
+ StealSpeed float64
AssassinLevel int
FinishingBlow string
@@ -126,7 +125,7 @@ type MobInstance struct {
ProgressNoun string
CompleteMessage string
- TalkConfig *action.TalkConfig
+ TalkConfig *behavior.TalkConfig
}
func (m *MobInstance) IsTalkable() bool { return m.TalkConfig != nil }
@@ -135,48 +134,48 @@ func (m *MobInstance) IsTask() bool { return m.Kind == "task" }
func NewMobInstance(def *MobDef, instanceID string, roomID int, wanderRooms []int, wanderInterval float64) *MobInstance {
return &MobInstance{
- InstanceID: instanceID,
- DefID: def.ID,
- Name: def.Name,
- HP: def.HP,
- MaxHP: def.HP,
- Attack: def.Attack,
- Strength: def.Strength,
- Defense: def.Defense,
- Ranged: def.Ranged,
- Science: def.Science,
- Speed: def.Speed,
- Aggressive: def.Aggressive,
- Protected: def.Protected,
- Unique: def.Unique,
- RespawnTicks: def.RespawnTicks,
- RoomID: roomID,
- HomeRoomID: roomID,
- WanderRooms: wanderRooms,
- WanderInterval: wanderInterval,
- Drops: def.Drops,
- AttackBonus: def.AttackBonus,
- StrengthBonus: def.StrengthBonus,
- AttackType: def.AttackType,
- StabDefense: def.StabDefense,
- SlashDefense: def.SlashDefense,
- CrushDefense: def.CrushDefense,
- ScienceDefense: def.ScienceDefense,
- RangedDefense: def.RangedDefense,
- Weakness: def.Weakness,
- StealTable: def.StealTable,
- StealLevel: def.StealLevel,
- StealXP: def.StealXP,
- StealSpeed: def.StealSpeed,
- AssassinLevel: def.AssassinLevel,
- FinishingBlow: def.FinishingBlow,
- DamageWithout: def.DamageWithout,
- Size: def.Size,
- Kind: def.Kind,
- Verb: def.Verb,
- ProgressNoun: def.ProgressNoun,
+ InstanceID: instanceID,
+ DefID: def.ID,
+ Name: def.Name,
+ HP: def.HP,
+ MaxHP: def.HP,
+ Attack: def.Attack,
+ Strength: def.Strength,
+ Defense: def.Defense,
+ Ranged: def.Ranged,
+ Science: def.Science,
+ Speed: def.Speed,
+ Aggressive: def.Aggressive,
+ Protected: def.Protected,
+ Unique: def.Unique,
+ RespawnTicks: def.RespawnTicks,
+ RoomID: roomID,
+ HomeRoomID: roomID,
+ WanderRooms: wanderRooms,
+ WanderInterval: wanderInterval,
+ Drops: def.Drops,
+ AttackBonus: def.AttackBonus,
+ StrengthBonus: def.StrengthBonus,
+ AttackType: def.AttackType,
+ StabDefense: def.StabDefense,
+ SlashDefense: def.SlashDefense,
+ CrushDefense: def.CrushDefense,
+ ScienceDefense: def.ScienceDefense,
+ RangedDefense: def.RangedDefense,
+ Weakness: def.Weakness,
+ StealTable: def.StealTable,
+ StealLevel: def.StealLevel,
+ StealXP: def.StealXP,
+ StealSpeed: def.StealSpeed,
+ AssassinLevel: def.AssassinLevel,
+ FinishingBlow: def.FinishingBlow,
+ DamageWithout: def.DamageWithout,
+ Size: def.Size,
+ Kind: def.Kind,
+ Verb: def.Verb,
+ ProgressNoun: def.ProgressNoun,
CompleteMessage: def.CompleteMessage,
- TalkConfig: def.Talk,
+ TalkConfig: def.Talk,
}
}
@@ -191,7 +190,7 @@ func (m *MobInstance) MatchQuality(input string) int {
if strings.ToLower(m.Name) == lower {
return MatchExact
}
- if object.WordPrefixMatch(input, m.Name) {
+ if behavior.WordPrefixMatch(input, m.Name) {
return MatchPrefix
}
return MatchNone
@@ -221,7 +220,7 @@ type MobStore struct {
func NewMobStore(dataDir string) *MobStore {
return &MobStore{
dataDir: dataDir,
- pathIndex: action.BuildPathIndex(filepath.Join(dataDir, "mobs")),
+ pathIndex: behavior.BuildPathIndex(filepath.Join(dataDir, "mobs")),
defs: make(map[string]*MobDef),
instances: make(map[string]*MobInstance),
}