Ultralight/game/logic.go
2024-04-03 18:18:55 -04:00

39 lines
777 B
Go

package game
import (
"git.vertinext.com/roryejinn/Ultralight/game"
"strings"
"math/rand/v2"
)
func (p *Player) AdjustStats(which string, newvalue int) *Player {
switch strings.ToLower(which) {
case "strength","str":
p.stats.strength.value = newvalue
case "endurance","end":
p.stats.endurance.value = newvalue
p.stats.health.value = 5 + (5*newvalue)
case "wisdom","wis":
p.stats.wisdom.value = newvalue
case "intelligence","int":
p.stats.intelligence.value = newvalue
case "dexterity","dex":
p.stats.dexterity.value = newvalue
}
return p
}
func (p *Player) AdjustMoney(adjustment int) *Player {
p.money += adjustment
return p
}
func (i Item) GetAmount() int {
chance := rand.IntN(100)+1
if chance <= i.drop {
return 2
} else {
return 1
}
}