From 9edc568e16741d443b67fbd23b0d91790085ced9 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 9 Jun 2026 17:15:13 -0400 Subject: combat, mobs, parsing, toggles, hard disconnect handling --- internal/combat/state.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'internal/combat') diff --git a/internal/combat/state.go b/internal/combat/state.go index b0e7dfe..0d8de45 100644 --- a/internal/combat/state.go +++ b/internal/combat/state.go @@ -5,9 +5,10 @@ import "sync" type State struct { PlayerName string MobID string - MobAttacks int // attacks mob has made (3-hit flee rule) - PlayerDamage int // total damage player dealt this combat + MobAttacks int // attacks mob has made (3-hit flee rule) + PlayerDamage int // total damage player dealt this combat Active bool + LockedTicks int // ticks remaining before player can move } var ( @@ -20,9 +21,10 @@ func EnterCombat(playerName, mobID string) { mu.Lock() defer mu.Unlock() combatants[playerName] = &State{ - PlayerName: playerName, - MobID: mobID, - Active: true, + PlayerName: playerName, + MobID: mobID, + Active: true, + LockedTicks: 15, } mobTargets[mobID] = playerName } @@ -51,6 +53,12 @@ func IsMobInCombat(mobID string) bool { return ok } +func GetMobTarget(mobID string) string { + mu.Lock() + defer mu.Unlock() + return mobTargets[mobID] +} + func RecordMobAttack(playerName string) { mu.Lock() defer mu.Unlock() @@ -77,6 +85,16 @@ func RecordPlayerDamage(playerName string, dmg int) { } } +func TickCombat() { + mu.Lock() + defer mu.Unlock() + for _, state := range combatants { + if state.LockedTicks > 0 { + state.LockedTicks-- + } + } +} + func GetTotalDamage(playerName string) int { mu.Lock() defer mu.Unlock() -- cgit v1.2.3