@@ -7,7 +7,7 @@ Author: Aarush & Ian
77---
88
99<meta charset =" UTF-8 " />
10- <title >:feet: TGDP Pack Opening Game </title >
10+ <title >👣 TGDP Pack Opening Game </title >
1111<link href =" https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css " rel =" stylesheet " />
1212<style >
1313 body {
@@ -58,7 +58,7 @@ Author: Aarush & Ian
5858 @keyframes explode {
5959 0% {transform : scale (0 ); opacity : 0 ;}
6060 50% {transform : scale (1.5 ); opacity : 1 ;}
61- 100% {transform : scale (1 );}
61+ 100% {transform : scale (1 ); opacity : 1 ; }
6262 }
6363 .pack-opening {
6464 font-size : 2em ;
@@ -85,22 +85,25 @@ Author: Aarush & Ian
8585 }
8686</style >
8787<div class =" container mt-5 " >
88- <h1 >:feet: TGDP Pack Opening</h1 >
88+ <h1 >👣 TGDP Pack Opening</h1 >
8989 <div id =" coinBalance " >Coins: 100</div >
9090 <p >Each pack costs 5 coins.</p >
9191 <p >Choose a pack to open:</p >
9292 <button class =" btn btn-success pack-btn " id =" jungleBtn " onclick =" openPack (' jungle' )" >Jungle Pack</button >
9393 <button class =" btn btn-primary pack-btn " id =" oceanBtn " onclick =" openPack (' ocean' )" >Ocean Pack</button >
9494 <button class =" btn btn-warning pack-btn " id =" desertBtn " onclick =" openPack (' desert' )" >Desert Pack</button >
9595 <button class =" btn btn-info pack-btn " id =" arcticBtn " onclick =" openPack (' arctic' )" >Arctic Pack</button >
96- <button class =" btn btn-warning binder-btn " onclick =" showBinder ()" >: ledger : Binder</button >
96+ <button class =" btn btn-warning binder-btn " onclick =" showBinder ()" >📓 Binder</button >
9797 <div id =" openingText " class =" pack-opening d-none " >Opening Pack...</div >
9898 <div id =" cardArea " class =" card-container " ></div >
9999 <div id =" binderArea " class =" card-container d-none " ></div >
100100</div >
101101<script >
102102 let coins = 100 ;
103103 const packCost = 5 ;
104+ let isOpening = false ;
105+ const collectedCards = JSON .parse (localStorage .getItem (' collectedCards' ) || ' []' );
106+
104107 const packs = {
105108 jungle: [
106109 { name: ' Leafy Lemur' , rarity: ' common' },
@@ -131,39 +134,37 @@ Author: Aarush & Ian
131134 { name: ' Frost Wolf' , rarity: ' rare' }
132135 ]
133136 };
137+
134138 const cardImageMap = {
135- ' Leafy Lemur' : ' https://upload.wikimedia.org/wikipedia/commons/4/46/Blue-eyed_lemur.jpg ' ,
136- ' Jungle Squirrel' : ' https://upload.wikimedia.org/wikipedia/commons/6/6b/Red-bellied_Squirrel.JPG ' ,
137- ' Tree Tamarin' : ' https://upload.wikimedia.org/wikipedia/commons/1/11/Golden_Lion_Tamarin_Rio_de_Janeiro_Zoo.jpg ' ,
138- ' Vine Panther' : ' https://upload.wikimedia.org/wikipedia/commons/e/e3/Jaguar_1.jpg ' ,
139- ' Jungle King' : ' https://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg ' ,
140- ' Bubble Fish' : ' https://upload.wikimedia.org/wikipedia/commons/3/3a/Blue_tang_fish_2.jpg ' ,
141- ' Sea Otter' : ' https://upload.wikimedia.org/wikipedia/commons/1/1a/Sea_otter_with_kelp.jpg ' ,
142- ' Coral Crab' : ' https://upload.wikimedia.org/wikipedia/commons/9/98/Xanthidae_Crab.jpg ' ,
143- ' Sharkfin Ray' : ' https://upload.wikimedia.org/wikipedia/commons/d/d8/Sharkray_Cephalopterus_latirostris_2.jpg ' ,
144- ' Leviathan' : ' https://upload.wikimedia.org/wikipedia/commons/3/37/Blue_Whale_2008-10-24_11-31-57.jpg ' ,
145- ' Sand Scorpion' : ' https://upload.wikimedia.org/wikipedia/commons/e/e3/Desert_Scorpion.jpg ' ,
146- ' Dune Lizard' : ' https://upload.wikimedia.org/wikipedia/commons/8/84/Dune_lizard.jpg ' ,
147- ' Cactus Hare' : ' https://upload.wikimedia.org/wikipedia/commons/1/1a/Desert_Jackrabbit.jpg ' ,
148- ' Desert Fox' : ' https://upload.wikimedia.org/wikipedia/commons/2/2e/Fennec_Fox_2010_2.JPG ' ,
149- ' Sand Serpent' : ' https://upload.wikimedia.org/wikipedia/commons/5/5c/Sidewinder_Mojave_desert.jpg ' ,
150- ' Snow Hare' : ' https://upload.wikimedia.org/wikipedia/commons/e/e1/Lepus_timidus.jpg ' ,
151- ' Ice Owl' : ' https://upload.wikimedia.org/wikipedia/commons/e/e5/Snowy_Owl_-_Alaska.jpg ' ,
152- ' Polar Fox' : ' https://upload.wikimedia.org/wikipedia/commons/c/c7/Arctic_Fox_-_Alaska.jpg ' ,
153- ' Glacier Bear' : ' https://upload.wikimedia.org/wikipedia/commons/1/1b/Polar_bear_-_Alaska.jpg ' ,
154- ' Frost Wolf' : ' https://upload.wikimedia.org/wikipedia/commons/9/98/Wolf_on_Snow.jpg '
139+ ' Leafy Lemur' : ' {{site.baseurl}}/images/icon1.png ' ,
140+ ' Jungle Squirrel' : ' {{site.baseurl}}/images/icon2.png ' ,
141+ ' Tree Tamarin' : ' {{site.baseurl}}/images/icon3.png ' ,
142+ ' Vine Panther' : ' {{site.baseurl}}/images/icon4.png ' ,
143+ ' Jungle King' : ' {{site.baseurl}}/images/icon5.png ' ,
144+ ' Bubble Fish' : ' {{site.baseurl}}/images/icon6.png ' ,
145+ ' Sea Otter' : ' {{site.baseurl}}/images/icon7.png ' ,
146+ ' Coral Crab' : ' {{site.baseurl}}/images/icon8.png ' ,
147+ ' Sharkfin Ray' : ' {{site.baseurl}}/images/icon9.png ' ,
148+ ' Leviathan' : ' {{site.baseurl}}/images/icon10.png ' ,
149+ ' Sand Scorpion' : ' {{site.baseurl}}/images/icon11.png ' ,
150+ ' Dune Lizard' : ' {{site.baseurl}}/images/icon12.png ' ,
151+ ' Cactus Hare' : ' {{site.baseurl}}/images/icon13.png ' ,
152+ ' Desert Fox' : ' {{site.baseurl}}/images/icon14.png ' ,
153+ ' Sand Serpent' : ' {{site.baseurl}}/images/icon15.png ' ,
154+ ' Snow Hare' : ' {{site.baseurl}}/images/icon16.png ' ,
155+ ' Ice Owl' : ' {{site.baseurl}}/images/icon17.png ' ,
156+ ' Polar Fox' : ' {{site.baseurl}}/images/icon18.png ' ,
157+ ' Glacier Bear' : ' {{site.baseurl}}/images/icon19.png ' ,
158+ ' Frost Wolf' : ' {{site.baseurl}}/images/icon20.png '
155159 };
156- const collectedCards = [];
157- function getImageUrlForName (name ) {
158- return cardImageMap[name] || ' https://via.placeholder.com/150?text=No+Image' ;
159- }
160- // Coin rewards per rarity
160+
161161 const coinRewards = {
162162 common: 1 ,
163163 uncommon: 3 ,
164164 rare: 7 ,
165165 legendary: 15
166166 };
167+
167168 function getRandomCard (pack ) {
168169 const rand = Math .random ();
169170 let rarity;
@@ -174,39 +175,48 @@ Author: Aarush & Ian
174175 const candidates = pack .filter (c => c .rarity === rarity);
175176 return candidates[Math .floor (Math .random () * candidates .length )];
176177 }
178+
177179 function updateCoinDisplay () {
178180 document .getElementById (' coinBalance' ).textContent = ` Coins: ${ coins} ` ;
179- // Disable buttons if coins are insufficient
180181 [' jungleBtn' , ' oceanBtn' , ' desertBtn' , ' arcticBtn' ].forEach (id => {
181- document .getElementById (id).disabled = coins < packCost;
182+ document .getElementById (id).disabled = coins < packCost || isOpening ;
182183 });
183184 }
185+
184186 function openPack (type ) {
187+ if (isOpening) return ;
185188 if (coins < packCost) {
186189 alert (" You don't have enough coins to open this pack!" );
187190 return ;
188191 }
192+
193+ isOpening = true ;
189194 coins -= packCost;
190195 updateCoinDisplay ();
191- disableButtons ();
196+
192197 const cardArea = document .getElementById (' cardArea' );
193198 const openingText = document .getElementById (' openingText' );
194199 const binderArea = document .getElementById (' binderArea' );
200+
195201 binderArea .classList .add (' d-none' );
196202 cardArea .innerHTML = ' ' ;
197203 openingText .classList .remove (' d-none' );
204+
198205 setTimeout (() => {
199206 openingText .classList .add (' d-none' );
207+
200208 const cards = [];
201209 for (let i = 0 ; i < 6 ; i++ ) {
202210 cards .push (getRandomCard (packs[type]));
203211 }
212+
204213 let totalReward = 0 ;
214+
205215 cards .forEach ((card , index ) => {
206216 setTimeout (() => {
207217 const cardDiv = document .createElement (' div' );
208218 cardDiv .className = ` card game-card ${ card .rarity } ` ;
209- const imgUrl = getImageUrlForName ( card .name ) ;
219+ const imgUrl = cardImageMap[ card .name ] || ' {{site.baseurl}}/images/placeholder.png ' ;
210220 cardDiv .innerHTML = `
211221 <img src =" ${imgUrl}" class =" card-img-top" alt =" ${card.name}" width =" 150" height =" 150" />
212222 <div class =" card-body" >
@@ -216,40 +226,36 @@ Author: Aarush & Ian
216226 cardArea .appendChild (cardDiv);
217227 saveToBinder (card);
218228 totalReward += coinRewards[card .rarity ] || 0 ;
219- // After last card shown, add reward coins and update display
220- if (index === cards .length - 1 ) {
229+
230+ if (index === cards .length - 1 ) {
221231 coins += totalReward;
222232 setTimeout (() => {
223233 alert (` You earned ${ totalReward} coins from this pack!` );
234+ isOpening = false ;
224235 updateCoinDisplay ();
225- enableButtons ();
226- }, 400 );
236+ }, 800 ); // wait for animation to complete before alert
227237 }
228- }, index * 400 );
238+ }, index * 500 );
229239 });
230240 }, 1000 );
231241 }
242+
232243 function rarityColor (rarity ) {
233244 return {
234245 common: ' secondary' ,
235246 uncommon: ' success' ,
236- rare: ' info' ,
237- legendary: ' warning'
238- }[rarity];
239- }
240- function disableButtons () {
241- [' jungleBtn' , ' oceanBtn' , ' desertBtn' , ' arcticBtn' ].forEach (id => {
242- document .getElementById (id).disabled = true ;
243- });
244- }
245- function enableButtons () {
246- updateCoinDisplay ();
247+ rare: ' primary' ,
248+ legendary: ' danger'
249+ }[rarity] || ' secondary' ;
247250 }
251+
248252 function saveToBinder (card ) {
249253 if (! collectedCards .find (c => c .name === card .name )) {
250254 collectedCards .push (card);
255+ localStorage .setItem (' collectedCards' , JSON .stringify (collectedCards));
251256 }
252257 }
258+
253259 function showBinder () {
254260 const cardArea = document .getElementById (' cardArea' );
255261 const binderArea = document .getElementById (' binderArea' );
@@ -259,7 +265,7 @@ Author: Aarush & Ian
259265 collectedCards .forEach (card => {
260266 const cardDiv = document .createElement (' div' );
261267 cardDiv .className = ` card game-card ${ card .rarity } ` ;
262- const imgUrl = getImageUrlForName ( card .name ) ;
268+ const imgUrl = cardImageMap[ card .name ] || ' {{site.baseurl}}/images/placeholder.png ' ;
263269 cardDiv .innerHTML = `
264270 <img src =" ${imgUrl}" class =" card-img-top" alt =" ${card.name}" width =" 150" height =" 150" />
265271 <div class =" card-body" >
@@ -269,25 +275,22 @@ Author: Aarush & Ian
269275 binderArea .appendChild (cardDiv);
270276 });
271277 }
272- // Initialize coin display on load
278+
279+ // Initialize
273280 updateCoinDisplay ();
274281</script >
275282
276283<script >
277- // filepath: /home/kasm-user/nighthawk/GenomeGamersFrontend/navigation/Worlds/world0.md
278- // ...existing code...
284+ // --- Background Music ---
285+ const music = new Audio (' {{site.baseurl}}/assets/audio/11confrontingmyself.mp3' );
286+ music .loop = true ;
287+ music .volume = 0.5 ;
279288
280- // --- Background Music ---
281- const music = new Audio (' {{site.baseurl}}/assets/audio/11confrontingmyself.mp3' ); // Change path as needed
282- music .loop = true ;
283- music .volume = 0.5 ;
284-
285- // Play music after first user interaction (required by browsers)
286- function startMusicOnce () {
287- music .play ().catch (() => {});
288- window .removeEventListener (' click' , startMusicOnce);
289- window .removeEventListener (' keydown' , startMusicOnce);
290- }
291- window .addEventListener (' click' , startMusicOnce);
292- window .addEventListener (' keydown' , startMusicOnce);
293- </script >
289+ function startMusicOnce () {
290+ music .play ().catch (() => {});
291+ window .removeEventListener (' click' , startMusicOnce);
292+ window .removeEventListener (' keydown' , startMusicOnce);
293+ }
294+ window .addEventListener (' click' , startMusicOnce);
295+ window .addEventListener (' keydown' , startMusicOnce);
296+ </script >
0 commit comments