forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharpness.go
46 lines (37 loc) · 1.05 KB
/
sharpness.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package enchantment
import (
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/item"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/world"
)
// Sharpness is an enchantment applied to a sword or axe that increases melee damage.
type Sharpness struct{}
// Name ...
func (Sharpness) Name() string {
return "Sharpness"
}
// MaxLevel ...
func (Sharpness) MaxLevel() int {
return 5
}
// Cost ...
func (Sharpness) Cost(level int) (int, int) {
min := 1 + (level-1)*11
return min, min + 20
}
// Rarity ...
func (Sharpness) Rarity() item.EnchantmentRarity {
return item.EnchantmentRarityCommon
}
// Addend returns the additional damage when attacking with sharpness.
func (Sharpness) Addend(level int) float64 {
return float64(level) * 1.25
}
// CompatibleWithEnchantment ...
func (Sharpness) CompatibleWithEnchantment(item.EnchantmentType) bool {
return true
}
// CompatibleWithItem ...
func (Sharpness) CompatibleWithItem(i world.Item) bool {
t, ok := i.(item.Tool)
return ok && (t.ToolType() == item.TypeSword || t.ToolType() == item.TypeAxe)
}