aboutsummaryrefslogtreecommitdiff
path: root/internal/game/game.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-16 04:17:43 -0400
committerhistoria <[not public]>2026-06-16 04:17:43 -0400
commit085e728d22a3369bd110b77409914cfbe9ebe611 (patch)
treeeeb88cb1ceb91cc9ea2b5a1877c3c66328fab503 /internal/game/game.go
parent43f21aabae8924f35c12c8485e690aeefe0089fb (diff)
downloadthehouseoficarus-085e728d22a3369bd110b77409914cfbe9ebe611.tar.gz
feat: recipe system, combining items, cooking skill
Diffstat (limited to 'internal/game/game.go')
-rw-r--r--internal/game/game.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/internal/game/game.go b/internal/game/game.go
index 456419f..33dd0d1 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -40,6 +40,7 @@ type Game struct {
AccountStore *player.AccountStore
MobStore *world.MobStore
BehaviorStore *action.Store
+ RecipeStore *action.RecipeStore
Hub *net.Hub
Ticks *engine.Engine
WorldFlags map[string]any
@@ -51,6 +52,7 @@ type Game struct {
combatPadWidth int
freeQueue map[string][]QueuedCommand
activeQueue map[string]*QueuedCommand
+ consumeQueue map[string]*QueuedCommand
pendingDepletions []pendingDepletion
}
@@ -62,6 +64,7 @@ func New(dataDir string, colorConfig *config.ColorsConfig) *Game {
AccountStore: player.NewAccountStore(dataDir),
MobStore: world.NewMobStore(dataDir),
BehaviorStore: action.NewStore(dataDir),
+ RecipeStore: action.NewRecipeStore(dataDir),
Ticks: engine.New(),
WorldFlags: make(map[string]any),
ColorConfig: colorConfig,
@@ -70,6 +73,7 @@ func New(dataDir string, colorConfig *config.ColorsConfig) *Game {
loggedInChars: make(map[string]*net.Session),
freeQueue: make(map[string][]QueuedCommand),
activeQueue: make(map[string]*QueuedCommand),
+ consumeQueue: make(map[string]*QueuedCommand),
pendingDepletions: nil,
}
}
@@ -118,6 +122,8 @@ func (g *Game) HandleSession(sess *net.Session, input string) {
g.handleTalkInput(sess, input)
case net.StateDropAllConfirm:
g.handleDropAllConfirm(sess, input)
+ case net.StateCookRecipe:
+ g.handleCookRecipe(sess, input)
}
}
@@ -134,8 +140,10 @@ func classifyCommand(cmd string) CommandClass {
"attack", "kill",
"north", "n", "south", "s", "east", "e",
"west", "w", "up", "u", "down", "d",
- "quit", "use", "burn", "stoke", "search", "walk":
+ "quit", "use", "burn", "stoke", "search", "walk", "cook":
return ClassActive
+ case "eat":
+ return ClassFree
}
if _, ok := verbAliases[cmd]; ok {
return ClassActive
@@ -314,7 +322,7 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
} else {
g.doHelp(sess, strings.Join(args, " "))
}
- case "mine", "chop", "fish", "cut", "use", "pull", "push":
+ case "mine", "chop", "fish", "cut", "pull", "push":
g.CancelAction(p)
if len(args) == 0 {
target := g.resolveDefaultTarget(p.RoomID, cmd)
@@ -328,6 +336,15 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
g.StartAction(sess, cmd, strings.Join(args, " "))
return
}
+ case "use":
+ g.doUse(sess, strings.Join(args, " "))
+ return
+ case "cook":
+ g.doCook(sess, strings.Join(args, " "))
+ return
+ case "eat":
+ g.doEat(sess, strings.Join(args, " "))
+ return
case "talk", "speak", "ask":
g.CancelAction(p)
if len(args) == 0 {
@@ -413,7 +430,7 @@ func (g *Game) ProcessQueuedCommands() {
}
switch as.Type {
case ActionGathering, ActionCombating, ActionUsing, ActionTalking,
- ActionToggling, ActionBurning, ActionStoking, ActionResting, ActionWalking:
+ ActionToggling, ActionBurning, ActionStoking, ActionResting, ActionWalking, ActionCooking:
default:
p.ActionState = nil
}
@@ -455,7 +472,8 @@ func (g *Game) ProcessQueuedCommands() {
g.executeCommand(qc.Session, parts[0], parts[1:], qc.Command+" "+qc.Args)
}
isBusy := p.Action != nil || len(p.WalkSequence) > 0 || combat.GetCombat(p.Name) != nil
- if wasBusy || !isBusy {
+ _, isResting := g.restTimers[p.Name]
+ if !isResting && (wasBusy || !isBusy) {
g.writePrompt(qc.Session)
}
}