package game import ( "fmt" "strings" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" "thehouseoficarus/internal/world" ) // taskWorkVerb returns the flavor verb for working on a task worksite. Designers // set `verb:` on the mob (e.g. "survey", "prospect", "build"); the default is // "work on". The player-facing command is always `work` (or `attack`). func taskWorkVerb(mob *world.MobInstance) string { if mob != nil && mob.Verb != "" { return mob.Verb } return "work on" } // progressBar renders a bar that fills as progress rises toward max — the // inverse of hpBar. It is used for task worksites whose internal HP drains to 0 // to complete the work (progress = MaxHP - HP). func (g *Game) progressBar(sess *net.Session, progress, max int) string { if max <= 0 { max = 1 } if progress < 0 { progress = 0 } if progress > max { progress = max } pct := float64(progress) / float64(max) * 100.0 var fgColor int switch { case pct >= 70: fgColor = 82 case pct >= 40: fgColor = 220 default: fgColor = 39 } unicode := sess.Player != nil && sess.Player.OptionBool("unicode") style := &BarStyle{FilledColor: fgColor, EmptyColor: 238, EmptyDim: true} bar := RenderColoredBar(progress, max, 10, unicode, style, g.colorMode(sess)) return "[" + bar + "]" } // writeTaskProgress prints the per-tick progress line for a task worksite, // mirroring the combat hit line but framed as labor instead of damage. func (g *Game) writeTaskProgress(sess *net.Session, p *player.Player, mob *world.MobInstance, dmg int, gains []xpGain) { progress := mob.MaxHP - mob.HP if progress < 0 { progress = 0 } pct := 0 if mob.MaxHP > 0 { pct = progress * 100 / mob.MaxHP } noun := mob.ProgressNoun if noun == "" { noun = "work" } prefix := fmt.Sprintf("You advance the %s on %s.", noun, g.colorize(sess, "mob", mobDisplayName(mob, true))) line := fmt.Sprintf("%s %s %3d%%", prefix, g.progressBar(sess, progress, mob.MaxHP), pct) if p.OptionBool("xp_drops") && len(gains) > 0 { var parts []string for _, gain := range gains { parts = append(parts, fmt.Sprintf("+%dxp %s", gain.XP, player.SkillAbbr[player.SkillName(gain.Skill)])) } line += g.colorize(sess, "xp", " ("+strings.Join(parts, ", ")+")") } sess.WriteLine(line) }