feat: apply relic passive effects (ATK/DEF boost, heal on kill, gold boost)

This commit is contained in:
2026-03-24 00:50:42 +09:00
parent ecf6ee64d0
commit 3cc6f783b3
3 changed files with 86 additions and 16 deletions

View File

@@ -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
}

View File

@@ -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)