aboutsummaryrefslogtreecommitdiff
path: root/internal/game/action_identify.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 02:51:05 -0400
committerhistoria <[not public]>2026-06-19 02:51:05 -0400
commitdea4a06764c507699cf9adcd1fd0a572d227aff0 (patch)
tree25769809d34db70cf0bec7d8c6d3422c23780a55 /internal/game/action_identify.go
parent2ae4a052fd1c15c3c6ba0f1dd324d896371aaffc (diff)
downloadthehouseoficarus-dea4a06764c507699cf9adcd1fd0a572d227aff0.tar.gz
feat: scavenge/scrap system started
Diffstat (limited to 'internal/game/action_identify.go')
-rw-r--r--internal/game/action_identify.go80
1 files changed, 80 insertions, 0 deletions
diff --git a/internal/game/action_identify.go b/internal/game/action_identify.go
new file mode 100644
index 0000000..3f63e62
--- /dev/null
+++ b/internal/game/action_identify.go
@@ -0,0 +1,80 @@
+package game
+
+import (
+ "fmt"
+
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) advanceIdentify(sess *net.Session, p *player.Player) {
+ junkID := p.Action.Data["junk_id"].(string)
+ xpPer := p.Action.Data["xp_per"].(int)
+
+ scrapCount := p.CountItem("scrap_metal")
+ if scrapCount == 0 {
+ sess.WriteLine("You don't have any scrap metal.")
+ g.CancelAction(p)
+ return
+ }
+
+ scavLevel := p.Level(player.Scavenging)
+ multiplier := junkMultiplier(junkID, scavLevel)
+ totalJunk := scrapCount * multiplier
+
+ hasExistingStack := false
+ for i := 0; i < 28; i++ {
+ slot := p.InvSlot(i)
+ if slot != nil && slot.ItemID == junkID {
+ hasExistingStack = true
+ break
+ }
+ }
+ if !hasExistingStack && p.FirstFreeSlot() == -1 {
+ sess.WriteLine("Your inventory is too full!")
+ g.CancelAction(p)
+ return
+ }
+
+ for i := 0; i < 28; i++ {
+ slot := p.InvSlot(i)
+ if slot != nil && slot.ItemID == "scrap_metal" {
+ p.SetInvSlot(i, nil)
+ }
+ }
+
+ placed := false
+ for i := 0; i < 28; i++ {
+ slot := p.InvSlot(i)
+ if slot != nil && slot.ItemID == junkID {
+ slot.Quantity += totalJunk
+ placed = true
+ break
+ }
+ }
+ if !placed {
+ freeSlot := p.FirstFreeSlot()
+ p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: junkID, Quantity: totalJunk})
+ }
+
+ totalXP := scrapCount * xpPer
+ junkName := junkID
+ if def, err := g.ItemStore.Load(junkID); err == nil {
+ junkName = def.Name
+ }
+
+ msg := fmt.Sprintf("The altar hums. You identify %d scrap metal into %d %s.", scrapCount, totalJunk, junkName)
+
+ if newLevel := p.AddSkillXP(player.Scavenging, totalXP); newLevel > 0 {
+ sess.WriteLine(g.colorize(sess, "level_up",
+ fmt.Sprintf("*** You are now level %d scavenging! ***", newLevel)))
+ }
+
+ if p.OptionBool("xp_drops") && totalXP > 0 {
+ msg += g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp scv)", totalXP))
+ }
+ sess.WriteLine(msg)
+
+ g.AccountStore.SaveCharacter(p)
+ g.CancelAction(p)
+}