soluzka

collect 50 apples and get amazon discount

Dec 27th, 2024 (edited)
87
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 26.96 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Eldoria's Legacy: The Quest for Food</title>
  8.     <script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.55.2/phaser.min.js"></script>
  9.     <style>
  10.         body {
  11.             margin: 0;
  12.             padding: 0;
  13.             display: flex;
  14.             justify-content: center;
  15.             align-items: center;
  16.             min-height: 100vh;
  17.             background: #000;
  18.             font-family: Arial, sans-serif;
  19.             color: white;
  20.         }
  21.  
  22.         #game-container {
  23.             position: relative;
  24.             width: 800px;
  25.             height: 600px;
  26.         }
  27.  
  28.         #welcome-screen,
  29.         #story-panel,
  30.         #dialog-panel,
  31.         #response-panel,
  32.         #trade-panel,
  33.         #store-panel,
  34.         #inventory-panel {
  35.             position: absolute;
  36.             left: 50%;
  37.             transform: translateX(-50%);
  38.             width: 80%;
  39.             background: rgba(0, 0, 0, 0.8);
  40.             padding: 20px;
  41.             border-radius: 10px;
  42.             box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  43.             text-align: center;
  44.             color: white;
  45.         }
  46.  
  47.         #buttons {
  48.             display: flex;
  49.             flex-direction: column;
  50.             align-items: center;
  51.         }
  52.  
  53.         button {
  54.             background: #4CAF50;
  55.             color: white;
  56.             border: none;
  57.             padding: 10px 15px;
  58.             margin: 5px 0;
  59.             border-radius: 6px;
  60.             cursor: pointer;
  61.             font-size: 16px;
  62.             transition: background 0.3s;
  63.             width: 80%;
  64.         }
  65.  
  66.         button:hover {
  67.             background: #45a049;
  68.         }
  69.  
  70.         input {
  71.             padding: 8px;
  72.             margin: 5px 0;
  73.             border: 2px solid #4CAF50;
  74.             border-radius: 4px;
  75.             width: 80%;
  76.             font-size: 16px;
  77.             background: rgba(255, 255, 255, 0.9);
  78.             color: #000;
  79.         }
  80.  
  81.         #stats-panel {
  82.             position: absolute;
  83.             top: 10px;
  84.             left: 10px;
  85.             background: rgba(0, 0, 0, 0.9);
  86.             padding: 10px;
  87.             border-radius: 10px;
  88.             border: 1px solid #4CAF50;
  89.             min-width: 150px;
  90.         }
  91.  
  92.         .item {
  93.             display: flex;
  94.             align-items: center;
  95.             margin: 5px 0;
  96.         }
  97.  
  98.         .item img {
  99.             width: 30px;
  100.             height: 30px;
  101.             margin-right: 10px;
  102.         }
  103.     </style>
  104. </head>
  105.  
  106. <body>
  107.     <audio id="bg-music" loop>
  108.         <source src="https://www.bensound.com/bensound-music/bensound-ukulele.mp3" type="audio/mpeg">
  109.     </audio>
  110.     <div id="game-container"></div>
  111.  
  112.     <script>
  113.         const config = {
  114.             type: Phaser.AUTO,
  115.             width: 800,
  116.             height: 600,
  117.             physics: {
  118.                 default: 'arcade',
  119.                 arcade: { gravity: { y: 0 }, debug: false },
  120.             },
  121.             scene: {
  122.                 preload: preload,
  123.                 create: create,
  124.                 update: update,
  125.             }
  126.         };
  127.  
  128.         const game = new Phaser.Game(config);
  129.  
  130.         let player;
  131.         let fruitGroup;
  132.         let trees;
  133.         let currentTreeIndex = 0;
  134.         let background;
  135.         let currentChapter = 0;
  136.         let collectedFruits = 0;
  137.         let moneyEarned = 0;
  138.         let experience = 0;
  139.         const bgMusic = document.getElementById('bg-music');
  140.  
  141.         let playerHealth = 100; // Player's health
  142.         let creatureHealth = 50; // Creature's health
  143.  
  144.         const dialogues = [
  145.             { pattern: /trade/i, response: "What do you want to trade? I can exchange 1 fruit for a special item.", type: "trade" },
  146.             { pattern: /give food/i, response: "Yum! More food means more adventures!", type: "bland" },
  147.             { pattern: /help/i, response: "I'll help if you've got the fruits!", type: "bland" },
  148.             { pattern: /threat/i, response: "Threat? Only if you refuse to share!", type: "fight" },
  149.             { pattern: /need food/i, response: "Food? Let’s whip up a meal!", type: "bland" },
  150.             { pattern: /share/i, response: "Sharing is caring! What do you have?", type: "bland" },
  151.             { pattern: /fight/i, response: "Fight? Only if it's a fruit brawl!", type: "fight" },
  152.             { pattern: /hungry/i, response: "I could eat a thousand fruits!", type: "bland" },
  153.             { pattern: /friend/i, response: "I love friends! Let’s hunt together!", type: "bland" },
  154.             { pattern: /join/i, response: "Join? Only if you promise fruits!", type: "trade" },
  155.             { pattern: /banana/i, response: "I'm a big fan of bananas, let's find some!", type: "bland" },
  156.             { pattern: /yes/i, response: "Great! Fruits await us!", type: "bland" },
  157.             { pattern: /no/i, response: "No? That’s a surprising answer!", type: "bland" },
  158.             { pattern: /food fight/i, response: "Count me in! Let's make a mess!", type: "fight" },
  159.             { pattern: /tell me a joke/i, response: "Why was the fruit so good at chess? It made all the right moves!", type: "bland" },
  160.             { pattern: /how are you/i, response: "Feeling berry good!", type: "bland" }
  161.         ];
  162.  
  163.         let story = [
  164.             { title: "Need for Survival", description: "In the land of Eldoria, resources are scarce. Your journey to gather fruits begins!" },
  165.             { title: "The First Encounter", description: "You meet a hungry traveler. Will you help each other out?" },
  166.             { title: "Conflict Arises", description: "The traveler demands some of your fruits; a skirmish for food begins." },
  167.             { title: "Unexpected Allies", description: "You find a group of monkeys willing to trade! What do they want?" },
  168.             { title: "The Magical Grove", description: "You stumble upon a grove said to be enchanted. What could that mean for your quest?" },
  169.             { title: "Bargaining", description: "You encounter a merchant creature. Can you bargain for some special fruits?" },
  170.             { title: "Battling for Fruits", description: "Some creatures just want to fight for your fruits! Be prepared for a tussle!" },
  171.             { title: "The Legendary Fruit", description: "Rumors speak of a fruit that can make its eater feel amazing. Will you find it?" },
  172.             { title: "The Great Exchange", description: "You discover a marketplace. Trade your excess fruits for treasures!" },
  173.             { title: "Return of the Rival", description: "Your rival appears. Will they join your journey or cause trouble?" },
  174.             { title: "The Feast", description: "Celebrate with the fruits you’ve gathered. Invite locals to share!" },
  175.             { title: "The Last Stand", description: "A powerful creature threatens your new friends. Gather your strength!" },
  176.             { title: "A Mysterious Island", description: "You come across an island filled with exotic fruits and creatures." },
  177.             { title: "The Berry Challenge", description: "A berry-loving creature challenges you to find the rarest fruits." },
  178.             { title: "A Tale of Two Creatures", description: "Two creatures dispute about who owns a hidden stash of fruits." },
  179.             { title: "Whispers of the Wind", description: "The wind carries tales of a hidden fruit treasure awaiting discovery." },
  180.             { title: "The Old Sage", description: "An old sage offers wisdom for the price of a fruit." },
  181.             { title: "Dancing with Spirits", description: "Spirits of the grove dance, granting you a glimpse of forgotten fruits." },
  182.             { title: "Grapple with Goblins", description: "Goblins challenge you; can you outsmart them to gain their stash?" },
  183.             { title: "The Bountiful Harvest", description: "A season of plenty begins! How many fruits can you gather?" },
  184.             { title: "Secrets of the Forest", description: "Deep within the woods, secrets of fruit magic await!" },
  185.             { title: "The Fruit Festival", description: "Join the fruit festival with various games and challenges!" },
  186.             { title: "Rivalry Renewed", description: "Your old rival has returned, but this time, they want to team up!" },
  187.             { title: "The Great Awakening", description: "Your efforts pay off. What will you do next?" }
  188.         ];
  189.  
  190.         let inventory = []; // Array to hold items added to the inventory
  191.  
  192.         function preload() {
  193.             this.load.image('background', 'https://play.rosebud.ai/assets/night_02.png?OjjR'); // Background Image
  194.             this.load.image('player', 'https://play.rosebud.ai/assets/red.png?jqlr'); // Player sprite (red apple)
  195.             this.load.image('fruit', 'https://play.rosebud.ai/assets/apple_without_Shadow.png?Lzp9'); // Apple Image
  196.             this.load.image('tree', 'https://pngimg.com/uploads/43740.png'); // Tree Image
  197.             bgMusic.play(); // Start playing background music
  198.         }
  199.  
  200.         function create() {
  201.             background = this.add.image(400, 300, 'background').setDisplaySize(800, 600);
  202.             player = this.physics.add.sprite(100, 500, 'player').setScale(0.3).setCollideWorldBounds(true);
  203.             fruitGroup = this.physics.add.group();
  204.  
  205.             // Create trees group
  206.             trees = this.physics.add.group({
  207.                 key: 'tree',
  208.                 repeat: 4,
  209.                 setXY: { x: 150, y: 450, stepX: 150 }
  210.             });
  211.             trees.children.iterate(function (tree) {
  212.                 tree.setScale(0.15).setOrigin(0.5, 1);
  213.             });
  214.  
  215.             // Spawn fruits
  216.             this.time.addEvent({
  217.                 delay: 3000,
  218.                 callback: spawnFruit,
  219.                 callbackScope: this,
  220.                 loop: true
  221.             });
  222.  
  223.             // Add overlap detection for collecting fruit
  224.             this.physics.add.overlap(player, fruitGroup, collectFruit, null, this);
  225.  
  226.             // Add input listener for jumping to the next tree
  227.             this.input.on('pointerdown', jumpToNextTree, this);
  228.  
  229.             // Create buttons
  230.             createButtons();
  231.  
  232.             updateStats();
  233.             showWelcomeScreen();
  234.         }
  235.  
  236.         function update() {
  237.             // Update game mechanics
  238.         }
  239.  
  240.         function createButtons() {
  241.             const buttonPanel = document.createElement('div');
  242.             buttonPanel.id = 'buttons';
  243.  
  244.             const resetButton = document.createElement('button');
  245.             resetButton.innerHTML = "Reset Chapters";
  246.             resetButton.onclick = resetChapters;
  247.             buttonPanel.appendChild(resetButton);
  248.  
  249.             const saveButton = document.createElement('button');
  250.             saveButton.innerHTML = "Save Progress";
  251.             saveButton.onclick = saveProgress;
  252.             buttonPanel.appendChild(saveButton);
  253.  
  254.             const eatFruitButton = document.createElement('button');
  255.             eatFruitButton.innerHTML = "Eat Fruit";
  256.             eatFruitButton.onclick = eatFruitButtonHandler;
  257.             buttonPanel.appendChild(eatFruitButton);
  258.  
  259.             const amazonStoreButton = document.createElement('button');
  260.             amazonStoreButton.innerHTML = "Visit Amazon Store";
  261.             amazonStoreButton.onclick = showAmazonStore; // Function to show Amazon Store
  262.             buttonPanel.appendChild(amazonStoreButton);
  263.  
  264.             const inventoryButton = document.createElement('button');
  265.             inventoryButton.innerHTML = "Open Inventory";
  266.             inventoryButton.onclick = showInventory; // Function to show inventory
  267.             buttonPanel.appendChild(inventoryButton);
  268.  
  269.             document.getElementById('game-container').appendChild(buttonPanel);
  270.         }
  271.  
  272.         function spawnFruit() {
  273.             const fruit = fruitGroup.create(Phaser.Math.Between(50, 750), Phaser.Math.Between(50, 550), 'fruit');
  274.             fruit.setScale(0.1);
  275.         }
  276.  
  277.         function collectFruit(player, fruit) {
  278.             fruit.destroy(); // Remove the fruit from the game
  279.             collectedFruits++; // Increment the fruit count
  280.             updateStats(); // Update stats display
  281.             alert(`You collected a fruit! Total fruits now: ${collectedFruits}`);
  282.         }
  283.  
  284.         function eatFruit() {
  285.             if (collectedFruits > 0) {
  286.                 collectedFruits--;
  287.                 let healthRestored = 10; // Amount of health restored
  288.                 let experienceGained = 5; // Experience gained from eating fruit
  289.                 let moneyGained = 1; // Money gained from eating fruit
  290.  
  291.                 playerHealth += healthRestored;
  292.                 experience += experienceGained;
  293.                 moneyEarned += moneyGained;
  294.  
  295.                 // Ensure health does not exceed maximum value
  296.                 if (playerHealth > 100) {
  297.                     playerHealth = 100;
  298.                 }
  299.  
  300.                 updateStats(); // Update stats display
  301.                 alert(`You ate a fruit! You restored ${healthRestored} HP and gained ${experienceGained} experience, as well as $${moneyGained}. Total fruits left: ${collectedFruits}`);
  302.             } else {
  303.                 alert("You don't have any fruits to eat!");
  304.             }
  305.         }
  306.  
  307.         function eatFruitButtonHandler() {
  308.             eatFruit();
  309.         }
  310.  
  311.         function jumpToNextTree() {
  312.             if (currentTreeIndex < trees.getLength()) {
  313.                const targetTree = trees.getChildren()[currentTreeIndex];
  314.                player.setPosition(targetTree.x, targetTree.y - (targetTree.height * 0.15));
  315.                currentTreeIndex++;
  316.                if (currentTreeIndex >= trees.getLength()) {
  317.                     currentTreeIndex = 0; // Reset to the first tree after the last
  318.                 }
  319.             }
  320.         }
  321.  
  322.         function showWelcomeScreen() {
  323.             const welcomePanel = document.createElement('div');
  324.             welcomePanel.id = 'welcome-screen';
  325.             welcomePanel.innerHTML = `
  326.                 <h1>Welcome to Eldoria's Legacy</h1>
  327.                 <input type="text" id="playerName" placeholder="Enter your name..." />
  328.                 <button id="start-button" onclick="createCharacter()">Start Game</button>
  329.             `;
  330.             document.getElementById('game-container').appendChild(welcomePanel);
  331.         }
  332.  
  333.         function createCharacter() {
  334.             const nameInput = document.getElementById('playerName').value;
  335.             if (nameInput.trim()) {
  336.                 document.getElementById('welcome-screen').remove();
  337.                 updateStats();
  338.                 showStory();
  339.             } else {
  340.                 alert('Please enter a name to start the adventure.');
  341.             }
  342.         }
  343.  
  344.         function showStory() {
  345.             const currentChapterInfo = story[currentChapter];
  346.             const storyPanel = document.createElement('div');
  347.             storyPanel.id = 'story-panel';
  348.             storyPanel.innerHTML = `
  349.                 <h2>${currentChapterInfo.title}</h2>
  350.                 <p>${currentChapterInfo.description}</p>
  351.                 <button onclick="nextChapter()">Continue Story</button>
  352.                 <button onclick="tradeAtChapter()">Trade Fruits</button>
  353.                 <button onclick="createDialogPanel()">Talk to a Creature</button>
  354.             `;
  355.             document.getElementById('game-container').appendChild(storyPanel);
  356.         }
  357.  
  358.         function nextChapter() {
  359.             if (currentChapter < story.length - 1) {
  360.                currentChapter++;
  361.                document.getElementById('story-panel').remove();
  362.                showStory();
  363.            } else {
  364.                alert("You've completed all chapters! Thank you for playing!");
  365.                resetGame();
  366.            }
  367.        }
  368.  
  369.        function tradeAtChapter() {
  370.            const tradePanel = document.getElementById('trade-panel') || document.createElement('div');
  371.            tradePanel.id = 'trade-panel';
  372.            tradePanel.innerHTML = `
  373.                <h2>Trade Fruits</h2>
  374.                 <p>You have ${collectedFruits} fruits. How many would you like to trade?</p>
  375.                 <input type="number" id="trade-input" min="1" max="${collectedFruits}" value="1" />
  376.                 <button onclick="executeTrade()">Trade</button>
  377.                 <button onclick="closeTradePanel()">Cancel</button>
  378.             `;
  379.  
  380.             document.getElementById('game-container').appendChild(tradePanel);
  381.         }
  382.  
  383.         function closeTradePanel() {
  384.             const tradePanel = document.getElementById('trade-panel');
  385.             if (tradePanel) {
  386.                 tradePanel.remove();
  387.             }
  388.         }
  389.  
  390.         function executeTrade() {
  391.             const tradeAmount = parseInt(document.getElementById('trade-input').value);
  392.             if (tradeAmount > collectedFruits) {
  393.                 alert("You don't have enough fruits to trade!");
  394.                 return;
  395.             }
  396.  
  397.             collectedFruits -= tradeAmount;
  398.             moneyEarned += tradeAmount; // Earn money equal to amount traded
  399.             experience += tradeAmount; // Earn experience equal to amount traded
  400.             const itemDescription = `Traded ${tradeAmount} fruit(s)`; // Description of the item
  401.             const itemImage = 'https://play.rosebud.ai/assets/apple_without_Shadow.png?Lzp9'; // Image link for inventory item
  402.             inventory.push({ description: itemDescription, image: itemImage }); // Add to inventory
  403.  
  404.             alert(`You traded ${tradeAmount} fruits for a special item! You now have ${collectedFruits} fruits left.`);
  405.             updateStats();
  406.             closeTradePanel();
  407.         }
  408.  
  409.         function updateStats() {
  410.             const statsPanel = document.getElementById('stats-panel') || document.createElement('div');
  411.             statsPanel.id = 'stats-panel';
  412.             statsPanel.innerHTML = `
  413.                 <div><strong>Collected Fruits:</strong> ${collectedFruits}</div>
  414.                 <div><strong>Money Earned:</strong> ${moneyEarned}</div>
  415.                 <div><strong>Experience:</strong> ${experience}</div>
  416.                 <div><strong>Player Health:</strong> ${playerHealth}</div>
  417.                 <div><strong>Creature Health:</strong> ${creatureHealth}</div>
  418.             `;
  419.             if (!document.getElementById('stats-panel')) {
  420.                 document.getElementById('game-container').appendChild(statsPanel);
  421.             }
  422.         }
  423.  
  424.         function resetGame() {
  425.             currentChapter = 0;
  426.             collectedFruits = 0;
  427.             moneyEarned = 0;
  428.             experience = 0;
  429.             playerHealth = 100; // Reset player's health
  430.             creatureHealth = 50; // Reset creature's health
  431.             inventory = []; // Reset inventory
  432.             document.getElementById('stats-panel')?.remove();
  433.             document.getElementById('story-panel')?.remove();
  434.             document.getElementById('inventory-panel')?.remove(); // Close inventory if open
  435.             showWelcomeScreen();
  436.         }
  437.  
  438.         function resetChapters() {
  439.             const confirmation = confirm("Are you sure you want to reset all chapters?");
  440.             if (confirmation) {
  441.                 resetGame();
  442.                 alert("All chapters have been reset.");
  443.             }
  444.         }
  445.  
  446.         function saveProgress() {
  447.             const progress = {
  448.                 collectedFruits: collectedFruits,
  449.                 moneyEarned: moneyEarned,
  450.                 experience: experience,
  451.                 currentChapter: currentChapter,
  452.                 playerHealth: playerHealth,
  453.                 creatureHealth: creatureHealth,
  454.                 inventory: inventory // Save the inventory too
  455.             };
  456.  
  457.             const progressString = JSON.stringify(progress, null, 4);
  458.             const blob = new Blob([progressString], { type: 'application/javascript' });
  459.             const link = document.createElement('a');
  460.             link.href = URL.createObjectURL(blob);
  461.             link.download = 'eldoria_progress.js';
  462.             link.click();
  463.             URL.revokeObjectURL(link.href); // Clean up the URL object
  464.             alert("Progress saved!");
  465.         }
  466.  
  467.         function createDialogPanel() {
  468.             const dialogPanel = document.createElement('div');
  469.             dialogPanel.id = 'dialog-panel';
  470.             dialogPanel.innerHTML = `
  471.                 <h2>Dialog with Creatures</h2>
  472.                 <input type="text" id="dialog-input" placeholder="Type your message here..." />
  473.                 <button onclick="sendDialog()">Send</button>
  474.                 <button onclick="closeDialog()">Close Dialog</button>
  475.                 <button onclick="attackCreature()">Attack!</button>
  476.                 <div id="response-panel"></div>
  477.                 <div id="trade-panel" style="display: none;"></div>
  478.             `;
  479.             document.getElementById('game-container').appendChild(dialogPanel);
  480.         }
  481.  
  482.         function closeDialog() {
  483.             document.getElementById('dialog-panel').remove();
  484.         }
  485.  
  486.         function getRandomResponse(input) {
  487.             const matchedResponses = dialogues.filter(resp => resp.pattern.test(input));
  488.             if (matchedResponses.length === 0) {
  489.                 return { response: "What a great day to talk about fruits and adventures!", type: "bland" };
  490.             }
  491.             return matchedResponses[Math.floor(Math.random() * matchedResponses.length)];
  492.         }
  493.  
  494.         function sendDialog() {
  495.             const input = document.getElementById('dialog-input').value.trim();
  496.             const responsePanel = document.getElementById('response-panel');
  497.  
  498.             if (input === "") {
  499.                 responsePanel.innerText = "Please type something before sending.";
  500.                 return;
  501.             }
  502.  
  503.             const randomResponse = getRandomResponse(input);
  504.             responsePanel.innerText = randomResponse.response;
  505.  
  506.             if (randomResponse.type === "fight") {
  507.                 attackCreature(); // Call attack creature if it's a fight type response
  508.             } else if (randomResponse.type === "trade") {
  509.                 tradeAtChapter(); // Open the trade panel
  510.             }
  511.  
  512.             document.getElementById('dialog-input').value = ''; // Clear input field
  513.         }
  514.  
  515.         function attackCreature() {
  516.             const responsePanel = document.getElementById('response-panel');
  517.  
  518.             // Simulate player attacking creature
  519.             if (creatureHealth > 0) {
  520.                 // Player deals damage
  521.                 creatureHealth -= 20; // Player deals 20 damage
  522.                 responsePanel.innerText = `You attacked the creature! The creature now has ${creatureHealth} HP left.`;
  523.  
  524.                 // Check if creature is still alive
  525.                 if (creatureHealth <= 0) {
  526.                    responsePanel.innerHTML += "<br>You defeated the creature!";
  527.                     // Reset health for next encounter
  528.                     creatureHealth = 50; // Reset creature's health after defeat
  529.                     updateStats();
  530.                     closeDialog();
  531.                     nextChapter();
  532.                 } else {
  533.                     // If the creature is still alive, it counterattacks
  534.                     playerHealth -= 10; // Creature deals 10 damage
  535.                     if (playerHealth <= 0) {
  536.                        responsePanel.innerHTML += "<br>You have been defeated! Game over.";
  537.                         closeDialog();
  538.                         resetGame(); // Reset game after defeat
  539.                     } else {
  540.                         responsePanel.innerHTML += `<br>The creature attacked back! You have ${playerHealth} HP left.`;
  541.                     }
  542.                 }
  543.             } else {
  544.                 responsePanel.innerText = "The creature is already defeated!";
  545.             }
  546.  
  547.             updateStats(); // Update health stats
  548.         }
  549.  
  550.         // Show Amazon Store Functionality
  551.         function showAmazonStore() {
  552.             const storePanel = document.createElement('div');
  553.             storePanel.id = 'store-panel';
  554.             storePanel.innerHTML = `
  555.                 <h2>Amazon Store</h2>
  556.                 <p>You have $${moneyEarned}.</p>
  557.                 <input type="number" id="withdraw-amount" min="1" max="${moneyEarned}" value="1" />
  558.                 <button onclick="withdrawMoney()">Withdraw Money</button>
  559.                 <button onclick="closeAmazonStore()">Close Store</button>
  560.             `;
  561.             document.getElementById('game-container').appendChild(storePanel);
  562.         }
  563.  
  564.         function withdrawMoney() {
  565.             const withdrawAmount = parseInt(document.getElementById('withdraw-amount').value);
  566.             if (withdrawAmount > moneyEarned) {
  567.                 alert("You don't have enough money to withdraw that amount!");
  568.                 return;
  569.             }
  570.             if (withdrawAmount <= 0) {
  571.                alert("Please enter a valid amount to withdraw.");
  572.                return;
  573.            }
  574.  
  575.            moneyEarned -= withdrawAmount;
  576.  
  577.            // This is where we simulate adding an item to the inventory as a 'purchase'
  578.            const itemDescription = `Purchased ${withdrawAmount} item(s)`; // Description of the item
  579.            const itemImage = 'https://play.rosebud.ai/assets/apple_without_Shadow.png?Lzp9'; // Image link for inventory item
  580.            inventory.push({ description: itemDescription, image: itemImage }); // Add to inventory
  581.  
  582.            alert(`You have successfully withdrawn $${withdrawAmount}! Your remaining balance is $${moneyEarned}.`);
  583.            updateStats(); // Update stats panel after withdrawal
  584.            closeAmazonStore();
  585.        }
  586.  
  587.        function closeAmazonStore() {
  588.            const storePanel = document.getElementById('store-panel');
  589.            if (storePanel) {
  590.                storePanel.remove();
  591.            }
  592.        }
  593.  
  594.        // Show inventory
  595.        function showInventory() {
  596.            // Create an inventory panel
  597.            const inventoryPanel = document.createElement('div');
  598.            inventoryPanel.id = 'inventory-panel';
  599.            inventoryPanel.innerHTML = `<h2>Your Inventory</h2>`;
  600.            
  601.             // Display each item in the inventory
  602.             inventory.forEach(item => {
  603.                 inventoryPanel.innerHTML += `
  604.                     <div class="item">
  605.                         <img src="${item.image}" alt="Item Image"/>
  606.                         <span>${item.description}</span>
  607.                     </div>
  608.                 `;
  609.             });
  610.  
  611.             // Close button for inventory
  612.             inventoryPanel.innerHTML += `<button onclick="closeInventory()">Close Inventory</button>`;
  613.             document.getElementById('game-container').appendChild(inventoryPanel);
  614.         }
  615.  
  616.         function closeInventory() {
  617.             const inventoryPanel = document.getElementById('inventory-panel');
  618.             if (inventoryPanel) {
  619.                 inventoryPanel.remove();
  620.             }
  621.         }
  622.  
  623.     </script>
  624. </body>
  625.  
  626. </html>
Tags: discount
Advertisement
Comments
Add Comment
Please, Sign In to add comment