package game import ( "fmt" "strings" "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) executeIdentify(sess *net.Session, args []string, rawInput string) { g.doIdentify(sess, strings.Join(args, " ")) } func (g *Game) doIdentify(sess *net.Session, input string) { p := sess.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} }