feat: apply relic passive effects (ATK/DEF boost, heal on kill, gold boost)
This commit is contained in:
@@ -82,6 +82,11 @@ func (p *Player) EffectiveATK() int {
|
||||
atk += item.Bonus
|
||||
}
|
||||
}
|
||||
for _, r := range p.Relics {
|
||||
if r.Effect == RelicATKBoost {
|
||||
atk += r.Value
|
||||
}
|
||||
}
|
||||
return atk
|
||||
}
|
||||
|
||||
@@ -92,5 +97,10 @@ func (p *Player) EffectiveDEF() int {
|
||||
def += item.Bonus
|
||||
}
|
||||
}
|
||||
for _, r := range p.Relics {
|
||||
if r.Effect == RelicDEFBoost {
|
||||
def += r.Value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
@@ -37,6 +37,18 @@ func TestAllClasses(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelicEffects(t *testing.T) {
|
||||
p := NewPlayer("test", ClassWarrior)
|
||||
p.Relics = append(p.Relics, Relic{Name: "Power Amulet", Effect: RelicATKBoost, Value: 3})
|
||||
if p.EffectiveATK() != 15 {
|
||||
t.Errorf("ATK with relic: got %d, want 15", p.EffectiveATK())
|
||||
}
|
||||
p.Relics = append(p.Relics, Relic{Name: "Iron Ward", Effect: RelicDEFBoost, Value: 2})
|
||||
if p.EffectiveDEF() != 10 {
|
||||
t.Errorf("DEF with relic: got %d, want 10", p.EffectiveDEF())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlayerTakeDamage(t *testing.T) {
|
||||
p := NewPlayer("test", ClassWarrior)
|
||||
p.TakeDamage(30)
|
||||
|
||||
Reference in New Issue
Block a user