diff options
| author | historia <[not public]> | 2026-06-19 02:40:22 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-19 02:40:22 -0400 |
| commit | 2ae4a052fd1c15c3c6ba0f1dd324d896371aaffc (patch) | |
| tree | 3caef60f71a462b7e7ace668053e1f02fb61db15 /internal/game/tick.go | |
| parent | 86aec0e14eb6fec0a39d742bab1761dad8d7012c (diff) | |
| download | thehouseoficarus-2ae4a052fd1c15c3c6ba0f1dd324d896371aaffc.tar.gz | |
feat: rough technology skill added
Diffstat (limited to 'internal/game/tick.go')
| -rw-r--r-- | internal/game/tick.go | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/internal/game/tick.go b/internal/game/tick.go index 8c40c96..4ab7e13 100644 --- a/internal/game/tick.go +++ b/internal/game/tick.go @@ -46,7 +46,19 @@ func (g *Game) RegenTick() { p.RegenerateTick = 0 continue } - p.RegenerateTick-- + regenSpeed := 1 + if p.ActiveTechs != nil { + for id := range p.ActiveTechs { + def := GetTechDef(id) + if def != nil && def.Effects.HPRegenMulti > 0 { + multi := int(def.Effects.HPRegenMulti) + if multi > regenSpeed { + regenSpeed = multi + } + } + } + } + p.RegenerateTick -= regenSpeed if p.RegenerateTick <= 0 { p.HP++ if p.HP >= p.MaxHP() { @@ -201,6 +213,69 @@ func (g *Game) legalMobExits(inst *world.MobInstance) []int { return legal } +func (g *Game) TechTick() { + if g.Hub == nil { + return + } + for _, sess := range g.Hub.AllSessions() { + p, ok := sess.Player.(*player.Player) + if !ok || p == nil || len(p.ActiveTechs) == 0 { + continue + } + + totalDrain := 0.0 + hasPreserve := false + preserveReduction := 0.0 + + for id := range p.ActiveTechs { + def := GetTechDef(id) + if def != nil && def.Effects.PreserveDrain > 0 { + hasPreserve = true + preserveReduction = def.Effects.PreserveDrain + } + } + + for id := range p.ActiveTechs { + def := GetTechDef(id) + if def == nil { + continue + } + if p.TechActivatedSinceTick[id] { + continue + } + drain := def.DrainRate + if hasPreserve && def.Effects.PreserveDrain == 0 { + drain *= (1.0 - preserveReduction) + } + totalDrain += drain + } + + p.TechActivatedSinceTick = nil + + equipTechBonus := g.totalTechBonus(p) + if equipTechBonus > 0 { + reduction := float64(equipTechBonus) * 0.01 + if reduction > 0.5 { + reduction = 0.5 + } + totalDrain *= (1.0 - reduction) + } + + if totalDrain <= 0 { + continue + } + + p.Battery -= totalDrain + if p.Battery <= 0 { + p.Battery = 0 + p.DeactivateAllTechs() + sess.WriteLine(g.colorize(sess, "tech_depleted", + "\nYour battery is depleted! All tech has been disabled.")) + g.writePrompt(sess) + } + } +} + func (g *Game) ConsumeTick() { if g.Hub == nil { return |
