ayush2917 commited on
Commit
8df5fe9
·
verified ·
1 Parent(s): e273c8d

Update templates/adventure.html

Browse files
Files changed (1) hide show
  1. templates/adventure.html +189 -70
templates/adventure.html CHANGED
@@ -33,6 +33,163 @@
33
 
34
  {% block scripts %}
35
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  document.addEventListener('DOMContentLoaded', function() {
37
  const sceneContent = document.getElementById('scene-content');
38
  const choicesContainer = document.getElementById('choices-container');
@@ -48,81 +205,43 @@ document.addEventListener('DOMContentLoaded', function() {
48
  });
49
 
50
  // Function to load a scene
51
- async function loadScene(sceneId, choice = '') {
52
- try {
53
- // Show loading state
54
- sceneContent.innerHTML = '<p>Krishna is thinking...</p>';
55
- choicesContainer.innerHTML = '';
56
-
57
- // Send request to server
58
- const response = await fetch('/adventure', {
59
- method: 'POST',
60
- headers: {
61
- 'Content-Type': 'application/x-www-form-urlencoded',
62
- },
63
- body: `current_scene=${sceneId}&choice=${encodeURIComponent(choice)}`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  });
65
-
66
- const data = await response.json();
67
-
68
- if (data.scene) {
69
- // Update scene content
70
- sceneContent.innerHTML = `<p>${data.scene}</p>`;
71
- currentScene = data.current_scene || sceneId;
72
-
73
- // Update Krishna image based on scene
74
- updateKrishnaImage(currentScene);
75
-
76
- // If there are choices, show them
77
- if (data.choices && data.choices.length > 0) {
78
- choicesContainer.innerHTML = '';
79
- data.choices.forEach(choiceText => {
80
- const choiceBtn = document.createElement('button');
81
- choiceBtn.className = 'choice-btn';
82
- choiceBtn.textContent = choiceText;
83
- choiceBtn.addEventListener('click', () => {
84
- loadScene(currentScene, choiceText);
85
- });
86
- choicesContainer.appendChild(choiceBtn);
87
- });
88
- } else {
89
- // No more choices - end of adventure
90
- choicesContainer.innerHTML = `
91
- <button class="choice-btn restart-btn" onclick="location.reload()">
92
- Play Again
93
- </button>
94
- `;
95
- }
96
- } else {
97
- throw new Error('Invalid scene data');
98
- }
99
- } catch (error) {
100
- console.error('Error:', error);
101
- sceneContent.innerHTML = `
102
- <p>Oh no! Something went wrong in Vrindavan.</p>
103
- <button class="choice-btn" onclick="loadScene('start')">
104
- Start Over
105
  </button>
106
  `;
107
  }
108
  }
109
-
110
- // Change Krishna's image based on the scene
111
- function updateKrishnaImage(sceneId) {
112
- let imageName = 'krishna_normal.png';
113
-
114
- if (sceneId.includes('peacock') || sceneId.includes('tree')) {
115
- imageName = 'krishna_playing.png';
116
- } else if (sceneId.includes('butter') || sceneId.includes('yamuna')) {
117
- imageName = 'krishna_mischievous.png';
118
- } else if (sceneId.includes('flute')) {
119
- imageName = 'krishna_flute.png';
120
- } else if (!choicesContainer.querySelector('.choice-btn')) {
121
- imageName = 'krishna_smiling.png';
122
- }
123
-
124
- krishnaImg.src = `{{ url_for('static', filename='assets/') }}${imageName}`;
125
- }
126
  });
127
  </script>
128
  {% endblock %}
 
33
 
34
  {% block scripts %}
35
  <script>
