aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_id.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/cmd_id.go
parent2ae4a052fd1c15c3c6ba0f1dd324d896371aaffc (diff)
downloadthehouseoficarus-dea4a06764c507699cf9adcd1fd0a572d227aff0.tar.gz
feat: scavenge/scrap system started
Diffstat (limited to 'internal/game/cmd_id.go')
-rw-r--r--internal/game/cmd_id.go144
1 files changed, 144 insertions, 0 deletions
diff --git a/internal/game/cmd_id.go b/internal/game/cmd_id.go
new file mode 100644
index 0000000..5ea146d
--- /dev/null
+++ b/internal/game/cmd_id.go
@@ -0,0 +1,144 @@
+package game
+
+import (
+ "fmt"
+
+ "thehouseoficarus/internal/action"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+type altarConfig struct {
+ AltarID string
+ IdentifierID string
+ JunkID string
+ LevelReq int
+ XPPer int
+}
+
+var altarConfigs = []altarConfig{
+ {"solar_altar", "solar_identifier", "solarjunk", 1, 5},
+ {"hydro_altar", "hydro_identifier", "hydrojunk", 14, 8},
+ {"cosmic_altar", "cosmic_identifier", "cosmicjunk", 27, 10},
+ {"eco_altar", "eco_identifier", "ecojunk", 28, 12},
+ {"chaos_altar", "chaos_identifier", "chaosjunk", 35, 11},
+ {"bio_altar", "bio_identifier", "biojunk", 44, 16},
+ {"nature_altar", "nature_identifier", "naturejunk", 44, 16},
+ {"law_altar", "law_identifier", "lawjunk", 54, 18},
+ {"death_altar", "death_identifier", "deathjunk", 65, 22},
+ {"blood_altar", "blood_identifier", "bloodjunk", 77, 28},
+}
+
+type junkMultiplierEntry struct {
+ Level int
+ Multiplier int
+}
+
+var junkMultipliers = map[string][]junkMultiplierEntry{
+ "solarjunk": {
+ {1, 1}, {22, 2}, {44, 3}, {66, 4}, {88, 5}, {99, 6},
+ },
+ "hydrojunk": {
+ {14, 1}, {36, 2}, {66, 3}, {88, 4},
+ },
+ "cosmicjunk": {
+ {27, 1}, {56, 2}, {78, 3},
+ },
+ "ecojunk": {
+ {28, 1}, {56, 2}, {78, 3},
+ },
+ "chaosjunk": {
+ {35, 1}, {66, 2}, {88, 3},
+ },
+ "biojunk": {
+ {44, 1}, {78, 2}, {99, 3},
+ },
+ "naturejunk": {
+ {44, 1}, {78, 2}, {99, 3},
+ },
+ "lawjunk": {
+ {54, 1}, {88, 2},
+ },
+ "deathjunk": {
+ {65, 1}, {99, 2},
+ },
+ "bloodjunk": {
+ {77, 1}, {99, 2},
+ },
+}
+
+func junkMultiplier(junkID string, level int) int {
+ entries, ok := junkMultipliers[junkID]
+ if !ok {
+ return 1
+ }
+ mult := 1
+ for _, e := range entries {
+ if level >= e.Level {
+ mult = e.Multiplier
+ }
+ }
+ return mult
+}
+
+func (g *Game) doIdentify(sess *net.Session, input string) {
+ p := sess.Player.(*player.Player)
+ g.CancelAction(p)
+
+ var found altarConfig
+ foundAny := false
+ for _, ac := range altarConfigs {
+ if defID, _ := g.findStation(p.RoomID, []string{ac.AltarID}); defID != "" {
+ found = ac
+ foundAny = true
+ break
+ }
+ }
+ if !foundAny {
+ sess.WriteLine("There is no altar here.")
+ return
+ }
+
+ identifierName := found.IdentifierID
+ if def, err := g.ItemStore.Load(found.IdentifierID); err == nil {
+ identifierName = def.Name
+ }
+ if !p.HasItem(found.IdentifierID) {
+ sess.WriteLine(fmt.Sprintf("You need a %s to use this altar.", identifierName))
+ return
+ }
+
+ scrapCount := p.CountItem("scrap_metal")
+ if scrapCount == 0 {
+ sess.WriteLine("You don't have any scrap metal.")
+ return
+ }
+
+ scavLevel := p.Level(player.Scavenging)
+ if scavLevel < found.LevelReq {
+ junkName := found.JunkID
+ if def, err := g.ItemStore.Load(found.JunkID); err == nil {
+ junkName = def.Name
+ }
+ sess.WriteLine(fmt.Sprintf("You need level %d scavenging to identify %s.", found.LevelReq, junkName))
+ return
+ }
+
+ altarName := found.AltarID
+ if def, err := g.ObjectStore.Load(found.AltarID); err == nil {
+ altarName = def.Name
+ }
+
+ p.Action = &action.Action{
+ Type: "identify",
+ TargetID: found.AltarID,
+ TargetName: altarName,
+ WaitLeft: 1,
+ Data: map[string]any{
+ "junk_id": found.JunkID,
+ "xp_per": found.XPPer,
+ "level_req": found.LevelReq,
+ },
+ }
+ p.ActionState = &ActionState{Type: ActionIdentifying, TargetName: altarName}
+}