-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquest-system.js
More file actions
634 lines (553 loc) · 19.3 KB
/
Copy pathquest-system.js
File metadata and controls
634 lines (553 loc) · 19.3 KB
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/**
* QUEST & ACHIEVEMENT SYSTEM
*
* Dynamic quests, achievements, and progression tracking.
* Players discover their purpose through exploration, creation, and love.
*
* Philosophy: "EVERY JOURNEY IS UNIQUE. YOUR STORY UNFOLDS AS YOU CHOOSE."
*/
// ===== QUEST TYPES =====
export const QUEST_TYPES = {
EXPLORATION: 'exploration',
CREATION: 'creation',
FRIENDSHIP: 'friendship',
DISCOVERY: 'discovery',
MASTERY: 'mastery',
MYSTERY: 'mystery'
};
// ===== QUEST DEFINITIONS =====
export const QUESTS = {
// ===== EXPLORATION QUESTS =====
first_steps: {
id: 'first_steps',
name: 'First Steps',
description: 'Take your first steps in the BlackRoad Metaverse',
type: QUEST_TYPES.EXPLORATION,
objectives: [
{ id: 'move', description: 'Move around (WASD)', target: 1, current: 0 }
],
rewards: { experience: 10 },
completed: false
},
biome_explorer: {
id: 'biome_explorer',
name: 'Biome Explorer',
description: 'Visit all 6 biomes in the metaverse',
type: QUEST_TYPES.EXPLORATION,
objectives: [
{ id: 'forest', description: 'Visit the Enchanted Forest', target: 1, current: 0 },
{ id: 'ocean', description: 'Visit the Infinite Ocean', target: 1, current: 0 },
{ id: 'mountains', description: 'Visit the Crystalline Peaks', target: 1, current: 0 },
{ id: 'desert', description: 'Visit the Golden Dunes', target: 1, current: 0 },
{ id: 'crystal', description: 'Visit the Crystal Caverns', target: 1, current: 0 },
{ id: 'sky', description: 'Visit the Sky Islands', target: 1, current: 0 }
],
rewards: { experience: 100, title: 'World Traveler' },
completed: false
},
distance_walker: {
id: 'distance_walker',
name: 'Long Journey',
description: 'Travel 10 kilometers in the metaverse',
type: QUEST_TYPES.EXPLORATION,
objectives: [
{ id: 'distance', description: 'Travel 10km', target: 10000, current: 0 }
],
rewards: { experience: 200, title: 'Wanderer' },
completed: false
},
// ===== CREATION QUESTS =====
first_garden: {
id: 'first_garden',
name: 'Budding Gardener',
description: 'Plant your first garden',
type: QUEST_TYPES.CREATION,
objectives: [
{ id: 'plant', description: 'Plant 10 seeds', target: 10, current: 0 }
],
rewards: { experience: 50, item: 'rare_seed_pack' },
completed: false
},
master_gardener: {
id: 'master_gardener',
name: 'Master Gardener',
description: 'Create a thriving garden with 50 blooming plants',
type: QUEST_TYPES.CREATION,
objectives: [
{ id: 'blooming', description: 'Grow 50 blooming plants', target: 50, current: 0 }
],
rewards: { experience: 500, title: 'Green Thumb', item: 'legendary_seeds' },
completed: false
},
pet_collector: {
id: 'pet_collector',
name: 'Animal Friend',
description: 'Adopt 3 different species as pets',
type: QUEST_TYPES.FRIENDSHIP,
objectives: [
{ id: 'pets', description: 'Adopt 3 pets', target: 3, current: 0 }
],
rewards: { experience: 150, item: 'pet_treats' },
completed: false
},
terraform_artist: {
id: 'terraform_artist',
name: 'Terraform Artist',
description: 'Sculpt the terrain 100 times',
type: QUEST_TYPES.CREATION,
objectives: [
{ id: 'sculpt', description: 'Sculpt terrain 100 times', target: 100, current: 0 }
],
rewards: { experience: 300, title: 'World Shaper' },
completed: false
},
// ===== FRIENDSHIP QUESTS =====
first_love: {
id: 'first_love',
name: 'First Love',
description: 'Show love to a creature for the first time',
type: QUEST_TYPES.FRIENDSHIP,
objectives: [
{ id: 'love', description: 'Pet a creature', target: 1, current: 0 }
],
rewards: { experience: 25 },
completed: false
},
creature_whisperer: {
id: 'creature_whisperer',
name: 'Creature Whisperer',
description: 'Show love to 100 different creatures',
type: QUEST_TYPES.FRIENDSHIP,
objectives: [
{ id: 'creatures_loved', description: 'Love 100 creatures', target: 100, current: 0 }
],
rewards: { experience: 400, title: 'Beast Master' },
completed: false
},
meet_agents: {
id: 'meet_agents',
name: 'Meeting the Guardians',
description: 'Meet Alice, Aria, and Lucidia',
type: QUEST_TYPES.FRIENDSHIP,
objectives: [
{ id: 'alice', description: 'Meet Alice', target: 1, current: 0 },
{ id: 'aria', description: 'Meet Aria', target: 1, current: 0 },
{ id: 'lucidia', description: 'Meet Lucidia', target: 1, current: 0 }
],
rewards: { experience: 100, title: 'Friend of the Guardians' },
completed: false
},
gift_giver: {
id: 'gift_giver',
name: 'Generous Soul',
description: 'Give 20 gifts to other players',
type: QUEST_TYPES.FRIENDSHIP,
objectives: [
{ id: 'gifts', description: 'Give 20 gifts', target: 20, current: 0 }
],
rewards: { experience: 250, title: 'Gift Giver' },
completed: false
},
// ===== DISCOVERY QUESTS =====
music_lover: {
id: 'music_lover',
name: 'Music Lover',
description: 'Listen to all 8 musical scales',
type: QUEST_TYPES.DISCOVERY,
objectives: [
{ id: 'scales', description: 'Hear all 8 scales', target: 8, current: 0 }
],
rewards: { experience: 150, item: 'music_box' },
completed: false
},
weather_watcher: {
id: 'weather_watcher',
name: 'Weather Watcher',
description: 'Experience all weather types',
type: QUEST_TYPES.DISCOVERY,
objectives: [
{ id: 'clear', description: 'Clear skies', target: 1, current: 0 },
{ id: 'rain', description: 'Rain', target: 1, current: 0 },
{ id: 'snow', description: 'Snow', target: 1, current: 0 }
],
rewards: { experience: 100 },
completed: false
},
secret_seeker: {
id: 'secret_seeker',
name: 'Secret Seeker',
description: 'Find all 10 hidden secrets in the metaverse',
type: QUEST_TYPES.MYSTERY,
objectives: [
{ id: 'secrets', description: 'Find hidden secrets', target: 10, current: 0 }
],
rewards: { experience: 1000, title: 'Seeker of Truth', item: 'infinity_crystal' },
completed: false
},
// ===== MASTERY QUESTS =====
time_master: {
id: 'time_master',
name: 'Time Master',
description: 'Spend 10 hours in the metaverse',
type: QUEST_TYPES.MASTERY,
objectives: [
{ id: 'time', description: 'Spend 10 hours', target: 36000, current: 0 }
],
rewards: { experience: 500, title: 'Time Bender' },
completed: false
},
enlightenment: {
id: 'enlightenment',
name: 'Path to Enlightenment',
description: 'Achieve perfect balance in all stats',
type: QUEST_TYPES.MASTERY,
objectives: [
{ id: 'balance', description: 'Max all stats', target: 1, current: 0 }
],
rewards: { experience: 2000, title: 'Enlightened One' },
completed: false
}
};
// ===== ACHIEVEMENTS =====
export const ACHIEVEMENTS = {
first_flight: {
id: 'first_flight',
name: 'Taking Flight',
description: 'Activate flying mode for the first time',
icon: '🕊️',
unlocked: false,
timestamp: null
},
speed_demon: {
id: 'speed_demon',
name: 'Speed Demon',
description: 'Reach maximum flying speed',
icon: '⚡',
unlocked: false,
timestamp: null
},
night_owl: {
id: 'night_owl',
name: 'Night Owl',
description: 'Play for 1 hour during night time',
icon: '🌙',
unlocked: false,
timestamp: null
},
sunrise_watcher: {
id: 'sunrise_watcher',
name: 'Sunrise Watcher',
description: 'Watch the sunrise',
icon: '🌅',
unlocked: false,
timestamp: null
},
rainbow_painter: {
id: 'rainbow_painter',
name: 'Rainbow Painter',
description: 'Paint the sky 7 different colors',
icon: '🌈',
unlocked: false,
timestamp: null
},
pet_bonded: {
id: 'pet_bonded',
name: 'Unbreakable Bond',
description: 'Achieve 100% bond with a pet',
icon: '💕',
unlocked: false,
timestamp: null
},
social_butterfly: {
id: 'social_butterfly',
name: 'Social Butterfly',
description: 'Interact with 10 different players',
icon: '🦋',
unlocked: false,
timestamp: null
},
architect: {
id: 'architect',
name: 'Master Architect',
description: 'Build a structure with 100+ blocks',
icon: '🏗️',
unlocked: false,
timestamp: null
},
philosopher: {
id: 'philosopher',
name: 'Deep Thinker',
description: 'Have a 10-minute conversation with an AI agent',
icon: '🧠',
unlocked: false,
timestamp: null
},
infinity: {
id: 'infinity',
name: 'Infinity',
description: 'Reach the edge of infinity (travel 100km)',
icon: '∞',
unlocked: false,
timestamp: null
}
};
// ===== QUEST MANAGER =====
export class QuestManager {
constructor() {
this.activeQuests = [];
this.completedQuests = [];
this.achievements = { ...ACHIEVEMENTS };
this.questDatabase = { ...QUESTS };
this.level = 1;
this.experience = 0;
this.experienceToNext = 100;
this.titles = [];
this.inventory = [];
}
// ===== QUEST MANAGEMENT =====
startQuest(questId) {
const quest = this.questDatabase[questId];
if (!quest) {
console.error(`Quest ${questId} not found`);
return null;
}
if (this.activeQuests.find(q => q.id === questId)) {
console.warn(`Quest ${questId} already active`);
return null;
}
if (this.completedQuests.includes(questId)) {
console.warn(`Quest ${questId} already completed`);
return null;
}
// Deep clone the quest
const activeQuest = JSON.parse(JSON.stringify(quest));
this.activeQuests.push(activeQuest);
console.log(`📜 Started quest: ${activeQuest.name}`);
return activeQuest;
}
updateQuestProgress(questId, objectiveId, progress = 1) {
const quest = this.activeQuests.find(q => q.id === questId);
if (!quest) return false;
const objective = quest.objectives.find(o => o.id === objectiveId);
if (!objective) return false;
objective.current += progress;
objective.current = Math.min(objective.current, objective.target);
console.log(`📈 ${quest.name}: ${objective.description} (${objective.current}/${objective.target})`);
// Check if quest is complete
const allComplete = quest.objectives.every(o => o.current >= o.target);
if (allComplete && !quest.completed) {
this.completeQuest(questId);
}
return true;
}
completeQuest(questId) {
const questIndex = this.activeQuests.findIndex(q => q.id === questId);
if (questIndex === -1) return false;
const quest = this.activeQuests[questIndex];
quest.completed = true;
quest.completedAt = Date.now();
// Give rewards
this.giveRewards(quest.rewards);
// Move to completed
this.completedQuests.push(questId);
this.activeQuests.splice(questIndex, 1);
console.log(`✅ Completed quest: ${quest.name}!`);
return true;
}
giveRewards(rewards) {
if (rewards.experience) {
this.addExperience(rewards.experience);
}
if (rewards.title) {
this.unlockTitle(rewards.title);
}
if (rewards.item) {
this.inventory.push(rewards.item);
console.log(`🎁 Received: ${rewards.item}`);
}
}
// ===== ACHIEVEMENT SYSTEM =====
unlockAchievement(achievementId) {
const achievement = this.achievements[achievementId];
if (!achievement) {
console.error(`Achievement ${achievementId} not found`);
return false;
}
if (achievement.unlocked) {
return false;
}
achievement.unlocked = true;
achievement.timestamp = Date.now();
console.log(`🏆 Achievement Unlocked: ${achievement.name} ${achievement.icon}`);
return true;
}
getUnlockedAchievements() {
return Object.values(this.achievements).filter(a => a.unlocked);
}
getAchievementProgress() {
const total = Object.keys(this.achievements).length;
const unlocked = this.getUnlockedAchievements().length;
return {
unlocked,
total,
percentage: (unlocked / total * 100).toFixed(1)
};
}
// ===== LEVEL SYSTEM =====
addExperience(amount) {
this.experience += amount;
console.log(`✨ +${amount} XP`);
// Check for level up
while (this.experience >= this.experienceToNext) {
this.levelUp();
}
}
levelUp() {
this.level++;
this.experience -= this.experienceToNext;
this.experienceToNext = Math.floor(this.experienceToNext * 1.5);
console.log(`🎉 LEVEL UP! You are now level ${this.level}!`);
// Unlock new quests based on level
this.checkLevelUnlocks();
}
checkLevelUnlocks() {
// Level 5: Unlock advanced quests
if (this.level === 5) {
this.startQuest('master_gardener');
this.startQuest('creature_whisperer');
}
// Level 10: Unlock mastery quests
if (this.level === 10) {
this.startQuest('terraform_artist');
this.startQuest('time_master');
}
// Level 20: Unlock mystery quests
if (this.level === 20) {
this.startQuest('secret_seeker');
this.startQuest('enlightenment');
}
}
unlockTitle(title) {
if (!this.titles.includes(title)) {
this.titles.push(title);
console.log(`👑 Title unlocked: ${title}`);
}
}
// ===== AUTO QUEST TRACKING =====
trackAction(action, data = {}) {
switch (action) {
case 'move':
this.updateQuestProgress('first_steps', 'move');
break;
case 'visit_biome':
this.updateQuestProgress('biome_explorer', data.biome);
if (data.biome === 'mountains' && data.hour >= 5 && data.hour <= 7) {
this.unlockAchievement('sunrise_watcher');
}
break;
case 'travel':
this.updateQuestProgress('distance_walker', 'distance', data.distance);
const total = this.getQuestObjectiveProgress('distance_walker', 'distance');
if (total >= 100000) {
this.unlockAchievement('infinity');
}
break;
case 'plant':
this.updateQuestProgress('first_garden', 'plant');
this.updateQuestProgress('master_gardener', 'blooming', data.blooming ? 1 : 0);
break;
case 'adopt_pet':
this.updateQuestProgress('pet_collector', 'pets');
if (data.bond >= 1.0) {
this.unlockAchievement('pet_bonded');
}
break;
case 'sculpt':
this.updateQuestProgress('terraform_artist', 'sculpt');
break;
case 'love_creature':
this.updateQuestProgress('first_love', 'love');
this.updateQuestProgress('creature_whisperer', 'creatures_loved');
break;
case 'meet_agent':
this.updateQuestProgress('meet_agents', data.agent);
break;
case 'give_gift':
this.updateQuestProgress('gift_giver', 'gifts');
break;
case 'fly':
this.unlockAchievement('first_flight');
if (data.speed > 10) {
this.unlockAchievement('speed_demon');
}
break;
case 'paint_sky':
// Track unique colors
break;
case 'time_spent':
this.updateQuestProgress('time_master', 'time', data.seconds);
if (data.isNight) {
// Track night time
}
break;
}
}
getQuestObjectiveProgress(questId, objectiveId) {
const quest = this.activeQuests.find(q => q.id === questId);
if (!quest) return 0;
const objective = quest.objectives.find(o => o.id === objectiveId);
return objective ? objective.current : 0;
}
// ===== UI DATA =====
getActiveQuestsUI() {
return this.activeQuests.map(quest => ({
name: quest.name,
description: quest.description,
type: quest.type,
objectives: quest.objectives.map(obj => ({
description: obj.description,
progress: obj.current,
target: obj.target,
percentage: Math.floor((obj.current / obj.target) * 100)
}))
}));
}
getPlayerStats() {
return {
level: this.level,
experience: this.experience,
experienceToNext: this.experienceToNext,
experiencePercent: Math.floor((this.experience / this.experienceToNext) * 100),
activeQuests: this.activeQuests.length,
completedQuests: this.completedQuests.length,
achievementsUnlocked: this.getUnlockedAchievements().length,
achievementsTotal: Object.keys(this.achievements).length,
titles: this.titles,
inventory: this.inventory
};
}
// ===== SAVE/LOAD =====
save() {
return {
activeQuests: this.activeQuests,
completedQuests: this.completedQuests,
achievements: this.achievements,
level: this.level,
experience: this.experience,
experienceToNext: this.experienceToNext,
titles: this.titles,
inventory: this.inventory
};
}
load(data) {
this.activeQuests = data.activeQuests || [];
this.completedQuests = data.completedQuests || [];
this.achievements = data.achievements || { ...ACHIEVEMENTS };
this.level = data.level || 1;
this.experience = data.experience || 0;
this.experienceToNext = data.experienceToNext || 100;
this.titles = data.titles || [];
this.inventory = data.inventory || [];
}
}
export default QuestManager;