aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_eat.go
diff options
context:
space:
mode:
authorworkhorse <workhorse@localhost.localdomain>2026-06-19 20:24:52 -0400
committerworkhorse <workhorse@localhost.localdomain>2026-06-19 20:24:52 -0400
commit8ee8982b8759bcae116647cc993867f4c8b0a6ce (patch)
treeee01f7b1d745cbc94d9981108a1209527487b3e5 /internal/game/cmd_eat.go
parent2bec24859af8f03c80a0a58e3240519942450167 (diff)
downloadthehouseoficarus-8ee8982b8759bcae116647cc993867f4c8b0a6ce.tar.gz
reorganized items, objects, and rooms in directories. oranized module names. added startup checks.
Diffstat (limited to 'internal/game/cmd_eat.go')
-rw-r--r--internal/game/cmd_eat.go145
1 files changed, 0 insertions, 145 deletions
diff --git a/internal/game/cmd_eat.go b/internal/game/cmd_eat.go
deleted file mode 100644
index f94ade3..0000000
--- a/internal/game/cmd_eat.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package game
-
-import (
- "fmt"
- "time"
-
- "thehouseoficarus/internal/net"
- "thehouseoficarus/internal/object"
- "thehouseoficarus/internal/player"
-)
-
-func (g *Game) doEat(sess *net.Session, input string) {
- p := sess.Player
-
- if input == "" {
- sess.WriteLine("Eat what?")
- return
- }
-
- qty, itemName := parseQty(input)
- _ = qty
-
- matches := g.findInventoryMatches(itemName, p)
- if len(matches) == 0 {
- sess.WriteLine(fmt.Sprintf("You don't have any '%s'.", itemName))
- return
- }
-
- unique := uniqueItemNames(matches)
- if len(unique) > 1 {
- g.showWhichOne(sess, matches)
- return
- }
-
- itemID := matches[0].ID
- def, _ := g.ItemStore.Load(itemID)
-
- if def == nil || def.EatMessage == "" {
- sess.WriteLine("You can't eat that.")
- return
- }
-
- if p.ConsumeCooldown > 0 {
- sess.WriteLine("You're still digesting your last meal.")
- return
- }
-
- g.cancelRest(p.Name)
-
- if p.Action == nil && len(p.WalkSequence) == 0 {
- g.doEatNow(sess, p, itemID, def)
- return
- }
-
- g.cancelAction(p)
-
- g.consumeQueue[p.Name] = &QueuedCommand{
- Session: sess,
- Command: "eat",
- Args: itemID,
- Timestamp: time.Now(),
- }
-
- if !p.OptionBool("queue_silently") {
- sess.WriteLine(fmt.Sprintf("\nYou prepare to eat %s.", g.itemColorize(sess, def, def.Name)))
- }
-}
-
-func (g *Game) doEatNow(sess *net.Session, p *player.Player, itemID string, def *object.ItemDef) {
- if def == nil {
- var err error
- def, err = g.ItemStore.Load(itemID)
- if err != nil || def.EatMessage == "" {
- return
- }
- }
-
- p.RemoveItem(itemID, 1)
-
- p.HP += def.HealValue
- maxHP := p.MaxHP()
- if p.HP > maxHP {
- p.HP = maxHP
- }
- if p.HP < 0 {
- p.HP = 0
- }
-
- if def.HealValue != 0 {
- p.StartRegen()
- }
-
- p.ConsumeCooldown = 3
- g.AccountStore.SaveCharacter(p)
-
- p.ActionState = &ActionState{Type: ActionEating, TargetName: def.Name}
-
- sess.WriteLine(g.colorize(sess, "eat_food", def.EatMessage))
-
- if p.HP <= 0 {
- g.endCombat(sess, p, nil)
- }
-}
-
-func (g *Game) processConsumeQueue(p *player.Player, sess *net.Session) bool {
- qc, ok := g.consumeQueue[p.Name]
- if !ok {
- return false
- }
- delete(g.consumeQueue, p.Name)
-
- itemID := qc.Args
- def, err := g.ItemStore.Load(itemID)
-
- if qc.Command == "drink" {
- if err != nil || (def.PotionEffect == "" && def.HealValue <= 0) {
- return false
- }
- if p.ConsumeCooldown > 0 {
- return false
- }
- if !p.HasItem(itemID) {
- sess.WriteLine("You no longer have that to drink.")
- return false
- }
- g.applyPotion(sess, p, itemID, def)
- return true
- }
-
- if err != nil || def.EatMessage == "" {
- return false
- }
-
- if p.ConsumeCooldown > 0 {
- return false
- }
-
- if !p.HasItem(itemID) {
- sess.WriteLine("You no longer have that to eat.")
- return false
- }
-
- g.doEatNow(sess, p, itemID, def)
- return true
-}