36
+ // Adventure scenes data - matches your backend logic
37
+ const adventureScenes = {
38
+ 'start': {
39
+ text: "Hare Manavi! Welcome to Vrindavan, the land of Lord Krishna! We're standing in front of the magnificent Vrindavan temple. Shall we offer flowers and prayers to the deity or explore the vibrant marketplace nearby?",
40
+ choices: ["Offer prayers", "Explore marketplace"],
41
+ image: "krishna_normal.png"
42
+ },
43
+ 'offer_prayers': {
44
+ text: "Great choice, Manavi! Let's first offer our prayers and seek Krishna's blessings. We'll offer these beautiful roses at the lotus feet of the Lord. Now, shall we spend some time singing bhajans and kirtans or simply meditate in His divine presence?",
45
+ choices: ["Sing bhajans and kirtans", "Meditate"],
46
+ image: "krishna_praying.png"
47
+ },
48
+ 'sing_bhajans': {
49
+ text: "Wonderful, Manavi! Let's sing the praises of the Lord with our sweet voices. Here are some traditional bhajans and kirtans that we can sing together. Now that we've offered our prayers and sung His praises, shall we go to the marketplace or visit the holy ghats by the Yamuna?",
50
+ choices: ["Marketplace", "Ghats"],
51
+ image: "krishna_flute.png"
52
+ },
53
+ 'marketplace': {
54
+ text: "Manavi, let's explore the colorful marketplace! It's filled with stalls selling vibrant rangoli powders, fragrant incense, and delicious sweets. Shall we buy some rangoli powders to decorate our homes or treat ourselves to some mouth-watering sweets?",
55
+ choices: ["Rangoli powders", "Sweets"],
56
+ image: "krishna_mischievous.png"
57
+ },
58
+ 'rangoli': {
59
+ text: "Excellent choice, Manavi! Let's buy some rangoli powders and use them to create beautiful patterns in our homes. We can also buy some incense to fill our homes with a divine fragrance. Now, shall we visit the holy ghats by the Yamuna or return to the temple to listen to the priest's discourse?",
60
+ choices: ["Ghats", "Discourses"],
61
+ image: "krishna_smiling.png"
62
+ },
63
+ 'ghats': {
64
+ text: "Manavi, let's visit the holy ghats by the Yamuna! It's a serene and sacred place where devotees come to take a dip in the holy waters. Shall we take a dip in the holy waters or simply sit by the banks and meditate?",
65
+ choices: ["Take a dip", "Sit and meditate"],
66
+ image: "krishna_meditating.png"
67
+ },
68
+ 'meditate': {
69
+ text: "Great choice, Manavi! Let's sit by the banks of the Yamuna and meditate. The cool breeze and the sound of the flowing water will help us connect with the divine. Now, shall we return to the temple to listen to the priest's discourse or spend some time in the lush forests of Vrindavan?",
70
+ choices: ["Discourses", "Forests"],
71
+ image: "krishna_peaceful.png"
72
+ },
73
+ 'forests': {
74
+ text: "Manavi, let's spend some time in the lush forests of Vrindavan! It's a place where Lord Krishna played His divine flute and enchanted the hearts of the gopis. Shall we take a leisurely stroll through the forest or simply sit under a tree and sing kirtans?",
75
+ choices: ["Stroll", "Sing kirtans"],
76
+ image: "krishna_playing.png"
77
+ },
78
+ 'stroll': {
79
+ text: "Wonderful choice, Manavi! Let's take a leisurely stroll through the forest and enjoy the beauty of nature. We can also sit under a tree and sing kirtans, offering our praises to the Lord. Now, shall we return to the temple to listen to the priest's discourse or visit the ashrams of the saints and sages?",
80
+ choices: ["Discourses", "Ashrams"],
81
+ image: "krishna_walking.png"
82
+ },
83
+ 'ashrams': {
84
+ text: "Manavi, let's visit the ashrams of the saints and sages! It's a place where they live in seclusion and meditate on the divine. Shall we learn some spiritual practices from the saints and sages or simply sit in their presence and soak in their divine energy?",
85
+ choices: ["Learn practices", "Soak in energy"],
86
+ image: "krishna_learning.png"
87
+ },
88
+ 'learn': {
89
+ text: "Great choice, Manavi! Let's learn some spiritual practices from the saints and sages. They can teach us the art of meditation, the power of mantras, and the secrets of self-realization. Now, shall we return to the temple to listen to the priest's discourse or spend some time in the company of the devotees?",
90
+ choices: ["Discourses", "Devotees"],
91
+ image: "krishna_teaching.png"
92
+ },
93
+ 'devotees': {
94
+ text: "Manavi, let's spend some time in the company of the devotees! It's a place where we can share our experiences, learn from each other, and grow together in our spiritual journey. Shall we participate in the bhajans and kirtans or simply sit and share our stories with each other?",
95
+ choices: ["Bhajans and kirtans", "Share stories"],
96
+ image: "krishna_singing.png"
97
+ },
98
+ 'bhajans': {
99
+ text: "Wonderful choice, Manavi! Let's participate in the bhajans and kirtans and sing the praises of the Lord. We can also sit and share our stories with each other, learning from each other's experiences. Now, shall we return to the temple to listen to the priest's discourse or visit the cowshed and play with the calves?",
100
+ choices: ["Discourses", "Play with calves"],
101
+ image: "krishna_dancing.png"
102
+ },
103
+ 'calves': {
104
+ text: "Manavi, let's visit the cowshed and play with the calves! It's a place where Lord Krishna spent His time playing with the calves and herding the cows. Shall we feed the calves or simply sit and play with them?",
105
+ choices: ["Feed calves", "Play with calves"],
106
+ image: "krishna_calf.png"
107
+ },
108
+ 'feed': {
109
+ text: "Great choice, Manavi! Let's feed the calves and take care of them. It's a way of serving the Lord and showing our devotion to Him. Now, shall we return to the temple to listen to the priest's discourse or spend some time in solitude, contemplating on the divine?",
110
+ choices: ["Discourses", "Solitude"],
111
+ image: "krishna_feeding.png"
112
+ },
113
+ 'solitude': {
114
+ text: "Manavi, let's spend some time in solitude, contemplating on the divine! It's a way of deepening our connection with the Lord and experiencing His presence within us. Shall we sit in a quiet place and meditate or simply take a walk in nature and enjoy its beauty?",
115
+ choices: ["Meditate", "Walk in nature"],
116
+ image: "krishna_contemplating.png"
117
+ },
118
+ 'final': {
119
+ text: "Wonderful choice, Manavi! Let's sit in a quiet place and meditate, focusing on the divine within us. We can also take a walk in nature and enjoy its beauty, offering our praises to the Lord for His wonderful creation. Now, our adventure in Vrindavan has come to an end. Thank you for spending this time with me, Manavi. May Lord Krishna bless you with peace, happiness, and divine grace. Hare Krishna!",
120
+ choices: [],
121
+ image: "krishna_blessing.png"
122
+ }
123
+ };
124
+
125
+ // Scene transitions mapping
126
+ const sceneTransitions = {
127
+ 'start': {
128
+ "Offer prayers": "offer_prayers",
129
+ "Explore marketplace": "marketplace"
130
+ },
131
+ 'offer_prayers': {
132
+ "Sing bhajans and kirtans": "sing_bhajans",
133
+ "Meditate": "meditate"
134
+ },
135
+ 'sing_bhajans': {
136
+ "Marketplace": "marketplace",
137
+ "Ghats": "ghats"
138
+ },
139
+ 'marketplace': {
140
+ "Rangoli powders": "rangoli",
141
+ "Sweets": "sweets"
142
+ },
143
+ 'rangoli': {
144
+ "Ghats": "ghats",
145
+ "Discourses": "final"
146
+ },
147
+ 'ghats': {
148
+ "Take a dip": "final",
149
+ "Sit and meditate": "meditate"
150
+ },
151
+ 'meditate': {
152
+ "Discourses": "final",
153
+ "Forests": "forests"
154
+ },
155
+ 'forests': {
156
+ "Stroll": "stroll",
157
+ "Sing kirtans": "final"
158
+ },
159
+ 'stroll': {
160
+ "Discourses": "final",
161
+ "Ashrams": "ashrams"
162
+ },
163
+ 'ashrams': {
164
+ "Learn practices": "learn",
165
+ "Soak in energy": "final"
166
+ },
167
+ 'learn': {
168
+ "Discourses": "final",
169
+ "Devotees": "devotees"
170
+ },
171
+ 'devotees': {
172
+ "Bhajans and kirtans": "bhajans",
173
+ "Share stories": "final"
174
+ },
175
+ 'bhajans': {
176
+ "Discourses": "final",
177
+ "Play with calves": "calves"
178
+ },
179
+ 'calves': {
180
+ "Feed calves": "feed",
181
+ "Play with calves": "final"
182
+ },
183
+ 'feed': {
184
+ "Discourses": "final",
185
+ "Solitude": "solitude"
186
+ },
187
+ 'solitude': {
188
+ "Meditate": "final",
189
+ "Walk in nature": "final"
190
+ }
191
+ };
192
+
193
  document.addEventListener('DOMContentLoaded', function() {
194
  const sceneContent = document.getElementById('scene-content');
195
  const choicesContainer = document.getElementById('choices-container');
 
205
  });
