aboutsummaryrefslogtreecommitdiff
path: root/internal/game/buff.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 13:28:06 -0400
committerhistoria <[not public]>2026-06-19 13:28:06 -0400
commit3a58125d14bb307f861b38c6c5b0a63babde7e08 (patch)
treebd89e866447d55e6dffd447d8ef5fabf9b8fbe9d /internal/game/buff.go
parent575a71dcfed3b9fa44af244836f638a23df05a9a (diff)
downloadthehouseoficarus-3a58125d14bb307f861b38c6c5b0a63babde7e08.tar.gz
feat: all skills kind of implemented, random prototype content added
Diffstat (limited to 'internal/game/buff.go')
-rw-r--r--internal/game/buff.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/internal/game/buff.go b/internal/game/buff.go
new file mode 100644
index 0000000..39abd8a
--- /dev/null
+++ b/internal/game/buff.go
@@ -0,0 +1,55 @@
+package game
+
+import (
+ "strings"
+
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) BuffTick() {
+ if g.Hub == nil {
+ return
+ }
+ for _, sess := range g.Hub.AllSessions() {
+ if sess.Player == nil {
+ continue
+ }
+ p := sess.Player.(*player.Player)
+ remaining := make([]player.PotionBuff, 0, len(p.ActiveBuffs))
+ dirty := false
+ for _, buff := range p.ActiveBuffs {
+ buff.TicksLeft--
+ if buff.TicksLeft > 0 {
+ remaining = append(remaining, buff)
+ } else {
+ dirty = true
+ }
+ }
+ if dirty {
+ p.ActiveBuffs = remaining
+ sess.WriteLine(g.colorize(sess, "broadcast", "\nYour potion buff has worn off."))
+ }
+ }
+}
+
+func (g *Game) buffLevelBonus(p *player.Player, stat string) int {
+ if g.Hub == nil {
+ return 0
+ }
+ totalPercent := 0
+ for _, buff := range p.ActiveBuffs {
+ if strings.EqualFold(buff.Stat, stat) {
+ totalPercent += buff.BonusPercent
+ }
+ }
+ if totalPercent == 0 {
+ return 0
+ }
+ baseLevel := p.Level(player.SkillName(strings.ToLower(stat)))
+ return baseLevel * totalPercent / 100
+}
+
+func (g *Game) totalBuffedLevel(sess *net.Session, p *player.Player, stat string) int {
+ return p.Level(player.SkillName(strings.ToLower(stat))) + g.buffLevelBonus(p, stat)
+}