func (m *Mob) Damage(amount int) { amountLeft := amount if m.shield > 0 { shieldDamage := num.MinI(m.shield, amountLeft) m.shield -= shieldDamage amountLeft -= shieldDamage // Freebie damage reduction from destroying shields. Only really // massive damage penetrates on the same turn. amountLeft = num.MaxI(0, amountLeft-3) } m.health = num.MaxI(0, m.health-amountLeft) }
func (m *Mob) AddShield(amount int) { m.shield = num.MaxI(0, m.shield+amount) }