honeytree 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/components/ForestApp.js +28 -8
- package/src/plant.js +3 -2
- package/src/rewards.js +4 -4
- package/src/sync.js +4 -1
- package/src/varieties.js +4 -4
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import os from "node:os";
|
|
|
6
6
|
import { execSync } from "node:child_process";
|
|
7
7
|
import { getAuth, isLoggedIn } from "../auth.js";
|
|
8
8
|
import { getRewards, syncRewards, uncelebratedUnlocked, markCelebrated } from "../rewards.js";
|
|
9
|
+
import { syncNow } from "../sync.js";
|
|
9
10
|
import UnlockCelebration from "./UnlockCelebration.js";
|
|
10
11
|
|
|
11
12
|
import ForestScene from "./ForestScene.js";
|
|
@@ -69,16 +70,35 @@ export default function ForestApp() {
|
|
|
69
70
|
const viewportXRef = useRef(viewportX);
|
|
70
71
|
viewportXRef.current = viewportX;
|
|
71
72
|
|
|
72
|
-
// Fetch rewards from server
|
|
73
|
+
// Fetch rewards from server, then re-poll so a variety unlocked on the web
|
|
74
|
+
// (after planting a real tree) appears here live, without restarting.
|
|
73
75
|
useEffect(() => {
|
|
74
|
-
if (isLoggedIn())
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (!isLoggedIn()) return;
|
|
77
|
+
let cancelled = false;
|
|
78
|
+
// Push the local forest up once on launch so the web mirror catches up
|
|
79
|
+
// even if no new tree gets planted this session.
|
|
80
|
+
syncNow().catch(() => {});
|
|
81
|
+
const pull = () =>
|
|
82
|
+
syncRewards()
|
|
83
|
+
.then((r) => {
|
|
84
|
+
if (!r || cancelled) return;
|
|
77
85
|
setRewards(r);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
// Queue any newly-unlocked celebrations without dropping one mid-show.
|
|
87
|
+
setCelebrationQueue((prev) => {
|
|
88
|
+
const merged = [...prev];
|
|
89
|
+
for (const k of uncelebratedUnlocked()) {
|
|
90
|
+
if (!merged.includes(k)) merged.push(k);
|
|
91
|
+
}
|
|
92
|
+
return merged;
|
|
93
|
+
});
|
|
94
|
+
})
|
|
95
|
+
.catch(() => {});
|
|
96
|
+
pull();
|
|
97
|
+
const id = setInterval(pull, 30000);
|
|
98
|
+
return () => {
|
|
99
|
+
cancelled = true;
|
|
100
|
+
clearInterval(id);
|
|
101
|
+
};
|
|
82
102
|
}, []);
|
|
83
103
|
|
|
84
104
|
// Sync width to disk
|
package/src/plant.js
CHANGED
|
@@ -129,8 +129,9 @@ export async function tick(shape = null) {
|
|
|
129
129
|
if (badgePath) writeBadgeSVG(forest, badgePath);
|
|
130
130
|
} catch {}
|
|
131
131
|
|
|
132
|
-
// Cloud sync every
|
|
133
|
-
|
|
132
|
+
// Cloud sync on every plant (fire-and-forget) so the web dashboard, which
|
|
133
|
+
// polls every 20s, mirrors the terminal in near real time.
|
|
134
|
+
if (isLoggedIn()) {
|
|
134
135
|
syncToCloud(forest).catch(() => {});
|
|
135
136
|
}
|
|
136
137
|
|
package/src/rewards.js
CHANGED
|
@@ -7,10 +7,10 @@ const REWARDS_FILE = path.join(os.homedir(), ".honeydew", "rewards.json");
|
|
|
7
7
|
|
|
8
8
|
const TIERS = [
|
|
9
9
|
{ slug: "cherry", label: "Cherry Blossom", threshold: 1, description: "Cherry blossom trees in your forest" },
|
|
10
|
-
{ slug: "pine", label: "Pine", threshold:
|
|
11
|
-
{ slug: "oak", label: "Oak", threshold:
|
|
12
|
-
{ slug: "ancient", label: "Ancient", threshold:
|
|
13
|
-
{ slug: "mythic", label: "Mythic", threshold:
|
|
10
|
+
{ slug: "pine", label: "Pine", threshold: 2, description: "Evergreen pines in your forest" },
|
|
11
|
+
{ slug: "oak", label: "Oak", threshold: 4, description: "Broad oaks in your forest" },
|
|
12
|
+
{ slug: "ancient", label: "Ancient", threshold: 7, description: "Rare tall golden ancients" },
|
|
13
|
+
{ slug: "mythic", label: "Mythic", threshold: 10, description: "Glowing mythic trees" },
|
|
14
14
|
];
|
|
15
15
|
|
|
16
16
|
export { TIERS };
|
package/src/sync.js
CHANGED
|
@@ -7,11 +7,14 @@ export async function syncToCloud(forest) {
|
|
|
7
7
|
const auth = getAuth();
|
|
8
8
|
if (!auth || !auth.access_token) return;
|
|
9
9
|
|
|
10
|
-
// Send tree data
|
|
10
|
+
// Send tree data for rendering on the web. variant ("ancient") and
|
|
11
|
+
// heightBonus must travel too, or gold/tall trees mirror as plain short ones.
|
|
11
12
|
const trees = (forest.trees || []).map((t) => ({
|
|
12
13
|
type: t.type,
|
|
13
14
|
growth: t.growth,
|
|
14
15
|
x: t.x,
|
|
16
|
+
...(t.variant ? { variant: t.variant } : {}),
|
|
17
|
+
...(t.heightBonus ? { heightBonus: t.heightBonus } : {}),
|
|
15
18
|
}));
|
|
16
19
|
|
|
17
20
|
try {
|
package/src/varieties.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
export const VARIETIES = [
|
|
6
6
|
{ key: "standard", threshold: 0, label: "Standard", species: [{ type: "birch" }, { type: "willow" }] },
|
|
7
7
|
{ key: "cherry", threshold: 1, label: "Cherry Blossom", species: [{ type: "cherry_blossom" }] },
|
|
8
|
-
{ key: "pine", threshold:
|
|
9
|
-
{ key: "oak", threshold:
|
|
10
|
-
{ key: "ancient", threshold:
|
|
11
|
-
{ key: "mythic", threshold:
|
|
8
|
+
{ key: "pine", threshold: 2, label: "Pine", species: [{ type: "pine" }] },
|
|
9
|
+
{ key: "oak", threshold: 4, label: "Oak", species: [{ type: "oak" }] },
|
|
10
|
+
{ key: "ancient", threshold: 7, label: "Ancient", species: [{ type: "oak", variant: "ancient" }] },
|
|
11
|
+
{ key: "mythic", threshold: 10, label: "Mythic", species: [{ type: "mythic" }] },
|
|
12
12
|
];
|
|
13
13
|
|
|
14
14
|
// Build the species pool from the set of unlocked variety keys.
|