about summary refs log tree commit diff stats
path: root/html/text-world/js/worldgen.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/text-world/js/worldgen.js')
-rw-r--r--html/text-world/js/worldgen.js130
1 files changed, 130 insertions, 0 deletions
diff --git a/html/text-world/js/worldgen.js b/html/text-world/js/worldgen.js
new file mode 100644
index 0000000..c8f5778
--- /dev/null
+++ b/html/text-world/js/worldgen.js
@@ -0,0 +1,130 @@
+'use strict';
+
+const WorldGenerator = {
+    generate() {
+        let world = World.create();
+        
+        // Create player
+        let result = WorldGenerator.createPlayer(world);
+        world = result.world;
+        const playerId = result.entityId;
+
+        // Generate environments
+        world = WorldGenerator.generateEnvironments(world);
+
+        return { world, playerId };
+    },
+
+    createPlayer(world) {
+        const newWorld = World.createEntity(world);
+        const entityId = newWorld.nextEntityId - 1;
+        
+        return {
+            world: World.addComponent(
+                World.addComponent(
+                    World.addComponent(
+                        newWorld,
+                        entityId,
+                        new Position(0, 0)
+                    ),
+                    entityId,
+                    new Inventory([])
+                ),
+                entityId,
+                new Messages([])
+            ),
+            entityId
+        };
+    },
+
+    generateEnvironments(world) {
+        let newWorld = world;
+        
+        for (let x = 0; x < 10; x++) {
+            for (let y = 0; y < 10; y++) {
+                newWorld = WorldGenerator.createEnvironment(newWorld, x, y);
+            }
+        }
+        
+        return newWorld;
+    },
+
+    createEnvironment(world, x, y) {
+        const newWorld = World.createEntity(world);
+        const entityId = newWorld.nextEntityId - 1;
+        
+        // Add basic components
+        let updatedWorld = World.addComponent(
+            World.addComponent(
+                newWorld,
+                entityId,
+                new Position(x, y)
+            ),
+            entityId,
+            this.generateEnvironmentDescription(x, y)
+        );
+
+        // Add items based on environment type
+        const items = this.generateItems(x, y);
+        items.forEach(item => {
+            const itemEntity = World.createEntity(updatedWorld);
+            updatedWorld = World.addComponent(
+                World.addComponent(
+                    updatedWorld,
+                    itemEntity,
+                    new Position(x, y)
+                ),
+                itemEntity,
+                item
+            );
+        });
+
+        return updatedWorld;
+    },
+
+    generateEnvironmentDescription(x, y) {
+        const environments = [
+            {
+                short: "Forest Clearing",
+                long: "A peaceful clearing surrounded by tall trees. Sunlight filters through the canopy above.",
+                explorable: {
+                    "trees": "The trees here are ancient oaks, their bark rough and weathered.",
+                    "ground": "The forest floor is covered in soft moss and fallen leaves."
+                }
+            },
+            {
+                short: "Rocky Outcrop",
+                long: "A rocky area with large boulders scattered about. Some seem to hide small caves.",
+                explorable: {
+                    "boulders": "The boulders are covered in colorful lichens.",
+                    "caves": "Small openings that could shelter wildlife."
+                }
+            }
+        ];
+
+        const index = (x * 7 + y * 13) % environments.length;
+        return new Description(
+            environments[index].short,
+            environments[index].long,
+            environments[index].explorable
+        );
+    },
+
+    generateItems(x, y) {
+        const items = [
+            new Item("mushroom", "A small, colorful mushroom that might be edible."),
+            new Item("stone", "A smooth, flat stone that catches your eye."),
+            new Item("stick", "A sturdy wooden stick."),
+            new Item("flower", "A beautiful wildflower with vibrant petals."),
+            new Item("feather", "A delicate feather from some unknown bird.")
+        ];
+
+        // Use coordinates to deterministically generate items
+        const numItems = ((x * 3 + y * 5) % 3) + 1; // 1-3 items per location
+        const startIndex = (x * 7 + y * 11) % items.length;
+        
+        return Array.from({ length: numItems }, (_, i) => 
+            items[(startIndex + i) % items.length]
+        );
+    }
+};
awan/blame/src/local/lineedit.nim?id=a8f05f18fdd64485c26b453e62e8073b50e271ef'>^
aaacdc35 ^
a6bbcd0d ^

0bc76d47 ^




d7a05e7a ^
a6bbcd0d ^

d7a05e7a ^


0bc76d47 ^
8e20aaaf ^
2b10a9b7 ^

d7a05e7a ^

34b02351 ^
0bc76d47 ^






































d7a05e7a ^
aaacdc35 ^
0bc76d47 ^
2f8edaff ^

aaacdc35 ^
0bc76d47 ^
aaacdc35 ^
91d18d27 ^
0bc76d47 ^









91d18d27 ^
0bc76d47 ^












aaacdc35 ^

0bc76d47 ^
19068fd7 ^
66b9574b ^
0bc76d47 ^



d7a05e7a ^
0bc76d47 ^
34b02351 ^
0bc76d47 ^






34b02351 ^
d7a05e7a ^
6a5596ec ^
6f7bcc54 ^
d7a05e7a ^
0bc76d47 ^

6a5596ec ^
a6bbcd0d ^
d7a05e7a ^
0bc76d47 ^


83857c03 ^
0bc76d47 ^

a6bbcd0d ^
66b9574b ^
0bc76d47 ^
78ffc938 ^
0bc76d47 ^


78ffc938 ^



0bc76d47 ^

af3c8348 ^

66b9574b ^
af3c8348 ^
6f7bcc54 ^
d7a05e7a ^
0bc76d47 ^



a6bbcd0d ^
d7a05e7a ^
a6bbcd0d ^

d7a05e7a ^
0bc76d47 ^




a6bbcd0d ^
d7a05e7a ^
4f6dacd1 ^

0bc76d47 ^
a6bbcd0d ^
d7a05e7a ^
0bc76d47 ^





a6bbcd0d ^
d7a05e7a ^
0bc76d47 ^





a6bbcd0d ^
3c156384 ^
0bc76d47 ^

99c6d7cd ^
0bc76d47 ^
99c6d7cd ^
0bc76d47 ^



99c6d7cd ^
a6bbcd0d ^
0bc76d47 ^



a6bbcd0d ^
3c156384 ^
0bc76d47 ^

99c6d7cd ^
0bc76d47 ^


99c6d7cd ^
0bc76d47 ^





99c6d7cd ^
0bc76d47 ^




a6bbcd0d ^
3c156384 ^
0bc76d47 ^
3c156384 ^
0bc76d47 ^


a6bbcd0d ^
3c156384 ^
0bc76d47 ^













a6bbcd0d ^
d7a05e7a ^
0bc76d47 ^



a6bbcd0d ^
d7a05e7a ^
0bc76d47 ^




a6bbcd0d ^
d7a05e7a ^




0bc76d47 ^
9d677d35 ^


d7a05e7a ^
0bc76d47 ^
a6bbcd0d ^
d7a05e7a ^


0bc76d47 ^
9d677d35 ^
d7a05e7a ^
0bc76d47 ^
d7a05e7a ^

0bc76d47 ^
9d677d35 ^
d7a05e7a ^
d7a05e7a ^
a6bbcd0d ^
66b9574b ^
b66ab79d ^

66b9574b ^

8e20aaaf ^

91d18d27 ^
0bc76d47 ^
8e20aaaf ^

0bc76d47 ^
8e20aaaf ^
0bc76d47 ^



d7a05e7a ^

a6bbcd0d ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332