package game import ( "fmt" "thehouseoficarus/internal/behavior" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" ) func (g *Game) advanceIdentify(sess *net.Session, p *player.Player) { data, ok := p.Action.Data.(*behavior.IdentifyData) if !ok { g.cancelAction(p) return } junkID := data.JunkID xpPer := data.XPPer scrapCount := p.CountItem("scrap") if scrapCount == 0 { sess.WriteLine("You don't have any scrap.") 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" { 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 = g.itemColorize(sess, def, def.Name) } msg := fmt.Sprintf("The altar hums. You identify %d scrap into %d %s.", scrapCount, totalJunk, junkName) g.awardSkillXP(sess, p, player.Scavenging, totalXP) if p.OptionBool("xp_drops") && totalXP > 0 { msg += g.formatXpDropSingle(sess, p, player.Scavenging, totalXP) } sess.WriteLine(msg) g.AccountStore.SaveCharacter(p) g.cancelAction(p) }