From 15b7e221b799ef107dec44ecdb294026dfd3d059 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 24 Jun 2026 22:55:35 -0400 Subject: refactor: pulled techs out to yaml files, unified numerous combat functions, broke up game object --- internal/game/cmd_attack.go | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'internal/game/cmd_attack.go') diff --git a/internal/game/cmd_attack.go b/internal/game/cmd_attack.go index f3b99c0..27307fe 100644 --- a/internal/game/cmd_attack.go +++ b/internal/game/cmd_attack.go @@ -272,11 +272,8 @@ func (g *Game) playerAttack(sess *net.Session, p *player.Player, mob *world.MobI attackType, weaponType, attRoll, defRoll, maxHit := g.calculatePlayerAttackRoll(p, mob) if g.isSafespotted(p.Name) && attackType != "ranged" && attackType != "science" { - g.safespotMu.Lock() - ss, ok := g.safespotStates[p.Name] - g.safespotMu.Unlock() - if ok { - g.forceLeaveSafespot(sess, p, ss, "You leave your cover to close in for melee!") + if ss, ok := g.safespot.Get(p.Name); ok { + g.forceLeaveSafespot(sess, p, &ss, "You leave your cover to close in for melee!") } } @@ -414,14 +411,7 @@ func (g *Game) applyPlayerHit(sess *net.Session, p *player.Player, mob *world.Mo prefix += strings.Repeat(" ", w-visLen+1) } hpSuffix := fmt.Sprintf("%s [%2d/%d]", g.hpBar(sess, mob.HP, mob.MaxHP), mob.HP, mob.MaxHP) - line := prefix + hpSuffix - 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, ", ")+")") - } + line := prefix + hpSuffix + g.formatXpDrop(sess, p, gains) sess.WriteLine(line) } @@ -556,14 +546,11 @@ func (g *Game) applyMobHit(sess *net.Session, p *player.Player, mob *world.MobIn hpSuffix := fmt.Sprintf("%s [%2d/%d]", g.hpBar(sess, p.HP, p.MaxHP()), p.HP, p.MaxHP()) sess.WriteLine(prefix + hpSuffix) - g.safespotMu.Lock() - ss, hasSS := g.safespotStates[p.Name] - if hasSS && ss.HideCountdown > 0 { - delete(g.safespotStates, p.Name) + if ss, hasSS := g.safespot.Get(p.Name); hasSS && ss.HideCountdown > 0 { + g.safespot.Delete(p.Name) p.ActionState = &ActionState{Type: ActionCombating, TargetName: mob.Name} sess.WriteLine(g.colorize(sess, "error", "You're hit while repositioning! You failed to hide.")) } - g.safespotMu.Unlock() if p.MoveTicks > 0 { p.ClearMoveState() @@ -702,12 +689,8 @@ func (g *Game) killPlayer(sess *net.Session, p *player.Player, mob *world.MobIns sess.WriteLine(g.colorize(sess, "death", "\nOh dear, you are dead!")) p.ClearMoveState() p.HazardTimer = 0 - g.safespotMu.Lock() - if ss, ok := g.safespotStates[p.Name]; ok { - g.safespotMu.Unlock() - g.forceLeaveSafespot(sess, p, ss, "") - } else { - g.safespotMu.Unlock() + if ss, ok := g.safespot.Get(p.Name); ok { + g.forceLeaveSafespot(sess, p, &ss, "") } g.dropItemsOnDeath(p) p.HP = p.MaxHP() -- cgit v1.2.3