Documentation
¶
Overview ¶
Package life is Flowbot's solo gamified productivity module.
Index ¶
- Constants
- func OnService(fn func(*Service))
- func ParseRewardCooldownHours(raw string) (int, error)
- func ParseRewardPrice(raw string) (int, error)
- func Register()
- type AchievementView
- type ActionInput
- type ActionLogView
- type CharacterView
- type CompleteResult
- type CreateRewardInput
- type GoalView
- type InventoryItem
- type InventoryPage
- type PlanNodeView
- type QuestAdjudicationView
- type QuestDMView
- type QuestEvidenceView
- type RedemptionView
- type RewardView
- type RewardsPage
- type Service
- func (s *Service) AdjudicateQuest(ctx context.Context, userID, questFlag string) (*QuestAdjudicationView, error)
- func (s *Service) ApplyQuestAdjudication(ctx context.Context, userID, questFlag, adjudicationFlag string) error
- func (s *Service) BuildSkillTree(ctx context.Context, userID string) (*SkillTreeView, error)
- func (s *Service) CheckInHabit(ctx context.Context, userID, nodeFlag string, at time.Time) error
- func (s *Service) CompleteActionOccurrence(ctx context.Context, userID, occurrenceFlag string) error
- func (s *Service) CompleteQuest(ctx context.Context, userID, questFlag string) (*CompleteResult, error)
- func (s *Service) ConfirmHabitAction(ctx context.Context, userID, nodeFlag string) error
- func (s *Service) CreateGoal(ctx context.Context, userID, title, category, areaFlag string) (*gen.LifeGoal, error)
- func (s *Service) CreatePlanNode(ctx context.Context, userID, parentFlag, nodeType, title, description string, ...) (*PlanNodeView, error)
- func (s *Service) CreateQuestFromPrompt(ctx context.Context, userID, prompt, goalFlag string) (*gen.LifeQuest, *lifecap.QuestEvaluation, float64, error)
- func (s *Service) CreateReward(ctx context.Context, userID string, in CreateRewardInput) (*gen.LifeReward, error)
- func (s *Service) DeactivateReward(ctx context.Context, userID, rewardFlag string) error
- func (s *Service) DeleteGoal(ctx context.Context, userID, goalFlag string) error
- func (s *Service) DismissQuest(ctx context.Context, userID, questFlag string) error
- func (s *Service) EnsureProfile(ctx context.Context, userID, nickname, defaultClass string) (*gen.LifeProfile, error)
- func (s *Service) Equip(ctx context.Context, userID, inventoryFlag string) error
- func (s *Service) FailQuest(ctx context.Context, userID, questFlag string) error
- func (s *Service) GetCharacter(ctx context.Context, userID string) (*CharacterView, error)
- func (s *Service) GetStatsPage(ctx context.Context, userID, timezoneName string) (*pkglife.StatsPage, error)
- func (s *Service) ImportGoalBreakdown(ctx context.Context, userID string, ...) error
- func (s *Service) ListAchievements(ctx context.Context, userID string) ([]AchievementView, error)
- func (s *Service) ListActionLogs(ctx context.Context, userID string, limit int) ([]ActionLogView, error)
- func (s *Service) ListActionLogsPage(ctx context.Context, userID string, page, perPage int) ([]ActionLogView, int, error)
- func (s *Service) ListCompletedQuestsPage(ctx context.Context, userID string, page, perPage int) ([]*gen.LifeQuest, int, error)
- func (s *Service) ListHabitCheckins(ctx context.Context, userID, nodeFlag string, from, to time.Time) ([]*gen.LifeHabitCheckin, error)
- func (s *Service) ListInventory(ctx context.Context, userID string) ([]InventoryItem, *gen.LifeEquippedSlots, error)
- func (s *Service) ListInventoryPage(ctx context.Context, userID string, page, perPage int) (*InventoryPage, error)
- func (s *Service) ListPendingQuestDMViews(ctx context.Context, userID string) ([]QuestDMView, error)
- func (s *Service) ListPlanTree(ctx context.Context, userID string) ([]*PlanNodeView, error)
- func (s *Service) ListQuests(ctx context.Context, userID, status string) ([]*gen.LifeQuest, error)
- func (s *Service) ListRewardsPage(ctx context.Context, userID string, redemptionsPage, inactivePage, perPage int) (*RewardsPage, error)
- func (s *Service) ListTodayActions(ctx context.Context, userID string) (*TodayBoardView, error)
- func (s *Service) PreviewDropChance(ctx context.Context, userID, questFlag string) (float64, error)
- func (s *Service) PreviewGoalBreakdown(ctx context.Context, userID, rootTitle, description string) (*lifecap.GoalBreakdownSuggestion, error)
- func (s *Service) ProcessPendingLore(ctx context.Context) (int, error)
- func (s *Service) RedeemReward(ctx context.Context, userID, rewardFlag string) error
- func (s *Service) RestoreReward(ctx context.Context, userID, rewardFlag string) error
- func (s *Service) SetClassType(ctx context.Context, userID, classType string) error
- func (s *Service) SetGoalStatus(ctx context.Context, userID, goalFlag, status string) error
- func (s *Service) SkipActionOccurrence(ctx context.Context, userID, occurrenceFlag string) error
- func (s *Service) SubmitQuestEvidence(ctx context.Context, userID, questFlag, sourceType, content, sourceURL string) (*QuestEvidenceView, error)
- func (s *Service) Unequip(ctx context.Context, userID, slotField string) error
- func (s *Service) UpdateGoal(ctx context.Context, userID, goalFlag, title, category, areaFlag string) error
- func (s *Service) UpdateReward(ctx context.Context, userID, rewardFlag string, in CreateRewardInput) error
- type SkillTreeEvidenceView
- type SkillTreeNodeView
- type SkillTreeView
- type TodayActionView
- type TodayBoardView
- type TodayHabitView
- type UnlockedAchievement
Constants ¶
const Name = "life"
Name is the module registry key.
Variables ¶
This section is empty.
Functions ¶
func OnService ¶
func OnService(fn func(*Service))
OnService registers a listener invoked whenever the Life service instance is assigned.
func ParseRewardCooldownHours ¶
ParseRewardCooldownHours parses optional cooldown hours (empty → 0).
func ParseRewardPrice ¶
ParseRewardPrice parses a form price string into a positive int.
Types ¶
type AchievementView ¶
type AchievementView struct {
Flag string
Name string
Description string
Unlocked bool
UnlockedAt *time.Time
ShowProgress bool
Current int
Target int
Retired bool
}
AchievementView is one memorial achievement row for the UI.
type ActionInput ¶
type ActionInput struct {
TaskType string
IsRepeatable bool
TrackingMode string
RepeatTrigger string
SuggestedCadence string
IsIdentityBuilding bool
Reason string
Difficulty string
BaseExp int
BaseGold int
DependencyFlags []string
}
ActionInput captures the structured fields used to classify an action node.
type ActionLogView ¶
type ActionLogView struct {
Flag string
SourceType string
QuestFlag string
QuestTitle string
GainedExp int
GainedGold int
Dice float64
HasDice bool
Dropped bool
CreatedAt time.Time
}
ActionLogView is one audit row for the UI.
type CharacterView ¶
type CharacterView struct {
Profile *gen.LifeProfile
Characteristics []*gen.LifeCharacteristic
Skills []*gen.LifeSkill
Slots *gen.LifeEquippedSlots
Buffs pkglife.BuffTotals
Goals []*gen.LifeGoal
PlanTree []*PlanNodeView
}
CharacterView is the character / identity aggregate (also feeds Goals, Plan, Quests).
type CompleteResult ¶
type CompleteResult struct {
Quest *gen.LifeQuest
GainedExp int
GainedGold int
Dropped bool
ItemName string
ItemFlag string
ItemRarity string
Dice float64
PityForced bool
NewlyUnlocked []UnlockedAchievement
ProfileLevelBefore int
ProfileLevelAfter int
SkillName string
SkillLevelBefore int
SkillLevelAfter int
}
CompleteResult is returned to the UI after completion.
type CreateRewardInput ¶
CreateRewardInput is the write-set for creating or updating a reward.
type GoalView ¶
type GoalView struct {
Flag string
Title string
Category string
Status string
AreaFlag string
AreaTitle string
}
GoalView is a UI-ready goal row with optional Area parent labels resolved.
func MapGoalViews ¶
MapGoalViews maps goal entities to view rows, resolving Area parents within the slice.
type InventoryItem ¶
type InventoryItem struct {
Inv *gen.LifeInventory
Equip *gen.LifeEquipment
}
InventoryItem pairs inventory with equipment template.
type InventoryPage ¶
type InventoryPage struct {
Items []InventoryItem
Equipped []InventoryItem
Slots *gen.LifeEquippedSlots
Total int
}
InventoryPage is one backpack page plus currently equipped items for the board.
type PlanNodeView ¶
type PlanNodeView struct {
Node *gen.LifePlanNode
Action *gen.LifeActionSpec
Children []*PlanNodeView
}
PlanNodeView is one rendered tree node with optional action metadata.
type QuestAdjudicationView ¶
type QuestAdjudicationView struct {
Flag string
Status string
Verdict string
Reason string
SuggestedExp int
SuggestedGold int
SuggestedNextSteps []string
CreatedAt time.Time
}
QuestAdjudicationView is the latest AI ruling for one quest.
type QuestDMView ¶
type QuestDMView struct {
Quest *gen.LifeQuest
Evidence []QuestEvidenceView
Adjudication *QuestAdjudicationView
DropChance float64
}
QuestDMView bundles a pending quest with its evidence and latest ruling.
type QuestEvidenceView ¶
type QuestEvidenceView struct {
Flag string
SourceType string
Content string
SourceURL string
Summary string
CreatedAt time.Time
}
QuestEvidenceView is one quest evidence item for the UI.
type RedemptionView ¶
RedemptionView is one redemption history row for the Rewards UI.
type RewardView ¶
type RewardView struct {
Flag string
Name string
Notes string
Price int
CooldownHours int
Active bool
OnCooldown bool
CooldownEndsAt string
CanAfford bool
LastRedeemedAt string
}
RewardView is one catalog reward for the Rewards UI.
type RewardsPage ¶
type RewardsPage struct {
Gold int
Active []RewardView
Inactive []RewardView
Redemptions []RedemptionView
InactiveTotal int
RedemptionsTotal int
}
RewardsPage is the full Rewards page model.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service orchestrates Life use cases for the web UI.
func ActiveService ¶
func ActiveService() *Service
ActiveService returns the module service for web injection.
func NewService ¶
NewService constructs a Life service.
func (*Service) AdjudicateQuest ¶
func (s *Service) AdjudicateQuest(ctx context.Context, userID, questFlag string) (*QuestAdjudicationView, error)
AdjudicateQuest asks the Life DM for a suggested quest ruling.
func (*Service) ApplyQuestAdjudication ¶
func (s *Service) ApplyQuestAdjudication(ctx context.Context, userID, questFlag, adjudicationFlag string) error
ApplyQuestAdjudication accepts a suggested ruling and applies its effect.
func (*Service) BuildSkillTree ¶
BuildSkillTree builds the read-only controlled skill tree for the Life UI.
func (*Service) CheckInHabit ¶
CheckInHabit writes one daily habit check-in.
func (*Service) CompleteActionOccurrence ¶
func (s *Service) CompleteActionOccurrence(ctx context.Context, userID, occurrenceFlag string) error
CompleteActionOccurrence marks an execution occurrence completed and grants rewards.
func (*Service) CompleteQuest ¶
func (s *Service) CompleteQuest(ctx context.Context, userID, questFlag string) (*CompleteResult, error)
CompleteQuest runs cascade + loot + action log in one store transaction.
func (*Service) ConfirmHabitAction ¶
ConfirmHabitAction marks a habit candidate as confirmed.
func (*Service) CreateGoal ¶
func (s *Service) CreateGoal(ctx context.Context, userID, title, category, areaFlag string) (*gen.LifeGoal, error)
CreateGoal creates an Active PARA goal. areaFlag optionally links Project/Resource to an Active Area.
func (*Service) CreatePlanNode ¶
func (s *Service) CreatePlanNode(ctx context.Context, userID, parentFlag, nodeType, title, description string, action *ActionInput) (*PlanNodeView, error)
CreatePlanNode creates one plan node under an optional parent.
func (*Service) CreateQuestFromPrompt ¶
func (s *Service) CreateQuestFromPrompt(ctx context.Context, userID, prompt, goalFlag string) (*gen.LifeQuest, *lifecap.QuestEvaluation, float64, error)
CreateQuestFromPrompt evaluates and persists a quest. goalFlag is optional; when set, the quest is linked to that active goal.
func (*Service) CreateReward ¶
func (s *Service) CreateReward(ctx context.Context, userID string, in CreateRewardInput) (*gen.LifeReward, error)
CreateReward creates a player-defined reward.
func (*Service) DeactivateReward ¶
DeactivateReward soft-deletes a reward (active=false).
func (*Service) DeleteGoal ¶
DeleteGoal removes a goal by flag. Deleting an Area clears child area_id links first.
func (*Service) DismissQuest ¶
DismissQuest removes a pending quest without rust or completion-rate penalty.
func (*Service) EnsureProfile ¶
func (s *Service) EnsureProfile(ctx context.Context, userID, nickname, defaultClass string) (*gen.LifeProfile, error)
EnsureProfile creates the profile graph for a user if needed.
func (*Service) GetCharacter ¶
GetCharacter loads character aggregates.
func (*Service) GetStatsPage ¶
func (s *Service) GetStatsPage(ctx context.Context, userID, timezoneName string) (*pkglife.StatsPage, error)
GetStatsPage builds the Life stats dashboard for the given IANA timezone. Invalid or empty timezoneName falls back to UTC.
func (*Service) ImportGoalBreakdown ¶
func (s *Service) ImportGoalBreakdown(ctx context.Context, userID string, suggestion *lifecap.GoalBreakdownSuggestion) error
ImportGoalBreakdown persists a suggestion tree as plan nodes.
func (*Service) ListAchievements ¶
ListAchievements returns catalog rows with progress and unlock state for the user.
func (*Service) ListActionLogs ¶
func (s *Service) ListActionLogs(ctx context.Context, userID string, limit int) ([]ActionLogView, error)
ListActionLogs returns recent completion audit rows for the user.
func (*Service) ListActionLogsPage ¶
func (s *Service) ListActionLogsPage(ctx context.Context, userID string, page, perPage int) ([]ActionLogView, int, error)
ListActionLogsPage returns one page of completion audit rows and the total count.
func (*Service) ListCompletedQuestsPage ¶
func (s *Service) ListCompletedQuestsPage(ctx context.Context, userID string, page, perPage int) ([]*gen.LifeQuest, int, error)
ListCompletedQuestsPage returns one page of completed quests and the total count.
func (*Service) ListHabitCheckins ¶
func (s *Service) ListHabitCheckins(ctx context.Context, userID, nodeFlag string, from, to time.Time) ([]*gen.LifeHabitCheckin, error)
ListHabitCheckins returns check-ins in a date range.
func (*Service) ListInventory ¶
func (s *Service) ListInventory(ctx context.Context, userID string) ([]InventoryItem, *gen.LifeEquippedSlots, error)
ListInventory returns inventory with templates.
func (*Service) ListInventoryPage ¶
func (s *Service) ListInventoryPage(ctx context.Context, userID string, page, perPage int) (*InventoryPage, error)
ListInventoryPage returns one backpack page, equipped items, slots, and total count. A non-positive perPage returns the full backpack on page 1.
func (*Service) ListPendingQuestDMViews ¶
func (s *Service) ListPendingQuestDMViews(ctx context.Context, userID string) ([]QuestDMView, error)
ListPendingQuestDMViews returns pending quests with evidence and latest rulings.
func (*Service) ListPlanTree ¶
ListPlanTree returns the profile planning tree.
func (*Service) ListQuests ¶
ListQuests lists quests for the user.
func (*Service) ListRewardsPage ¶
func (s *Service) ListRewardsPage(ctx context.Context, userID string, redemptionsPage, inactivePage, perPage int) (*RewardsPage, error)
ListRewardsPage returns gold, active rewards, and paged inactive/redemption lists.
func (*Service) ListTodayActions ¶
ListTodayActions syncs recurring actions and returns today's action/habit board.
func (*Service) PreviewDropChance ¶
PreviewDropChance returns the effective drop chance for a pending quest.
func (*Service) PreviewGoalBreakdown ¶
func (s *Service) PreviewGoalBreakdown(ctx context.Context, userID, rootTitle, description string) (*lifecap.GoalBreakdownSuggestion, error)
PreviewGoalBreakdown asks the life capability for a suggested tree.
func (*Service) ProcessPendingLore ¶
ProcessPendingLore consumes lore outbox rows.
func (*Service) RedeemReward ¶
RedeemReward deducts gold and records a redemption in one transaction.
func (*Service) RestoreReward ¶
RestoreReward reactivates a soft-deleted reward.
func (*Service) SetClassType ¶
SetClassType updates class.
func (*Service) SetGoalStatus ¶
SetGoalStatus updates a goal status by flag.
func (*Service) SkipActionOccurrence ¶
SkipActionOccurrence marks a pending occurrence skipped.
func (*Service) SubmitQuestEvidence ¶
func (s *Service) SubmitQuestEvidence(ctx context.Context, userID, questFlag, sourceType, content, sourceURL string) (*QuestEvidenceView, error)
SubmitQuestEvidence stores a new evidence item for a pending quest.
func (*Service) UpdateGoal ¶
func (s *Service) UpdateGoal(ctx context.Context, userID, goalFlag, title, category, areaFlag string) error
UpdateGoal updates title, category, and optional Area parent for a goal by flag.
func (*Service) UpdateReward ¶
func (s *Service) UpdateReward(ctx context.Context, userID, rewardFlag string, in CreateRewardInput) error
UpdateReward updates name/notes/price/cooldown for a reward by flag.
type SkillTreeEvidenceView ¶
type SkillTreeEvidenceView struct {
Title string
SourceType string
Detail string
OccurredAt time.Time
WindowDays int
}
SkillTreeEvidenceView is one recent practice record linked to a tree node.
type SkillTreeNodeView ¶
type SkillTreeNodeView struct {
Key string
Title string
Subtitle string
Characteristic string
Children []*SkillTreeNodeView
PracticeCount int
SkillCount int
LastActivityAt *time.Time
Status string
Evidence []SkillTreeEvidenceView
// contains filtered or unexported fields
}
SkillTreeNodeView is one node in the controlled skills tree.
type SkillTreeView ¶
type SkillTreeView struct {
Roots []*SkillTreeNodeView
DefaultSelected string
ActiveNodeCount int
TrackedNodeCount int
}
SkillTreeView is the aggregated skills page model.
type TodayActionView ¶
type TodayActionView struct {
Occurrence *gen.LifeActionOccurrence
Node *gen.LifePlanNode
Spec *gen.LifeActionSpec
}
TodayActionView is one pending action occurrence with definition metadata.
type TodayBoardView ¶
type TodayBoardView struct {
Actions []TodayActionView
Habits []TodayHabitView
}
TodayBoardView is the execution board rendered on the quests page.
type TodayHabitView ¶
type TodayHabitView struct {
Node *gen.LifePlanNode
Spec *gen.LifeActionSpec
Checkin *gen.LifeHabitCheckin
CheckedIn bool
}
TodayHabitView is one habit plus today's check-in state.
type UnlockedAchievement ¶
UnlockedAchievement is one memorial unlock surfaced to the UI.