User prompt
Remove pipe mania game
User prompt
Not all card's descriptions are visible...
User prompt
Not all card's descriptions are shown...
User prompt
Not all cards have descriptions; fix that
User prompt
Remove the pipe mania minigame
User prompt
Add description for each animal
User prompt
Make it so that the collection shows one by one each animal with buttons to change animal
User prompt
Make a tier list of all event cards in the game
User prompt
Add new feature: Card trading! Trade your cards to get more cards! You can either trade fair, or scam who you're trading!
User prompt
Tap fast Minigame is now called "Gem collector"
User prompt
Add a sound effect for having an event card
User prompt
Add assets for event cards
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'x' in undefined' in or related to this line: 'tween(this.scale, {' Line Number: 761 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'x' in undefined' in or related to this line: 'tween(this.scale, {' Line Number: 760
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'x' in undefined' in or related to this line: 'tween(this.scale, {' Line Number: 753
User prompt
Tap fast Minigame now gives 25 points for each mud cleaned
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'x' in undefined' in or related to this line: 'tween(this.scale, {' Line Number: 746 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'x' in undefined' in or related to this line: 'tween(this.scale, {' Line Number: 741 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add a new feature: Events! Play mini games to get points for the event; every 100 points give you a random card of a rarity chosen at random (up to epic). Every 1000 points you get a random card of the "Event" rarity that can only be gotten from the events(Event rarity cards: Walrus, Bat, Elephant, Moose, Wasp, Seal)
User prompt
Fake cards are removed from your collection ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'resultText.style.fill = 0xFF0000;' Line Number: 896
User prompt
Add a new feature: Scanner! You can scan Cards you got from packs to see if they're fake or not; you can also see if they're fake in the collection
User prompt
Add assets for Dodo, Sabertooth tiger, Wooly rhino, Megalodon and Mammoth
User prompt
Add new pack: Ancient pack! A pack with 4 cards; most of them are mammals, but there's at least 1 guaranteed Exctint Animal card!(Extinct Animal cards: Unique: Dodo, Sabertooth tiger; Epic: Woolly rhino; Legendary: Megalodon; Exotic: Wolly Mammoth)
User prompt
Add new pack: Ancient pack! A pack with 4 cards; most of them are mammals, but there's at least 1 guaranteed Exctint Animal card!(Extinct Animal cards: Unique: Dodo, Sabertooth tiger; Epic: Woolly rhino; Legendary: Megalodon; Exotic: Wolly Mammoth)
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { collection: {}, stats: { totalCards: 0, common: 0, uncommon: 0, rare: 0, unique: 0, epic: 0, legendary: 0, exotic: 0, event: 0 } }); /**** * Classes ****/ var Button = Container.expand(function (text, width, height, color) { var self = Container.call(this); var background = self.attachAsset('cardButton', { anchorX: 0.5, anchorY: 0.5, width: width || 300, height: height || 100 }); var label = new Text2(text, { size: 40, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); // Initialize scale object explicitly to avoid 'in' operator TypeError self.scale = { x: 1, y: 1 }; self.down = function () { // Ensure scale exists before tweening to avoid TypeError if (!this.scale) { this.scale = { x: 1, y: 1 }; } // Use self.scale instead of this.scale to ensure the correct scope tween(self.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; self.up = function () { // Ensure scale exists before tweening to avoid TypeError if (!self.scale) { self.scale = { x: 1, y: 1 }; } tween(self.scale, { x: 1, y: 1 }, { duration: 100 }); }; return self; }); var Card = Container.expand(function (rarity, id, name, type) { var self = Container.call(this); self.rarity = rarity; self.id = id; self.name = name; self.type = type; self.revealed = false; // Card back initially shown var cardBack = self.attachAsset('cardBack', { anchorX: 0.5, anchorY: 0.5 }); // The actual card (initially hidden) var cardFront; switch (rarity) { case 'common': cardFront = self.attachAsset('commonCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'uncommon': cardFront = self.attachAsset('uncommonCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'rare': cardFront = self.attachAsset('rareCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'unique': cardFront = self.attachAsset('uniqueCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'epic': cardFront = self.attachAsset('epicCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'legendary': cardFront = self.attachAsset('legendaryCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'exotic': cardFront = self.attachAsset('exoticCard', { anchorX: 0.5, anchorY: 0.5, visible: false }); break; case 'event': cardFront = self.attachAsset('epicCard', { anchorX: 0.5, anchorY: 0.5, visible: false, tint: 0x00FFFF // Cyan color for event cards }); break; } // Card icon var icon; if (rarity === 'event') { // Event card icons by name if (self.name === 'Walrus') { icon = self.attachAsset('cardIconWalrus', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Bat') { icon = self.attachAsset('cardIconBat', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Elephant') { icon = self.attachAsset('cardIconElephant', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Moose') { icon = self.attachAsset('cardIconMoose', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Wasp') { icon = self.attachAsset('cardIconWasp', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Seal') { icon = self.attachAsset('cardIconSeal', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconEVERYTHING', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } } else switch (type) { case 'ExtinctAnimal': // Check for specific Extinct Animals if (self.name === 'Dodo') { icon = self.attachAsset('cardIconDodo', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Sabertooth Tiger') { icon = self.attachAsset('cardIconSabertoothTiger', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Woolly Rhino') { icon = self.attachAsset('cardIconWoollyRhino', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Megalodon') { icon = self.attachAsset('cardIconMegalodon', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Woolly Mammoth') { icon = self.attachAsset('cardIconWoollyMammoth', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconMammal', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Rodent': icon = self.attachAsset('cardIconRat', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); break; case 'Avian': // Check for specific Avians that have unique icons if (self.name === 'Owl') { icon = self.attachAsset('cardIconOwl', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Ostrich') { icon = self.attachAsset('cardIconOstrich', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Duck') { icon = self.attachAsset('cardIconDuck', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Penguin') { icon = self.attachAsset('cardIconPenguin', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Eagle') { icon = self.attachAsset('cardIconEagle', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconPidgeon', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Amphibian': // Check for specific Amphibians that have unique icons if (self.name === 'Frog') { icon = self.attachAsset('cardIconFrog', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconSalamander', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Insect': // Check for specific Insects that have unique icons if (self.name === 'Beetle') { icon = self.attachAsset('cardIconBeetle', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconAnt', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Aquatic': // Check for specific Aquatics that have unique icons if (self.name === 'Shark') { icon = self.attachAsset('cardIconShark', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Whale') { icon = self.attachAsset('cardIconWhale', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconSalmon', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Mammal': // Check for specific Mammals that have unique icons if (self.name === 'Pig') { icon = self.attachAsset('cardIconPig', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Fox') { icon = self.attachAsset('cardIconFox', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Wolf') { icon = self.attachAsset('cardIconWolf', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Bear') { icon = self.attachAsset('cardIconBear', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Hippo') { icon = self.attachAsset('cardIconHippo', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Rhino') { icon = self.attachAsset('cardIconRhino', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconHare', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Reptile': // Check for specific Reptiles that have unique icons if (self.name === 'Crocodile') { icon = self.attachAsset('cardIconCrocodile', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Snake') { icon = self.attachAsset('cardIconSnake', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Cobra') { icon = self.attachAsset('cardIconCobra', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconLizard', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Feline': if (self.name === 'Cheetah') { icon = self.attachAsset('cardIconCheetah', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else { icon = self.attachAsset('cardIconLion', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; case 'Primate': icon = self.attachAsset('cardIconGorilla', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); break; case 'EVERYTHING': icon = self.attachAsset('cardIconDuck', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); break; case 'Dinosaur': if (self.name === 'Velociraptor') { icon = self.attachAsset('cardIconVelociraptor', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Parasaur') { icon = self.attachAsset('cardIconParasaur', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Pterodactyl') { icon = self.attachAsset('cardIconPterodactyl', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Stegosaurus') { icon = self.attachAsset('cardIconStegosaurus', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Ankylosaurus') { icon = self.attachAsset('cardIconAnkylosaurus', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Spinosaurus') { icon = self.attachAsset('cardIconSpinosaurus', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Diplodocus') { icon = self.attachAsset('cardIconDiplodocus', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'Triceratops') { icon = self.attachAsset('cardIconTriceratops', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } else if (self.name === 'T-REX') { icon = self.attachAsset('cardIconTRex', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); } break; default: // Default icon if type not found (optional) icon = self.attachAsset('cardIconEVERYTHING', { anchorX: 0.5, anchorY: 0.5, y: -150, visible: false }); break; } // Card text var nameText = new Text2(name, { size: 50, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0); nameText.y = 50; nameText.visible = false; self.addChild(nameText); var typeText = new Text2(type, { size: 40, fill: 0xFFFFFF }); typeText.anchor.set(0.5, 0); typeText.y = 120; typeText.visible = false; self.addChild(typeText); var rarityText = new Text2(rarity.toUpperCase(), { size: 35, fill: 0xFFFFFF }); rarityText.anchor.set(0.5, 1); rarityText.y = 300; rarityText.visible = false; self.addChild(rarityText); // Reveal the card self.reveal = function () { if (self.revealed) { return; } self.revealed = true; LK.getSound('cardFlip').play(); // Play special sounds for card rarities if (rarity === 'unique') { LK.getSound('uniqueDrop').play(); } else if (rarity === 'epic') { LK.getSound('epicDrop').play(); } else if (rarity === 'legendary') { LK.getSound('legendaryDrop').play(); } else if (rarity === 'exotic') { LK.getSound('exoticDrop').play(); } else if (rarity === 'rare') { LK.getSound('rareDrop').play(); } else if (rarity === 'event') { LK.getSound('eventCard').play(); } // Flip animation tween(cardBack.scale, { x: 0 }, { duration: 200, onFinish: function onFinish() { cardBack.visible = false; cardFront.visible = true; icon.visible = true; nameText.visible = true; typeText.visible = true; rarityText.visible = true; tween(cardFront.scale, { x: 1 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { // Add card to collection if (!storage.collection[self.id]) { // Initialize collection entry with primitive values separately storage.collection[self.id + "_rarity"] = self.rarity; storage.collection[self.id + "_name"] = self.name; storage.collection[self.id + "_type"] = self.type; storage.collection[self.id + "_count"] = 0; } storage.collection[self.id + "_count"] = (storage.collection[self.id + "_count"] || 0) + 1; storage.stats.totalCards++; if (!storage.stats[self.rarity]) { storage.stats[self.rarity] = 0; } storage.stats[self.rarity]++; } }); cardFront.scale.x = 0; } }); }; self.down = function () { self.reveal(); }; return self; }); var MiniGame = Container.expand(function (gameType) { var self = Container.call(this); self.gameType = gameType; self.score = 0; self.isActive = true; self.gameTimer = 30; // 30 seconds game duration self.lastUpdateTime = Date.now(); // Background for the mini game var background = self.attachAsset('cardButton', { anchorX: 0.5, anchorY: 0.5, width: 1800, height: 2000, tint: 0x333333 }); // Game title var displayTitle = gameType === 'GemCollector' ? "GEM COLLECTOR" : gameType.toUpperCase() + " MINI GAME"; var titleText = new Text2(displayTitle, { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.y = -900; self.addChild(titleText); // Score display var scoreText = new Text2("SCORE: 0", { size: 50, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); scoreText.y = -800; self.addChild(scoreText); // Timer display var timerText = new Text2("TIME: 30s", { size: 50, fill: 0xFFFFFF }); timerText.anchor.set(0.5, 0); timerText.y = -720; self.addChild(timerText); // Game elements based on type var gameElements = []; if (gameType === 'GemCollector') { // Create gem targets (was mudSplat, now gems) for (var i = 0; i < 5; i++) { var target = self.attachAsset('mudSplat', { anchorX: 0.5, anchorY: 0.5, x: Math.random() * 1200 - 600, y: Math.random() * 1200 - 400, scaleX: 2, scaleY: 2 }); target.down = function () { if (!self.isActive) return; // Move to a new position this.x = Math.random() * 1200 - 600; this.y = Math.random() * 1200 - 400; // Increase score by 25 points for each gem collected self.score += 25; scoreText.setText("SCORE: " + self.score); // Visual feedback // Ensure scale exists before tweening to avoid TypeError if (!this.scale) { this.scale = { x: 2, y: 2 }; } tween(this.scale, { x: 1.5, y: 1.5 }, { duration: 100, onFinish: function onFinish() { // Ensure scale exists before tweening back if (!this.scale) { this.scale = { x: 2, y: 2 }; } tween(this.scale, { x: 2, y: 2 }, { duration: 100 }); } }); }; gameElements.push(target); } } else if (gameType === 'PipeMania') { // Create a simple pipe connection game var grid = []; var gridSize = 5; // Create grid of pipe connectors for (var i = 0; i < gridSize; i++) { grid[i] = []; for (var j = 0; j < gridSize; j++) { var isPipe = Math.random() < 0.7; var pipeType = Math.random() < 0.5 ? 'pipeCorner' : 'pipeStraight'; var rotation = Math.floor(Math.random() * 4) * 90 * (Math.PI / 180); var cell; if (isPipe) { cell = self.attachAsset(pipeType, { anchorX: 0.5, anchorY: 0.5, x: (j - gridSize / 2) * 200, y: (i - gridSize / 2) * 200, rotation: rotation }); } else { cell = self.attachAsset('pipeConnector', { anchorX: 0.5, anchorY: 0.5, x: (j - gridSize / 2) * 200, y: (i - gridSize / 2) * 200 }); } cell.gridX = j; cell.gridY = i; cell.isPipe = isPipe; cell.down = function () { if (!self.isActive) return; // Rotate the pipe this.rotation += Math.PI / 2; // Check connections and award points self.checkPipeConnections(); }; grid[i][j] = cell; gameElements.push(cell); } } self.grid = grid; // Function to check pipe connections self.checkPipeConnections = function () { var connected = 0; // Simple connection check - if adjacent pipes exist for (var i = 0; i < gridSize; i++) { for (var j = 0; j < gridSize - 1; j++) { if (grid[i][j].isPipe && grid[i][j + 1].isPipe) { connected++; } if (i < gridSize - 1 && grid[i][j].isPipe && grid[i + 1][j].isPipe) { connected++; } } } // Update score self.score = connected * 2; scoreText.setText("SCORE: " + self.score); }; // Initial check self.checkPipeConnections(); } // End game function self.endGame = function () { self.isActive = false; // Show the final score var finalScoreText = new Text2("FINAL SCORE: " + self.score, { size: 70, fill: 0xFFFFFF }); finalScoreText.anchor.set(0.5, 0.5); self.addChild(finalScoreText); // Determine rewards var eventPoints = self.score; // Add points to event stats if (!storage.stats.eventPoints) { storage.stats.eventPoints = 0; } storage.stats.eventPoints += eventPoints; // Check if player earned reward thresholds var cardsEarned = []; // Calculate how many 100-point rewards var regularRewards = Math.floor(eventPoints / 100); for (var i = 0; i < regularRewards; i++) { // Random rarity up to epic var rarities = ['common', 'uncommon', 'rare', 'unique', 'epic']; var rarity = rarities[Math.floor(Math.random() * rarities.length)]; // Filter cards by rarity var possibleCards = CARD_DATABASE.filter(function (card) { return card.rarity === rarity; }); // Select random card if (possibleCards.length > 0) { var card = possibleCards[Math.floor(Math.random() * possibleCards.length)]; var newCard = new Card(card.rarity, card.id, card.name, card.type); newCard.reveal(); cardsEarned.push(newCard); } } // Check for 1000-point event card reward var eventRewards = Math.floor(eventPoints / 1000); for (var i = 0; i < eventRewards; i++) { // Find event cards var eventCards = CARD_DATABASE.filter(function (card) { return card.rarity === 'event'; }); // Select random event card if (eventCards.length > 0) { var card = eventCards[Math.floor(Math.random() * eventCards.length)]; var newCard = new Card(card.rarity, card.id, card.name, card.type); newCard.reveal(); cardsEarned.push(newCard); } } // Show earned cards or let the player know they didn't earn any var rewardText = new Text2("REWARDS EARNED:", { size: 50, fill: 0xFFFFFF }); rewardText.anchor.set(0.5, 0); rewardText.y = 100; self.addChild(rewardText); if (cardsEarned.length > 0) { // Display earned cards for (var i = 0; i < cardsEarned.length; i++) { var card = cardsEarned[i]; card.scale.set(0.4); card.x = (i - (cardsEarned.length - 1) / 2) * 250; card.y = 300; self.addChild(card); } } else { var noRewardText = new Text2("No rewards earned.\nGet more points next time!", { size: 40, fill: 0xFFFFFF }); noRewardText.anchor.set(0.5, 0); noRewardText.y = 150; self.addChild(noRewardText); } // Add continue button var continueButton = new Button("CONTINUE", 400, 100); continueButton.y = 700; self.addChild(continueButton); continueButton.down = function () { tween(continueButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; continueButton.up = function () { tween(continueButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { // Return to event screen showEventScreen(); self.destroy(); } }); }; }; // Update function self.update = function () { if (!self.isActive) return; // Update timer var currentTime = Date.now(); var deltaTime = (currentTime - self.lastUpdateTime) / 1000; self.lastUpdateTime = currentTime; self.gameTimer -= deltaTime; if (self.gameTimer <= 0) { self.gameTimer = 0; self.endGame(); } timerText.setText("TIME: " + Math.ceil(self.gameTimer) + "s"); // Game specific updates if (gameType === 'GemCollector') { // Update gem targets for (var i = 0; i < gameElements.length; i++) { var target = gameElements[i]; target.rotation += 0.01; } } }; return self; }); var Pack = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.opened = false; // Pack artwork based on type var packArt; switch (type) { case 'ancient': packArt = self.attachAsset('packAncient', { anchorX: 0.5, anchorY: 0.5 }); break; case 'common': packArt = self.attachAsset('packCommon', { anchorX: 0.5, anchorY: 0.5 }); break; case 'advanced': packArt = self.attachAsset('packAdvanced', { anchorX: 0.5, anchorY: 0.5 }); break; case 'rare': packArt = self.attachAsset('packRare', { anchorX: 0.5, anchorY: 0.5 }); break; case 'magic': packArt = self.attachAsset('packMagic', { anchorX: 0.5, anchorY: 0.5 }); break; case 'legendary': packArt = self.attachAsset('packLegendary', { anchorX: 0.5, anchorY: 0.5 }); break; case 'jurassic': packArt = self.attachAsset('packJurassic', { anchorX: 0.5, anchorY: 0.5 }); break; case 'random': packArt = self.attachAsset('packRandom', { anchorX: 0.5, anchorY: 0.5 }); break; } // Pack type text var typeText = new Text2(type.toUpperCase() + " PACK", { size: 40, fill: 0xFFFFFF }); typeText.anchor.set(0.5, 0.5); self.addChild(typeText); self.down = function () { if (!currentlyOpeningPack && !self.opened) { self.openPack(); } }; self.openPack = function () { if (self.opened || currentlyOpeningPack) { return; } currentlyOpeningPack = true; LK.getSound('packOpen').play(); // Hide all packs for (var i = 0; i < packDisplays.length; i++) { if (packDisplays[i] !== self) { tween(packDisplays[i], { alpha: 0 }, { duration: 300 }); } } // Move to center and fade out tween(self, { y: 2732 / 2 - 200, scale: 1.5 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.visible = false; // Generate cards based on pack type var cards = generateCardsFromPack(self.type); // Display cards for (var i = 0; i < cards.length; i++) { var card = cards[i]; card.x = 2048 / 2 + (i - (cards.length - 1) / 2) * 550; card.y = 2732 / 2; card.scale.set(0.7); game.addChild(card); displayedCards.push(card); // Animate card entry card.y = 2732 + 400; tween(card, { y: 2732 / 2 }, { duration: 500, easing: tween.easeOut }); } // Show return button showReturnButton(); } }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ // Game state variables // Event card icon assets var currentScreen = 'home'; // 'home', 'packs', 'collection' var currentlyOpeningPack = false; var packDisplays = []; var displayedCards = []; var screenElements = []; // Game constants var CARD_DATABASE = [ // Event cards - Only obtainable through events { id: 'ev_1', rarity: 'event', name: 'Walrus', type: 'Mammal' }, { id: 'ev_2', rarity: 'event', name: 'Bat', type: 'Mammal' }, { id: 'ev_3', rarity: 'event', name: 'Elephant', type: 'Mammal' }, { id: 'ev_4', rarity: 'event', name: 'Moose', type: 'Mammal' }, { id: 'ev_5', rarity: 'event', name: 'Wasp', type: 'Insect' }, { id: 'ev_6', rarity: 'event', name: 'Seal', type: 'Mammal' }, // Extinct Animal cards - for Ancient Pack { id: 'e_1', rarity: 'unique', name: 'Dodo', type: 'ExtinctAnimal' }, { id: 'e_2', rarity: 'unique', name: 'Sabertooth Tiger', type: 'ExtinctAnimal' }, { id: 'e_3', rarity: 'epic', name: 'Woolly Rhino', type: 'ExtinctAnimal' }, { id: 'e_4', rarity: 'legendary', name: 'Megalodon', type: 'ExtinctAnimal' }, { id: 'e_5', rarity: 'exotic', name: 'Woolly Mammoth', type: 'ExtinctAnimal' }, // Common cards (id, name, type) { id: 'c1', rarity: 'common', name: 'Rat', type: 'Rodent' }, { id: 'c2', rarity: 'common', name: 'Pidgeon', type: 'Avian' }, { id: 'c3', rarity: 'common', name: 'Frog', type: 'Amphibian' }, { id: 'c4', rarity: 'common', name: 'Ant', type: 'Insect' }, { id: 'c5', rarity: 'common', name: 'Salmon', type: 'Aquatic' }, { id: 'c6', rarity: 'common', name: 'Hare', type: 'Mammal' }, { id: 'c8', rarity: 'common', name: 'Pig', type: 'Mammal' }, { id: 'c9', rarity: 'common', name: 'Snake', type: 'Reptile' }, // Uncommon cards { id: 'u1', rarity: 'uncommon', name: 'Fox', type: 'Mammal' }, { id: 'u2', rarity: 'uncommon', name: 'Owl', type: 'Avian' }, { id: 'u3', rarity: 'uncommon', name: 'Salamander', type: 'Amphibian' }, { id: 'u4', rarity: 'uncommon', name: 'Lizard', type: 'Reptile' }, { id: 'u5', rarity: 'uncommon', name: 'Beetle', type: 'Insect' }, { id: 'u6', rarity: 'uncommon', name: 'Cobra', type: 'Reptile' }, { id: 'u7', rarity: 'uncommon', name: 'Eagle', type: 'Avian' }, { id: 'u8', rarity: 'uncommon', name: 'Penguin', type: 'Avian' }, // Rare cards { id: 'r1', rarity: 'rare', name: 'Wolf', type: 'Mammal' }, { id: 'r2', rarity: 'rare', name: 'Ostrich', type: 'Avian' }, { id: 'r3', rarity: 'rare', name: 'Shark', type: 'Aquatic' }, { id: 'r4', rarity: 'rare', name: 'Rhino', type: 'Mammal' }, { id: 'r5', rarity: 'rare', name: 'Cheetah', type: 'Feline' }, // Unique cards { id: 'q1', rarity: 'unique', name: 'Bear', type: 'Mammal' }, { id: 'q2', rarity: 'unique', name: 'Lion', type: 'Feline' }, // Epic cards { id: 'e1', rarity: 'epic', name: 'Gorilla', type: 'Primate' }, { id: 'e2', rarity: 'epic', name: 'Crocodile', type: 'Reptile' }, // Legendary cards { id: 'l1', rarity: 'legendary', name: 'Hippo', type: 'Mammal' }, { id: 'l2', rarity: 'legendary', name: 'Whale', type: 'Aquatic' }, // Exotic card { id: 'x1', rarity: 'exotic', name: 'Duck', type: 'EVERYTHING' }, // Jurassic pack cards { id: 'j1', rarity: 'unique', name: 'Velociraptor', type: 'Dinosaur' }, { id: 'j2', rarity: 'unique', name: 'Parasaur', type: 'Dinosaur' }, { id: 'j3', rarity: 'epic', name: 'Pterodactyl', type: 'Dinosaur' }, { id: 'j4', rarity: 'epic', name: 'Stegosaurus', type: 'Dinosaur' }, { id: 'j5', rarity: 'epic', name: 'Ankylosaurus', type: 'Dinosaur' }, { id: 'j6', rarity: 'legendary', name: 'Spinosaurus', type: 'Dinosaur' }, { id: 'j7', rarity: 'legendary', name: 'Diplodocus', type: 'Dinosaur' }, { id: 'j8', rarity: 'legendary', name: 'Triceratops', type: 'Dinosaur' }, { id: 'j9', rarity: 'exotic', name: 'T-REX', type: 'Dinosaur' }]; // Play background music LK.playMusic('bgMusic'); // Initialize stats text var statsText = new Text2("Collection: 0 cards", { size: 50, fill: 0xFFFFFF }); statsText.anchor.set(0.5, 0); statsText.y = 100; LK.gui.top.addChild(statsText); updateStatsDisplay(); // Setup the home screen showHomeScreen(); // Show home screen with main menu function showHomeScreen() { clearScreen(); currentScreen = 'home'; var title = new Text2("ANIMALMON", { size: 120, fill: 0xFFFFFF }); title.anchor.set(0.5, 0); title.x = 2048 / 2; title.y = 300; game.addChild(title); screenElements.push(title); var subtitle = new Text2("Pocket Menagerie", { size: 80, fill: 0xFFFFFF }); subtitle.anchor.set(0.5, 0); subtitle.x = 2048 / 2; subtitle.y = 450; game.addChild(subtitle); screenElements.push(subtitle); var packButton = new Button("OPEN PACKS", 400, 120); packButton.x = 2048 / 2; packButton.y = 1200; game.addChild(packButton); screenElements.push(packButton); packButton.down = function () { tween(packButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; packButton.up = function () { tween(packButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showPacksScreen(); } }); }; var collectionButton = new Button("COLLECTION", 400, 120); collectionButton.x = 2048 / 2; collectionButton.y = 1400; game.addChild(collectionButton); screenElements.push(collectionButton); collectionButton.down = function () { tween(collectionButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; collectionButton.up = function () { tween(collectionButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showCollectionScreen(); } }); }; // Add Event Button var eventButton = new Button("EVENTS", 400, 120); eventButton.x = 2048 / 2; eventButton.y = 1600; game.addChild(eventButton); screenElements.push(eventButton); eventButton.down = function () { tween(eventButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; eventButton.up = function () { tween(eventButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showEventScreen(); } }); }; updateStatsDisplay(); } // Show packs selection screen function showPacksScreen() { clearScreen(); currentScreen = 'packs'; var title = new Text2("SELECT A PACK", { size: 80, fill: 0xFFFFFF }); title.anchor.set(0.5, 0); title.x = 2048 / 2; title.y = 200; game.addChild(title); screenElements.push(title); // Common Pack var commonPack = new Pack('common'); commonPack.x = 2048 / 2 - 700; commonPack.y = 800; game.addChild(commonPack); packDisplays.push(commonPack); screenElements.push(commonPack); var commonText = new Text2("3 Cards\n1-2 Common\n1 Chance for Uncommon", { size: 30, fill: 0xFFFFFF }); commonText.anchor.set(0.5, 0); commonText.x = commonPack.x; commonText.y = commonPack.y + 250; game.addChild(commonText); screenElements.push(commonText); // Advanced Pack var advancedPack = new Pack('advanced'); advancedPack.x = 2048 / 2 - 350; advancedPack.y = 800; game.addChild(advancedPack); packDisplays.push(advancedPack); screenElements.push(advancedPack); var advancedText = new Text2("4 Cards\n2-3 Common\n1-2 Uncommon\nSmall Chance for Rare", { size: 30, fill: 0xFFFFFF }); advancedText.anchor.set(0.5, 0); advancedText.x = advancedPack.x; advancedText.y = advancedPack.y + 250; game.addChild(advancedText); screenElements.push(advancedText); // Rare Pack var rarePack = new Pack('rare'); rarePack.x = 2048 / 2; rarePack.y = 800; game.addChild(rarePack); packDisplays.push(rarePack); screenElements.push(rarePack); var rareText = new Text2("4 Cards\n1-2 Uncommon\n1-2 Rare\nChance for Unique", { size: 30, fill: 0xFFFFFF }); rareText.anchor.set(0.5, 0); rareText.x = rarePack.x; rareText.y = rarePack.y + 250; game.addChild(rareText); screenElements.push(rareText); // Magic Pack var magicPack = new Pack('magic'); magicPack.x = 2048 / 2 + 350; magicPack.y = 800; game.addChild(magicPack); packDisplays.push(magicPack); screenElements.push(magicPack); var magicText = new Text2("5 Cards\n1-2 Rare\n1-2 Unique\nChance for Epic", { size: 30, fill: 0xFFFFFF }); magicText.anchor.set(0.5, 0); magicText.x = magicPack.x; magicText.y = magicPack.y + 250; game.addChild(magicText); screenElements.push(magicText); // Legendary Pack var legendaryPack = new Pack('legendary'); legendaryPack.x = 2048 / 2 + 700; legendaryPack.y = 800; game.addChild(legendaryPack); packDisplays.push(legendaryPack); screenElements.push(legendaryPack); var legendaryText = new Text2("5 Cards\n1-2 Unique\n1-2 Epic\nChance for Legendary\nRare Chance for Exotic", { size: 30, fill: 0xFFFFFF }); legendaryText.anchor.set(0.5, 0); legendaryText.x = legendaryPack.x; legendaryText.y = legendaryPack.y + 250; game.addChild(legendaryText); screenElements.push(legendaryText); // Random Pack var randomPack = new Pack('random'); randomPack.x = 2048 / 2 - 350; randomPack.y = 1400; game.addChild(randomPack); packDisplays.push(randomPack); screenElements.push(randomPack); var randomText = new Text2("1 Card\nCompletely Random", { size: 30, fill: 0xFFFFFF }); randomText.anchor.set(0.5, 0); randomText.x = randomPack.x; randomText.y = randomPack.y + 250; game.addChild(randomText); screenElements.push(randomText); // Back button var backButton = new Button("BACK", 200, 80); backButton.x = 200; backButton.y = 200; game.addChild(backButton); screenElements.push(backButton); backButton.down = function () { tween(backButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; backButton.up = function () { tween(backButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showHomeScreen(); } }); }; // Jurassic Pack var jurassicPack = new Pack('jurassic'); jurassicPack.x = 2048 / 2 - 700; jurassicPack.y = 1400; game.addChild(jurassicPack); packDisplays.push(jurassicPack); screenElements.push(jurassicPack); var jurassicText = new Text2("4 Cards\nMost are Reptiles\nChance for Dinosaurs\n(Unique, Epic, Legendary, Exotic)", { size: 30, fill: 0xFFFFFF }); jurassicText.anchor.set(0.5, 0); jurassicText.x = jurassicPack.x; jurassicText.y = jurassicPack.y + 250; game.addChild(jurassicText); screenElements.push(jurassicText); // Ancient Pack var ancientPack = new Pack('ancient'); ancientPack.x = 2048 / 2 + 350; ancientPack.y = 1400; game.addChild(ancientPack); packDisplays.push(ancientPack); screenElements.push(ancientPack); var ancientText = new Text2("4 Cards\nMost are Mammals\nGuaranteed Extinct Animal\n(Unique, Epic, Legendary, Exotic)", { size: 30, fill: 0xFFFFFF }); ancientText.anchor.set(0.5, 0); ancientText.x = ancientPack.x; ancientText.y = ancientPack.y + 250; game.addChild(ancientText); screenElements.push(ancientText); } // Show return button after opening pack function showReturnButton() { var returnButton = new Button("RETURN", 300, 100); returnButton.x = 2048 / 2; returnButton.y = 2732 - 200; game.addChild(returnButton); screenElements.push(returnButton); returnButton.down = function () { tween(returnButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; returnButton.up = function () { tween(returnButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { // Clear displayed cards for (var i = 0; i < displayedCards.length; i++) { displayedCards[i].destroy(); } displayedCards = []; // Return to packs screen currentlyOpeningPack = false; showPacksScreen(); updateStatsDisplay(); } }); }; } // Show collection screen function showCollectionScreen() { clearScreen(); currentScreen = 'collection'; var currentCardIndex = 0; var title = new Text2("YOUR COLLECTION", { size: 80, fill: 0xFFFFFF }); title.anchor.set(0.5, 0); title.x = 2048 / 2; title.y = 200; game.addChild(title); screenElements.push(title); // Get all collected cards var allKeys = Object.keys(storage.collection); var cardIds = []; for (var i = 0; i < allKeys.length; i++) { var key = allKeys[i]; if (key.endsWith("_rarity")) { cardIds.push(key.substring(0, key.length - 7)); } } // Sort cards by rarity var rarityOrder = { 'common': 1, 'uncommon': 2, 'rare': 3, 'unique': 4, 'epic': 5, 'legendary': 6, 'exotic': 7, 'event': 8 }; cardIds.sort(function (a, b) { var rarityA = storage.collection[a + "_rarity"]; var rarityB = storage.collection[b + "_rarity"]; return rarityOrder[rarityA] - rarityOrder[rarityB]; }); // Display current card if collection has cards var currentCard = null; var cardInfoText = null; var navigationText = null; function displayCard(index) { // Remove previous card if exists if (currentCard) { currentCard.destroy(); } if (cardInfoText) { cardInfoText.destroy(); } if (navigationText) { navigationText.destroy(); } if (cardIds.length === 0) { var noCardsText = new Text2("No cards in collection yet!", { size: 60, fill: 0xFFFFFF }); noCardsText.anchor.set(0.5, 0.5); noCardsText.x = 2048 / 2; noCardsText.y = 2732 / 2; game.addChild(noCardsText); screenElements.push(noCardsText); return; } // Ensure index is within bounds currentCardIndex = Math.max(0, Math.min(index, cardIds.length - 1)); var cardId = cardIds[currentCardIndex]; currentCard = new Card(storage.collection[cardId + "_rarity"], cardId, storage.collection[cardId + "_name"], storage.collection[cardId + "_type"]); currentCard.x = 2048 / 2; currentCard.y = 2732 / 2 - 200; currentCard.scale.set(0.8); currentCard.reveal(); game.addChild(currentCard); screenElements.push(currentCard); // Display card info cardInfoText = new Text2("Card " + (currentCardIndex + 1) + " of " + cardIds.length + "\n" + "Owned: x" + storage.collection[cardId + "_count"], { size: 50, fill: 0xFFFFFF }); cardInfoText.anchor.set(0.5, 0); cardInfoText.x = 2048 / 2; cardInfoText.y = 2732 / 2 + 300; game.addChild(cardInfoText); screenElements.push(cardInfoText); // Navigation hint navigationText = new Text2("Use buttons to browse collection", { size: 40, fill: 0xFFFFFF }); navigationText.anchor.set(0.5, 0); navigationText.x = 2048 / 2; navigationText.y = 2732 / 2 + 450; game.addChild(navigationText); screenElements.push(navigationText); } // Navigation buttons var prevButton = new Button("< PREVIOUS", 300, 100); prevButton.x = 2048 / 2 - 400; prevButton.y = 2732 / 2; game.addChild(prevButton); screenElements.push(prevButton); prevButton.down = function () { tween(prevButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; prevButton.up = function () { tween(prevButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { if (currentCardIndex > 0) { displayCard(currentCardIndex - 1); } } }); }; var nextButton = new Button("NEXT >", 300, 100); nextButton.x = 2048 / 2 + 400; nextButton.y = 2732 / 2; game.addChild(nextButton); screenElements.push(nextButton); nextButton.down = function () { tween(nextButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; nextButton.up = function () { tween(nextButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { if (currentCardIndex < cardIds.length - 1) { displayCard(currentCardIndex + 1); } } }); }; // Display first card displayCard(0); // Back button var backButton = new Button("BACK", 200, 80); backButton.x = 200; backButton.y = 200; game.addChild(backButton); screenElements.push(backButton); backButton.down = function () { tween(backButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; backButton.up = function () { tween(backButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showHomeScreen(); } }); }; // Reset collection button var resetButton = new Button("RESET COLLECTION", 400, 80); resetButton.x = 2048 / 2; resetButton.y = 2732 - 200; game.addChild(resetButton); screenElements.push(resetButton); resetButton.down = function () { tween(resetButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; resetButton.up = function () { tween(resetButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { // Reset collection data storage.collection = {}; storage.stats = { totalCards: 0, common: 0, uncommon: 0, rare: 0, unique: 0, epic: 0, legendary: 0, exotic: 0, event: 0, eventPoints: 0 }; // Update display and return to home screen updateStatsDisplay(); showHomeScreen(); } }); }; } // Generate cards based on pack type function generateCardsFromPack(packType) { var cards = []; var rarityPool = []; switch (packType) { case 'common': // 3 cards: 1-2 Common, chance for Uncommon for (var i = 0; i < 3; i++) { if (i < 2) { rarityPool.push('common'); } else { rarityPool.push(Math.random() < 0.3 ? 'uncommon' : 'common'); } } break; case 'advanced': // 4 cards: 2-3 Common, 1-2 Uncommon, small chance for Rare for (var i = 0; i < 4; i++) { if (i < 2) { rarityPool.push('common'); } else if (i == 2) { rarityPool.push(Math.random() < 0.7 ? 'uncommon' : 'common'); } else { var roll = Math.random(); if (roll < 0.1) { rarityPool.push('rare'); } else if (roll < 0.6) { rarityPool.push('uncommon'); } else { rarityPool.push('common'); } } } break; case 'rare': // 4 cards: 1-2 Uncommon, 1-2 Rare, chance for Unique for (var i = 0; i < 4; i++) { if (i < 1) { rarityPool.push('uncommon'); } else if (i < 3) { rarityPool.push(Math.random() < 0.6 ? 'rare' : 'uncommon'); } else { var roll = Math.random(); if (roll < 0.15) { rarityPool.push('unique'); } else if (roll < 0.6) { rarityPool.push('rare'); } else { rarityPool.push('uncommon'); } } } break; case 'magic': // 5 cards: 1-2 Rare, 1-2 Unique, chance for Epic for (var i = 0; i < 5; i++) { if (i < 1) { rarityPool.push('rare'); } else if (i < 3) { rarityPool.push(Math.random() < 0.6 ? 'unique' : 'rare'); } else if (i < 4) { rarityPool.push(Math.random() < 0.7 ? 'unique' : 'rare'); } else { var roll = Math.random(); if (roll < 0.2) { rarityPool.push('epic'); } else if (roll < 0.6) { rarityPool.push('unique'); } else { rarityPool.push('rare'); } } } break; case 'legendary': // 5 cards: 1-2 Unique, 1-2 Epic, chance for Legendary, rare chance for Exotic for (var i = 0; i < 5; i++) { if (i < 1) { rarityPool.push('unique'); } else if (i < 3) { rarityPool.push(Math.random() < 0.6 ? 'epic' : 'unique'); } else if (i < 4) { var roll = Math.random(); if (roll < 0.2) { rarityPool.push('legendary'); } else if (roll < 0.6) { rarityPool.push('epic'); } else { rarityPool.push('unique'); } } else { var roll = Math.random(); if (roll < 0.02) { rarityPool.push('exotic'); } else if (roll < 0.15) { rarityPool.push('legendary'); } else if (roll < 0.5) { rarityPool.push('epic'); } else { rarityPool.push('unique'); } } } case 'random': // 1 card: Completely random rarityPool.push(CARD_DATABASE[Math.floor(Math.random() * CARD_DATABASE.length)].rarity); break; case 'ancient': // 4 cards: Guarantees at least 1 Extinct Animal card, rest are mostly mammals var hasExtinct = false; for (var i = 0; i < 4; i++) { // For the last card, if we haven't added an extinct animal yet, guarantee one if (i === 3 && !hasExtinct) { // Choose an extinct animal rarity var extinctRoll = Math.random(); if (extinctRoll < 0.05) { rarityPool.push('exotic'); } else if (extinctRoll < 0.15) { rarityPool.push('legendary'); } else if (extinctRoll < 0.35) { rarityPool.push('epic'); } else { rarityPool.push('unique'); } hasExtinct = true; continue; } var roll = Math.random(); if (roll < 0.05) { rarityPool.push('exotic'); hasExtinct = true; // Mark that we've added an extinct animal } else if (roll < 0.1) { rarityPool.push('legendary'); hasExtinct = true; // Mark that we've added an extinct animal } else if (roll < 0.2) { rarityPool.push('epic'); hasExtinct = true; // Mark that we've added an extinct animal } else if (roll < 0.35) { rarityPool.push('unique'); hasExtinct = true; // Mark that we've added an extinct animal } else if (roll < 0.7) { rarityPool.push('rare'); // Primarily mammals } else { rarityPool.push('uncommon'); } } break; case 'jurassic': // 4 cards: Guarantees at least 1 Dinosaur card, rest are mostly Reptiles var hasDinosaur = false; for (var i = 0; i < 4; i++) { // For the last card, if we haven't added a dinosaur yet, guarantee one if (i === 3 && !hasDinosaur) { // Choose a dinosaur rarity var dinoRoll = Math.random(); if (dinoRoll < 0.01) { rarityPool.push('exotic'); } else if (dinoRoll < 0.1) { rarityPool.push('legendary'); } else if (dinoRoll < 0.3) { rarityPool.push('epic'); } else { rarityPool.push('unique'); } hasDinosaur = true; continue; } var roll = Math.random(); if (roll < 0.01) { rarityPool.push('exotic'); hasDinosaur = true; // Mark that we've added a dinosaur } else if (roll < 0.05) { rarityPool.push('legendary'); hasDinosaur = true; // Mark that we've added a dinosaur } else if (roll < 0.15) { rarityPool.push('epic'); hasDinosaur = true; // Mark that we've added a dinosaur } else if (roll < 0.3) { rarityPool.push('unique'); hasDinosaur = true; // Mark that we've added a dinosaur } else { rarityPool.push('rare'); // Primarily reptiles, could be other rare types } } break; } // Create cards based on rarity pool for (var i = 0; i < rarityPool.length; i++) { var rarity = rarityPool[i]; var possibleCards = CARD_DATABASE.filter(function (card) { if (packType === 'jurassic' && (rarity === 'unique' || rarity === 'epic' || rarity === 'legendary' || rarity === 'exotic')) { return card.rarity === rarity && card.type === 'Dinosaur'; } else if (packType === 'ancient' && (rarity === 'unique' || rarity === 'epic' || rarity === 'legendary' || rarity === 'exotic')) { return card.rarity === rarity && card.type === 'ExtinctAnimal'; } return card.rarity === rarity; }); if (possibleCards.length > 0) { var selectedCard = possibleCards[Math.floor(Math.random() * possibleCards.length)]; cards.push(new Card(selectedCard.rarity, selectedCard.id, selectedCard.name, selectedCard.type)); } } return cards; } // Clear current screen elements function clearScreen() { for (var i = 0; i < screenElements.length; i++) { screenElements[i].destroy(); } screenElements = []; packDisplays = []; } // Show all cards in collection screen function showAllCardsScreen() { clearScreen(); currentScreen = 'allCards'; var title = new Text2("ALL COLLECTED CARDS", { size: 80, fill: 0xFFFFFF }); title.anchor.set(0.5, 0); title.x = 2048 / 2; title.y = 200; game.addChild(title); screenElements.push(title); // Get all cards from collection var allKeys = Object.keys(storage.collection); var cardIds = []; // Filter keys to get unique card IDs for (var i = 0; i < allKeys.length; i++) { var key = allKeys[i]; if (key.endsWith("_rarity")) { cardIds.push(key.substring(0, key.length - 7)); } } // Sort cards by rarity var rarityOrder = { 'common': 1, 'uncommon': 2, 'rare': 3, 'unique': 4, 'epic': 5, 'legendary': 6, 'exotic': 7, 'event': 8 }; cardIds.sort(function (a, b) { var rarityA = storage.collection[a + "_rarity"]; var rarityB = storage.collection[b + "_rarity"]; return rarityOrder[rarityA] - rarityOrder[rarityB]; }); // Display cards in a grid var cardsPerRow = 5; var startY = 400; var cardScale = 0.35; var cardSpacingX = 400 * cardScale; var cardSpacingY = 850 * cardScale; for (var i = 0; i < cardIds.length; i++) { var cardId = cardIds[i]; var row = Math.floor(i / cardsPerRow); var col = i % cardsPerRow; var card = new Card(storage.collection[cardId + "_rarity"], cardId, storage.collection[cardId + "_name"], storage.collection[cardId + "_type"]); card.x = 2048 / 2 + (col - (cardsPerRow - 1) / 2) * cardSpacingX; card.y = startY + row * cardSpacingY; card.scale.set(cardScale); card.reveal(); // Already revealed // Add count indicator var countText = new Text2("x" + storage.collection[cardId + "_count"], { size: 40, fill: 0xFFFFFF }); countText.anchor.set(1, 1); countText.x = 220; countText.y = 300; card.addChild(countText); game.addChild(card); screenElements.push(card); } // Back button var backButton = new Button("BACK", 200, 80); backButton.x = 200; backButton.y = 200; game.addChild(backButton); screenElements.push(backButton); backButton.down = function () { tween(backButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; backButton.up = function () { tween(backButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showCollectionScreen(); } }); }; } // Show event screen with mini-games and current progress function showEventScreen() { clearScreen(); currentScreen = 'event'; var title = new Text2("EVENTS", { size: 80, fill: 0xFFFFFF }); title.anchor.set(0.5, 0); title.x = 2048 / 2; title.y = 200; game.addChild(title); screenElements.push(title); // Initialize event points if not exists if (!storage.stats.eventPoints) { storage.stats.eventPoints = 0; } // Event progress display var eventProgress = new Text2("EVENT POINTS: " + storage.stats.eventPoints, { size: 50, fill: 0xFFFFFF }); eventProgress.anchor.set(0.5, 0); eventProgress.x = 2048 / 2; eventProgress.y = 300; game.addChild(eventProgress); screenElements.push(eventProgress); // Reward tiers explanation var rewardText = new Text2("Every 100 points: Random card up to Epic rarity\nEvery 1000 points: Random Event card", { size: 40, fill: 0xFFFFFF }); rewardText.anchor.set(0.5, 0); rewardText.x = 2048 / 2; rewardText.y = 400; game.addChild(rewardText); screenElements.push(rewardText); // Mini-games buttons var game1Button = new Button("GEM COLLECTOR", 400, 120); game1Button.x = 2048 / 2; game1Button.y = 700; game.addChild(game1Button); screenElements.push(game1Button); game1Button.down = function () { tween(game1Button.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; game1Button.up = function () { tween(game1Button.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { startMiniGame('GemCollector'); } }); }; var game2Button = new Button("PIPE MANIA GAME", 400, 120); game2Button.x = 2048 / 2; game2Button.y = 900; game.addChild(game2Button); screenElements.push(game2Button); game2Button.down = function () { tween(game2Button.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; game2Button.up = function () { tween(game2Button.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { startMiniGame('PipeMania'); } }); }; // Back button var backButton = new Button("BACK", 200, 80); backButton.x = 200; backButton.y = 200; game.addChild(backButton); screenElements.push(backButton); backButton.down = function () { tween(backButton.scale, { x: 0.95, y: 0.95 }, { duration: 100 }); }; backButton.up = function () { tween(backButton.scale, { x: 1, y: 1 }, { duration: 100, onFinish: function onFinish() { showHomeScreen(); } }); }; } // Function to start a mini-game function startMiniGame(gameType) { clearScreen(); currentScreen = 'minigame'; var miniGame = new MiniGame(gameType); miniGame.x = 2048 / 2; miniGame.y = 2732 / 2; game.addChild(miniGame); screenElements.push(miniGame); } // Update stats display function updateStatsDisplay() { var totalCards = storage.stats.totalCards || 0; statsText.setText("Collection: " + totalCards + " cards"); } // Update function called by the game engine game.update = function () { // Game logic updates (if needed) }; // Event handling game.move = function (x, y, obj) { // Mouse/touch move handling }; game.down = function (x, y, obj) { // Mouse/touch down handling }; game.up = function (x, y, obj) { // Mouse/touch up handling };
===================================================================
--- original.js
+++ change.js
@@ -1054,401 +1054,8 @@
});
};
return self;
});
-var Trading = Container.expand(function () {
- var self = Container.call(this);
- self.isPlayerTurn = true;
- self.playerOffer = [];
- self.aiOffer = [];
- self.tradeComplete = false;
- // Background
- var background = self.attachAsset('cardButton', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 1900,
- height: 2400,
- tint: 0x2a2a3a
- });
- // Title
- var title = new Text2("CARD TRADING", {
- size: 80,
- fill: 0xFFFFFF
- });
- title.anchor.set(0.5, 0);
- title.y = -1100;
- self.addChild(title);
- // Player side label
- var playerLabel = new Text2("YOUR OFFER", {
- size: 50,
- fill: 0xFFFFFF
- });
- playerLabel.anchor.set(0.5, 0);
- playerLabel.x = -450;
- playerLabel.y = -950;
- self.addChild(playerLabel);
- // AI side label
- var aiLabel = new Text2("TRADER'S OFFER", {
- size: 50,
- fill: 0xFFFFFF
- });
- aiLabel.anchor.set(0.5, 0);
- aiLabel.x = 450;
- aiLabel.y = -950;
- self.addChild(aiLabel);
- // Trading areas
- var playerArea = self.attachAsset('cardButton', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: -450,
- y: -300,
- width: 700,
- height: 900,
- tint: 0x3f4673
- });
- var aiArea = self.attachAsset('cardButton', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 450,
- y: -300,
- width: 700,
- height: 900,
- tint: 0x4a3f67
- });
- // Status text
- var statusText = new Text2("Select cards from your collection to trade", {
- size: 40,
- fill: 0xFFFFFF
- });
- statusText.anchor.set(0.5, 0);
- statusText.y = 250;
- self.addChild(statusText);
- // Trade value display
- var tradeValueText = new Text2("Trade Value: Your: 0 | Trader: 0", {
- size: 35,
- fill: 0xFFFFFF
- });
- tradeValueText.anchor.set(0.5, 0);
- tradeValueText.y = 350;
- self.addChild(tradeValueText);
- // Collection display area
- var collectionContainer = new Container();
- collectionContainer.y = 500;
- self.addChild(collectionContainer);
- // Action buttons
- var proposeButton = new Button("PROPOSE TRADE", 300, 80);
- proposeButton.x = -300;
- proposeButton.y = 450;
- self.addChild(proposeButton);
- var scamButton = new Button("SCAM TRADE", 300, 80);
- scamButton.x = 0;
- scamButton.y = 450;
- scamButton.visible = false;
- self.addChild(scamButton);
- var acceptButton = new Button("ACCEPT", 300, 80);
- acceptButton.x = 300;
- acceptButton.y = 450;
- acceptButton.visible = false;
- self.addChild(acceptButton);
- var backButton = new Button("BACK", 200, 80);
- backButton.x = 0;
- backButton.y = 1000;
- self.addChild(backButton);
- // Calculate trade value
- var rarityValues = {
- 'common': 1,
- 'uncommon': 3,
- 'rare': 10,
- 'unique': 30,
- 'epic': 100,
- 'legendary': 300,
- 'exotic': 1000,
- 'event': 500
- };
- self.calculateValue = function (cards) {
- var total = 0;
- for (var i = 0; i < cards.length; i++) {
- total += rarityValues[cards[i].rarity] || 0;
- }
- return total;
- };
- // Update trade value display
- self.updateTradeValue = function () {
- var playerValue = self.calculateValue(self.playerOffer);
- var aiValue = self.calculateValue(self.aiOffer);
- tradeValueText.setText("Trade Value: Your: " + playerValue + " | Trader: " + aiValue);
- };
- // Display player's collection
- self.displayCollection = function () {
- // Clear existing
- while (collectionContainer.children.length > 0) {
- collectionContainer.removeChildAt(0);
- }
- var allKeys = Object.keys(storage.collection);
- var cardIds = [];
- for (var i = 0; i < allKeys.length; i++) {
- var key = allKeys[i];
- if (key.endsWith("_rarity")) {
- cardIds.push(key.substring(0, key.length - 7));
- }
- }
- var cardsPerRow = 6;
- var cardScale = 0.25;
- var cardSpacingX = 300 * cardScale;
- var cardSpacingY = 400 * cardScale;
- for (var i = 0; i < Math.min(cardIds.length, 18); i++) {
- var cardId = cardIds[i];
- var row = Math.floor(i / cardsPerRow);
- var col = i % cardsPerRow;
- var card = new Card(storage.collection[cardId + "_rarity"], cardId, storage.collection[cardId + "_name"], storage.collection[cardId + "_type"]);
- card.x = (col - (cardsPerRow - 1) / 2) * cardSpacingX;
- card.y = row * cardSpacingY;
- card.scale.set(cardScale);
- card.revealed = true;
- card.tradingCard = true;
- card.down = function () {
- if (self.isPlayerTurn && !self.tradeComplete) {
- self.toggleCardSelection(this);
- }
- };
- collectionContainer.addChild(card);
- }
- };
- // Toggle card selection
- self.toggleCardSelection = function (card) {
- var index = -1;
- for (var i = 0; i < self.playerOffer.length; i++) {
- if (self.playerOffer[i].id === card.id) {
- index = i;
- break;
- }
- }
- if (index >= 0) {
- // Remove from offer
- self.playerOffer.splice(index, 1);
- card.alpha = 1;
- } else if (self.playerOffer.length < 3) {
- // Add to offer (max 3 cards)
- self.playerOffer.push({
- id: card.id,
- rarity: card.rarity,
- name: card.name,
- type: card.type
- });
- card.alpha = 0.5;
- }
- self.updatePlayerOfferDisplay();
- self.updateTradeValue();
- };
- // Update player offer display
- self.updatePlayerOfferDisplay = function () {
- // Clear existing cards in player area
- var toRemove = [];
- for (var i = 0; i < self.children.length; i++) {
- if (self.children[i].isOfferCard && self.children[i].isPlayerCard) {
- toRemove.push(self.children[i]);
- }
- }
- for (var i = 0; i < toRemove.length; i++) {
- self.removeChild(toRemove[i]);
- }
- // Add offer cards
- for (var i = 0; i < self.playerOffer.length; i++) {
- var offerCard = new Card(self.playerOffer[i].rarity, self.playerOffer[i].id, self.playerOffer[i].name, self.playerOffer[i].type);
- offerCard.x = -450;
- offerCard.y = -500 + i * 250;
- offerCard.scale.set(0.4);
- offerCard.reveal();
- offerCard.isOfferCard = true;
- offerCard.isPlayerCard = true;
- self.addChild(offerCard);
- }
- };
- // Generate AI offer
- self.generateAITrade = function (isScam) {
- self.aiOffer = [];
- var playerValue = self.calculateValue(self.playerOffer);
- var targetValue = isScam ? playerValue * 0.3 : playerValue * (0.8 + Math.random() * 0.4);
- // Filter available cards
- var availableCards = CARD_DATABASE.filter(function (card) {
- return card.rarity !== 'event';
- });
- var currentValue = 0;
- var attempts = 0;
- while (currentValue < targetValue && self.aiOffer.length < 3 && attempts < 50) {
- var card = availableCards[Math.floor(Math.random() * availableCards.length)];
- var cardValue = rarityValues[card.rarity];
- if (currentValue + cardValue <= targetValue * 1.2) {
- self.aiOffer.push(card);
- currentValue += cardValue;
- }
- attempts++;
- }
- // Update AI offer display
- self.updateAIOfferDisplay();
- self.updateTradeValue();
- };
- // Update AI offer display
- self.updateAIOfferDisplay = function () {
- // Clear existing cards in AI area
- var toRemove = [];
- for (var i = 0; i < self.children.length; i++) {
- if (self.children[i].isOfferCard && !self.children[i].isPlayerCard) {
- toRemove.push(self.children[i]);
- }
- }
- for (var i = 0; i < toRemove.length; i++) {
- self.removeChild(toRemove[i]);
- }
- // Add AI offer cards
- for (var i = 0; i < self.aiOffer.length; i++) {
- var offerCard = new Card(self.aiOffer[i].rarity, self.aiOffer[i].id, self.aiOffer[i].name, self.aiOffer[i].type);
- offerCard.x = 450;
- offerCard.y = -500 + i * 250;
- offerCard.scale.set(0.4);
- offerCard.reveal();
- offerCard.isOfferCard = true;
- offerCard.isPlayerCard = false;
- self.addChild(offerCard);
- }
- };
- // Complete trade
- self.completeTrade = function () {
- // Remove player's cards from collection
- for (var i = 0; i < self.playerOffer.length; i++) {
- var cardId = self.playerOffer[i].id;
- var count = storage.collection[cardId + "_count"] || 0;
- if (count > 1) {
- storage.collection[cardId + "_count"] = count - 1;
- } else {
- // Remove card entirely
- delete storage.collection[cardId + "_rarity"];
- delete storage.collection[cardId + "_name"];
- delete storage.collection[cardId + "_type"];
- delete storage.collection[cardId + "_count"];
- }
- storage.stats.totalCards--;
- storage.stats[self.playerOffer[i].rarity]--;
- }
- // Add AI's cards to collection
- for (var i = 0; i < self.aiOffer.length; i++) {
- var card = self.aiOffer[i];
- if (!storage.collection[card.id]) {
- storage.collection[card.id + "_rarity"] = card.rarity;
- storage.collection[card.id + "_name"] = card.name;
- storage.collection[card.id + "_type"] = card.type;
- storage.collection[card.id + "_count"] = 0;
- }
- storage.collection[card.id + "_count"] = (storage.collection[card.id + "_count"] || 0) + 1;
- storage.stats.totalCards++;
- storage.stats[card.rarity]++;
- }
- self.tradeComplete = true;
- statusText.setText("Trade Complete!");
- updateStatsDisplay();
- };
- // Button handlers
- proposeButton.down = function () {
- tween(proposeButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- proposeButton.up = function () {
- tween(proposeButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- if (self.playerOffer.length > 0) {
- self.generateAITrade(false);
- self.isPlayerTurn = false;
- statusText.setText("Trader is considering your offer...");
- proposeButton.visible = false;
- scamButton.visible = true;
- acceptButton.visible = true;
- }
- }
- });
- };
- scamButton.down = function () {
- tween(scamButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- scamButton.up = function () {
- tween(scamButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- // 50% chance to succeed
- if (Math.random() < 0.5) {
- self.generateAITrade(true);
- statusText.setText("You successfully scammed the trader!");
- } else {
- statusText.setText("Trader caught your scam attempt! Trade cancelled.");
- self.aiOffer = [];
- self.updateAIOfferDisplay();
- }
- scamButton.visible = false;
- }
- });
- };
- acceptButton.down = function () {
- tween(acceptButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- acceptButton.up = function () {
- tween(acceptButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- if (self.aiOffer.length > 0) {
- self.completeTrade();
- acceptButton.visible = false;
- scamButton.visible = false;
- }
- }
- });
- };
- backButton.down = function () {
- tween(backButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- backButton.up = function () {
- tween(backButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- showHomeScreen();
- self.destroy();
- }
- });
- };
- // Initialize
- self.displayCollection();
- return self;
-});
/****
* Initialize Game
****/
@@ -1458,10 +1065,10 @@
/****
* Game Code
****/
-// Event card icon assets
// Game state variables
+// Event card icon assets
var currentScreen = 'home'; // 'home', 'packs', 'collection'
var currentlyOpeningPack = false;
var packDisplays = [];
var displayedCards = [];
@@ -1835,33 +1442,8 @@
showEventScreen();
}
});
};
- // Add Trade Cards Button
- var tradeButton = new Button("TRADE CARDS", 400, 120);
- tradeButton.x = 2048 / 2;
- tradeButton.y = 1800;
- game.addChild(tradeButton);
- screenElements.push(tradeButton);
- tradeButton.down = function () {
- tween(tradeButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- tradeButton.up = function () {
- tween(tradeButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- showTradingScreen();
- }
- });
- };
updateStatsDisplay();
}
// Show packs selection screen
function showPacksScreen() {
@@ -2068,8 +1650,9 @@
// Show collection screen
function showCollectionScreen() {
clearScreen();
currentScreen = 'collection';
+ var currentCardIndex = 0;
var title = new Text2("YOUR COLLECTION", {
size: 80,
fill: 0xFFFFFF
});
@@ -2077,105 +1660,171 @@
title.x = 2048 / 2;
title.y = 200;
game.addChild(title);
screenElements.push(title);
- // Collection stats
- var collectionStats = new Text2("Total Cards: " + storage.stats.totalCards + "\n\n" + "Common: " + storage.stats.common + "\n" + "Uncommon: " + storage.stats.uncommon + "\n" + "Rare: " + storage.stats.rare + "\n" + "Unique: " + storage.stats.unique + "\n" + "Epic: " + storage.stats.epic + "\n" + "Legendary: " + storage.stats.legendary + "\n" + "Exotic: " + storage.stats.exotic + "\n" + "Event: " + (storage.stats.event || 0), {
- size: 50,
- fill: 0xFFFFFF
- });
- collectionStats.anchor.set(0.5, 0);
- collectionStats.x = 2048 / 2;
- collectionStats.y = 400;
- game.addChild(collectionStats);
- screenElements.push(collectionStats);
- // Display recently acquired cards (up to 3)
- var recentText = new Text2("RECENT ACQUISITIONS:", {
- size: 50,
- fill: 0xFFFFFF
- });
- recentText.anchor.set(0.5, 0);
- recentText.x = 2048 / 2;
- recentText.y = 1000;
- game.addChild(recentText);
- screenElements.push(recentText);
- // Get recent cards
+ // Get all collected cards
var allKeys = Object.keys(storage.collection);
var cardIds = [];
- // Filter keys to get unique card IDs
for (var i = 0; i < allKeys.length; i++) {
var key = allKeys[i];
if (key.endsWith("_rarity")) {
cardIds.push(key.substring(0, key.length - 7));
}
}
- var recentCards = [];
- // Sort by count (higher count means they were collected more recently)
+ // Sort cards by rarity
+ var rarityOrder = {
+ 'common': 1,
+ 'uncommon': 2,
+ 'rare': 3,
+ 'unique': 4,
+ 'epic': 5,
+ 'legendary': 6,
+ 'exotic': 7,
+ 'event': 8
+ };
cardIds.sort(function (a, b) {
- return (storage.collection[b + "_count"] || 0) - (storage.collection[a + "_count"] || 0);
+ var rarityA = storage.collection[a + "_rarity"];
+ var rarityB = storage.collection[b + "_rarity"];
+ return rarityOrder[rarityA] - rarityOrder[rarityB];
});
- // Display up to 3 recent cards
- var displayCount = Math.min(3, cardIds.length);
- for (var i = 0; i < displayCount; i++) {
- var cardId = cardIds[i];
- var card = new Card(storage.collection[cardId + "_rarity"], cardId, storage.collection[cardId + "_name"], storage.collection[cardId + "_type"]);
- card.x = 2048 / 2 + (i - (displayCount - 1) / 2) * 550;
- card.y = 1400;
- card.scale.set(0.6);
- card.reveal(); // Already revealed
- game.addChild(card);
- screenElements.push(card);
+ // Display current card if collection has cards
+ var currentCard = null;
+ var cardInfoText = null;
+ var navigationText = null;
+ function displayCard(index) {
+ // Remove previous card if exists
+ if (currentCard) {
+ currentCard.destroy();
+ }
+ if (cardInfoText) {
+ cardInfoText.destroy();
+ }
+ if (navigationText) {
+ navigationText.destroy();
+ }
+ if (cardIds.length === 0) {
+ var noCardsText = new Text2("No cards in collection yet!", {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ noCardsText.anchor.set(0.5, 0.5);
+ noCardsText.x = 2048 / 2;
+ noCardsText.y = 2732 / 2;
+ game.addChild(noCardsText);
+ screenElements.push(noCardsText);
+ return;
+ }
+ // Ensure index is within bounds
+ currentCardIndex = Math.max(0, Math.min(index, cardIds.length - 1));
+ var cardId = cardIds[currentCardIndex];
+ currentCard = new Card(storage.collection[cardId + "_rarity"], cardId, storage.collection[cardId + "_name"], storage.collection[cardId + "_type"]);
+ currentCard.x = 2048 / 2;
+ currentCard.y = 2732 / 2 - 200;
+ currentCard.scale.set(0.8);
+ currentCard.reveal();
+ game.addChild(currentCard);
+ screenElements.push(currentCard);
+ // Display card info
+ cardInfoText = new Text2("Card " + (currentCardIndex + 1) + " of " + cardIds.length + "\n" + "Owned: x" + storage.collection[cardId + "_count"], {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ cardInfoText.anchor.set(0.5, 0);
+ cardInfoText.x = 2048 / 2;
+ cardInfoText.y = 2732 / 2 + 300;
+ game.addChild(cardInfoText);
+ screenElements.push(cardInfoText);
+ // Navigation hint
+ navigationText = new Text2("Use buttons to browse collection", {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ navigationText.anchor.set(0.5, 0);
+ navigationText.x = 2048 / 2;
+ navigationText.y = 2732 / 2 + 450;
+ game.addChild(navigationText);
+ screenElements.push(navigationText);
}
- // Back button
- var backButton = new Button("BACK", 200, 80);
- backButton.x = 200;
- backButton.y = 200;
- game.addChild(backButton);
- screenElements.push(backButton);
- backButton.down = function () {
- tween(backButton.scale, {
+ // Navigation buttons
+ var prevButton = new Button("< PREVIOUS", 300, 100);
+ prevButton.x = 2048 / 2 - 400;
+ prevButton.y = 2732 / 2;
+ game.addChild(prevButton);
+ screenElements.push(prevButton);
+ prevButton.down = function () {
+ tween(prevButton.scale, {
x: 0.95,
y: 0.95
}, {
duration: 100
});
};
- backButton.up = function () {
- tween(backButton.scale, {
+ prevButton.up = function () {
+ tween(prevButton.scale, {
x: 1,
y: 1
}, {
duration: 100,
onFinish: function onFinish() {
- showHomeScreen();
+ if (currentCardIndex > 0) {
+ displayCard(currentCardIndex - 1);
+ }
}
});
};
- // View all cards button
- var viewCardsButton = new Button("VIEW ALL CARDS", 400, 80);
- viewCardsButton.x = 2048 / 2;
- viewCardsButton.y = 2732 - 300;
- game.addChild(viewCardsButton);
- screenElements.push(viewCardsButton);
- viewCardsButton.down = function () {
- tween(viewCardsButton.scale, {
+ var nextButton = new Button("NEXT >", 300, 100);
+ nextButton.x = 2048 / 2 + 400;
+ nextButton.y = 2732 / 2;
+ game.addChild(nextButton);
+ screenElements.push(nextButton);
+ nextButton.down = function () {
+ tween(nextButton.scale, {
x: 0.95,
y: 0.95
}, {
duration: 100
});
};
- viewCardsButton.up = function () {
- tween(viewCardsButton.scale, {
+ nextButton.up = function () {
+ tween(nextButton.scale, {
x: 1,
y: 1
}, {
duration: 100,
onFinish: function onFinish() {
- showAllCardsScreen();
+ if (currentCardIndex < cardIds.length - 1) {
+ displayCard(currentCardIndex + 1);
+ }
}
});
};
+ // Display first card
+ displayCard(0);
+ // Back button
+ var backButton = new Button("BACK", 200, 80);
+ backButton.x = 200;
+ backButton.y = 200;
+ game.addChild(backButton);
+ screenElements.push(backButton);
+ backButton.down = function () {
+ tween(backButton.scale, {
+ x: 0.95,
+ y: 0.95
+ }, {
+ duration: 100
+ });
+ };
+ backButton.up = function () {
+ tween(backButton.scale, {
+ x: 1,
+ y: 1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ showHomeScreen();
+ }
+ });
+ };
// Reset collection button
var resetButton = new Button("RESET COLLECTION", 400, 80);
resetButton.x = 2048 / 2;
resetButton.y = 2732 - 200;
@@ -2520,18 +2169,8 @@
}
});
};
}
-// Show trading screen
-function showTradingScreen() {
- clearScreen();
- currentScreen = 'trading';
- var trading = new Trading();
- trading.x = 2048 / 2;
- trading.y = 2732 / 2;
- game.addChild(trading);
- screenElements.push(trading);
-}
// Show event screen with mini-games and current progress
function showEventScreen() {
clearScreen();
currentScreen = 'event';
@@ -2616,33 +2255,8 @@
startMiniGame('PipeMania');
}
});
};
- // Event Card Tier List button
- var tierListButton = new Button("EVENT CARD TIER LIST", 400, 120);
- tierListButton.x = 2048 / 2;
- tierListButton.y = 1100;
- game.addChild(tierListButton);
- screenElements.push(tierListButton);
- tierListButton.down = function () {
- tween(tierListButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- tierListButton.up = function () {
- tween(tierListButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- showEventCardTierList();
- }
- });
- };
// Back button
var backButton = new Button("BACK", 200, 80);
backButton.x = 200;
backButton.y = 200;
@@ -2677,120 +2291,8 @@
miniGame.y = 2732 / 2;
game.addChild(miniGame);
screenElements.push(miniGame);
}
-// Show event card tier list
-function showEventCardTierList() {
- clearScreen();
- currentScreen = 'tierList';
- var title = new Text2("EVENT CARD TIER LIST", {
- size: 80,
- fill: 0xFFFFFF
- });
- title.anchor.set(0.5, 0);
- title.x = 2048 / 2;
- title.y = 150;
- game.addChild(title);
- screenElements.push(title);
- // Define tiers for event cards
- var tierData = {
- 'S-Tier': ['Elephant', 'Seal'],
- 'A-Tier': ['Walrus', 'Moose'],
- 'B-Tier': ['Bat', 'Wasp']
- };
- // Tier backgrounds and labels
- var tierColors = {
- 'S-Tier': 0xFF6B6B,
- 'A-Tier': 0x4ECDC4,
- 'B-Tier': 0x45B7D1
- };
- var currentY = 350;
- var tierNames = ['S-Tier', 'A-Tier', 'B-Tier'];
- // Display each tier
- for (var t = 0; t < tierNames.length; t++) {
- var tierName = tierNames[t];
- var tierCards = tierData[tierName];
- // Tier background
- var tierBg = LK.getAsset('cardButton', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 1600,
- height: 400,
- tint: tierColors[tierName]
- });
- tierBg.x = 2048 / 2;
- tierBg.y = currentY;
- game.addChild(tierBg);
- screenElements.push(tierBg);
- // Tier label
- var tierLabel = new Text2(tierName, {
- size: 60,
- fill: 0xFFFFFF
- });
- tierLabel.anchor.set(0, 0.5);
- tierLabel.x = 300;
- tierLabel.y = currentY;
- game.addChild(tierLabel);
- screenElements.push(tierLabel);
- // Display cards in this tier
- for (var i = 0; i < tierCards.length; i++) {
- var cardName = tierCards[i];
- // Find the card data
- var cardData = null;
- for (var j = 0; j < CARD_DATABASE.length; j++) {
- if (CARD_DATABASE[j].rarity === 'event' && CARD_DATABASE[j].name === cardName) {
- cardData = CARD_DATABASE[j];
- break;
- }
- }
- if (cardData) {
- var card = new Card(cardData.rarity, cardData.id, cardData.name, cardData.type);
- card.x = 700 + i * 350;
- card.y = currentY;
- card.scale.set(0.4);
- card.reveal();
- game.addChild(card);
- screenElements.push(card);
- }
- }
- currentY += 500;
- }
- // Tier explanations
- var explanationText = new Text2("S-Tier: Most powerful and versatile event cards\n" + "A-Tier: Strong cards with good utility\n" + "B-Tier: Decent cards but more situational", {
- size: 35,
- fill: 0xFFFFFF
- });
- explanationText.anchor.set(0.5, 0);
- explanationText.x = 2048 / 2;
- explanationText.y = currentY;
- game.addChild(explanationText);
- screenElements.push(explanationText);
- // Back button
- var backButton = new Button("BACK", 200, 80);
- backButton.x = 200;
- backButton.y = 200;
- game.addChild(backButton);
- screenElements.push(backButton);
- backButton.down = function () {
- tween(backButton.scale, {
- x: 0.95,
- y: 0.95
- }, {
- duration: 100
- });
- };
- backButton.up = function () {
- tween(backButton.scale, {
- x: 1,
- y: 1
- }, {
- duration: 100,
- onFinish: function onFinish() {
- showEventScreen();
- }
- });
- };
-}
// Update stats display
function updateStatsDisplay() {
var totalCards = storage.stats.totalCards || 0;
statsText.setText("Collection: " + totalCards + " cards");
Light gray card packet with a hare in the center. In-Game asset. 2d. High contrast. No shadows
Green card packet with a Salamander in the center. In-Game asset. 2d. High contrast. No shadows
Orange card packet with a Rhino in the center. In-Game asset. 2d. High contrast. No shadows
Purple card packet with a Crocodile in the center. In-Game asset. 2d. High contrast. No shadows
Dark red card packet with a Whale in the center. In-Game asset. 2d. High contrast. No shadows
Rabbit. In-Game asset. 2d. High contrast. No shadows
Orange salamander. In-Game asset. 2d. High contrast. No shadows
Ant. In-Game asset. 2d. High contrast. No shadows
Pidgeon. In-Game asset. 2d. High contrast. No shadows
Pig. In-Game asset. 2d. High contrast. No shadows
Frog. In-Game asset. 2d. High contrast. No shadows
Rat. In-Game asset. 2d. High contrast. No shadows
Squirrel. In-Game asset. 2d. High contrast. No shadows
Salmon. In-Game asset. 2d. High contrast. No shadows
Fox. In-Game asset. 2d. High contrast. No shadows
Owl. In-Game asset. 2d. High contrast. No shadows
Silverback gorilla. In-Game asset. 2d. High contrast. No shadows
Ostrich. In-Game asset. 2d. High contrast. No shadows
Wolf. In-Game asset. 2d. High contrast. No shadows
Bear. In-Game asset. 2d. High contrast. No shadows
Hammerhead shark. In-Game asset. 2d. High contrast. No shadows
Lion. In-Game asset. 2d. High contrast. No shadows
Aggressive hippo. In-Game asset. 2d. High contrast. No shadows
Sperm whale. In-Game asset. 2d. High contrast. No shadows
Crocodile. In-Game asset. 2d. High contrast. No shadows
Lizard. In-Game asset. 2d. High contrast. No shadows
Dung beetle. In-Game asset. 2d. High contrast. No shadows
Duck. In-Game asset. 2d. High contrast. No shadows
Ankylosaurus. In-Game asset. 2d. High contrast. No shadows
Diplodocus. In-Game asset. 2d. High contrast. No shadows
Parasaur. In-Game asset. 2d. High contrast. No shadows
Pterodactyl. In-Game asset. 2d. High contrast. No shadows
A Yellow card pack with a T-TEX in the center
Spinosaurus. In-Game asset. 2d. High contrast. No shadows
Stegosaurus. In-Game asset. 2d. High contrast. No shadows
T-REX. In-Game asset. 2d. High contrast. No shadows
Triceratops. In-Game asset. 2d. High contrast. No shadows
Raptor. In-Game asset. 2d. High contrast. No shadows
White card packet with a "?" Sign in the middle. In-Game asset. 2d. High contrast. No shadows
Cat. In-Game asset. 2d. High contrast. No shadows
Cheetah. In-Game asset. 2d. High contrast. No shadows
Penguin. In-Game asset. 2d. High contrast. No shadows
Cobra. In-Game asset. 2d. High contrast. No shadows
Snake. In-Game asset. 2d. High contrast. No shadows
Rhino. In-Game asset. 2d. High contrast. No shadows
Card packet made out of stone with a Tribal drawing of people Hunting a wolly Mammoth. In-Game asset. 2d. High contrast. No shadows
Mammoth. In-Game asset. 2d. High contrast. No shadows
Dodo. In-Game asset. 2d. High contrast. No shadows
Megalodon. In-Game asset. 2d. High contrast. No shadows
Sabertooth tiger. In-Game asset. 2d. High contrast. No shadows
Wooly Rhino. In-Game asset. 2d. High contrast. No shadows
Giant bat. In-Game asset. 2d. High contrast. No shadows
Moose. In-Game asset. 2d. High contrast. No shadows
Wasp. In-Game asset. 2d. High contrast. No shadows
Seal. In-Game asset. 2d. High contrast. No shadows
Eagle. In-Game asset. 2d. High contrast. No shadows
Make the outlines on my character a dark black
Elephant. In-Game asset. 2d. High contrast. No shadows
Gem. In-Game asset. 2d. High contrast. No shadows
Remove the background
Remove the background
RE.MO.VE. THE. BACKGROUND!
Remove the background
Remove the baccground
Remove the background
Remov the bagroud