diff options
| author | historia <[not public]> | 2026-06-25 00:44:47 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 00:44:47 -0400 |
| commit | 94a06fbbe682701ca4d4bd2a70cd74d8df29c932 (patch) | |
| tree | eb49fb1893e61092138164d419e863ee3fe0d1e2 /internal/game/action_state.go | |
| parent | 15b7e221b799ef107dec44ecdb294026dfd3d059 (diff) | |
| download | thehouseoficarus-94a06fbbe682701ca4d4bd2a70cd74d8df29c932.tar.gz | |
refactor: replaced map[string]any with typed structs for Data
Diffstat (limited to 'internal/game/action_state.go')
| -rw-r--r-- | internal/game/action_state.go | 187 |
1 files changed, 88 insertions, 99 deletions
diff --git a/internal/game/action_state.go b/internal/game/action_state.go index bed936d..fc4b461 100644 --- a/internal/game/action_state.go +++ b/internal/game/action_state.go @@ -1,109 +1,98 @@ package game -type ActionType string - -const ( - ActionIdle ActionType = "" - ActionGathering ActionType = "gathering" - ActionCombating ActionType = "combating" - ActionMoving ActionType = "moving" - ActionUsing ActionType = "using" - ActionTalking ActionType = "talking" - ActionBurning ActionType = "burning" - ActionStoking ActionType = "stoking" - ActionPickingUp ActionType = "picking_up" - ActionDropping ActionType = "dropping" - ActionSearching ActionType = "searching" - ActionResting ActionType = "resting" - ActionWalking ActionType = "walking" - ActionProducing ActionType = "producing" - ActionFletching ActionType = "fletching" - ActionEating ActionType = "eating" - ActionCleaning ActionType = "cleaning" - ActionIdentifying ActionType = "identifying" - ActionStealing ActionType = "stealing" - ActionPlanting ActionType = "planting" - ActionHarvesting ActionType = "harvesting_crop" - ActionRaking ActionType = "raking" - ActionWatering ActionType = "watering" - ActionCuring ActionType = "curing" - ActionTraversing ActionType = "traversing" - ActionHacking ActionType = "hacking" - ActionHiding ActionType = "hiding" - ActionWorking ActionType = "working" +import ( + "thehouseoficarus/internal/action" + "thehouseoficarus/internal/combat" + "thehouseoficarus/internal/player" ) -type ActionState struct { - Type ActionType - TargetName string - ToolName string - Direction string - Verb string -} +func (g *Game) playerActionDisplay(p *player.Player) string { + if cs := combat.GetCombat(p.Name); cs != nil { + mob := g.MobStore.GetInstance(cs.MobID) + if mob != nil { + if mob.IsTask() { + return "working on a " + mob.Name + } + return "fighting a " + mob.Name + } + } -func (a *ActionState) Description() string { - if a == nil || a.Type == ActionIdle { - return "" + if p.MoveTicks > 0 { + return "heading " + p.MoveDirection } - switch a.Type { - case ActionGathering: - desc := a.Verb + " a " + a.TargetName - if a.ToolName != "" { - desc += " with a " + a.ToolName - } - return desc - case ActionCombating: - return "fighting a " + a.TargetName - case ActionMoving: - return "heading " + a.Direction - case ActionUsing: - return "using a " + a.TargetName - case ActionTalking: - return "talking to " + a.TargetName - case ActionBurning: - return "trying to start a fire" - case ActionStoking: - return "tending to a fire" - case ActionPickingUp: - return "picking up " + a.TargetName - case ActionDropping: - return "dropping " + a.TargetName - case ActionSearching: - return "digging through a " + a.TargetName - case ActionResting: - return "resting" - case ActionWalking: + if len(p.WalkSequence) > 0 { return "walking somewhere with a purpose!" - case ActionProducing: - return a.Verb + " some " + a.TargetName - case ActionFletching: - return "fletching " + a.TargetName - case ActionEating: - return "eating " + a.TargetName - case ActionCleaning: - return "cleaning herbs" - case ActionIdentifying: - return "identifying scrap at " + a.TargetName - case ActionStealing: - return "stealing from " + a.TargetName - case ActionPlanting: - return "planting " + a.TargetName - case ActionHarvesting: - return "harvesting " + a.TargetName - case ActionRaking: - return "raking a " + a.TargetName - case ActionWatering: - return "watering a " + a.TargetName - case ActionCuring: - return "curing a " + a.TargetName - case ActionTraversing: - return a.Verb + " across " + a.TargetName - case ActionHacking: - return "jacked into a " + a.TargetName - case ActionHiding: - return "positioning behind a " + a.TargetName - case ActionWorking: - return "working on a " + a.TargetName } + + if ss, ok := g.safespot.Get(p.Name); ok && ss.Active { + obj, err := g.ObjectStore.Load(ss.ObjectDefID) + if err == nil { + return "positioning behind a " + obj.Name + } + return "hiding" + } + + if a := p.Action; a != nil { + switch a.Type { + case action.TypeGather: + if d, ok := a.Data.(*action.GatherData); ok { + desc := d.Verb + " a " + a.TargetName + if d.ToolName != "" { + desc += " with a " + d.ToolName + } + return desc + } + case action.TypeSteal: + return "stealing from " + a.TargetName + case action.TypeTalk: + return "talking to " + a.TargetName + case action.TypeUse: + return "using a " + a.TargetName + case action.TypeBurn: + return "trying to start a fire" + case action.TypeStoke: + return "tending to a fire" + case action.TypeSearch: + return "digging through a " + a.TargetName + case action.TypeIdentify: + return "identifying scrap at " + a.TargetName + case action.TypePlant: + return "planting " + a.TargetName + case action.TypeHarvest: + return "harvesting " + a.TargetName + case action.TypeRake: + return "raking a " + a.TargetName + case action.TypeWater: + return "watering a " + a.TargetName + case action.TypeCure: + return "curing a " + a.TargetName + case action.TypeObstacle: + return "traversing across " + a.TargetName + case action.TypeCook: + return "cooking some " + a.TargetName + case action.TypeSmelt: + return "smelting some " + a.TargetName + case action.TypeSmith: + return "smithing some " + a.TargetName + case action.TypeCraft: + return "crafting some " + a.TargetName + case action.TypeCombine: + return "combining some " + a.TargetName + case action.TypeMix: + return "mixing some " + a.TargetName + case action.TypeConstruct: + return "constructing some " + a.TargetName + } + } + + if a := p.BackgroundAction; a != nil { + switch a.Type { + case action.TypeFletch: + return "fletching " + a.TargetName + case action.TypeClean: + return "cleaning herbs" + } + } + return "" } |
