The Farming system allows players to passively accumulate resources over time. By letting your "crops" grow, you can harvest increasingly valuable rewards.
- Command:
/harvest - Requirement: Must have the
feature_farmingprogression node unlocked. - Minimum Wait: 1 Hour.
- Maximum Wait (Spoilage): 336 Hours (2 Weeks).
The longer you wait between harvests, the more rewards you accumulate. You receive all rewards from every tier you have surpassed.
| Tier | Time Reached | Added Rewards | Cumulative Total |
|---|---|---|---|
| 1 | 2 Hours | 2 Money | 2 Money |
| 2 | 5 Hours | 10 Money | 12 Money |
| 3 | 12 Hours | 5 Money, 1 Stick | 17 Money, 1 Stick |
| 4 | 24 Hours | 5 Money, 2 Sticks | 22 Money, 3 Sticks |
| 5 | 48 Hours | 10 Money, 1 Lootbox0 | 32 Money, 3 Sticks, 1 Lootbox0 |
| 6 | 72 Hours | 10 Money, 2 Lootbox0 | 42 Money, 3 Sticks, 3 Lootbox0 |
| 7 | 90 Hours | 5 Money, 5 Sticks | 47 Money, 8 Sticks, 3 Lootbox0 |
| 8 | 110 Hours | 15 Money, 1 Lootbox1 | 62 Money, 8 Sticks, 3 Lootbox0, 1 Lootbox1 |
| 9 | 130 Hours | 15 Money, 1 Lootbox1 | 77 Money, 8 Sticks, 3 Lootbox0, 2 Lootbox1 |
| 10 | 168 Hours (1 Wk) | 20 Money, 1 Lootbox2 | 97 Money, 8 Sticks, 3 Lootbox0, 2 Lootbox1, 1 Lootbox2 |
Note: Some items (like Sticks and Lootboxes) may require specific progression unlocks to be received. If you haven't unlocked the item, you won't get it, but you'll still get the money.
- Unlock: Starts accumulating after 5 hours.
- Rate: 8 XP per hour.
- Award: Granted automatically upon harvest.
If you wait longer than 336 hours (2 weeks), your crops will spoil!
- Penalty: You lose the standard accumulated rewards.
- Salvage: You receive a consolation prize of 1 Lootbox1 and 3 Sticks.
The system is implemented in internal/harvest/.
- Service Interface:
internal/harvest/service.go - Core Logic:
internal/harvest/harvest.go - Rewards:
internal/harvest/rewards.go - Persistence: Harvest state is stored in the database, tracking
last_harvested_at.
The harvest service employs robust concurrency patterns to ensure reliability:
- Graceful Shutdown: The service exposes a
Shutdown(ctx)method and uses async.WaitGroupto ensure all background operations (like XP awarding) complete before the application stops. - Asynchronous XP Awarding: Farmer XP is awarded asynchronously to prevent blocking the harvest transaction.
- Context Management: The asynchronous XP task uses
context.WithoutCancel(Go 1.21+) to detach from the request context, ensuring the award process completes even if the user cancels the HTTP request immediately after the transaction commits. - Transaction Safety: The harvest operation runs within a database transaction, ensuring the harvest timestamp is only updated if the rewards are successfully added to the inventory.
The Compost system allows players to recycle unwanted items into useful resources.
- Unlock: Requires the
feature_compostprogression node. - Capacity: Default bin holds 5 items.
- Efficiency: Converts items at 50% value efficiency (Default).
- Output: Produces the highest-value item possible of the dominant input type.
- Deposit: Add items with the
compostabletag to your bin.- Command:
/use compost <item> <amount>(or via UI)
- Command:
- Process: The bin processes items over time.
- Warmup: 1 Hour fixed time.
- Per Item: +30 Minutes per item.
- Example: 5 items take 1h + (5 * 30m) = 3.5 Hours.
- Harvest: Collect the result once ready.
- Command:
/harvest compost(or via UI) - XP: Awards XP equal to 10% of input value.
- Command:
The system calculates the Total Input Value based on item base values and quality. The Output Value is 50% of the Input Value.
The system determines the Dominant Type (e.g., Organic, Gem, Metal) based on what you deposited. It then rewards you with the most valuable item of that type that fits within the Output Value.
Example: You deposit 10 Common Herbs (Value 100 each, Type: Organic). Total Input: 1000. Output Value: 500. Dominant Type: Organic. The system looks for Organic items worth <= 500. If "Premium Fertilizer" is worth 250, you receive 2 of them.
If you leave your finished compost in the bin for too long (1 Week after finishing), it turns into Sludge.
- Reward:
compost_sludge(Quantity = Input Value / 10). - Value: Significantly less than a proper harvest.
The compost system uses a "Garbage In, Value Out" engine in internal/compost/engine.go.
- Service: Service logic is split across multiple files in
internal/compost/:service.go: Interface definitions, lifecycle management, and validation.deposit.go: Logic for adding items to the bin.harvest.go: Logic for checking status and collecting rewards.
- Engine:
internal/compost/engine.gocontains pure logic for calculating ready times, spoil times, and output items based on input value and types. - Shutdown: The service implements
Shutdown(ctx)to gracefully wait for asynchronous operations (usingsync.WaitGroup) before the application stops. - Events: Publishes
compost.harvestedfor stats and notifications.