forked from df-mc/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protection.go
49 lines (40 loc) · 1.15 KB
/
protection.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
47
48
49
package enchantment
import (
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/item"
"github.com/Adrian8115/dragonfly-Amethyst-Protocol/server/world"
)
// Protection is an armour enchantment which increases the damage reduction.
type Protection struct{}
// Name ...
func (Protection) Name() string {
return "Protection"
}
// MaxLevel ...
func (Protection) MaxLevel() int {
return 4
}
// Cost ...
func (Protection) Cost(level int) (int, int) {
min := 1 + (level-1)*11
return min, min + 11
}
// Rarity ...
func (Protection) Rarity() item.EnchantmentRarity {
return item.EnchantmentRarityCommon
}
// Modifier returns the base protection modifier for the enchantment.
func (Protection) Modifier() float64 {
return 0.04
}
// CompatibleWithEnchantment ...
func (Protection) CompatibleWithEnchantment(t item.EnchantmentType) bool {
_, blastProtection := t.(BlastProtection)
_, fireProtection := t.(FireProtection)
_, projectileProtection := t.(ProjectileProtection)
return !blastProtection && !fireProtection && !projectileProtection
}
// CompatibleWithItem ...
func (Protection) CompatibleWithItem(i world.Item) bool {
_, ok := i.(item.Armour)
return ok
}