pushing current

This commit is contained in:
dingo
2026-09-07 13:44:10 -04:00
parent bc0ffbbbe5
commit 3f58de5744
15 changed files with 872 additions and 60 deletions
+24 -2
View File
@@ -31,10 +31,26 @@ func (w *World) orderedCharacters() []*Character {
}
func (w *World) restoreProgression(c *Character) error {
if c.View.Level == 0 {
c.View.Level = 1
}
if c.Progression == nil {
rules := *w.Balance.Progression
c.Progression = &rules
}
if c.StatsVersion == 0 {
rules := *c.Progression
if rules.StatPointsPerLevel < w.Balance.Progression.StatPointsPerLevel {
c.View.StatPoints += (c.View.Level - 1) * (w.Balance.Progression.StatPointsPerLevel - rules.StatPointsPerLevel)
}
rules.StatPointsPerLevel = w.Balance.Progression.StatPointsPerLevel
rules.StaminaPerLevel = w.Balance.Progression.StaminaPerLevel
rules.VitalPointsPerChoice = w.Balance.Progression.VitalPointsPerChoice
c.Progression = &rules
c.View.PendingVitalChoices = c.View.Level - 1
c.StatsVersion = 1
w.dirty = true
}
if err := c.Progression.Validate(); err != nil {
return err
}
@@ -65,13 +81,16 @@ func (w *World) grantXP(c *Character, amount int64) {
if amount <= 0 || c.View.Entity.State != "alive" || c.View.Level >= c.Progression.MaxLevel {
return
}
amount = int64(math.Min(1000000000, math.Floor(float64(amount)*c.View.Stats["xpGain"].Final/100)))
c.View.Experience += amount
before := c.View.Level
for c.View.Level < c.Progression.MaxLevel && c.View.Experience >= c.nextLevelXP() {
c.View.Experience -= c.nextLevelXP()
c.View.Level++
c.View.StatPoints += c.Progression.StatPointsPerLevel
c.View.PendingVitalChoices++
}
w.RefreshStats(c)
c.View.ExperienceToNextLevel = c.nextLevelXP()
if c.View.ExperienceToNextLevel == 0 {
c.View.Experience = 0
@@ -101,6 +120,9 @@ func (w *World) evaluateTitles(c *Character) {
}
return 0
default:
if value, ok := c.View.Stats[name]; ok {
return int64(math.Floor(value.Final))
}
return c.View.Skills[name]
}
}
@@ -136,7 +158,7 @@ func (w *World) evaluateTitles(c *Character) {
}
w.PendingTitles = append(w.PendingTitles, TitleCandidate{CharacterID: c.View.Entity.ID, Award: p.TitleAward{
ID: title.ID, Name: title.Name, Description: title.Description, Scope: title.Scope, WorldID: w.ID,
EarnedAt: w.now.UTC().Format(time.RFC3339Nano), Effects: p.TitleEffects{Damage: title.Effects.Damage, MoveSpeed: title.Effects.MoveSpeed},
EarnedAt: w.now.UTC().Format(time.RFC3339Nano), Effects: p.TitleEffects{Damage: title.Effects.Damage, MoveSpeed: title.Effects.MoveSpeed, Modifiers: protocolModifiers(title.Effects.Modifiers)},
}})
w.dirty = true
}
@@ -158,5 +180,5 @@ func (c *Character) titleEffects() p.TitleEffects {
}
func (w *World) playerSpeed(c *Character) float64 {
return math.Max(0, w.Balance.PlayerSpeed+c.titleEffects().MoveSpeed)
return c.View.Stats["moveSpeed"].Final
}