package model

import "time"

// ShiftHeroEffectDeadlines moves buff/debuff expiry and buff quota windows by d so in-game time
// does not advance during a global server pause (wall clock still moves).
func ShiftHeroEffectDeadlines(h *Hero, d time.Duration) {
	if h == nil || d <= 0 {
		return
	}
	for i := range h.Buffs {
		h.Buffs[i].ExpiresAt = h.Buffs[i].ExpiresAt.Add(d)
		h.Buffs[i].AppliedAt = h.Buffs[i].AppliedAt.Add(d)
	}
	for i := range h.Debuffs {
		h.Debuffs[i].ExpiresAt = h.Debuffs[i].ExpiresAt.Add(d)
		h.Debuffs[i].AppliedAt = h.Debuffs[i].AppliedAt.Add(d)
	}
	if h.BuffQuotaPeriodEnd != nil {
		t := h.BuffQuotaPeriodEnd.Add(d)
		h.BuffQuotaPeriodEnd = &t
	}
	for k, v := range h.BuffCharges {
		if v.PeriodEnd != nil {
			t := v.PeriodEnd.Add(d)
			v.PeriodEnd = &t
		}
		h.BuffCharges[k] = v
	}
}
