aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_clean.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 02:08:55 -0400
committerhistoria <[not public]>2026-06-19 02:08:55 -0400
commit458916fb78dcef3ff77cb29b7ba98d9f646819fc (patch)
tree19cd8b8eef41a1aa00d155bf7953ad2770f91a4c /internal/game/cmd_clean.go
parent97a1a908b9e6e6d3516628c139c9b64262b4fe08 (diff)
downloadthehouseoficarus-458916fb78dcef3ff77cb29b7ba98d9f646819fc.tar.gz
feat: rough pharmacy skill added
Diffstat (limited to 'internal/game/cmd_clean.go')
-rw-r--r--internal/game/cmd_clean.go78
1 files changed, 78 insertions, 0 deletions
diff --git a/internal/game/cmd_clean.go b/internal/game/cmd_clean.go
new file mode 100644
index 0000000..b3d8408
--- /dev/null
+++ b/internal/game/cmd_clean.go
@@ -0,0 +1,78 @@
+package game
+
+import (
+ "strings"
+
+ "thehouseoficarus/internal/action"
+ "thehouseoficarus/internal/combat"
+ "thehouseoficarus/internal/engine"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) doClean(sess *net.Session, input string) {
+ p := sess.Player.(*player.Player)
+
+ if combat.GetCombat(p.Name) != nil {
+ sess.WriteLine("You can't do that during combat!")
+ return
+ }
+
+ allRecipes, err := g.RecipeStore.LoadAll()
+ if err != nil {
+ sess.WriteLine("Error loading recipes.")
+ return
+ }
+
+ filter := strings.TrimSpace(input)
+
+ found := false
+ for _, r := range allRecipes {
+ if r.Type != "clean" {
+ continue
+ }
+ if filter != "" && !matchesCleanFilter(r, filter) {
+ continue
+ }
+ if p.Level(player.Pharmacy) < r.Level {
+ continue
+ }
+ if !r.HasAllItems(p.HasItem) {
+ continue
+ }
+ found = true
+ break
+ }
+
+ if !found {
+ sess.WriteLine("You don't have any herbs to clean.")
+ return
+ }
+
+ g.CancelBackgroundAction(p)
+
+ p.BackgroundAction = &action.Action{
+ Type: "clean",
+ TargetID: "clean_herbs",
+ Data: map[string]any{
+ "phase": 0,
+ "filter": filter,
+ },
+ WaitLeft: engine.ToTicks(1),
+ }
+ p.BackgroundActionState = &ActionState{Type: ActionCleaning}
+
+ sess.WriteLine("\nYou begin cleaning herbs.")
+}
+
+func matchesCleanFilter(r action.RecipeDef, filter string) bool {
+ if len(r.Consume) > 0 && len(r.Consume[0].Items) > 0 {
+ if strings.Contains(r.Consume[0].Items[0], filter) {
+ return true
+ }
+ }
+ if strings.Contains(r.Output, filter) {
+ return true
+ }
+ return false
+}