From 8ee8982b8759bcae116647cc993867f4c8b0a6ce Mon Sep 17 00:00:00 2001 From: workhorse Date: Fri, 19 Jun 2026 20:24:52 -0400 Subject: reorganized items, objects, and rooms in directories. oranized module names. added startup checks. --- internal/game/cmd_eat.go | 145 ----------------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 internal/game/cmd_eat.go (limited to 'internal/game/cmd_eat.go') 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 -} -- cgit v1.2.3