Add durable recipe discovery and profession crafting
This commit is contained in:
@@ -89,6 +89,7 @@ func (w *World) RefreshStats(c *Character) {
|
||||
w.revalidateEquipment(c)
|
||||
c.View.Stats = w.statValues(c, true)
|
||||
w.refreshGathering(c)
|
||||
w.refreshCrafting(c)
|
||||
attack := w.playerAttack(c)
|
||||
c.View.Attack = &attack
|
||||
c.View.Entity.MaxHP = c.View.Stats["healthPoints"].Final
|
||||
@@ -171,6 +172,9 @@ func (w *World) ApplyCatalog(catalog content.Catalog) error {
|
||||
if catalog.Combat != nil {
|
||||
w.Balance.Combat = catalog.Combat
|
||||
}
|
||||
if catalog.Crafting != nil {
|
||||
w.Balance.Crafting = catalog.Crafting
|
||||
}
|
||||
w.Balance.Titles = catalog.Titles
|
||||
w.Balance.Items = catalog.Items
|
||||
w.Balance.Stats = &catalog.Stats
|
||||
@@ -188,9 +192,12 @@ func (w *World) roll(chance float64) bool {
|
||||
if chance >= 100 {
|
||||
return true
|
||||
}
|
||||
return w.randomUnit()*100 < chance
|
||||
}
|
||||
func (w *World) randomUnit() float64 {
|
||||
w.RandomCounter++
|
||||
sum := sha256.Sum256([]byte(fmt.Sprintf("%d:%d", w.Seed, w.RandomCounter)))
|
||||
return float64(binary.LittleEndian.Uint64(sum[:8])>>11)/float64(uint64(1)<<53)*100 < chance
|
||||
return float64(binary.LittleEndian.Uint64(sum[:8])>>11) / float64(uint64(1)<<53)
|
||||
}
|
||||
func (w *World) yieldAmount(rate float64) int64 {
|
||||
amount := math.Max(0, math.Min(float64(w.Balance.MaxYieldPerAction), rate/100))
|
||||
|
||||
Reference in New Issue
Block a user