206
 
207
  // Function to load a scene
208
+ function loadScene(sceneId, choice = '') {
209
+ const scene = adventureScenes[sceneId];
210
+
211
+ if (!scene) {
212
+ sceneContent.innerHTML = '<p>Oh no! The adventure path seems unclear. Let\'s start over.</p>';
213
+ choicesContainer.innerHTML = '<button class="choice-btn" onclick="loadScene(\'start\')">Start Over</button>';
214
+ return;
215
+ }
216
+
217
+ // Update scene content
218
+ sceneContent.innerHTML = `<p>${scene.text}</p>`;
219
+ krishnaImg.src = `{{ url_for('static', filename='assets/') }}${scene.image}`;
220
+
221
+ // Clear previous choices
222
+ choicesContainer.innerHTML = '';
223
+
224
+ // Add new choices if available
225
+ if (scene.choices && scene.choices.length > 0) {
226
+ scene.choices.forEach(choiceText => {
227
+ const choiceBtn = document.createElement('button');
228
+ choiceBtn.className = 'choice-btn';
229
+ choiceBtn.textContent = choiceText;
230
+ choiceBtn.addEventListener('click', () => {
231
+ const nextScene = sceneTransitions[sceneId][choiceText];
232
+ loadScene(nextScene, choiceText);
233
+ });
234
+ choicesContainer.appendChild(choiceBtn);
235
  });
236
+ } else {
237
+ // End of adventure
238
+ choicesContainer.innerHTML = `
239
+ <button class="choice-btn restart-btn" onclick="location.reload()">
240
+ Play Again
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  </button>
242
  `;
243
  }
244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  });
246
  </script>
247
  {% endblock %}