-
Notifications
You must be signed in to change notification settings - Fork 141
/
respiration.go
47 lines (38 loc) · 1.03 KB
/
respiration.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
package enchantment
import (
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
)
// Respiration extends underwater breathing time by +15 seconds per enchantment level in addition to the default time of
// 15 seconds.
type Respiration struct{}
// Name ...
func (Respiration) Name() string {
return "Respiration"
}
// MaxLevel ...
func (Respiration) MaxLevel() int {
return 3
}
// Cost ...
func (Respiration) Cost(level int) (int, int) {
min := 10 * level
return min, min + 30
}
// Rarity ...
func (Respiration) Rarity() item.EnchantmentRarity {
return item.EnchantmentRarityRare
}
// Chance returns the chance of the enchantment blocking the air supply from ticking.
func (Respiration) Chance(level int) float64 {
return 1.0 / float64(level+1)
}
// CompatibleWithEnchantment ...
func (Respiration) CompatibleWithEnchantment(item.EnchantmentType) bool {
return true
}
// CompatibleWithItem ...
func (Respiration) CompatibleWithItem(i world.Item) bool {
h, ok := i.(item.HelmetType)
return ok && h.Helmet()
}