up3
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled

This commit is contained in:
2026-07-09 08:33:57 +08:00
commit 26ed99fda6
845 changed files with 75419 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package enchantment
import (
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
)
// Sharpness is an enchantment applied to a sword or axe that increases melee
// damage.
var Sharpness sharpness
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) {
minCost := 1 + (level-1)*11
return minCost, minCost + 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)
}