aboutsummaryrefslogtreecommitdiff
path: root/internal/game/action_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/action_clean.go
parent97a1a908b9e6e6d3516628c139c9b64262b4fe08 (diff)
downloadthehouseoficarus-458916fb78dcef3ff77cb29b7ba98d9f646819fc.tar.gz
feat: rough pharmacy skill added
Diffstat (limited to 'internal/game/action_clean.go')
-rw-r--r--internal/game/action_clean.go123
1 files changed, 123 insertions, 0 deletions
diff --git a/internal/game/action_clean.go b/internal/game/action_clean.go
new file mode 100644
index 0000000..dab3619
--- /dev/null
+++ b/internal/game/action_clean.go
@@ -0,0 +1,123 @@
+package game
+
+import (
+ "fmt"
+ "strings"
+
+ "thehouseoficarus/internal/engine"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) advanceClean(sess *net.Session, p *player.Player) {
+ phase, _ := p.BackgroundAction.Data["phase"].(int)
+ filter, _ := p.BackgroundAction.Data["filter"].(string)
+
+ if phase == 0 {
+ p.BackgroundAction.Data["phase"] = 1
+ p.BackgroundAction.WaitLeft = engine.ToTicks(2)
+ return
+ }
+
+ allRecipes, err := g.RecipeStore.LoadAll()
+ if err != nil {
+ g.CancelBackgroundAction(p)
+ return
+ }
+
+ var recipe *cleanMatch
+ for _, r := range allRecipes {
+ if r.Type != "clean" {
+ continue
+ }
+ if filter != "" {
+ if len(r.Consume) == 0 || len(r.Consume[0].Items) == 0 {
+ continue
+ }
+ if !strings.Contains(r.Consume[0].Items[0], filter) &&
+ !strings.Contains(r.Output, filter) {
+ continue
+ }
+ }
+ if p.Level(player.Pharmacy) < r.Level {
+ continue
+ }
+ if !r.HasAllItems(p.HasItem) {
+ continue
+ }
+ recipe = &cleanMatch{r.Consume[0].Items[0], r.Output, r.XP, r.Message}
+ break
+ }
+
+ if recipe == nil {
+ sess.WriteLine("\nYou've finished cleaning herbs.")
+ g.CancelBackgroundAction(p)
+ return
+ }
+
+ for i := 0; i < 28; i++ {
+ slot := p.InvSlot(i)
+ if slot != nil && slot.ItemID == recipe.consumeID {
+ slot.ItemID = recipe.outputID
+ break
+ }
+ }
+
+ if recipe.xp > 0 {
+ if newLevel := p.AddSkillXP(player.Pharmacy, recipe.xp); newLevel > 0 {
+ sess.WriteLine(g.colorize(sess, "level_up",
+ fmt.Sprintf("*** You are now level %d pharmacy! ***", newLevel)))
+ }
+ }
+ g.AccountStore.SaveCharacter(p)
+
+ msg := recipe.message
+ if msg == "" {
+ outDef, _ := g.ItemStore.Load(recipe.outputID)
+ outputName := recipe.outputID
+ if outDef != nil {
+ outputName = outDef.Name
+ }
+ msg = fmt.Sprintf("You clean a %s.", outputName)
+ }
+ if p.OptionBool("xp_drops") && recipe.xp > 0 {
+ abbr := player.SkillAbbr[player.Pharmacy]
+ msg += g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp %s)", recipe.xp, abbr))
+ }
+ sess.WriteLine(msg)
+
+ hasMore := false
+ for _, r := range allRecipes {
+ if r.Type != "clean" {
+ continue
+ }
+ if filter != "" {
+ if len(r.Consume) == 0 || len(r.Consume[0].Items) == 0 {
+ continue
+ }
+ if !strings.Contains(r.Consume[0].Items[0], filter) &&
+ !strings.Contains(r.Output, filter) {
+ continue
+ }
+ }
+ if p.Level(player.Pharmacy) >= r.Level && r.HasAllItems(p.HasItem) {
+ hasMore = true
+ break
+ }
+ }
+
+ if !hasMore {
+ sess.WriteLine("\nYou've finished cleaning herbs.")
+ g.CancelBackgroundAction(p)
+ return
+ }
+
+ p.BackgroundAction.WaitLeft = engine.ToTicks(2)
+}
+
+type cleanMatch struct {
+ consumeID string
+ outputID string
+ xp int
+ message string
+}