Documentation
¶
Overview ¶
Package life provides pure formulas for Flowbot Life (cascade, loot, buffs, achievements).
Index ¶
- Constants
- Variables
- func AchievementConditionKey(questType, difficulty string) string
- func AchievementKeysForCompletion(questType, difficulty string) []string
- func AchievementShowsProgress(def AchievementDef) bool
- func BlendCompletionRate(rate float64, success bool) float64
- func DefaultRewards(diff string) (fear, exp, gold int, tier string)
- func ExpToNextLevel(level int) int64
- func IsTarnished(until *time.Time, now time.Time) bool
- func MergeBuffs(template, instance map[string]any) map[string]float64
- func NeedsInstanceLore(questType, difficulty string) bool
- func NormalizeDifficulty(raw string) string
- func PreviewDropChance(in LootInput) float64
- func RewardCooldownEndsAt(lastRedeemed *time.Time, cooldownHours int, now time.Time) *time.Time
- func RewardOnCooldown(lastRedeemed *time.Time, cooldownHours int, now time.Time) bool
- func RollUnit() (float64, error)
- func SkillTreeWindowDays(cadence string) int
- func SlotField(slotType string) string
- func SoftHPFromWillpower(wilLevel int, wilExp, wilNeed int64, profileLevel int) (current, maxHP int)
- func SourceTypeLabel(sourceType string) string
- func StatsWindowBounds(now time.Time, loc *time.Location, days int) (start, endExclusive time.Time)
- func TaskTypeLabel(taskType string) string
- type AchievementDef
- type AchievementEvalInput
- type AchievementEvalResult
- type BuffTotals
- type CascadeInput
- type CascadeResult
- type LootInput
- type LootResult
- type StatSnapshot
- type StatsActionEvent
- type StatsInput
- type StatsPage
- type StatsQuestCompletion
- type StatsRedemptionEvent
- type StatsUnlockEvent
Constants ¶
const ( // AchievementKindFirst is a one-shot memorial (threshold treated as 1). AchievementKindFirst = "first" // AchievementKindCount is a cumulative memorial with visible progress. AchievementKindCount = "count" )
const ( GoalCategoryProject = "Project" GoalCategoryArea = "Area" GoalCategoryResource = "Resource" )
PARA goal categories (life_goals.category).
const ( GoalStatusActive = "Active" GoalStatusPaused = "Paused" GoalStatusCompleted = "Completed" )
Goal lifecycle statuses (life_goals.status).
const ( // SoftHPMax is the soft HP ceiling used by the character HUD. SoftHPMax = 1000 // SoftHPHeartCount is how many heart segments the HUD shows. SoftHPHeartCount = 10 )
const DefaultPityThreshold = 10
DefaultPityThreshold is the miss count that forces a drop.
const RustDuration = 24 * time.Hour
RustDuration is how long equipped gear stays tarnished after a failed quest.
const StatsOtherBucket = "Other"
StatsOtherBucket is the growth chart label for unattributed EXP.
const StatsWindowDays = 30
StatsWindowDays is the fixed analytics window length.
Variables ¶
var DefaultCharacteristics = []struct { Code string Name string }{ {Code: "INT", Name: "Intelligence"}, {Code: "PHY", Name: "Physique"}, {Code: "WIL", Name: "Willpower"}, {Code: "CHA", Name: "Charisma"}, {Code: "CRE", Name: "Creativity"}, {Code: "FIN", Name: "Financial"}, {Code: "WRI", Name: "Writing"}, {Code: "FOC", Name: "Focus"}, }
DefaultCharacteristics are seeded on EnsureProfile (and backfilled for older profiles).
Functions ¶
func AchievementConditionKey ¶
AchievementConditionKey builds the progress key for optional type/difficulty filters. Empty questType or difficulty means "any" (*).
func AchievementKeysForCompletion ¶
AchievementKeysForCompletion returns every progress key bumped by one quest completion.
func AchievementShowsProgress ¶
func AchievementShowsProgress(def AchievementDef) bool
AchievementShowsProgress reports whether the UI should show N/M for this definition.
func BlendCompletionRate ¶
BlendCompletionRate applies a 90/10 exponential blend after a quest outcome.
func DefaultRewards ¶
DefaultRewards returns fear, exp, gold, and drop tier for a difficulty code. Everyday tiers (E–S) grow ~1.5x with gold near exp/3; SS/SSS jump harder for boss-tier payoff (C still anchors ~4 completions to ExpToNextLevel(1)=100).
func ExpToNextLevel ¶
ExpToNextLevel returns exp required to advance from the given level.
func IsTarnished ¶
IsTarnished reports whether rust is still active at now.
func MergeBuffs ¶
MergeBuffs merges template and instance buff maps (instance wins on key clash).
func NeedsInstanceLore ¶
NeedsInstanceLore reports whether a drop should enqueue memorial lore generation.
func NormalizeDifficulty ¶
NormalizeDifficulty coerces a raw difficulty label to a known tier.
func PreviewDropChance ¶
PreviewDropChance returns the effective drop threshold without rolling.
func RewardCooldownEndsAt ¶
RewardCooldownEndsAt returns when the cooldown expires, or nil if not on cooldown.
func RewardOnCooldown ¶
RewardOnCooldown reports whether a reward cannot be redeemed yet. cooldownHours <= 0 or a nil lastRedeemed means not on cooldown.
func SkillTreeWindowDays ¶
SkillTreeWindowDays maps a cadence hint to an activity window length in days.
func SoftHPFromWillpower ¶
func SoftHPFromWillpower(wilLevel int, wilExp, wilNeed int64, profileLevel int) (current, maxHP int)
SoftHPFromWillpower derives a soft HP pool from Willpower (or profile level fallback).
func SourceTypeLabel ¶
SourceTypeLabel returns a concise label for one audit / skill-tree source.
func StatsWindowBounds ¶
StatsWindowBounds returns [start, endExclusive) for the last days calendar days in loc, ending at the start of tomorrow relative to now.
func TaskTypeLabel ¶
TaskTypeLabel returns a concise label for one plan action type.
Types ¶
type AchievementDef ¶
type AchievementDef struct {
Flag string
Name string
Description string
Active bool
Kind string
QuestType string
Difficulty string
Threshold int
SortOrder int
}
AchievementDef is one catalog achievement definition (pure data).
type AchievementEvalInput ¶
type AchievementEvalInput struct {
QuestType string
Difficulty string
Catalog []AchievementDef
Progress map[string]int
Unlocked map[string]struct{}
}
AchievementEvalInput is the pure input for evaluating unlocks after a quest completion.
type AchievementEvalResult ¶
type AchievementEvalResult struct {
ProgressAfter map[string]int
NewlyUnlocked []AchievementDef
}
AchievementEvalResult is the progress deltas and newly unlocked definitions.
func EvaluateAchievements ¶
func EvaluateAchievements(in AchievementEvalInput) AchievementEvalResult
EvaluateAchievements bumps matching condition keys and returns new unlocks.
type BuffTotals ¶
BuffTotals aggregates equipped item buffs.
func SumEquippedBuffs ¶
func SumEquippedBuffs(items []map[string]float64) BuffTotals
SumEquippedBuffs sums float buffs from multiple items.
type CascadeInput ¶
type CascadeInput struct {
BaseExp int
BaseGold int
Skill StatSnapshot
Characteristic StatSnapshot
Profile StatSnapshot
ProfileGold int
ExpToCharacteristicRatio float64
}
CascadeInput is the reward applied when a quest completes.
type CascadeResult ¶
type CascadeResult struct {
Skill StatSnapshot
Characteristic StatSnapshot
Profile StatSnapshot
ProfileGold int
GainedExp int
GainedGold int
}
CascadeResult is the post-cascade state and gained totals.
func ApplyCascade ¶
func ApplyCascade(in CascadeInput) CascadeResult
ApplyCascade distributes quest rewards into skill, characteristic, and profile snapshots.
type LootInput ¶
type LootInput struct {
BaseDropChance float64
ProfileBonus float64
EquippedDropRate float64
PityCount int
PityThreshold int
Roll float64 // [0,1); if < 0, caller should set via RollUnit
PoolSize int
}
LootInput drives a single drop roll.
type LootResult ¶
type LootResult struct {
Dropped bool
ForcedPity bool
Roll float64
Threshold float64
PoolIndex int
NextPity int
}
LootResult is the outcome of a loot roll.
func ResolveLoot ¶
func ResolveLoot(in LootInput) LootResult
ResolveLoot decides whether an item drops and which pool index.
type StatSnapshot ¶
StatSnapshot is mutable progress for cascade application.
type StatsActionEvent ¶
type StatsActionEvent struct {
At time.Time
GainedExp int
GainedGold int
Dropped bool
CharacteristicCode string // empty → Other
}
StatsActionEvent is one action-log row for stats aggregation.
type StatsInput ¶
type StatsInput struct {
Actions []StatsActionEvent
Quests []StatsQuestCompletion
Redemptions []StatsRedemptionEvent
Unlocks []StatsUnlockEvent
Location *time.Location
Now time.Time
TimezoneName string
}
StatsInput is the raw event set for BuildStatsPage.
type StatsPage ¶
type StatsPage struct {
Timezone string
DayLabels []string
Completions int
TotalExp int
GoldInTotal int
GoldOutTotal int
GoldNet int
ActivityCounts []int
ActivityExp []int
GrowthLabels []string
GrowthValues []int
QuestTypeLabels []string
QuestTypeValues []int
GoldIn []int
GoldOut []int
Drops []int
AchievementUnlocks int
HasActivity bool
WindowStart time.Time
WindowEndExclusive time.Time
}
StatsPage is the aggregated Life stats dashboard model.
func BuildStatsPage ¶
func BuildStatsPage(in StatsInput) StatsPage
BuildStatsPage aggregates action / quest / redemption / unlock events into chart series.
type StatsQuestCompletion ¶
StatsQuestCompletion is one completed quest for type breakdown.
type StatsRedemptionEvent ¶
StatsRedemptionEvent is one reward redemption for gold outflow.
type StatsUnlockEvent ¶
StatsUnlockEvent is one achievement unlock in the window.