aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_attack.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-24 22:55:35 -0400
committerhistoria <[not public]>2026-06-24 22:55:35 -0400
commit15b7e221b799ef107dec44ecdb294026dfd3d059 (patch)
tree3748e464a77f0f082bea1567e9d6990052054961 /internal/game/cmd_attack.go
parent9d4b799db4868bcab291b83599ff088763cd4ed6 (diff)
downloadthehouseoficarus-15b7e221b799ef107dec44ecdb294026dfd3d059.tar.gz
refactor: pulled techs out to yaml files, unified numerous combat functions, broke up game object
Diffstat (limited to 'internal/game/cmd_attack.go')
-rw-r--r--internal/game/cmd_attack.go31
1 files changed, 7 insertions, 24 deletions
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()