diff options
| author | historia <[not public]> | 2026-06-09 17:15:13 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-09 17:15:13 -0400 |
| commit | 9edc568e16741d443b67fbd23b0d91790085ced9 (patch) | |
| tree | d54be40531ba124dcf8299f9e94bfba4ece273ae /internal/combat/state.go | |
| parent | 56be6a3f45830594225a765b406816e6179ccde1 (diff) | |
| download | thehouseoficarus-9edc568e16741d443b67fbd23b0d91790085ced9.tar.gz | |
combat, mobs, parsing, toggles, hard disconnect handling
Diffstat (limited to 'internal/combat/state.go')
| -rw-r--r-- | internal/combat/state.go | 28 |
1 files changed, 23 insertions, 5 deletions
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() |
