User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.tradeRequestsReceived = tradeRequestsReceived;' Line Number: 4210 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.currentPuzzleQuestion = selectedQuestion;' Line Number: 1509 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'window.addEventListener is not a function' in or related to this line: 'window.addEventListener('blur', function () {' Line Number: 5555
User prompt
Oyun müziği telefonun arka planında çalmasın yani oyundan çıkınca kullanıcı arka planda müzik devam etmesin
User prompt
Kılavuzun altindkai işaret yazıyla iyumlu şekilde altta olsun ve yazı koyu mavi olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kilavuzun altındaki Kırmızı yazı çok daha büyük ve altta olsun
User prompt
Saha büyük olsun ve altta olsun biraz daha
User prompt
Kılavuz sekmesinin altına kırmızı renkli bir şekilde oyuna yeni başladıysanız okuyun yazsın ve kılavuz sekmesini işaret etsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyuna herşeyi detaylıca anlatan bir kılavuz ekle
User prompt
Map düğmesi çalışmasın
User prompt
Daha anlaşılır yap herşey iç içe girmiş düzelt ve oyuna başladığımızda veya baska sekmeye girdiğinizde ekranda map yazmasın
User prompt
Map kısmını daha anlaşılır ve düzenli yap
User prompt
Map sekmesini düzenle menü ile karışmasın açınca başka sekmeye atsın bizi
User prompt
Oyuna MAP sekmesi ekle ve bu sekme Stock butonunun 2-3 metre altında olsun
User prompt
Oyuna MAP sekmesi ekle
User prompt
Oyuna MAP sekmesi ekle
User prompt
Oyunun en alt orta tarafının biraz üstüne MAP yazan bir sekme butonu koy
User prompt
Mutasyonlu PARASAUROLUPHUSun özelliği her 4 seviyede bir kere kullanılsın
User prompt
Mutasyonlu PARASAUROLUPHUSun özelliğini değiştir yeni özelliği ile maptaki normal blokları 2 sert blokları 3 aşırı sert blokları ise 7 tıkla indirsin
User prompt
PARASAUROLUPHUSun özelliğinin sıradan yumurta içeriğindeki yazısını düzelt aşırı sert blokları 9 tıklamada indirir yaz
User prompt
PARASAUROLUPHUSun özelliğinin açıklamasını düzelt
User prompt
PARASAUROLUPHUS özelliği ile aşırı sert blokları 9 vuruşta indirelim
User prompt
ANKYLOSAURUS ve TRİCERATOPSun özelliği her tur 1 kere kullanılsın
User prompt
ANKYLOSAURUS ve TRİCERATOPS stok sekmesine eklensin
User prompt
Oyunda son seviyeye gelen ve oyun bitiren birinin birinin üstünde 👑 olsun ve en fazla 5 adet olsun 5 adet kral tacı alındıktan sonra ise oyuncu oyunu 1 kere bitirirse kral taçları mavi 2 kere bitirirse yeşil 3 kere bitirirse kırmızı 4 kere bitirirse mor olsun ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var DinosaurImage = Container.expand(function (dinosaurName) { var self = Container.call(this); // Main dinosaur body var dinoBody = self.attachAsset(dinosaurName, { anchorX: 0.5, anchorY: 0.5 }); // Add red eyes var leftEye = self.attachAsset('redEye', { anchorX: 0.5, anchorY: 0.5 }); leftEye.x = -30; leftEye.y = -20; var rightEye = self.attachAsset('redEye', { anchorX: 0.5, anchorY: 0.5 }); rightEye.x = 30; rightEye.y = -20; return self; }); var Fossil = Container.expand(function (fossilType) { var self = Container.call(this); var fossilGraphics = self.attachAsset(fossilType, { anchorX: 0.5, anchorY: 0.5 }); self.fossilType = fossilType; self.isCollected = false; self.points = fossilType === 'rareFossil' ? 500 : 100; self.down = function (x, y, obj) { if (!self.isCollected) { self.collectFossil(); } }; self.collectFossil = function () { self.isCollected = true; LK.getSound('fossilFound').play(); // Apply dinosaur abilities // Add fossil to inventory playerInventory.push(self.fossilType); storage.playerInventory = playerInventory; // Award points based on extraction speed var speedBonus = Math.max(0, 100 - Math.floor(levelTimer / 100)); var basePoints = self.points + speedBonus; // Apply upgrade bonus to points if dinosaur is selected var totalPoints = basePoints; if (selectedDinosaur) { totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur)); } // Apply 2X MONEY effect if active if (doubleMoneyLevelsLeft > 0) { totalPoints *= 2; } LK.setScore(LK.getScore() + totalPoints); scoreText.setText('Score: ' + LK.getScore()); self.animateCollection(); }; self.animateCollection = function () { // Animate collection tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { currentLevel.fossilsCollected++; currentLevel.checkLevelComplete(); } }); }; return self; }); var Level = Container.expand(function (levelNumber) { var self = Container.call(this); self.levelNumber = levelNumber; self.blocks = []; self.fossils = []; self.fossilsCollected = 0; self.totalFossils = 0; self.blocksCollected = 0; self.totalBlocks = 0; self.createLevel = function () { // Create excavation site background var site = self.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); site.x = 1024; site.y = 1000; // Get difficulty settings for this level var difficulty = getLevelDifficulty(levelNumber); var fossilCount = difficulty.fossilCount; var blocksPerRow = difficulty.gridWidth; var rows = difficulty.gridHeight; var rareChance = difficulty.rareChance; var fossilTypes = ['fossil1', 'fossil2', 'fossil3']; // Add rare fossil chance based on level difficulty if (Math.random() < rareChance) { fossilTypes.push('rareFossil'); } self.totalFossils = fossilCount; // Create limestone blocks grid with scaling difficulty var startX = 1024 - blocksPerRow * 140 / 2 + 70; // Center the grid var startY = 600; var spacing = 140; var fossilPositions = []; for (var i = 0; i < fossilCount; i++) { var randomPos = Math.floor(Math.random() * (blocksPerRow * rows)); while (fossilPositions.indexOf(randomPos) !== -1) { randomPos = Math.floor(Math.random() * (blocksPerRow * rows)); } fossilPositions.push(randomPos); } var blockIndex = 0; for (var row = 0; row < rows; row++) { for (var col = 0; col < blocksPerRow; col++) { // Determine block type - 25% chance for ultra hard block, 30% chance for hard rock, 45% chance for limestone var random = Math.random(); var blockType; if (random < 0.25) { blockType = 'ultraHardBlock'; } else if (random < 0.55) { blockType = 'hardRock'; } else { blockType = 'limestone'; } var block = new LimestoneBlock(blockType); block.x = startX + col * spacing; block.y = startY + row * spacing; // Check if this block contains a fossil if (fossilPositions.indexOf(blockIndex) !== -1) { block.hasFossil = true; var fossilTypeIndex = Math.floor(Math.random() * fossilTypes.length); block.fossilType = fossilTypes[fossilTypeIndex]; } self.blocks.push(block); self.addChild(block); blockIndex++; } } self.totalBlocks = self.blocks.length; }; self.revealFossil = function (fossilType, x, y) { var fossil = new Fossil(fossilType); fossil.x = x; fossil.y = y; // Animate fossil appearance fossil.alpha = 0; fossil.scaleX = 0; fossil.scaleY = 0; self.fossils.push(fossil); self.addChild(fossil); tween(fossil, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.easeOut }); }; self.checkBlockCollection = function () { self.blocksCollected++; if (self.blocksCollected >= self.totalBlocks) { // All blocks collected, show any remaining fossils for (var i = 0; i < self.blocks.length; i++) { var block = self.blocks[i]; if (block.hasFossil && !block.isCollected) { self.revealFossil(block.fossilType, block.x, block.y); } } } }; self.checkLevelComplete = function () { if (self.fossilsCollected >= self.totalFossils) { LK.getSound('levelComplete').play(); // Level completion bonus with scaling difficulty var baseLevelBonus = Math.floor(currentLevelNumber / 10) * 100; // Bonus increases every 10 levels var timeBonus = Math.max(0, 1000 + baseLevelBonus - Math.floor(levelTimer / 10)); LK.setScore(LK.getScore() + timeBonus); scoreText.setText('Score: ' + LK.getScore()); // Decrease power-up counters if (xrayLevelsLeft > 0) { xrayLevelsLeft--; storage.xrayLevelsLeft = xrayLevelsLeft; } if (doubleMoneyLevelsLeft > 0) { doubleMoneyLevelsLeft--; storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; } // Progress to next level after delay LK.setTimeout(function () { if (currentLevelNumber < maxLevels) { // Check if next level is a puzzle level if (isPuzzleLevel(currentLevelNumber + 1)) { startPuzzleLevel(currentLevelNumber + 1); } else { startLevel(currentLevelNumber + 1); } } else { // Game complete - award crown and reset progress gameCompletions++; storage.gameCompletions = gameCompletions; // Award crown if player has less than 5 crowns if (playerCrowns < 5) { playerCrowns++; storage.playerCrowns = playerCrowns; } storage.currentLevelNumber = 1; currentLevelNumber = 1; LK.showYouWin(); } }, 2000); } }; return self; }); var LimestoneBlock = Container.expand(function (blockType) { var self = Container.call(this); self.blockType = blockType || 'limestone'; // Use tan colored asset for ultra hard blocks var assetName = self.blockType === 'ultraHardBlock' ? 'ultraHardRock' : self.blockType; var blockGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.hasFossil = false; self.fossilType = null; self.isCollected = false; self.hitsRequired = self.blockType === 'ultraHardBlock' ? 10 : self.blockType === 'hardRock' ? 5 : 3; self.currentHits = 0; self.down = function (x, y, obj) { if (!self.isCollected) { self.currentHits++; if (self.currentHits >= self.hitsRequired) { self.collectBlock(); } else { // Show visual feedback for partial damage var damageAlpha = 1 - self.currentHits / self.hitsRequired * 0.6; blockGraphics.alpha = damageAlpha; LK.getSound('dig').play(); } } }; self.collectBlock = function () { // All dinosaurs now use normal collection - abilities only work via button press self.performCollection(); }; self.performCollection = function () { self.isCollected = true; LK.getSound('dig').play(); // Animate collection tween(self, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { if (self.hasFossil) { currentLevel.revealFossil(self.fossilType, self.x, self.y); } currentLevel.checkBlockCollection(); } }); }; self.performTrexCollection = function () { // TREX roars and collects all fossils (every 10 levels) if (currentLevelNumber % 10 === 0) { // Create roar effect with screen shake animation var roarEffect = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.0, scaleY: 3.0 }); roarEffect.x = 1024; roarEffect.y = 1000; roarEffect.alpha = 0.7; roarEffect.tint = 0xFF4500; // Orange roar effect currentLevel.addChild(roarEffect); // Animate roar effect with tween tween(roarEffect, { scaleX: 5.0, scaleY: 5.0, alpha: 0 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { roarEffect.destroy(); } }); // Collect all fossils on the level instantly for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Instantly reveal and collect the fossil currentLevel.revealFossil(block.fossilType, block.x, block.y); // Mark block as collected block.isCollected = true; block.alpha = 0; } } // Break current block normally self.performCollection(); } else { // Regular collection for non-10th levels self.performCollection(); } }; self.performSpinoCollection = function () { // SPINO ability to automatically find and collect 3 fossils (1 use per level) if (storage.spinoUsedThisLevel === undefined) storage.spinoUsedThisLevel = false; if (storage.spinoUsedThisLevel) { // Already used this level self.performCollection(); return; } storage.spinoUsedThisLevel = true; // Create visual fossil hunt effect var fossilHuntEffect = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.0, scaleY: 3.0 }); fossilHuntEffect.x = 1024; // Center of screen fossilHuntEffect.y = 1000; // Center of screen fossilHuntEffect.alpha = 0.9; fossilHuntEffect.tint = 0x228B22; // Green fossil hunt effect currentLevel.addChild(fossilHuntEffect); // Animate fossil hunt effect tween(fossilHuntEffect, { scaleX: 6.0, scaleY: 6.0, alpha: 0 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { fossilHuntEffect.destroy(); } }); // Find all blocks with fossils that haven't been collected yet var fossilBlocks = []; for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { fossilBlocks.push(block); } } // Select up to 3 fossil blocks to reveal var blocksToReveal = Math.min(3, fossilBlocks.length); for (var j = 0; j < blocksToReveal; j++) { var fossilBlock = fossilBlocks[j]; // Instantly reveal the fossil currentLevel.revealFossil(fossilBlock.fossilType, fossilBlock.x, fossilBlock.y); // Mark block as collected fossilBlock.isCollected = true; fossilBlock.alpha = 0; } // Break current block normally self.performCollection(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x8B7D6B // Desert sand color }); /**** * Game Code ****/ // Background rotation system - select different background each time function selectNextBackground() { var availableBackgrounds = [0, 1, 2, 3]; // 4 different backgrounds // Remove last shown background from available options if (lastBackgroundIndex !== -1) { var lastIndex = availableBackgrounds.indexOf(lastBackgroundIndex); if (lastIndex !== -1) { availableBackgrounds.splice(lastIndex, 1); } } // Select random background from remaining options currentBackgroundIndex = availableBackgrounds[Math.floor(Math.random() * availableBackgrounds.length)]; // Save current selection as last shown storage.lastBackgroundIndex = currentBackgroundIndex; lastBackgroundIndex = currentBackgroundIndex; } // Create dynamic backgrounds based on selection function createBackground(backgroundIndex) { if (backgroundIndex === 0) { // 1. Current arid desert with gold and dinosaur bones var desertBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); desertBackground.x = 1024; desertBackground.y = 1366; desertBackground.alpha = 0.3; desertBackground.tint = 0xD2B48C; // Sandy brown color // Add scattered dinosaur bones and gold pieces for (var i = 0; i < 8; i++) { var bone = LK.getAsset('fossil2', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7 }); bone.x = 200 + Math.random() * 1648; bone.y = 1500 + Math.random() * 1000; bone.alpha = 0.4; bone.rotation = Math.random() * Math.PI * 2; game.addChild(bone); } // Add scattered gold pieces for (var j = 0; j < 6; j++) { var gold = LK.getAsset('rareFossil', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); gold.x = 300 + Math.random() * 1448; gold.y = 1600 + Math.random() * 900; gold.alpha = 0.6; gold.tint = 0xFFD700; // Golden color game.addChild(gold); } } else if (backgroundIndex === 1) { // 2. Swampy forest with Spinosaurus and Sarcosuchus fossils var swampBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); swampBackground.x = 1024; swampBackground.y = 1366; swampBackground.alpha = 0.3; swampBackground.tint = 0x228B22; // Forest green color // Add shore trees along the edges using limestone blocks for (var t = 0; t < 10; t++) { var tree = LK.getAsset('limestone', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 1.5 }); // Place trees along the shore (top and bottom edges) if (t < 5) { // Top shore trees tree.x = 200 + t * 300; tree.y = 800 + Math.random() * 200; } else { // Bottom shore trees tree.x = 200 + (t - 5) * 300; tree.y = 2300 + Math.random() * 200; } tree.alpha = 0.4; tree.tint = 0x8B4513; // Brown color for tree trunks game.addChild(tree); } // Add SPINO fossils scattered around for (var s = 0; s < 4; s++) { var spinoFossil = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); spinoFossil.x = 300 + Math.random() * 1448; spinoFossil.y = 1600 + Math.random() * 800; spinoFossil.alpha = 0.3; spinoFossil.rotation = Math.random() * Math.PI * 2; game.addChild(spinoFossil); } // Add crocodile-like fossils (using BARYONYX as substitute for Sarcosuchus) for (var c = 0; c < 3; c++) { var crocFossil = LK.getAsset('BARYONYX', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); crocFossil.x = 400 + Math.random() * 1248; crocFossil.y = 1700 + Math.random() * 700; crocFossil.alpha = 0.3; crocFossil.rotation = Math.random() * Math.PI * 2; game.addChild(crocFossil); } } else if (backgroundIndex === 2) { // 3. Snowy mountain with GIGA and Argentavis fossils (white background) var snowyBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); snowyBackground.x = 1024; snowyBackground.y = 1366; snowyBackground.alpha = 0.3; snowyBackground.tint = 0xFFFFFF; // White color for snowy mountain // Add GIGA fossils scattered around for (var g = 0; g < 3; g++) { var gigaFossil = LK.getAsset('GIGA', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); gigaFossil.x = 300 + Math.random() * 1448; gigaFossil.y = 1600 + Math.random() * 800; gigaFossil.alpha = 0.3; gigaFossil.rotation = Math.random() * Math.PI * 2; game.addChild(gigaFossil); } // Add Argentavis fossils (using YUTY as substitute for Argentavis) for (var a = 0; a < 2; a++) { var argentavisFossil = LK.getAsset('YUTY', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); argentavisFossil.x = 400 + Math.random() * 1248; argentavisFossil.y = 1700 + Math.random() * 700; argentavisFossil.alpha = 0.3; argentavisFossil.rotation = Math.random() * Math.PI * 2; game.addChild(argentavisFossil); } // Add snow patches using limestone blocks for (var s = 0; s < 8; s++) { var snowPatch = LK.getAsset('limestone', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); snowPatch.x = 200 + Math.random() * 1648; snowPatch.y = 1500 + Math.random() * 1000; snowPatch.alpha = 0.4; snowPatch.tint = 0xF0F8FF; // Alice blue for snow patches snowPatch.rotation = Math.random() * Math.PI * 2; game.addChild(snowPatch); } } else if (backgroundIndex === 3) { // 4. Ocean floor with Megalodon and Mosasaurus fossils (light blue background) var oceanBackground = game.attachAsset('excavationSite', { anchorX: 0.5, anchorY: 0.5 }); oceanBackground.x = 1024; oceanBackground.y = 1366; oceanBackground.alpha = 0.3; oceanBackground.tint = 0x87CEEB; // Light blue color for ocean // Add Megalodon fossils (using TREX as substitute for Megalodon) for (var m = 0; m < 2; m++) { var megalodonFossil = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); megalodonFossil.x = 300 + Math.random() * 1448; megalodonFossil.y = 1600 + Math.random() * 800; megalodonFossil.alpha = 0.3; megalodonFossil.rotation = Math.random() * Math.PI * 2; game.addChild(megalodonFossil); } // Add Mosasaurus fossils (using SPINO as substitute for Mosasaurus) for (var mo = 0; mo < 3; mo++) { var mosasaurusFossil = LK.getAsset('SPINO', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.9, scaleY: 0.9 }); mosasaurusFossil.x = 400 + Math.random() * 1248; mosasaurusFossil.y = 1700 + Math.random() * 700; mosasaurusFossil.alpha = 0.3; mosasaurusFossil.rotation = Math.random() * Math.PI * 2; game.addChild(mosasaurusFossil); } // Add coral formations using fossil shapes for (var c = 0; c < 6; c++) { var coral = LK.getAsset('fossil3', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); coral.x = 200 + Math.random() * 1648; coral.y = 1500 + Math.random() * 1000; coral.alpha = 0.4; coral.tint = 0xFF7F50; // Coral color coral.rotation = Math.random() * Math.PI * 2; game.addChild(coral); } } } // Select and create background selectNextBackground(); createBackground(currentBackgroundIndex); // Dinosaur images with red eyes and different skin colors var gameState = 'nickname'; // 'nickname', 'playing' var playerNickname = storage.playerNickname || ''; var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var currentLetterIndex = 0; var currentLevelNumber = storage.currentLevelNumber || 1; var maxLevels = 200; var currentLevel = null; var levelTimer = 0; var leaderboardTexts = []; // Player data storage - Load persistent data from storage var playerCoins = storage.playerCoins || 0; var playerInventory = storage.playerInventory || []; var dinosaurCollection = storage.dinosaurCollection || []; var selectedDinosaur = storage.selectedDinosaur || null; var playerLevel = storage.playerLevel || 1; // Dinosaur hunger system - Load persistent data var dinosaurHunger = storage.dinosaurHunger || {}; var lastFeedingCheck = storage.lastFeedingCheck || Date.now(); // Food inventory - Load persistent data var leafFood = storage.leafFood || 0; var meatFood = storage.meatFood || 0; var fishFood = storage.fishFood || 0; // Dinosaur diet mapping based on real-life diets var dinosaurDiets = { 'PARASOUROLUPHUS': 'leaf', // Herbivore - ate plants, leaves 'TRICERATOPS': 'leaf', // Herbivore - ate plants, leaves 'ANKYLOSAURUS': 'leaf', // Herbivore - ate plants, leaves 'BARYONYX': 'fish', // Piscivore - fish eater with crocodile-like snout 'ALLO': 'meat', // Carnivore - large predator 'YUTY': 'meat', // Carnivore - feathered tyrannosaur 'TREX': 'meat', // Carnivore - apex predator 'SPINO': 'fish', // Piscivore - semi-aquatic fish eater 'GIGA': 'meat', // Carnivore - massive predator 'Mutated BARYONYX': 'fish', // Piscivore - enhanced fish eater 'Mutated PARASAUROLUPHUS': 'leaf' // Herbivore - enhanced plant eater }; var feedingCosts = { 'PARASOUROLUPHUS': 50, 'TRICERATOPS': 60, 'ANKYLOSAURUS': 70, 'BARYONYX': 200, 'ALLO': 300, 'YUTY': 400, 'TREX': 800, 'SPINO': 600, 'GIGA': 700, 'Mutated BARYONYX': 500, 'Mutated PARASAUROLUPHUS': 550 }; // Ensure storage is properly initialized storage.playerCoins = playerCoins; storage.playerInventory = playerInventory; storage.dinosaurCollection = dinosaurCollection; storage.selectedDinosaur = selectedDinosaur; storage.dinosaurHunger = dinosaurHunger; storage.lastFeedingCheck = lastFeedingCheck; // Background rotation system - track last shown background var lastBackgroundIndex = storage.lastBackgroundIndex || -1; var currentBackgroundIndex = 0; // Load persistent gamepass purchases var xrayLevelsLeft = storage.xrayLevelsLeft || 0; var doubleMoneyLevelsLeft = 0; // Reset 2X MONEY gamepass bug for everyone storage.doubleMoneyLevelsLeft = 0; // Save reset value to storage var doubleValueActive = storage.doubleValueActive || false; var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false; // Load persistent +1 SELECT gamepass purchases // Note: passPurchases is already loaded from storage in the showBag function // GIGA fast mining state var gigaFastMiningActive = false; var gigaFastMiningLevel = 0; // Crown system for game completions var gameCompletions = storage.gameCompletions || 0; var playerCrowns = storage.playerCrowns || 0; // Number of crowns earned (max 5) // Daily gifts system - Load persistent data var lastGiftDate = storage.lastGiftDate || 0; var currentGiftDay = storage.currentGiftDay || 1; var dailyGifts = [1000, 2000, 4000, 8000, 10000, 12000, 16000]; // 7 days of gifts var dailyGiftClaimed = storage.dailyGiftClaimed || false; // Weekly food rewards system - Load persistent data var lastFoodGiftDate = storage.lastFoodGiftDate || 0; var currentFoodGiftDay = storage.currentFoodGiftDay || 1; var weeklyFoodGifts = [{ leaf: 1, meat: 1, fish: 1 }, // Day 1: 1 of each { leaf: 2, meat: 2, fish: 2 }, // Day 2: 2 of each { leaf: 3, meat: 3, fish: 3 }, // Day 3: 3 of each { leaf: 5, meat: 5, fish: 5 }, // Day 4: 5 of each { leaf: 7, meat: 7, fish: 7 }, // Day 5: 7 of each { leaf: 8, meat: 8, fish: 8 }, // Day 6: 8 of each { leaf: 10, meat: 10, fish: 10 } // Day 7: 10 of each ]; var weeklyFoodGiftClaimed = storage.weeklyFoodGiftClaimed || false; // Trade system - Load persistent data var dailyTradesLeft = storage.dailyTradesLeft || 5; // 5 trades per day var lastTradeDate = storage.lastTradeDate || 0; var currentTradeOffer = storage.currentTradeOffer || null; var tradeRequestsReceived = storage.tradeRequestsReceived || []; var activePlayers = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']; // Mock active players // Puzzle and difficulty system var puzzleLevels = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; // Puzzle every 10 levels var currentPuzzle = null; var puzzleUIElements = []; function isPuzzleLevel(levelNumber) { return puzzleLevels.indexOf(levelNumber) !== -1; } function getLevelDifficulty(levelNumber) { // Calculate difficulty scaling: more fossils, less time, harder patterns var baseFossils = 3; var bonusFossils = Math.floor(levelNumber / 20); // +1 fossil every 20 levels var totalFossils = Math.min(baseFossils + bonusFossils, 10); // Max 10 fossils var baseBlocks = 48; // 8x6 grid var bonusBlocks = Math.floor(levelNumber / 25) * 8; // +8 blocks every 25 levels var totalBlocks = Math.min(baseBlocks + bonusBlocks, 80); // Max 80 blocks (10x8 grid) var rareChance = Math.min(0.05 + levelNumber * 0.002, 0.25); // Increase rare fossil chance, max 25% return { fossilCount: totalFossils, blockCount: totalBlocks, rareChance: rareChance, gridWidth: Math.min(8 + Math.floor(bonusBlocks / 8), 10), gridHeight: Math.min(6 + Math.floor(bonusBlocks / 16), 8) }; } // Stock system - Load persistent data (coming soon) var stockUIElements = []; var fossilRarities = { 'fossil1': 'common', 'fossil2': 'common', 'fossil3': 'common', 'rareFossil': 'rare' }; var fossilValues = { 'fossil1': 10, 'fossil2': 15, 'fossil3': 20, 'rareFossil': 100 }; var dinosaurRarities = { 'PARASOUROLUPHUS': 'common', 'TRICERATOPS': 'common', 'ANKYLOSAURUS': 'common', 'BARYONYX': 'rare', 'ALLO': 'rare', 'YUTY': 'rare', 'TREX': 'chromatic', 'SPINO': 'legendary', 'GIGA': 'legendary', 'Mutated BARYONYX': 'legendary', 'Mutated PARASAUROLUPHUS': 'legendary' }; // Dinosaur abilities - Original characteristics restored var dinosaurAbilities = { 'PARASOUROLUPHUS': 'slow_dig', // Very slow digging, takes more time to break blocks 'TRICERATOPS': 'head_charge', // Head charge reduces 5 random blocks to 2 hit requirement 'ANKYLOSAURUS': 'tail_strike', // Tail strike reduces 4 random blocks to 1 hit requirement 'BARYONYX': 'speed_dig', // 20% faster digging speed 'YUTY': 'fast_dig', // 70% faster digging speed 'ALLO': 'medium_speed_dig', // 40% faster digging speed 'TREX': 'roar_collector', // Roars every 10 levels and collects all fossils 'SPINO': 'line_breaker', // Tail strike breaks 3 blocks in horizontal line, 1 use per level 'GIGA': 'fast_mining', // Fast mining: normal blocks 1 hit, hard blocks 2 hits, ultra hard blocks 4 hits until level ends, usable every 5 levels 'Mutated BARYONYX': 'ultra_fast_dig', // 90% faster digging speed 'Mutated PARASAUROLUPHUS': 'improved_slow_dig' // Faster than regular PARASAUROLUPHUS but still slower than others }; // Dinosaur egg contents var commonEggDinosaurs = ['PARASOUROLUPHUS', 'TRICERATOPS', 'ANKYLOSAURUS']; var rareEggDinosaurs = [{ name: 'BARYONYX', chance: 0.45 }, { name: 'ALLO', chance: 0.35 }, { name: 'YUTY', chance: 0.20 }]; var legendaryEggDinosaurs = [{ name: 'TREX', chance: 0.03 }, { name: 'SPINO', chance: 0.15 }, { name: 'GIGA', chance: 0.22 }, { name: 'Mutated BARYONYX', chance: 0.30 }, { name: 'Mutated PARASAUROLUPHUS', chance: 0.30 }]; function openEgg(eggType) { var dinosaurName = ''; if (eggType === 'common') { // Equal chance for all common dinosaurs dinosaurName = commonEggDinosaurs[Math.floor(Math.random() * commonEggDinosaurs.length)]; } else if (eggType === 'rare') { // Weighted random selection for rare dinosaurs - apply 2X LUCK if active var randomValue = Math.random(); var cumulativeChance = 0; for (var i = 0; i < rareEggDinosaurs.length; i++) { var currentChance = rareEggDinosaurs[i].chance; // Apply 2X LUCK effect if active if (doubleSpawnChanceActive) { currentChance *= 2; } cumulativeChance += currentChance; if (randomValue <= cumulativeChance) { dinosaurName = rareEggDinosaurs[i].name; break; } } } else if (eggType === 'legendary') { // Weighted random selection for legendary dinosaurs - apply 2X LUCK if active var randomValue = Math.random(); var cumulativeChance = 0; for (var i = 0; i < legendaryEggDinosaurs.length; i++) { var currentChance = legendaryEggDinosaurs[i].chance; // Apply 2X LUCK effect if active if (doubleSpawnChanceActive) { currentChance *= 2; } cumulativeChance += currentChance; if (randomValue <= cumulativeChance) { dinosaurName = legendaryEggDinosaurs[i].name; break; } } } // Reset 2X LUCK effect after use if (doubleSpawnChanceActive) { doubleSpawnChanceActive = false; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; } // Add to dinosaur collection dinosaurCollection.push(dinosaurName); storage.dinosaurCollection = dinosaurCollection; // Show congratulations popup showCongratulationsPopup(dinosaurName); return dinosaurName; } function showCongratulationsPopup(dinosaurName) { gameState = 'congratulations'; // Hide all current UI hideAllStoreUI(); hideAllMenuUI(); hideAllGameUI(); // Create congratulations display var congratsTitle = new Text2('TEBRİKLER!', { size: 100, fill: '#FFD700' }); congratsTitle.anchor.set(0.5, 0.5); congratsTitle.x = 1024; congratsTitle.y = 600; game.addChild(congratsTitle); infoUIElements.push(congratsTitle); var winMessage = new Text2('KAZANDINIZ!', { size: 80, fill: '#FFFFFF' }); winMessage.anchor.set(0.5, 0.5); winMessage.x = 1024; winMessage.y = 800; game.addChild(winMessage); infoUIElements.push(winMessage); // Add dinosaur image var dinoImage = new DinosaurImage(dinosaurName); dinoImage.x = 1024; dinoImage.y = 900; dinoImage.scaleX = 2; dinoImage.scaleY = 2; game.addChild(dinoImage); infoUIElements.push(dinoImage); var dinosaurMessage = new Text2(dinosaurName, { size: 60, fill: '#32CD32' }); dinosaurMessage.anchor.set(0.5, 0.5); dinosaurMessage.x = 1024; dinosaurMessage.y = 1100; game.addChild(dinosaurMessage); infoUIElements.push(dinosaurMessage); var closeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); closeButton.x = 1024; closeButton.y = 1300; var closeButtonText = new Text2('TAMAM', { size: 35, fill: '#FFFFFF' }); closeButtonText.anchor.set(0.5, 0.5); closeButtonText.x = 1024; closeButtonText.y = 1300; game.addChild(closeButtonText); infoUIElements.push(closeButton, closeButtonText); closeButton.down = function () { hideInfoScreen(); gameState = 'nickname'; showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); }; } // UI Element arrays for different game states var menuUIElements = []; var gameUIElements = []; var storeUIElements = []; var sellUIElements = []; var bagUIElements = []; var infoUIElements = []; var giftsUIElements = []; var tradeUIElements = []; var stockUIElements = []; // UI Elements var nicknameText = new Text2('Enter Nickname: A', { size: 80, fill: '#FFFFFF' }); nicknameText.anchor.set(0.5, 0.5); nicknameText.x = 1024; nicknameText.y = 800; var instructionText = new Text2('Use arrows to select letters, ADD to add, DELETE to remove', { size: 45, fill: '#CCCCCC' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 900; var scoreText = new Text2('Score: 0', { size: 60, fill: '#FFFFFF' }); scoreText.anchor.set(0, 0); var levelText = new Text2('Level: 1', { size: 60, fill: '#FFFFFF' }); levelText.anchor.set(1, 0); var timerText = new Text2('Time: 0', { size: 50, fill: '#FFFFFF' }); timerText.anchor.set(0.5, 0); // Nickname input elements var leftArrow = game.attachAsset('arrowLeft', { anchorX: 0.5, anchorY: 0.5 }); leftArrow.x = 800; leftArrow.y = 1000; var leftArrowSymbol = new Text2('<', { size: 60, fill: '#FFFFFF' }); leftArrowSymbol.anchor.set(0.5, 0.5); leftArrowSymbol.x = 800; leftArrowSymbol.y = 1000; game.addChild(leftArrowSymbol); var rightArrow = game.attachAsset('arrowRight', { anchorX: 0.5, anchorY: 0.5 }); rightArrow.x = 1248; rightArrow.y = 1000; var rightArrowSymbol = new Text2('>', { size: 60, fill: '#FFFFFF' }); rightArrowSymbol.anchor.set(0.5, 0.5); rightArrowSymbol.x = 1248; rightArrowSymbol.y = 1000; game.addChild(rightArrowSymbol); var startButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); startButton.x = 1024; startButton.y = 1200; var startButtonText = new Text2('START', { size: 40, fill: '#FFFFFF' }); startButtonText.anchor.set(0.5, 0.5); startButtonText.x = 1024; startButtonText.y = 1200; var addButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); addButton.x = 900; addButton.y = 1100; var addButtonText = new Text2('ADD', { size: 35, fill: '#FFFFFF' }); addButtonText.anchor.set(0.5, 0.5); addButtonText.x = 900; addButtonText.y = 1100; var deleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); deleteButton.x = 1148; deleteButton.y = 1100; var deleteButtonText = new Text2('DELETE', { size: 35, fill: '#FFFFFF' }); deleteButtonText.anchor.set(0.5, 0.5); deleteButtonText.x = 1148; deleteButtonText.y = 1100; var storeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); storeButton.x = 650; storeButton.y = 1300; var storeButtonText = new Text2('STORE', { size: 35, fill: '#FFFFFF' }); storeButtonText.anchor.set(0.5, 0.5); storeButtonText.x = 650; storeButtonText.y = 1300; var sellButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellButton.x = 1398; sellButton.y = 1300; var sellButtonText = new Text2('SELL', { size: 35, fill: '#FFFFFF' }); sellButtonText.anchor.set(0.5, 0.5); sellButtonText.x = 1398; sellButtonText.y = 1300; var shopButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopButton.x = 1024; shopButton.y = 1550; var shopButtonText = new Text2('SHOP', { size: 35, fill: '#FFFFFF' }); shopButtonText.anchor.set(0.5, 0.5); shopButtonText.x = 1024; shopButtonText.y = 1550; var bagButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagButton.x = 1024; bagButton.y = 1650; var bagButtonText = new Text2('BAG', { size: 35, fill: '#FFFFFF' }); bagButtonText.anchor.set(0.5, 0.5); bagButtonText.x = 1024; bagButtonText.y = 1650; var tradeButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); tradeButton.x = 650; tradeButton.y = 1750; var tradeButtonText = new Text2('TRADE', { size: 35, fill: '#FFFFFF' }); tradeButtonText.anchor.set(0.5, 0.5); tradeButtonText.x = 650; tradeButtonText.y = 1750; var giftsButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); giftsButton.x = 1398; giftsButton.y = 1750; var giftsButtonText = new Text2('GIFTS', { size: 35, fill: '#FFFFFF' }); giftsButtonText.anchor.set(0.5, 0.5); giftsButtonText.x = 1398; giftsButtonText.y = 1750; var stockButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); stockButton.x = 1024; stockButton.y = 1850; var stockButtonText = new Text2('STOCK', { size: 35, fill: '#FFFFFF' }); stockButtonText.anchor.set(0.5, 0.5); stockButtonText.x = 1024; stockButtonText.y = 1850; var coinsText = new Text2('Coins: ' + playerCoins, { size: 50, fill: '#FFD700' }); coinsText.anchor.set(0.5, 0.5); coinsText.x = 1024; coinsText.y = 1400; // Add nickname UI to game and track as menu elements game.addChild(nicknameText); game.addChild(instructionText); game.addChild(leftArrow); game.addChild(rightArrow); game.addChild(addButton); game.addChild(addButtonText); game.addChild(deleteButton); game.addChild(deleteButtonText); game.addChild(startButton); game.addChild(startButtonText); game.addChild(storeButton); game.addChild(storeButtonText); game.addChild(sellButton); game.addChild(sellButtonText); game.addChild(shopButton); game.addChild(shopButtonText); game.addChild(bagButton); game.addChild(bagButtonText); game.addChild(tradeButton); game.addChild(tradeButtonText); game.addChild(giftsButton); game.addChild(giftsButtonText); game.addChild(stockButton); game.addChild(stockButtonText); game.addChild(coinsText); // Track menu UI elements menuUIElements.push(nicknameText, instructionText, leftArrow, leftArrowSymbol, rightArrow, rightArrowSymbol, addButton, addButtonText, deleteButton, deleteButtonText, startButton, startButtonText, storeButton, storeButtonText, sellButton, sellButtonText, shopButton, shopButtonText, bagButton, bagButtonText, tradeButton, tradeButtonText, giftsButton, giftsButtonText, stockButton, stockButtonText, coinsText); // Track game UI elements gameUIElements.push(scoreText, levelText, timerText); // Add game UI to GUI LK.gui.topLeft.addChild(scoreText); scoreText.x = 120; scoreText.y = 20; scoreText.visible = false; LK.gui.topRight.addChild(levelText); levelText.y = 20; levelText.visible = false; LK.gui.top.addChild(timerText); timerText.y = 100; timerText.visible = false; function hideAllMenuUI() { for (var i = 0; i < menuUIElements.length; i++) { menuUIElements[i].visible = false; } } function showAllMenuUI() { for (var i = 0; i < menuUIElements.length; i++) { menuUIElements[i].visible = true; } // Display player crowns displayPlayerCrowns(); } function hideAllGameUI() { for (var i = 0; i < gameUIElements.length; i++) { gameUIElements[i].visible = false; } } function showAllGameUI() { for (var i = 0; i < gameUIElements.length; i++) { gameUIElements[i].visible = true; } } function hideAllStoreUI() { for (var i = 0; i < storeUIElements.length; i++) { storeUIElements[i].destroy(); } storeUIElements = []; } function hideAllSellUI() { for (var i = 0; i < sellUIElements.length; i++) { sellUIElements[i].destroy(); } sellUIElements = []; } function hideAllBagUI() { for (var i = 0; i < bagUIElements.length; i++) { bagUIElements[i].destroy(); } bagUIElements = []; } function hideAllInfoUI() { for (var i = 0; i < infoUIElements.length; i++) { infoUIElements[i].destroy(); } infoUIElements = []; } function updateNicknameDisplay() { var currentLetter = alphabet[currentLetterIndex]; var displayText = 'Enter Nickname: ' + playerNickname + currentLetter; nicknameText.setText(displayText); // Update instruction text to show current letter selection instructionText.setText('Current Letter: ' + currentLetter + ' - Use arrows to select, ADD to add, DELETE to remove'); } function startLevel(levelNumber) { // Clean up previous level if (currentLevel) { currentLevel.destroy(); } currentLevelNumber = levelNumber; storage.currentLevelNumber = currentLevelNumber; levelTimer = 0; // Reset SPINO usage for new level storage.spinoUsedThisLevel = false; // No special ability resets needed for original abilities // Create new level currentLevel = new Level(levelNumber); currentLevel.createLevel(); game.addChild(currentLevel); levelText.setText('Level: ' + levelNumber + '/' + maxLevels); } function startPuzzleLevel(levelNumber) { // Clean up previous level if (currentLevel) { currentLevel.destroy(); } if (currentPuzzle) { currentPuzzle.destroy(); } currentLevelNumber = levelNumber; storage.currentLevelNumber = currentLevelNumber; levelTimer = 0; levelText.setText('Level: ' + levelNumber + ' (PUZZLE)'); // Create dinosaur trivia puzzle createPuzzle(0, levelNumber); } function createPuzzle(puzzleType, levelNumber) { currentPuzzle = new Container(); game.addChild(currentPuzzle); // All puzzles are now dinosaur trivia questions createDinosaurTriviaPuzzle(levelNumber); } function createDinosaurTriviaPuzzle(levelNumber) { // Create diverse trivia questions with increasing difficulty based on level var triviaQuestions = [ // Levels 10-30: Basic questions about size, strength, and diet { question: "T-Rex'in ısırma gücü ne kadardı?", answers: ["5,000 PSI", "12,800 PSI", "20,000 PSI"], correct: 1, minLevel: 10 }, { question: "Spinosaurus nasıl yaşardı?", answers: ["Sadece karada", "Yarı suda yarı karada", "Sadece suda"], correct: 1, minLevel: 10 }, { question: "Giganotosaurus nasıl savaşırdı?", answers: ["Tek başına", "Grup halinde", "Hiç savaşmazdı"], correct: 1, minLevel: 20 }, { question: "Triceratops'un frill'i ne için kullanılırdı?", answers: ["Sadece savunma", "Gösteriş ve termoregülasyon", "Uçmak için"], correct: 1, minLevel: 20 }, { question: "Parasaurolophus nasıl iletişim kurardı?", answers: ["Çıkardığı seslerle", "Renk değiştirerek", "Dans ederek"], correct: 0, minLevel: 20 }, { question: "Allosaurus'un avlama stratejisi neydi?", answers: ["Hızlı saldırı", "Pusu kurma", "Grup avcılığı"], correct: 0, minLevel: 30 }, // Levels 40-70: Intermediate questions about behavior and abilities { question: "Velociraptor'un en büyük avantajı neydi?", answers: ["Büyüklüğü", "Zekası ve çevikliği", "Uçma yeteneği"], correct: 1, minLevel: 40 }, { question: "Baryonyx'in özel beslenme adaptasyonu neydi?", answers: ["Timsah benzeri çene", "Uzun boyun", "Güçlü bacaklar"], correct: 0, minLevel: 40 }, { question: "Dimetrodon'un sırtındaki yelken ne işe yarardı?", answers: ["Uçmak için", "Vücut ısısını düzenlemek", "Yüzmek için"], correct: 1, minLevel: 50 }, { question: "Carnotaurus'un koşu hızı ne kadardı?", answers: ["25 km/s", "55 km/s", "80 km/s"], correct: 1, minLevel: 50 }, { question: "Therizinosaurus'un dev pençeleri ne için kullanılırdı?", answers: ["Avlamak için", "Bitki toplamak için", "Savaşmak için"], correct: 1, minLevel: 60 }, { question: "Utahraptor'un avlama taktiği neydi?", answers: ["Tek başına saldırı", "Grup koordinasyonu", "Zehirli ısırık"], correct: 1, minLevel: 70 }, // Levels 80-120: Advanced questions about combat and survival { question: "Ankylosaurus nasıl kendini savunurdu?", answers: ["Hızla kaçarak", "Zırhlı vücut ve kuyruk sopası", "Yüksek yerlere tırmanarak"], correct: 1, minLevel: 80 }, { question: "Dilophosaurus'un gerçek silahı neydi?", answers: ["Zehirli tükürük", "Güçlü çeneleri", "Hızlı pençeleri"], correct: 1, minLevel: 80 }, { question: "Compsognathus'un hayatta kalma stratejisi neydi?", answers: ["Büyük boyut", "Hız ve çeviklik", "Zehirli ısırık"], correct: 1, minLevel: 90 }, { question: "Stegosaurus'un kuyruk dikenleri nasıl kullanılırdı?", answers: ["Savunma silahı olarak", "Termoregülasyon için", "Çiftleşme gösterisi"], correct: 0, minLevel: 100 }, { question: "Maiasaura nasıl ebeveynlik yapardı?", answers: ["Yumurtaları terk ederdi", "Yuva yapıp yavrularını beslerdi", "Sadece erkekler bakardı"], correct: 1, minLevel: 110 }, { question: "Microraptor'un uçma yeteneği nasıldı?", answers: ["Mükemmel uçucu", "Sadece süzülme", "Hiç uçamaz"], correct: 1, minLevel: 120 }, // Levels 130-200: Expert questions about complex behaviors { question: "Orodromeus'un en büyük özelliği neydi?", answers: ["Dev boyut", "İnanılmaz hız", "Güçlü pençeler"], correct: 1, minLevel: 130 }, { question: "Amargasaurus'un boyun dikenleri ne işe yarardı?", answers: ["Ses çıkarmak", "Savunma", "Gösteriş ve termoregülasyon"], correct: 2, minLevel: 140 }, { question: "Ceratosaurus'un burun boynuzu ne için kullanılırdı?", answers: ["Çiftleşme ritüelleri", "Savaş", "Her ikisi de"], correct: 2, minLevel: 150 }, { question: "Diplodocus nasıl beslenirdi?", answers: ["Yüksek ağaç dallarından", "Yerdeki bitkilerden", "Her iki şekilde de"], correct: 2, minLevel: 160 }, { question: "Archaeopteryx'in evrimsel önemi nedir?", answers: ["İlk dinozor", "Dinozor-kuş geçişi", "En büyük uçan hayvan"], correct: 1, minLevel: 170 }, { question: "Saurophaganax'in avlama stratejisi neydi?", answers: ["Gece avcılığı", "Su kenarında pusu", "Açık alanda hızlı saldırı"], correct: 0, minLevel: 180 }, { question: "Dracorex'in kafatası yapısı neyi gösterir?", answers: ["Savaşçı doğa", "Güçlü çene kasları", "Gösteriş amaçlı süsler"], correct: 2, minLevel: 190 }, { question: "Carcharodontosaurus'un ısırma tekniği nasıldı?", answers: ["Hızlı çoklu ısırık", "Tek güçlü ısırık", "Sallayarak parçalama"], correct: 0, minLevel: 200 }]; // Filter questions appropriate for current level var availableQuestions = []; for (var i = 0; i < triviaQuestions.length; i++) { if (levelNumber >= triviaQuestions[i].minLevel) { availableQuestions.push(triviaQuestions[i]); } } // Select random question from available ones, or use stored question if retrying var selectedQuestion; if (storage.currentPuzzleQuestion) { selectedQuestion = storage.currentPuzzleQuestion; } else { selectedQuestion = availableQuestions[Math.floor(Math.random() * availableQuestions.length)]; // Store the question for potential retries storage.currentPuzzleQuestion = selectedQuestion; } // Create puzzle title var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); // Display question var questionText = new Text2(selectedQuestion.question, { size: 50, fill: '#FFFFFF' }); questionText.anchor.set(0.5, 0.5); questionText.x = 1024; questionText.y = 600; currentPuzzle.addChild(questionText); puzzleUIElements.push(questionText); // Create answer buttons for (var a = 0; a < 3; a++) { var answerButton = currentPuzzle.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); answerButton.x = 1024; answerButton.y = 900 + a * 150; currentPuzzle.addChild(answerButton); puzzleUIElements.push(answerButton); var answerText = new Text2(selectedQuestion.answers[a], { size: 40, fill: '#FFFFFF' }); answerText.anchor.set(0.5, 0.5); answerText.x = 1024; answerText.y = 900 + a * 150; currentPuzzle.addChild(answerText); puzzleUIElements.push(answerText); // Add click handler with closure (function (answerIndex, correctIndex) { answerButton.down = function () { if (answerIndex === correctIndex) { solvePuzzle(); } else { resetTriviaPuzzle(); } }; })(a, selectedQuestion.correct); } } function resetTriviaPuzzle() { // Keep the same question - just reset the UI and regenerate with same question if (currentPuzzle) { currentPuzzle.destroy(); } hideAllPuzzleUI(); // Store the current question before recreating var storedQuestion = storage.currentPuzzleQuestion || null; // Create new puzzle container currentPuzzle = new Container(); game.addChild(currentPuzzle); // If we have a stored question, use it, otherwise generate new one if (storedQuestion) { createStoredTriviaPuzzle(storedQuestion); } else { createDinosaurTriviaPuzzle(currentLevelNumber); } } function createSequencePuzzle(levelNumber) { // Sequence puzzle: Click fossils in correct order var puzzleTitle = new Text2('SEQUENCE PUZZLE - Click fossils in order!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var sequenceLength = Math.min(3 + Math.floor(levelNumber / 30), 8); // Longer sequences for higher levels var correctSequence = []; var playerSequence = []; var fossils = []; // Create sequence of fossils for (var i = 0; i < sequenceLength; i++) { var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), { anchorX: 0.5, anchorY: 0.5 }); fossil.x = 300 + i * 150; fossil.y = 800; fossil.sequenceNumber = i + 1; fossils.push(fossil); correctSequence.push(i); puzzleUIElements.push(fossil); var numberText = new Text2(String(i + 1), { size: 40, fill: '#FFFFFF' }); numberText.anchor.set(0.5, 0.5); numberText.x = fossil.x; numberText.y = fossil.y - 80; currentPuzzle.addChild(numberText); puzzleUIElements.push(numberText); // Add click handler (function (index, fossilObj) { fossilObj.down = function () { playerSequence.push(index); fossilObj.alpha = 0.5; if (playerSequence.length === sequenceLength) { checkSequence(); } }; })(i, fossil); } function checkSequence() { var correct = true; for (var i = 0; i < sequenceLength; i++) { if (playerSequence[i] !== correctSequence[i]) { correct = false; break; } } if (correct) { solvePuzzle(); } else { resetSequencePuzzle(); } } function resetSequencePuzzle() { playerSequence = []; for (var i = 0; i < fossils.length; i++) { fossils[i].alpha = 1; } } } function createPatternPuzzle(levelNumber) { // Pattern puzzle: Complete the fossil pattern var puzzleTitle = new Text2('PATTERN PUZZLE - Complete the pattern!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var gridSize = Math.min(3 + Math.floor(levelNumber / 50), 5); // Larger grids for higher levels var pattern = []; var playerPattern = []; // Generate pattern for (var i = 0; i < gridSize * gridSize; i++) { pattern.push(Math.random() > 0.5 ? 1 : 0); } // Show pattern briefly, then hide half of it for (var row = 0; row < gridSize; row++) { for (var col = 0; col < gridSize; col++) { var index = row * gridSize + col; var shouldShow = pattern[index] === 1; var isHidden = (row + col) % 2 === 1; // Checkerboard hiding pattern var fossil = null; if (shouldShow && !isHidden) { fossil = currentPuzzle.attachAsset('fossil1', { anchorX: 0.5, anchorY: 0.5 }); } else if (shouldShow && isHidden) { fossil = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); fossil.isHiddenPattern = true; fossil.correctPattern = true; } else if (isHidden) { fossil = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); fossil.isHiddenPattern = true; fossil.correctPattern = false; } if (fossil) { fossil.x = 700 + col * 100; fossil.y = 600 + row * 100; fossil.gridIndex = index; puzzleUIElements.push(fossil); if (fossil.isHiddenPattern) { (function (fossilObj) { fossilObj.down = function () { if (fossilObj.correctPattern) { fossilObj.destroy(); var correctFossil = currentPuzzle.attachAsset('fossil1', { anchorX: 0.5, anchorY: 0.5 }); correctFossil.x = fossilObj.x; correctFossil.y = fossilObj.y; currentPuzzle.addChild(correctFossil); checkPatternComplete(); } else { resetPatternPuzzle(); } }; })(fossil); } } } } } function checkPatternComplete() { // Simple check - if we get here from correct clicks, puzzle is solved solvePuzzle(); } function resetPatternPuzzle() { // Reset puzzle on wrong click createPatternPuzzle(currentLevelNumber); } function createMemoryPuzzle(levelNumber) { // Memory puzzle: Remember fossil locations var puzzleTitle = new Text2('MEMORY PUZZLE - Remember the fossil locations!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); var fossilCount = Math.min(3 + Math.floor(levelNumber / 40), 6); var memoryPositions = []; var revealedFossils = []; // Generate random positions for (var i = 0; i < fossilCount; i++) { var pos = { x: 400 + Math.floor(Math.random() * 5) * 150, y: 600 + Math.floor(Math.random() * 3) * 150 }; memoryPositions.push(pos); var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), { anchorX: 0.5, anchorY: 0.5 }); fossil.x = pos.x; fossil.y = pos.y; fossil.memoryIndex = i; currentPuzzle.addChild(fossil); revealedFossils.push(fossil); puzzleUIElements.push(fossil); } // Hide fossils after showing them briefly LK.setTimeout(function () { for (var i = 0; i < revealedFossils.length; i++) { revealedFossils[i].alpha = 0; } createMemoryGrid(); }, 2000); function createMemoryGrid() { var playerGuesses = 0; var correctGuesses = 0; for (var row = 0; row < 3; row++) { for (var col = 0; col < 5; col++) { var gridX = 400 + col * 150; var gridY = 600 + row * 150; var isCorrectPos = false; for (var p = 0; p < memoryPositions.length; p++) { if (memoryPositions[p].x === gridX && memoryPositions[p].y === gridY) { isCorrectPos = true; break; } } var gridBlock = currentPuzzle.attachAsset('limestone', { anchorX: 0.5, anchorY: 0.5 }); gridBlock.x = gridX; gridBlock.y = gridY; gridBlock.isCorrectMemory = isCorrectPos; currentPuzzle.addChild(gridBlock); puzzleUIElements.push(gridBlock); (function (blockObj) { blockObj.down = function () { playerGuesses++; if (blockObj.isCorrectMemory) { correctGuesses++; blockObj.tint = 0x00FF00; // Green for correct } else { blockObj.tint = 0xFF0000; // Red for wrong } if (playerGuesses === fossilCount) { if (correctGuesses === fossilCount) { solvePuzzle(); } else { resetMemoryPuzzle(); } } }; })(gridBlock); } } } } function resetMemoryPuzzle() { createMemoryPuzzle(currentLevelNumber); } function createLogicPuzzle(levelNumber) { // Logic puzzle: Mathematical sequence var puzzleTitle = new Text2('LOGIC PUZZLE - Complete the sequence!', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); // Generate arithmetic sequence var startNum = Math.floor(Math.random() * 10) + 1; var step = Math.floor(Math.random() * 5) + 2; var sequence = [startNum, startNum + step, startNum + step * 2, startNum + step * 3]; var missingIndex = Math.floor(Math.random() * 4); var correctAnswer = sequence[missingIndex]; // Display sequence with missing number for (var i = 0; i < 4; i++) { var numText; if (i === missingIndex) { numText = new Text2('?', { size: 80, fill: '#FF0000' }); } else { numText = new Text2(String(sequence[i]), { size: 80, fill: '#FFFFFF' }); } numText.anchor.set(0.5, 0.5); numText.x = 600 + i * 150; numText.y = 700; currentPuzzle.addChild(numText); puzzleUIElements.push(numText); } // Create answer options var options = [correctAnswer]; for (var j = 0; j < 3; j++) { var wrongAnswer; do { wrongAnswer = correctAnswer + (Math.floor(Math.random() * 10) - 5); } while (options.indexOf(wrongAnswer) !== -1 || wrongAnswer <= 0); options.push(wrongAnswer); } // Shuffle options for (var k = options.length - 1; k > 0; k--) { var randomIndex = Math.floor(Math.random() * (k + 1)); var temp = options[k]; options[k] = options[randomIndex]; options[randomIndex] = temp; } // Display options for (var o = 0; o < options.length; o++) { var optionButton = currentPuzzle.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); optionButton.x = 500 + o * 200; optionButton.y = 1000; currentPuzzle.addChild(optionButton); puzzleUIElements.push(optionButton); var optionText = new Text2(String(options[o]), { size: 60, fill: '#FFFFFF' }); optionText.anchor.set(0.5, 0.5); optionText.x = optionButton.x; optionText.y = optionButton.y; currentPuzzle.addChild(optionText); puzzleUIElements.push(optionText); (function (answer) { optionButton.down = function () { if (answer === correctAnswer) { solvePuzzle(); } else { resetLogicPuzzle(); } }; })(options[o]); } } function resetLogicPuzzle() { createLogicPuzzle(currentLevelNumber); } function solvePuzzle() { // Award bonus points for solving puzzle var puzzleBonus = 1000 * Math.floor(currentLevelNumber / 15); LK.setScore(LK.getScore() + puzzleBonus); scoreText.setText('Score: ' + LK.getScore()); // Clear stored puzzle question since it was solved correctly storage.currentPuzzleQuestion = null; // Clean up puzzle hideAllPuzzleUI(); currentPuzzle.destroy(); currentPuzzle = null; // Continue to regular level startLevel(currentLevelNumber); } function hideAllPuzzleUI() { for (var i = 0; i < puzzleUIElements.length; i++) { puzzleUIElements[i].destroy(); } puzzleUIElements = []; } function showStore() { gameState = 'store'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create store display var storeTitle = new Text2('FOSSIL STORE', { size: 80, fill: '#FFFFFF' }); storeTitle.anchor.set(0.5, 0.5); storeTitle.x = 1024; storeTitle.y = 200; game.addChild(storeTitle); storeUIElements.push(storeTitle); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1500; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1500; game.addChild(backButtonText); storeUIElements.push(backButton, backButtonText); // Sort and display inventory by rarity var rareFossils = []; var commonFossils = []; for (var i = 0; i < playerInventory.length; i++) { if (fossilRarities[playerInventory[i]] === 'rare') { rareFossils.push(playerInventory[i]); } else { commonFossils.push(playerInventory[i]); } } var allFossils = rareFossils.concat(commonFossils); var startY = 350; for (var j = 0; j < allFossils.length; j++) { var fossilName = allFossils[j]; var rarity = fossilRarities[fossilName]; var color = rarity === 'rare' ? '#FFD700' : '#FFFFFF'; var fossilText = new Text2(fossilName + ' (' + rarity + ')', { size: 40, fill: color }); fossilText.anchor.set(0.5, 0.5); fossilText.x = 1024; fossilText.y = startY + j * 60; game.addChild(fossilText); storeUIElements.push(fossilText); } backButton.down = function () { hideStore(); }; } function hideStore() { gameState = 'nickname'; // Remove all store UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); } function showSell() { gameState = 'sell'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create sell display var sellTitle = new Text2('SELL FOSSILS', { size: 80, fill: '#FFFFFF' }); sellTitle.anchor.set(0.5, 0.5); sellTitle.x = 1024; sellTitle.y = 200; game.addChild(sellTitle); sellUIElements.push(sellTitle); var sellAllButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellAllButton.x = 1024; sellAllButton.y = 1400; var sellAllButtonText = new Text2('SELL ALL', { size: 35, fill: '#FFFFFF' }); sellAllButtonText.anchor.set(0.5, 0.5); sellAllButtonText.x = 1024; sellAllButtonText.y = 1400; game.addChild(sellAllButtonText); sellUIElements.push(sellAllButton, sellAllButtonText); var sellBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); sellBackButton.x = 1024; sellBackButton.y = 1600; var sellBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); sellBackButtonText.anchor.set(0.5, 0.5); sellBackButtonText.x = 1024; sellBackButtonText.y = 1600; game.addChild(sellBackButtonText); // Add 2X MONEY use button var use2xMoneyButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); use2xMoneyButton.x = 1024; use2xMoneyButton.y = 1500; var use2xMoneyButtonText = new Text2('2X MONEY (' + doubleMoneyLevelsLeft + ')', { size: 35, fill: '#FFFFFF' }); use2xMoneyButtonText.anchor.set(0.5, 0.5); use2xMoneyButtonText.x = 1024; use2xMoneyButtonText.y = 1500; game.addChild(use2xMoneyButtonText); sellUIElements.push(sellBackButton, sellBackButtonText, use2xMoneyButton, use2xMoneyButtonText); // Calculate total value var totalValue = 0; for (var i = 0; i < playerInventory.length; i++) { var fossilValue = fossilValues[playerInventory[i]]; if (doubleValueActive) { fossilValue *= 2; } totalValue += fossilValue; } var totalValueText = new Text2('Total Value: ' + totalValue + ' coins', { size: 50, fill: '#FFD700' }); totalValueText.anchor.set(0.5, 0.5); totalValueText.x = 1024; totalValueText.y = 300; game.addChild(totalValueText); sellUIElements.push(totalValueText); sellAllButton.down = function () { playerCoins += totalValue; playerInventory = []; // Reset 2X VALUE effect after use if (doubleValueActive) { doubleValueActive = false; storage.doubleValueActive = doubleValueActive; } storage.playerCoins = playerCoins; storage.playerInventory = playerInventory; hideSell(); }; use2xMoneyButton.down = function () { if (doubleMoneyLevelsLeft > 0) { // Activate 2X MONEY effect for selling doubleValueActive = true; storage.doubleValueActive = doubleValueActive; // Update button text to show remaining uses use2xMoneyButtonText.setText('2X MONEY (' + doubleMoneyLevelsLeft + ')'); // Recalculate and update total value display var newTotalValue = 0; for (var i = 0; i < playerInventory.length; i++) { var fossilValue = fossilValues[playerInventory[i]]; if (doubleValueActive) { fossilValue *= 2; } newTotalValue += fossilValue; } totalValueText.setText('Total Value: ' + newTotalValue + ' coins'); } }; sellBackButton.down = function () { hideSell(); }; } function hideSell() { gameState = 'nickname'; // Remove all sell UI elements hideAllSellUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showShop() { gameState = 'shop'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create shop display var shopTitle = new Text2('POWER-UP SHOP', { size: 80, fill: '#FFFFFF' }); shopTitle.anchor.set(0.5, 0.5); shopTitle.x = 1024; shopTitle.y = 200; game.addChild(shopTitle); storeUIElements.push(shopTitle); // XRAY Power-up var xrayButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); xrayButton.x = 1024; xrayButton.y = 400; var xrayText = new Text2('XRAY - 500 Coins\nReveals all fossils for 1 level', { size: 35, fill: '#FFFFFF' }); xrayText.anchor.set(0.5, 0.5); xrayText.x = 1024; xrayText.y = 400; // 2X MONEY Power-up var doubleMoneyButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); doubleMoneyButton.x = 1024; doubleMoneyButton.y = 550; var doubleMoneyText = new Text2('2X MONEY - 3250 Coins\nDouble money from fossils', { size: 35, fill: '#FFFFFF' }); doubleMoneyText.anchor.set(0.5, 0.5); doubleMoneyText.x = 1024; doubleMoneyText.y = 550; // 2X VALUE Power-up var doubleValueButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); doubleValueButton.x = 1024; doubleValueButton.y = 700; var doubleValueText = new Text2('2X LUCK - 1250 Coins\nDouble egg chances', { size: 35, fill: '#FFFFFF' }); doubleValueText.anchor.set(0.5, 0.5); doubleValueText.x = 1024; doubleValueText.y = 700; // Common Egg var commonEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); commonEggButton.x = 1024; commonEggButton.y = 1400; var commonEggText = new Text2('Sıradan Yumurta - 500 Coins\nCommon fossil guaranteed', { size: 35, fill: '#FFFFFF' }); commonEggText.anchor.set(0.5, 0.5); commonEggText.x = 1024; commonEggText.y = 1400; // Common Egg Info Button var commonEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); commonEggInfoButton.anchor.set(0.5, 0.5); commonEggInfoButton.x = 1350; commonEggInfoButton.y = 1400; game.addChild(commonEggInfoButton); // Rare Egg var rareEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); rareEggButton.x = 1024; rareEggButton.y = 1550; var rareEggText = new Text2('Nadir Yumurta - 2000 Coins\nRare fossil guaranteed', { size: 35, fill: '#FFD700' }); rareEggText.anchor.set(0.5, 0.5); rareEggText.x = 1024; rareEggText.y = 1550; // Rare Egg Info Button var rareEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); rareEggInfoButton.anchor.set(0.5, 0.5); rareEggInfoButton.x = 1350; rareEggInfoButton.y = 1550; game.addChild(rareEggInfoButton); // Legendary Egg var legendaryEggButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); legendaryEggButton.x = 1024; legendaryEggButton.y = 1700; var legendaryEggText = new Text2('Destansı - 10000 Coins\nLegendary guaranteed', { size: 35, fill: '#FF69B4' }); legendaryEggText.anchor.set(0.5, 0.5); legendaryEggText.x = 1024; legendaryEggText.y = 1700; // Legendary Egg Info Button var legendaryEggInfoButton = new Text2('❗', { size: 60, fill: '#FFD700' }); legendaryEggInfoButton.anchor.set(0.5, 0.5); legendaryEggInfoButton.x = 1350; legendaryEggInfoButton.y = 1700; game.addChild(legendaryEggInfoButton); // FEED button to navigate to food section var feedSectionButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); feedSectionButton.x = 1024; feedSectionButton.y = 1000; var feedSectionButtonText = new Text2('FEED', { size: 35, fill: '#FFFFFF' }); feedSectionButtonText.anchor.set(0.5, 0.5); feedSectionButtonText.x = 1024; feedSectionButtonText.y = 1000; // Back button var shopBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); shopBackButton.x = 1024; shopBackButton.y = 1150; var shopBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); shopBackButtonText.anchor.set(0.5, 0.5); shopBackButtonText.x = 1024; shopBackButtonText.y = 1150; game.addChild(xrayText); game.addChild(doubleMoneyText); game.addChild(doubleValueText); game.addChild(commonEggText); game.addChild(rareEggText); game.addChild(legendaryEggText); game.addChild(feedSectionButtonText); game.addChild(shopBackButtonText); storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, feedSectionButton, feedSectionButtonText, shopBackButton, shopBackButtonText); // Purchase handlers xrayButton.down = function () { if (playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; xrayLevelsLeft++; storage.xrayLevelsLeft = xrayLevelsLeft; hideShop(); } }; doubleMoneyButton.down = function () { if (playerCoins >= 3250) { playerCoins -= 3250; storage.playerCoins = playerCoins; doubleMoneyLevelsLeft = 999999; // Permanent 2X money effect storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; hideShop(); } }; doubleValueButton.down = function () { if (playerCoins >= 1250) { playerCoins -= 1250; storage.playerCoins = playerCoins; doubleSpawnChanceActive = true; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; hideShop(); } }; // Common egg info handler commonEggInfoButton.down = function () { showCommonEggInfo(); }; // Egg purchase handlers commonEggButton.down = function () { if (playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; // Open common egg and get dinosaur var dinosaurName = openEgg('common'); } }; // Rare egg info handler rareEggInfoButton.down = function () { showRareEggInfo(); }; rareEggButton.down = function () { if (playerCoins >= 2000) { playerCoins -= 2000; storage.playerCoins = playerCoins; // Open rare egg and get dinosaur var dinosaurName = openEgg('rare'); } }; // Legendary egg info handler legendaryEggInfoButton.down = function () { showLegendaryEggInfo(); }; legendaryEggButton.down = function () { if (playerCoins >= 10000) { playerCoins -= 10000; storage.playerCoins = playerCoins; // Open legendary egg and get dinosaur var dinosaurName = openEgg('legendary'); } }; // FEED button click handler - navigate to food section feedSectionButton.down = function () { showFeedSection(); }; shopBackButton.down = function () { hideShop(); }; } function showFeedSection() { gameState = 'feed'; // Hide all shop UI elements hideAllStoreUI(); // Create feed section display var feedTitle = new Text2('DİNOZOR YİYECEKLERİ', { size: 80, fill: '#FFFFFF' }); feedTitle.anchor.set(0.5, 0.5); feedTitle.x = 1024; feedTitle.y = 200; game.addChild(feedTitle); storeUIElements.push(feedTitle); // Dinosaur Food Items var leafFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); leafFoodButton.x = 1024; leafFoodButton.y = 400; var leafFoodText = new Text2('Yaprak Paketi - 15 Coins\n5 adet yaprak (Otçul dinozorlar)', { size: 35, fill: '#FFFFFF' }); leafFoodText.anchor.set(0.5, 0.5); leafFoodText.x = 1024; leafFoodText.y = 400; // Add ❗ next to leaf food button var leafFoodAlert = new Text2('❗', { size: 60, fill: '#FFD700' }); leafFoodAlert.anchor.set(0.5, 0.5); leafFoodAlert.x = 1350; leafFoodAlert.y = 400; game.addChild(leafFoodAlert); // Add click handler to show which dinosaurs eat leaves leafFoodAlert.down = function () { showFoodDinosaursInfo('leaf'); }; var meatFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); meatFoodButton.x = 1024; meatFoodButton.y = 550; var meatFoodText = new Text2('Et Paketi - 100 Coins\n5 adet et (Etçil dinozorlar)', { size: 35, fill: '#FFFFFF' }); meatFoodText.anchor.set(0.5, 0.5); meatFoodText.x = 1024; meatFoodText.y = 550; // Add ❗ next to meat food button var meatFoodAlert = new Text2('❗', { size: 60, fill: '#FFD700' }); meatFoodAlert.anchor.set(0.5, 0.5); meatFoodAlert.x = 1350; meatFoodAlert.y = 550; game.addChild(meatFoodAlert); // Add click handler to show which dinosaurs eat meat meatFoodAlert.down = function () { showFoodDinosaursInfo('meat'); }; var fishFoodButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); fishFoodButton.x = 1024; fishFoodButton.y = 700; var fishFoodText = new Text2('Balık Paketi - 55 Coins\n5 adet balık (Balık yiyen dinozorlar)', { size: 35, fill: '#FFFFFF' }); fishFoodText.anchor.set(0.5, 0.5); fishFoodText.x = 1024; fishFoodText.y = 700; // Add ❗ next to fish food button var fishFoodAlert = new Text2('❗', { size: 60, fill: '#FFD700' }); fishFoodAlert.anchor.set(0.5, 0.5); fishFoodAlert.x = 1350; fishFoodAlert.y = 700; game.addChild(fishFoodAlert); // Add click handler to show which dinosaurs eat fish fishFoodAlert.down = function () { showFoodDinosaursInfo('fish'); }; // Back to shop button var backToShopButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backToShopButton.x = 1024; backToShopButton.y = 850; var backToShopButtonText = new Text2('SHOP\'A GERİ DÖN', { size: 35, fill: '#FFFFFF' }); backToShopButtonText.anchor.set(0.5, 0.5); backToShopButtonText.x = 1024; backToShopButtonText.y = 850; // Add BACK text above the back button, centered var feedBackText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); feedBackText.anchor.set(0.5, 0.5); feedBackText.x = 1024; feedBackText.y = 800; game.addChild(feedBackText); game.addChild(leafFoodText); game.addChild(meatFoodText); game.addChild(fishFoodText); game.addChild(backToShopButtonText); storeUIElements.push(leafFoodButton, leafFoodText, leafFoodAlert, meatFoodButton, meatFoodText, meatFoodAlert, fishFoodButton, fishFoodText, fishFoodAlert, backToShopButton, backToShopButtonText, feedBackText); // Food purchase handlers leafFoodButton.down = function () { if (playerCoins >= 15) { playerCoins -= 15; storage.playerCoins = playerCoins; // Add 5 leaf food to inventory leafFood += 5; storage.leafFood = leafFood; hideFeedSection(); } }; meatFoodButton.down = function () { if (playerCoins >= 100) { playerCoins -= 100; storage.playerCoins = playerCoins; // Add 5 meat food to inventory meatFood += 5; storage.meatFood = meatFood; hideFeedSection(); } }; fishFoodButton.down = function () { if (playerCoins >= 55) { playerCoins -= 55; storage.playerCoins = playerCoins; // Add 5 fish food to inventory fishFood += 5; storage.fishFood = fishFood; hideFeedSection(); } }; backToShopButton.down = function () { hideFeedSection(); showShop(); }; } function hideFeedSection() { gameState = 'nickname'; // Remove all feed UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function hideShop() { gameState = 'nickname'; // Remove all shop UI elements hideAllStoreUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showBag() { gameState = 'bag'; // Check hunger status when opening bag checkDinosaurHunger(); // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create bag display var bagTitle = new Text2('DINOSAUR BAG', { size: 80, fill: '#FFFFFF' }); bagTitle.anchor.set(0.5, 0.5); bagTitle.x = 1024; bagTitle.y = 200; game.addChild(bagTitle); bagUIElements.push(bagTitle); // Calculate vomit limit (1 base slot only) var maxVomitSlots = 1; var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available', { size: 35, fill: '#FFD700' }); vomitText.anchor.set(0.5, 0.5); vomitText.x = 1024; vomitText.y = 280; game.addChild(vomitText); // Add coins display in bag var bagCoinsText = new Text2('Para: ' + playerCoins + ' coin', { size: 35, fill: '#FFD700' }); bagCoinsText.anchor.set(0.5, 0.5); bagCoinsText.x = 1024; bagCoinsText.y = 320; game.addChild(bagCoinsText); // Add food inventory display var foodInventoryText = new Text2('Yiyecekler: Yaprak(' + leafFood + ') Et(' + meatFood + ') Balık(' + fishFood + ')', { size: 30, fill: '#32CD32' }); foodInventoryText.anchor.set(0.5, 0.5); foodInventoryText.x = 1024; foodInventoryText.y = 360; game.addChild(foodInventoryText); bagUIElements.push(vomitText, bagCoinsText, foodInventoryText); // Get selected dinosaurs var selectedDinosaurs = []; if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) { selectedDinosaurs = storage.selectedDinosaurs; } else if (selectedDinosaur) { selectedDinosaurs = [selectedDinosaur]; } // Sort dinosaurs by rarity var chromaticDinos = []; var legendaryDinos = []; var rareDinos = []; var commonDinos = []; for (var i = 0; i < dinosaurCollection.length; i++) { var dino = dinosaurCollection[i]; var rarity = dinosaurRarities[dino]; if (rarity === 'chromatic') { chromaticDinos.push(dino); } else if (rarity === 'legendary') { legendaryDinos.push(dino); } else if (rarity === 'rare') { rareDinos.push(dino); } else { commonDinos.push(dino); } } var allDinos = chromaticDinos.concat(legendaryDinos).concat(rareDinos).concat(commonDinos); // Reorder dinosaurs to show selected ones at the bottom var unselectedDinos = []; var selectedDinosForDisplay = []; for (var k = 0; k < allDinos.length; k++) { if (selectedDinosaurs.indexOf(allDinos[k]) !== -1) { selectedDinosForDisplay.push(allDinos[k]); } else { unselectedDinos.push(allDinos[k]); } } var orderedDinos = unselectedDinos.concat(selectedDinosForDisplay); // Display all dinosaurs - unlimited storage, but limited vomit selection var startY = 480; var itemSpacing = 120; // Increased spacing between dinosaur entries for (var j = 0; j < orderedDinos.length; j++) { var dinoName = orderedDinos[j]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic else if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common var isSelected = selectedDinosaurs.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SELECTED]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + j * itemSpacing; // Add dinosaur image var dinoImage = new DinosaurImage(dinoName); dinoImage.x = 700; dinoImage.y = startY + j * itemSpacing; dinoImage.scaleX = 0.8; dinoImage.scaleY = 0.8; game.addChild(dinoImage); bagUIElements.push(dinoImage); var dinoText = new Text2(displayText, { size: 35, fill: isSelected ? '#000000' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + j * itemSpacing; game.addChild(dinoText); // Add hunger status and feeding button var hungerStatus = getHungerStatus(dinoName); var hungerText = getHungerText(hungerStatus); var hungerColor = getHungerColor(hungerStatus); var hungerDisplay = new Text2(hungerText, { size: 25, fill: hungerColor }); hungerDisplay.anchor.set(0.5, 0.5); hungerDisplay.x = 1024; hungerDisplay.y = startY + j * itemSpacing + 30; game.addChild(hungerDisplay); // Add ❗ next to dinosaur for info (larger size) var dinoInfoAlert = new Text2('❗', { size: 60, fill: '#FFD700' }); dinoInfoAlert.anchor.set(0.5, 0.5); dinoInfoAlert.x = 1448; dinoInfoAlert.y = startY + j * itemSpacing; game.addChild(dinoInfoAlert); bagUIElements.push(dinoButton, dinoText, hungerDisplay, dinoInfoAlert); // Create closure for dinosaur info (function (dinosaurName) { dinoInfoAlert.down = function () { showDinosaurInfo(dinosaurName); }; })(dinoName); // Create closure for selection - check vomit limit (function (dinosaurName) { dinoButton.down = function () { var currentIndex = selectedDinosaurs.indexOf(dinosaurName); if (currentIndex !== -1) { // Remove from selection selectedDinosaurs.splice(currentIndex, 1); } else { // Check if player can select dinosaurs - everyone gets 1 base slot only // If at selection limit, replace the first selected dinosaur if (selectedDinosaurs.length >= maxVomitSlots) { selectedDinosaurs.shift(); // Remove first selected dinosaur } selectedDinosaurs.push(dinosaurName); // Add new selection } // Update storage and backward compatibility storage.selectedDinosaurs = selectedDinosaurs; if (selectedDinosaurs.length > 0) { selectedDinosaur = selectedDinosaurs[0]; // Keep backward compatibility storage.selectedDinosaur = selectedDinosaur; } else { selectedDinosaur = null; storage.selectedDinosaur = null; } hideBag(); showBag(); // Refresh to show selected at bottom }; })(dinoName); } // Back button // Delete button var deleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); deleteButton.x = 700; deleteButton.y = startY + orderedDinos.length * itemSpacing + 150; var deleteButtonText = new Text2('DELETE', { size: 35, fill: '#FFFFFF' }); deleteButtonText.anchor.set(0.5, 0.5); deleteButtonText.x = 700; deleteButtonText.y = startY + orderedDinos.length * itemSpacing + 150; game.addChild(deleteButtonText); bagUIElements.push(deleteButton, deleteButtonText); var bagBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); bagBackButton.x = 1348; bagBackButton.y = startY + orderedDinos.length * itemSpacing + 150; var bagBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); bagBackButtonText.anchor.set(0.5, 0.5); bagBackButtonText.x = 1348; bagBackButtonText.y = startY + orderedDinos.length * itemSpacing + 150; game.addChild(bagBackButtonText); bagUIElements.push(bagBackButton, bagBackButtonText); // Delete button handler deleteButton.down = function () { showDeleteMode(); }; bagBackButton.down = function () { hideBag(); }; } function showDeleteMode() { gameState = 'deleteMode'; // Hide current bag UI hideAllBagUI(); // Create delete mode display var deleteTitle = new Text2('DELETE DINOSAURS', { size: 80, fill: '#FF4444' }); deleteTitle.anchor.set(0.5, 0.5); deleteTitle.x = 1024; deleteTitle.y = 200; game.addChild(deleteTitle); bagUIElements.push(deleteTitle); var deleteInstructionText = new Text2('Select dinosaurs to delete:', { size: 50, fill: '#FFFFFF' }); deleteInstructionText.anchor.set(0.5, 0.5); deleteInstructionText.x = 1024; deleteInstructionText.y = 280; game.addChild(deleteInstructionText); bagUIElements.push(deleteInstructionText); // Sort dinosaurs by rarity for display var legendaryDinos = []; var rareDinos = []; var commonDinos = []; for (var i = 0; i < dinosaurCollection.length; i++) { var dino = dinosaurCollection[i]; var rarity = dinosaurRarities[dino]; if (rarity === 'legendary') { legendaryDinos.push(dino); } else if (rarity === 'rare') { rareDinos.push(dino); } else { commonDinos.push(dino); } } var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos); // Track selected dinosaurs for deletion var selectedForDeletion = []; // Display all dinosaurs with delete option var startY = 410; var itemSpacing = 120; // Increased spacing between dinosaur entries for (var j = 0; j < allDinos.length; j++) { var dinoName = allDinos[j]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common var isSelectedForDeletion = selectedForDeletion.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelectedForDeletion ? ' [TO DELETE]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + j * itemSpacing; var dinoText = new Text2(displayText, { size: 35, fill: isSelectedForDeletion ? '#FF4444' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + j * itemSpacing; game.addChild(dinoText); bagUIElements.push(dinoButton, dinoText); // Create closure for selection toggle (function (dinosaurName, textElement) { dinoButton.down = function () { var index = selectedForDeletion.indexOf(dinosaurName); if (index === -1) { // Add to deletion list selectedForDeletion.push(dinosaurName); textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [TO DELETE]'); textElement.fill = '#FF4444'; } else { // Remove from deletion list selectedForDeletion.splice(index, 1); var rarity = dinosaurRarities[dinosaurName]; var color = '#87CEEB'; // Light blue for common/regular dinosaurs if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common textElement.setText(dinosaurName + ' (' + rarity + ')'); textElement.fill = color; } }; })(dinoName, dinoText); } // Confirm delete button var confirmDeleteButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); confirmDeleteButton.x = 700; confirmDeleteButton.y = startY + allDinos.length * itemSpacing + 100; var confirmDeleteText = new Text2('CONFIRM DELETE', { size: 30, fill: '#FFFFFF' }); confirmDeleteText.anchor.set(0.5, 0.5); confirmDeleteText.x = 700; confirmDeleteText.y = startY + allDinos.length * itemSpacing + 100; game.addChild(confirmDeleteText); bagUIElements.push(confirmDeleteButton, confirmDeleteText); // Cancel delete button var cancelDeleteButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); cancelDeleteButton.x = 1348; cancelDeleteButton.y = startY + allDinos.length * itemSpacing + 100; var cancelDeleteText = new Text2('CANCEL', { size: 35, fill: '#FFFFFF' }); cancelDeleteText.anchor.set(0.5, 0.5); cancelDeleteText.x = 1348; cancelDeleteText.y = startY + allDinos.length * itemSpacing + 100; game.addChild(cancelDeleteText); bagUIElements.push(cancelDeleteButton, cancelDeleteText); // Event handlers confirmDeleteButton.down = function () { // Remove selected dinosaurs from collection for (var i = 0; i < selectedForDeletion.length; i++) { var dinoToDelete = selectedForDeletion[i]; var index = dinosaurCollection.indexOf(dinoToDelete); if (index !== -1) { dinosaurCollection.splice(index, 1); // If deleted dinosaur was selected, clear selection if (selectedDinosaur === dinoToDelete) { selectedDinosaur = null; storage.selectedDinosaur = null; } } } // Save updated collection storage.dinosaurCollection = dinosaurCollection; // Return to bag view hideAllBagUI(); showBag(); }; cancelDeleteButton.down = function () { // Return to bag view without deleting hideAllBagUI(); showBag(); }; } function hideBag() { gameState = 'nickname'; // Remove all bag UI elements hideAllBagUI(); // Restore menu UI elements showAllMenuUI(); } function showCommonEggInfo() { gameState = 'commonEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('SIRADAN YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'PARASOUROLUPHUS - %33.3\n'; infoText += 'Yavaş kazma (1 saniye gecikme)\n\n'; infoText += 'TRICERATOPS - %33.3\n'; infoText += 'Kafa darbesi: 5 bloku 2 tıklamaya indirir\n\n'; infoText += 'ANKYLOSAURUS - %33.3\n'; infoText += 'Kuyruk darbesi: 4 bloku 1 tıklamaya indirir'; var infoDisplay = new Text2(infoText, { size: 40, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 600; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function showRareEggInfo() { gameState = 'rareEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('NADİR YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'BARYONYX - %45\n'; infoText += '0.2x daha hızlı kaya kazma\n\n'; infoText += 'ALLO - %35\n'; infoText += '0.4x daha hızlı kaya kazma\n\n'; infoText += 'YUTY - %20\n'; infoText += '0.7x daha hızlı kaya kazma'; var infoDisplay = new Text2(infoText, { size: 40, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 600; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function showLegendaryEggInfo() { gameState = 'legendaryEggInfo'; // Hide all shop UI elements hideAllStoreUI(); // Create info display var infoTitle = new Text2('DESTANSI YUMURTA İÇERİĞİ', { size: 60, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); var infoText = 'TREX - %3 (Chromatic)\n'; infoText += '??? ??? ???\n\n'; infoText += 'SPINO - %15\n'; infoText += '?\n\n'; infoText += 'GIGA - %22\n'; infoText += '?\n\n'; infoText += 'Mutasyonlu BARYONYX - %30\n'; infoText += '?\n\n'; infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n'; infoText += '?'; // Add animated color-changing question marks for TREX ability var trexQuestionMarks = []; for (var q = 0; q < 3; q++) { var questionMark = new Text2('?', { size: 40, fill: getRandomColor() }); questionMark.anchor.set(0.5, 0.5); questionMark.x = 950 + q * 40; questionMark.y = 450; game.addChild(questionMark); infoUIElements.push(questionMark); trexQuestionMarks.push(questionMark); } // Animate color changes for question marks var colorChangeTimer = LK.setInterval(function () { for (var i = 0; i < trexQuestionMarks.length; i++) { tween(trexQuestionMarks[i], { fill: getRandomColor() }, { duration: 500 }); } }, 600); // Store timer reference to clear it when hiding info screen infoUIElements.colorChangeTimer = colorChangeTimer; var infoDisplay = new Text2(infoText, { size: 30, fill: '#FFFFFF' }); infoDisplay.anchor.set(0.5, 0.5); infoDisplay.x = 1024; infoDisplay.y = 700; game.addChild(infoDisplay); infoUIElements.push(infoDisplay); var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1200; var backButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1200; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showShop(); }; } function getRandomColor() { var colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3']; return colors[Math.floor(Math.random() * colors.length)]; } function hideInfoScreen() { // Clear color change timer if it exists if (infoUIElements.colorChangeTimer) { LK.clearInterval(infoUIElements.colorChangeTimer); infoUIElements.colorChangeTimer = null; } // Remove all info UI elements hideAllInfoUI(); } function hideAllGiftsUI() { for (var i = 0; i < giftsUIElements.length; i++) { giftsUIElements[i].destroy(); } giftsUIElements = []; } function hideAllTradeUI() { for (var i = 0; i < tradeUIElements.length; i++) { tradeUIElements[i].destroy(); } tradeUIElements = []; } function hideAllStockUI() { for (var i = 0; i < stockUIElements.length; i++) { stockUIElements[i].destroy(); } stockUIElements = []; } function checkDailyGift() { var currentDate = new Date(); var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch var lastDate = storage.lastGiftDate || 0; if (today > lastDate) { // New day - reset gift status only when it's actually a new day storage.dailyGiftClaimed = false; dailyGiftClaimed = false; // Check if it's been more than 1 day - reset streak if so if (today > lastDate + 1) { storage.currentGiftDay = 1; currentGiftDay = 1; } storage.lastGiftDate = today; lastGiftDate = today; } else { // Same day - load existing gift claimed status from storage dailyGiftClaimed = storage.dailyGiftClaimed || false; } } function checkWeeklyFoodGift() { var currentDate = new Date(); var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch var lastDate = storage.lastFoodGiftDate || 0; if (today > lastDate) { // New day - reset food gift status only when it's actually a new day storage.weeklyFoodGiftClaimed = false; weeklyFoodGiftClaimed = false; // Check if it's been more than 1 day - reset streak if so if (today > lastDate + 1) { storage.currentFoodGiftDay = 1; currentFoodGiftDay = 1; } storage.lastFoodGiftDate = today; lastFoodGiftDate = today; } else { // Same day - load existing food gift claimed status from storage weeklyFoodGiftClaimed = storage.weeklyFoodGiftClaimed || false; } } function checkDailyTrades() { var currentDate = new Date(); var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch var lastDate = storage.lastTradeDate || 0; if (today > lastDate) { // New day - reset trade count storage.dailyTradesLeft = 5; dailyTradesLeft = 5; storage.lastTradeDate = today; lastTradeDate = today; } } function canStartTrade() { checkDailyTrades(); return dailyTradesLeft > 0; } function createTradeOffer(targetPlayer, offeredDinosaurs) { if (!canStartTrade() || offeredDinosaurs.length > 4) { return false; } var tradeOffer = { fromPlayer: playerNickname, toPlayer: targetPlayer, offeredDinosaurs: offeredDinosaurs, requestedDinosaurs: [], status: 'pending' }; storage.currentTradeOffer = tradeOffer; currentTradeOffer = tradeOffer; return true; } function acceptTradeOffer(tradeOffer) { if (!canStartTrade()) { return false; } // Execute trade (simplified implementation) // In real implementation, this would involve server coordination // For now, we simulate giving random dinosaurs in return // Remove offered dinosaurs from player's collection (simulate giving them away) for (var i = 0; i < tradeOffer.offeredDinosaurs.length; i++) { var dinoToRemove = tradeOffer.offeredDinosaurs[i]; var index = dinosaurCollection.indexOf(dinoToRemove); if (index !== -1) { dinosaurCollection.splice(index, 1); } } // Add random dinosaurs as trade return (simulate receiving) var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO']; var receivedCount = Math.min(tradeOffer.offeredDinosaurs.length, 3); // Receive up to 3 dinosaurs for (var j = 0; j < receivedCount; j++) { var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)]; dinosaurCollection.push(randomDino); } // Save updated collection storage.dinosaurCollection = dinosaurCollection; // Use one daily trade dailyTradesLeft--; storage.dailyTradesLeft = dailyTradesLeft; // Clear current offer storage.currentTradeOffer = null; currentTradeOffer = null; return true; } function showGifts() { gameState = 'gifts'; checkDailyGift(); checkWeeklyFoodGift(); // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create gifts display var giftsTitle = new Text2('GÜNLÜK HEDİYELER', { size: 80, fill: '#FFFFFF' }); giftsTitle.anchor.set(0.5, 0.5); giftsTitle.x = 1024; giftsTitle.y = 150; game.addChild(giftsTitle); giftsUIElements.push(giftsTitle); // Show weekly gift calendar var weekText = new Text2('Para Döngüsü - Gün ' + currentGiftDay + '/7', { size: 40, fill: '#FFD700' }); weekText.anchor.set(0.5, 0.5); weekText.x = 1024; weekText.y = 220; game.addChild(weekText); giftsUIElements.push(weekText); // Display all 7 days for coins for (var day = 1; day <= 7; day++) { var dayButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dayButton.x = 200 + (day - 1) * 240; dayButton.y = 400; dayButton.scaleX = 0.8; dayButton.scaleY = 0.8; var isCurrentDay = day === currentGiftDay; var canClaim = isCurrentDay && !dailyGiftClaimed; var isPastDay = day < currentGiftDay; // Change button color based on status if (isPastDay) { dayButton.alpha = 0.5; // Already claimed } else if (canClaim) { dayButton.tint = 0x32CD32; // Green for claimable } else { dayButton.tint = 0x808080; // Gray for future days } var dayText = new Text2('Gün ' + day + '\n' + dailyGifts[day - 1] + ' Para', { size: 25, fill: canClaim ? '#000000' : '#FFFFFF' }); dayText.anchor.set(0.5, 0.5); dayText.x = 200 + (day - 1) * 240; dayText.y = 400; game.addChild(dayText); var statusText = new Text2(isPastDay ? 'ALındı' : canClaim ? 'AL!' : 'Bekliyor', { size: 20, fill: canClaim ? '#000000' : isPastDay ? '#FFD700' : '#CCCCCC' }); statusText.anchor.set(0.5, 0.5); statusText.x = 200 + (day - 1) * 240; statusText.y = 440; game.addChild(statusText); giftsUIElements.push(dayButton, dayText, statusText); // Add click handler for current day if (canClaim) { (function (giftAmount, dayNum) { dayButton.down = function () { // Claim gift playerCoins += giftAmount; storage.playerCoins = playerCoins; // Mark gift as claimed and save to storage immediately dailyGiftClaimed = true; storage.dailyGiftClaimed = true; // Move to next day, reset to 1 after day 7 if (dayNum >= 7) { storage.currentGiftDay = 1; } else { storage.currentGiftDay = dayNum + 1; } currentGiftDay = storage.currentGiftDay; // Refresh gifts display hideGifts(); showGifts(); }; })(dailyGifts[day - 1], day); } } // Weekly Food Rewards Section var foodTitle = new Text2('HAFTALIK YİYECEK ÖDÜLLERİ', { size: 70, fill: '#32CD32' }); foodTitle.anchor.set(0.5, 0.5); foodTitle.x = 1024; foodTitle.y = 550; game.addChild(foodTitle); giftsUIElements.push(foodTitle); // Show weekly food gift calendar var foodWeekText = new Text2('Yiyecek Döngüsü - Gün ' + currentFoodGiftDay + '/7', { size: 40, fill: '#32CD32' }); foodWeekText.anchor.set(0.5, 0.5); foodWeekText.x = 1024; foodWeekText.y = 620; game.addChild(foodWeekText); giftsUIElements.push(foodWeekText); // Display all 7 days for food for (var day = 1; day <= 7; day++) { var foodDayButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); foodDayButton.x = 200 + (day - 1) * 240; foodDayButton.y = 800; foodDayButton.scaleX = 0.8; foodDayButton.scaleY = 0.8; var isCurrentFoodDay = day === currentFoodGiftDay; var canClaimFood = isCurrentFoodDay && !weeklyFoodGiftClaimed; var isPastFoodDay = day < currentFoodGiftDay; // Change button color based on status if (isPastFoodDay) { foodDayButton.alpha = 0.5; // Already claimed } else if (canClaimFood) { foodDayButton.tint = 0x32CD32; // Green for claimable } else { foodDayButton.tint = 0x808080; // Gray for future days } var currentFoodGift = weeklyFoodGifts[day - 1]; var foodDayText = new Text2('Gün ' + day + '\nY:' + currentFoodGift.leaf + ' E:' + currentFoodGift.meat + ' B:' + currentFoodGift.fish, { size: 22, fill: canClaimFood ? '#000000' : '#FFFFFF' }); foodDayText.anchor.set(0.5, 0.5); foodDayText.x = 200 + (day - 1) * 240; foodDayText.y = 800; game.addChild(foodDayText); var foodStatusText = new Text2(isPastFoodDay ? 'ALındı' : canClaimFood ? 'AL!' : 'Bekliyor', { size: 20, fill: canClaimFood ? '#000000' : isPastFoodDay ? '#32CD32' : '#CCCCCC' }); foodStatusText.anchor.set(0.5, 0.5); foodStatusText.x = 200 + (day - 1) * 240; foodStatusText.y = 840; game.addChild(foodStatusText); giftsUIElements.push(foodDayButton, foodDayText, foodStatusText); // Add click handler for current food day if (canClaimFood) { (function (foodGift, dayNum) { foodDayButton.down = function () { // Claim food gift leafFood += foodGift.leaf; meatFood += foodGift.meat; fishFood += foodGift.fish; storage.leafFood = leafFood; storage.meatFood = meatFood; storage.fishFood = fishFood; // Mark food gift as claimed and save to storage immediately weeklyFoodGiftClaimed = true; storage.weeklyFoodGiftClaimed = true; // Move to next day, reset to 1 after day 7 if (dayNum >= 7) { storage.currentFoodGiftDay = 1; } else { storage.currentFoodGiftDay = dayNum + 1; } currentFoodGiftDay = storage.currentFoodGiftDay; // Refresh gifts display hideGifts(); showGifts(); }; })(weeklyFoodGifts[day - 1], day); } } // Daily Discounted Offers Section var discountTitle = new Text2('GÜNLÜK İNDİRİMLİ TEKLİFLER', { size: 60, fill: '#FF6B35' }); discountTitle.anchor.set(0.5, 0.5); discountTitle.x = 1024; discountTitle.y = 1100; game.addChild(discountTitle); giftsUIElements.push(discountTitle); // Generate daily offers based on current date var currentDate = new Date(); var dayOfYear = Math.floor((currentDate - new Date(currentDate.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24)); var seedValue = dayOfYear; // Use day of year as seed for consistent daily offers // Define available discounted items var discountedItems = [{ type: 'egg', name: 'Sıradan Yumurta', originalPrice: 500, icon: 'fossil1' }, { type: 'egg', name: 'Nadir Yumurta', originalPrice: 2000, icon: 'fossil2' }, { type: 'egg', name: 'Destansı Yumurta', originalPrice: 10000, icon: 'fossil3' }, { type: 'gamepass', name: 'XRAY', originalPrice: 500, icon: 'limestone' }, { type: 'gamepass', name: '2X MONEY', originalPrice: 3250, icon: 'rareFossil' }, { type: 'gamepass', name: '2X LUCK', originalPrice: 1250, icon: 'hardRock' }]; // Simple seeded random function for consistent daily offers function seededRandom(seed) { var x = Math.sin(seed) * 10000; return x - Math.floor(x); } // Select 3 different offers for today var todaysOffers = []; var usedIndices = []; for (var offer = 0; offer < 3; offer++) { var randomIndex; do { randomIndex = Math.floor(seededRandom(seedValue + offer * 7) * discountedItems.length); } while (usedIndices.indexOf(randomIndex) !== -1); usedIndices.push(randomIndex); var selectedItem = discountedItems[randomIndex]; // Generate discount between 20-50% var discountPercent = 20 + Math.floor(seededRandom(seedValue + offer * 13) * 31); // 20-50% var discountedPrice = Math.floor(selectedItem.originalPrice * (100 - discountPercent) / 100); todaysOffers.push({ item: selectedItem, discount: discountPercent, discountedPrice: discountedPrice }); } // Display the 3 discounted offers for (var i = 0; i < 3; i++) { var offerData = todaysOffers[i]; var xPos = 350 + i * 350; // Space offers horizontally // Offer background var offerButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); offerButton.x = xPos; offerButton.y = 1300; offerButton.scaleX = 0.9; offerButton.scaleY = 1.2; offerButton.tint = 0xFF6B35; // Orange tint for discount // Item icon var itemIcon = game.attachAsset(offerData.item.icon, { anchorX: 0.5, anchorY: 0.5 }); itemIcon.x = xPos; itemIcon.y = 1240; itemIcon.scaleX = 0.6; itemIcon.scaleY = 0.6; game.addChild(itemIcon); // Item name var itemNameText = new Text2(offerData.item.name, { size: 25, fill: '#FFFFFF' }); itemNameText.anchor.set(0.5, 0.5); itemNameText.x = xPos; itemNameText.y = 1290; game.addChild(itemNameText); // Discount percentage var discountText = new Text2('-' + offerData.discount + '%', { size: 30, fill: '#FFD700' }); discountText.anchor.set(0.5, 0.5); discountText.x = xPos; discountText.y = 1320; game.addChild(discountText); // Original price (crossed out effect with smaller text) var originalPriceText = new Text2(offerData.item.originalPrice + ' Para', { size: 20, fill: '#888888' }); originalPriceText.anchor.set(0.5, 0.5); originalPriceText.x = xPos; originalPriceText.y = 1345; game.addChild(originalPriceText); // Discounted price var discountedPriceText = new Text2(offerData.discountedPrice + ' Para', { size: 28, fill: '#32CD32' }); discountedPriceText.anchor.set(0.5, 0.5); discountedPriceText.x = xPos; discountedPriceText.y = 1370; game.addChild(discountedPriceText); giftsUIElements.push(offerButton, itemIcon, itemNameText, discountText, originalPriceText, discountedPriceText); // Add purchase functionality (function (offer, price) { offerButton.down = function () { if (playerCoins >= price) { playerCoins -= price; storage.playerCoins = playerCoins; if (offer.item.type === 'egg') { // Open the corresponding egg var eggType = offer.item.name === 'Sıradan Yumurta' ? 'common' : offer.item.name === 'Nadir Yumurta' ? 'rare' : 'legendary'; var dinosaurName = openEgg(eggType); } else if (offer.item.type === 'gamepass') { // Apply gamepass effect if (offer.item.name === 'XRAY') { xrayLevelsLeft++; storage.xrayLevelsLeft = xrayLevelsLeft; } else if (offer.item.name === '2X MONEY') { doubleMoneyLevelsLeft = 999999; storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; } else if (offer.item.name === '2X LUCK') { doubleSpawnChanceActive = true; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; } } // Refresh gifts display hideGifts(); showGifts(); } }; })(offerData, offerData.discountedPrice); } // Back button var giftsBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); giftsBackButton.x = 1024; giftsBackButton.y = 1450; // Moved down to make room for discounted offers var giftsBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); giftsBackButtonText.anchor.set(0.5, 0.5); giftsBackButtonText.x = 1024; giftsBackButtonText.y = 1450; game.addChild(giftsBackButtonText); giftsUIElements.push(giftsBackButton, giftsBackButtonText); giftsBackButton.down = function () { hideGifts(); }; } function hideGifts() { gameState = 'nickname'; // Remove all gifts UI elements hideAllGiftsUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function showTrade() { // Check if player meets level requirement var playerLevel = storage.playerLevel || 1; if (playerLevel < 50) { // Show level requirement message gameState = 'levelRequirement'; hideAllMenuUI(); hideAllGameUI(); var levelReqTitle = new Text2('SEVİYE GEREKSİNİMİ', { size: 80, fill: '#FF4444' }); levelReqTitle.anchor.set(0.5, 0.5); levelReqTitle.x = 1024; levelReqTitle.y = 600; game.addChild(levelReqTitle); infoUIElements.push(levelReqTitle); var levelReqMessage = new Text2('Takas yapmak için 50. seviyeye ulaşmalısınız!\nŞu anki seviyeniz: ' + playerLevel, { size: 50, fill: '#FFFFFF' }); levelReqMessage.anchor.set(0.5, 0.5); levelReqMessage.x = 1024; levelReqMessage.y = 800; game.addChild(levelReqMessage); infoUIElements.push(levelReqMessage); var okButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); okButton.x = 1024; okButton.y = 1000; var okButtonText = new Text2('TAMAM', { size: 35, fill: '#FFFFFF' }); okButtonText.anchor.set(0.5, 0.5); okButtonText.x = 1024; okButtonText.y = 1000; game.addChild(okButtonText); infoUIElements.push(okButton, okButtonText); okButton.down = function () { hideInfoScreen(); gameState = 'nickname'; showAllMenuUI(); }; return; } gameState = 'trade'; checkDailyTrades(); // Reset daily trades if new day // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create trade display var tradeTitle = new Text2('TİCARET SİSTEMİ', { size: 80, fill: '#FFFFFF' }); tradeTitle.anchor.set(0.5, 0.5); tradeTitle.x = 1024; tradeTitle.y = 150; game.addChild(tradeTitle); tradeUIElements.push(tradeTitle); // Show daily trades remaining var tradesLeftText = new Text2('Günlük Takas Hakkı: ' + dailyTradesLeft + '/5', { size: 40, fill: '#FFD700' }); tradesLeftText.anchor.set(0.5, 0.5); tradesLeftText.x = 1024; tradesLeftText.y = 220; game.addChild(tradesLeftText); tradeUIElements.push(tradesLeftText); // Show active players for trading var playersTitle = new Text2('AKTİF OYUNCULAR', { size: 60, fill: '#32CD32' }); playersTitle.anchor.set(0.5, 0.5); playersTitle.x = 1024; playersTitle.y = 320; game.addChild(playersTitle); tradeUIElements.push(playersTitle); // Display mock active players var startY = 420; for (var i = 0; i < activePlayers.length; i++) { var playerName = activePlayers[i]; var playerButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); playerButton.x = 1024; playerButton.y = startY + i * 80; var playerText = new Text2(playerName + ' (Çevrimiçi)', { size: 35, fill: '#FFFFFF' }); playerText.anchor.set(0.5, 0.5); playerText.x = 1024; playerText.y = startY + i * 80; game.addChild(playerText); // Add online indicator var onlineIndicator = new Text2('●', { size: 30, fill: '#00FF00' }); onlineIndicator.anchor.set(0.5, 0.5); onlineIndicator.x = 800; onlineIndicator.y = startY + i * 80; game.addChild(onlineIndicator); tradeUIElements.push(playerButton, playerText, onlineIndicator); // Create closure for trade initiation (function (targetPlayer) { playerButton.down = function () { if (dailyTradesLeft > 0) { showTradeSetup(targetPlayer); } else { // Show no trades left message var noTradesMessage = new Text2('Günlük takas hakkınız kalmadı!', { size: 40, fill: '#FF4444' }); noTradesMessage.anchor.set(0.5, 0.5); noTradesMessage.x = 1024; noTradesMessage.y = 1000; game.addChild(noTradesMessage); // Remove message after 3 seconds LK.setTimeout(function () { if (noTradesMessage && noTradesMessage.parent) { noTradesMessage.destroy(); } }, 3000); } }; })(playerName); } // Show pending trade requests section var requestsTitle = new Text2('GELEN TAKAS İSTEKLERİ', { size: 50, fill: '#FF6B35' }); requestsTitle.anchor.set(0.5, 0.5); requestsTitle.x = 1024; requestsTitle.y = 850; game.addChild(requestsTitle); tradeUIElements.push(requestsTitle); // Display pending trade requests if (tradeRequestsReceived.length > 0) { for (var j = 0; j < tradeRequestsReceived.length; j++) { var request = tradeRequestsReceived[j]; var requestY = 920 + j * 60; var requestText = new Text2(request.fromPlayer + ' takas teklifi gönderdi', { size: 30, fill: '#FFFFFF' }); requestText.anchor.set(0.5, 0.5); requestText.x = 700; requestText.y = requestY; game.addChild(requestText); var acceptButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); acceptButton.x = 1200; acceptButton.y = requestY; acceptButton.scaleX = 0.7; acceptButton.scaleY = 0.7; var acceptText = new Text2('KABUL ET', { size: 25, fill: '#FFFFFF' }); acceptText.anchor.set(0.5, 0.5); acceptText.x = 1200; acceptText.y = requestY; game.addChild(acceptText); var rejectButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); rejectButton.x = 1350; rejectButton.y = requestY; rejectButton.scaleX = 0.7; rejectButton.scaleY = 0.7; var rejectText = new Text2('REDDET', { size: 25, fill: '#FFFFFF' }); rejectText.anchor.set(0.5, 0.5); rejectText.x = 1350; rejectText.y = requestY; game.addChild(rejectText); tradeUIElements.push(requestText, acceptButton, acceptText, rejectButton, rejectText); // Create closures for accept/reject (function (tradeRequest, index) { acceptButton.down = function () { if (acceptTradeOffer(tradeRequest)) { // Remove request from list tradeRequestsReceived.splice(index, 1); storage.tradeRequestsReceived = tradeRequestsReceived; // Show success message var successMessage = new Text2('Takas başarılı!', { size: 50, fill: '#32CD32' }); successMessage.anchor.set(0.5, 0.5); successMessage.x = 1024; successMessage.y = 1200; game.addChild(successMessage); LK.setTimeout(function () { if (successMessage && successMessage.parent) { successMessage.destroy(); } hideTrade(); showTrade(); // Refresh }, 2000); } }; rejectButton.down = function () { // Remove request from list tradeRequestsReceived.splice(index, 1); storage.tradeRequestsReceived = tradeRequestsReceived; hideTrade(); showTrade(); // Refresh }; })(request, j); } } else { var noRequestsText = new Text2('Şu anda takas isteği yok', { size: 35, fill: '#888888' }); noRequestsText.anchor.set(0.5, 0.5); noRequestsText.x = 1024; noRequestsText.y = 920; game.addChild(noRequestsText); tradeUIElements.push(noRequestsText); } // Back button var tradeBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); tradeBackButton.x = 1024; tradeBackButton.y = 1400; var tradeBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); tradeBackButtonText.anchor.set(0.5, 0.5); tradeBackButtonText.x = 1024; tradeBackButtonText.y = 1400; game.addChild(tradeBackButtonText); tradeUIElements.push(tradeBackButton, tradeBackButtonText); tradeBackButton.down = function () { hideTrade(); }; } function showTradeSetup(targetPlayer) { gameState = 'tradeSetup'; // Hide current trade UI hideAllTradeUI(); // Create trade setup display var setupTitle = new Text2('TAKAS KURULUMU: ' + targetPlayer, { size: 70, fill: '#FFFFFF' }); setupTitle.anchor.set(0.5, 0.5); setupTitle.x = 1024; setupTitle.y = 200; game.addChild(setupTitle); tradeUIElements.push(setupTitle); var instructionText = new Text2('Direkt takas gönderiliyor - NPC otomatik karşılık verecek (' + dailyTradesLeft + ' takas hakkı)', { size: 45, fill: '#FFD700' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 280; game.addChild(instructionText); tradeUIElements.push(instructionText); // Track selected dinosaurs for trade var selectedForTrade = []; // Display available dinosaurs var startY = 400; for (var i = 0; i < dinosaurCollection.length; i++) { var dinoName = dinosaurCollection[i]; var rarity = dinosaurRarities[dinoName]; var color = '#87CEEB'; if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B'; var isSelected = selectedForTrade.indexOf(dinoName) !== -1; var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SEÇİLDİ]' : ''); var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + i * 80; var dinoText = new Text2(displayText, { size: 35, fill: isSelected ? '#32CD32' : color }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + i * 80; game.addChild(dinoText); tradeUIElements.push(dinoButton, dinoText); // Create closure for selection (function (dinosaurName, textElement) { dinoButton.down = function () { var index = selectedForTrade.indexOf(dinosaurName); if (index === -1) { // Add to selection if under limit if (selectedForTrade.length < 4) { selectedForTrade.push(dinosaurName); textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [SEÇİLDİ]'); textElement.fill = '#32CD32'; } } else { // Remove from selection selectedForTrade.splice(index, 1); var rarity = dinosaurRarities[dinosaurName]; var color = '#87CEEB'; if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B'; textElement.setText(dinosaurName + ' (' + rarity + ')'); textElement.fill = color; } }; })(dinoName, dinoText); } // Send trade request button var sendRequestButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); sendRequestButton.x = 700; sendRequestButton.y = 1500; var sendRequestText = new Text2('TAKAS İSTEĞİ GÖNDER', { size: 30, fill: '#FFFFFF' }); sendRequestText.anchor.set(0.5, 0.5); sendRequestText.x = 700; sendRequestText.y = 1500; game.addChild(sendRequestText); tradeUIElements.push(sendRequestButton, sendRequestText); sendRequestButton.down = function () { if (selectedForTrade.length > 0) { // Generate NPC trade offer with value variations var npcOffer = generateNPCTradeOffer(selectedForTrade); // Show trade confirmation screen showTradeConfirmation(targetPlayer, selectedForTrade, npcOffer); } }; // Back button var setupBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); setupBackButton.x = 1348; setupBackButton.y = 1500; var setupBackText = new Text2('GERİ', { size: 35, fill: '#FFFFFF' }); setupBackText.anchor.set(0.5, 0.5); setupBackText.x = 1348; setupBackText.y = 1500; game.addChild(setupBackText); tradeUIElements.push(setupBackButton, setupBackText); setupBackButton.down = function () { hideTrade(); showTrade(); // Return to main trade screen }; } function generateNPCTradeOffer(playerDinosaurs) { // Define dinosaur values for trade calculation var dinosaurValues = { 'PARASOUROLUPHUS': 100, 'BARYONYX': 300, 'ALLO': 400, 'YUTY': 500, 'TREX': 1500, 'SPINO': 800, 'GIGA': 900, 'Mutated BARYONYX': 1200, 'Mutated PARASAUROLUPHUS': 1100 }; var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO', 'YUTY', 'SPINO', 'GIGA']; // Calculate total value of player's offered dinosaurs var totalPlayerValue = 0; for (var i = 0; i < playerDinosaurs.length; i++) { totalPlayerValue += dinosaurValues[playerDinosaurs[i]] || 100; } // NPC offers with value variation - 25% chance for higher value offer var valueMultiplier; if (Math.random() < 0.25) { // 25% chance: Offer higher value (110% to 150% of player's offer) valueMultiplier = 1.1 + Math.random() * 0.4; // 1.1 to 1.5 } else { // 75% chance: Standard offer (-30% to +50% of player's offer) valueMultiplier = 0.7 + Math.random() * 0.8; // 0.7 to 1.5 } var targetValue = Math.floor(totalPlayerValue * valueMultiplier); var npcOffer = []; var currentOfferValue = 0; var attempts = 0; var maxAttempts = 20; // Generate NPC offer to match target value while (currentOfferValue < targetValue && attempts < maxAttempts && npcOffer.length < 4) { var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)]; var dinoValue = dinosaurValues[randomDino] || 100; if (currentOfferValue + dinoValue <= targetValue + 200) { // Allow some tolerance npcOffer.push(randomDino); currentOfferValue += dinoValue; } attempts++; } // Ensure at least one dinosaur is offered if (npcOffer.length === 0) { npcOffer.push(tradableTypes[Math.floor(Math.random() * tradableTypes.length)]); } return { dinosaurs: npcOffer, playerValue: totalPlayerValue, npcValue: currentOfferValue, isGoodDeal: valueMultiplier > 1.0 }; } function showTradeConfirmation(npcName, playerDinosaurs, npcOffer) { gameState = 'tradeConfirmation'; hideAllTradeUI(); var confirmTitle = new Text2('TAKAS ONAY', { size: 80, fill: '#FFFFFF' }); confirmTitle.anchor.set(0.5, 0.5); confirmTitle.x = 1024; confirmTitle.y = 200; game.addChild(confirmTitle); tradeUIElements.push(confirmTitle); var tradePartnerText = new Text2('NPC: ' + npcName, { size: 50, fill: '#FFD700' }); tradePartnerText.anchor.set(0.5, 0.5); tradePartnerText.x = 1024; tradePartnerText.y = 300; game.addChild(tradePartnerText); tradeUIElements.push(tradePartnerText); // Show what player is giving var playerOfferTitle = new Text2('SİZ VERİYORSUNUZ:', { size: 45, fill: '#FF6B35' }); playerOfferTitle.anchor.set(0.5, 0.5); playerOfferTitle.x = 512; playerOfferTitle.y = 400; game.addChild(playerOfferTitle); tradeUIElements.push(playerOfferTitle); for (var i = 0; i < playerDinosaurs.length; i++) { var playerDinoText = new Text2('• ' + playerDinosaurs[i], { size: 35, fill: '#FFFFFF' }); playerDinoText.anchor.set(0.5, 0.5); playerDinoText.x = 512; playerDinoText.y = 450 + i * 40; game.addChild(playerDinoText); tradeUIElements.push(playerDinoText); } // Show what NPC is offering var npcOfferTitle = new Text2('NPC VERİYOR:', { size: 45, fill: '#32CD32' }); npcOfferTitle.anchor.set(0.5, 0.5); npcOfferTitle.x = 1536; npcOfferTitle.y = 400; game.addChild(npcOfferTitle); tradeUIElements.push(npcOfferTitle); for (var j = 0; j < npcOffer.dinosaurs.length; j++) { var npcDinoText = new Text2('• ' + npcOffer.dinosaurs[j], { size: 35, fill: '#FFFFFF' }); npcDinoText.anchor.set(0.5, 0.5); npcDinoText.x = 1536; npcDinoText.y = 450 + j * 40; game.addChild(npcDinoText); tradeUIElements.push(npcDinoText); } // Show trade value analysis var dealQualityText = npcOffer.isGoodDeal ? 'İYİ ANLAŞMA!' : 'ZAYIF ANLAŞMA'; var dealQualityColor = npcOffer.isGoodDeal ? '#32CD32' : '#FF4444'; var dealAnalysis = new Text2('Değer Analizi: ' + dealQualityText + '\nSizin: ' + npcOffer.playerValue + ' | NPC: ' + npcOffer.npcValue, { size: 35, fill: dealQualityColor }); dealAnalysis.anchor.set(0.5, 0.5); dealAnalysis.x = 1024; dealAnalysis.y = 700; game.addChild(dealAnalysis); tradeUIElements.push(dealAnalysis); // Confirm button var confirmTradeButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); confirmTradeButton.x = 700; confirmTradeButton.y = 850; var confirmTradeText = new Text2('TAKASI ONAYLA', { size: 30, fill: '#FFFFFF' }); confirmTradeText.anchor.set(0.5, 0.5); confirmTradeText.x = 700; confirmTradeText.y = 850; game.addChild(confirmTradeText); tradeUIElements.push(confirmTradeButton, confirmTradeText); // Cancel button var cancelTradeButton = game.attachAsset('deleteButton', { anchorX: 0.5, anchorY: 0.5 }); cancelTradeButton.x = 1348; cancelTradeButton.y = 850; var cancelTradeText = new Text2('İPTAL ET', { size: 30, fill: '#FFFFFF' }); cancelTradeText.anchor.set(0.5, 0.5); cancelTradeText.x = 1348; cancelTradeText.y = 850; game.addChild(cancelTradeText); tradeUIElements.push(cancelTradeButton, cancelTradeText); confirmTradeButton.down = function () { // Execute the trade executeTrade(playerDinosaurs, npcOffer.dinosaurs); }; cancelTradeButton.down = function () { hideTrade(); showTrade(); }; } function executeTrade(playerDinosaurs, npcDinosaurs) { // Remove player's dinosaurs for (var i = 0; i < playerDinosaurs.length; i++) { var index = dinosaurCollection.indexOf(playerDinosaurs[i]); if (index !== -1) { dinosaurCollection.splice(index, 1); } } // Add NPC's dinosaurs for (var j = 0; j < npcDinosaurs.length; j++) { dinosaurCollection.push(npcDinosaurs[j]); } // Update storage storage.dinosaurCollection = dinosaurCollection; // Use daily trade dailyTradesLeft--; storage.dailyTradesLeft = dailyTradesLeft; // Show success message var successMessage = new Text2('Takas başarılı!', { size: 60, fill: '#32CD32' }); successMessage.anchor.set(0.5, 0.5); successMessage.x = 1024; successMessage.y = 1000; game.addChild(successMessage); LK.setTimeout(function () { if (successMessage && successMessage.parent) { successMessage.destroy(); } hideTrade(); showTrade(); }, 2000); } function generateMockTradeRequest() { // Generate mock trade requests from other players var mockTraders = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']; var randomTrader = mockTraders[Math.floor(Math.random() * mockTraders.length)]; // Generate random offered dinosaurs var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO', 'YUTY']; var offerCount = Math.floor(Math.random() * 3) + 1; // 1-3 dinosaurs var offeredDinosaurs = []; for (var i = 0; i < offerCount; i++) { var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)]; offeredDinosaurs.push(randomDino); } var mockRequest = { fromPlayer: randomTrader, toPlayer: playerNickname, offeredDinosaurs: offeredDinosaurs, timestamp: Date.now(), status: 'pending' }; // Add to received requests tradeRequestsReceived.push(mockRequest); storage.tradeRequestsReceived = tradeRequestsReceived; } function hideTrade() { gameState = 'nickname'; // Remove all trade UI elements hideAllTradeUI(); // Restore menu UI elements showAllMenuUI(); } function showStock() { gameState = 'stock'; // Hide all menu and game UI elements hideAllMenuUI(); hideAllGameUI(); // Create stock display var stockTitle = new Text2('DİNOZOR STOKU', { size: 80, fill: '#FFFFFF' }); stockTitle.anchor.set(0.5, 0.5); stockTitle.x = 1024; stockTitle.y = 200; game.addChild(stockTitle); stockUIElements.push(stockTitle); // Define dinosaur buy prices based on rarity and value (higher than sell prices) var dinosaurBuyPrices = { 'PARASOUROLUPHUS': 1200, 'BARYONYX': 3750, 'ALLO': 4500, 'YUTY': 5250, 'SPINO': 12000, 'GIGA': 15000, 'Mutated BARYONYX': 18000, 'Mutated PARASAUROLUPHUS': 27000 }; // Get all purchasable dinosaurs (all except TREX) - ordered by expensive dinosaur hierarchy // SPINO (1st), GIGA (2nd), Mutated DIMETRODON (3rd), Mutated BARYONYX (4th), then others by price var allDinosaurs = ['SPINO', 'GIGA', 'Mutated BARYONYX', 'Mutated PARASAUROLUPHUS', 'YUTY', 'ALLO', 'BARYONYX', 'PARASOUROLUPHUS']; // No need to sort as we've manually ordered them by hierarchy // Show current coins var coinsDisplayText = new Text2('Mevcut Para: ' + playerCoins + ' coin', { size: 50, fill: '#FFD700' }); coinsDisplayText.anchor.set(0.5, 0.5); coinsDisplayText.x = 1024; coinsDisplayText.y = 280; game.addChild(coinsDisplayText); stockUIElements.push(coinsDisplayText); // Show instruction var instructionText = new Text2('Satın almak istediğiniz dinozorları seçin (TREX satın alınamaz)', { size: 40, fill: '#CCCCCC' }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 340; game.addChild(instructionText); stockUIElements.push(instructionText); // Track selected dinosaurs for buying var selectedForBuying = []; // Display purchasable dinosaurs var startY = 500; var itemSpacing = 120; // Increased spacing between dinosaur entries for (var n = 0; n < allDinosaurs.length; n++) { var dinoName = allDinosaurs[n]; var rarity = dinosaurRarities[dinoName]; var price = dinosaurBuyPrices[dinoName]; // Get rarity color var color = '#87CEEB'; // Light blue for common if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic else if (rarity === 'legendary') color = '#FF0000'; // Red for legendary else if (rarity === 'rare') color = '#800080'; // Purple for rare else if (rarity === 'common') color = '#00008B'; // Dark blue for common var displayText = dinoName + ' (' + rarity + ') - ' + price + ' coin'; var canAfford = playerCoins >= price; var dinoButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); dinoButton.x = 1024; dinoButton.y = startY + n * itemSpacing; // Dim button if can't afford if (!canAfford) { dinoButton.alpha = 0.5; } // Add dinosaur image var dinoImage = new DinosaurImage(dinoName); dinoImage.x = 400; dinoImage.y = startY + n * itemSpacing; dinoImage.scaleX = 0.6; dinoImage.scaleY = 0.6; if (!canAfford) { dinoImage.alpha = 0.5; } game.addChild(dinoImage); stockUIElements.push(dinoImage); var dinoText = new Text2(displayText, { size: 35, fill: canAfford ? color : '#666666' }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + n * itemSpacing; game.addChild(dinoText); var statusText = new Text2(canAfford ? 'SATIN ALINABIL√¨R' : 'YETERS√¨Z PARA', { size: 25, fill: canAfford ? '#32CD32' : '#FF4444' }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = startY + n * itemSpacing + 25; game.addChild(statusText); stockUIElements.push(dinoButton, dinoText, statusText); // Create closure for purchase (function (dinosaurName, buyPrice, textElement, buttonElement, statusElement, imageElement) { dinoButton.down = function () { if (playerCoins >= buyPrice) { // Purchase dinosaur playerCoins -= buyPrice; storage.playerCoins = playerCoins; // Add dinosaur to collection dinosaurCollection.push(dinosaurName); storage.dinosaurCollection = dinosaurCollection; // Update display coinsDisplayText.setText('Mevcut Para: ' + playerCoins + ' coin'); // Refresh stock display hideStock(); showStock(); } }; })(dinoName, price, dinoText, dinoButton, statusText, dinoImage); } // Back button centered var stockBackButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); stockBackButton.x = 1024; stockBackButton.y = startY + allDinosaurs.length * itemSpacing + 50; var stockBackButtonText = new Text2('BACK', { size: 35, fill: '#FFFFFF' }); stockBackButtonText.anchor.set(0.5, 0.5); stockBackButtonText.x = 1024; stockBackButtonText.y = startY + allDinosaurs.length * itemSpacing + 50; game.addChild(stockBackButtonText); stockUIElements.push(stockBackButton, stockBackButtonText); // Event handlers stockBackButton.down = function () { hideStock(); }; } function hideStock() { gameState = 'nickname'; // Remove all stock UI elements hideAllStockUI(); // Restore menu UI elements showAllMenuUI(); coinsText.setText('Coins: ' + playerCoins); } function checkDinosaurHunger() { var currentTime = Date.now(); var timePassed = currentTime - lastFeedingCheck; // Check hunger every hour (3600000 ms) if (timePassed >= 3600000) { var hoursElapsed = Math.floor(timePassed / 3600000); // Initialize hunger for new dinosaurs and increase hunger for existing ones for (var i = 0; i < dinosaurCollection.length; i++) { var dinoName = dinosaurCollection[i]; if (!dinosaurHunger[dinoName]) { dinosaurHunger[dinoName] = 0; // New dinosaurs start with 0 hunger } else { // Calculate hunger increase based on dinosaur feeding schedule var hungerIncrease = 0; // TREX, GIGA, and SPINO eat every 2 days (48 hours) if (dinoName === 'TREX' || dinoName === 'GIGA' || dinoName === 'SPINO') { hungerIncrease = Math.floor(hoursElapsed / 48); } // All mutated dinosaurs except Mutated PARASAUROLUPHUS eat daily (24 hours) else if (dinoName.indexOf('Mutated') === 0 && dinoName !== 'Mutated PARASAUROLUPHUS') { hungerIncrease = Math.floor(hoursElapsed / 24); } // Mutated PARASAUROLUPHUS eats every 2 days (48 hours) else if (dinoName === 'Mutated PARASAUROLUPHUS') { hungerIncrease = Math.floor(hoursElapsed / 48); } // All fish-eating dinosaurs except SPINO eat twice daily (12 hours) else if (dinosaurDiets[dinoName] === 'fish' && dinoName !== 'SPINO') { hungerIncrease = Math.floor(hoursElapsed / 12); } // All herbivorous dinosaurs eat twice daily (12 hours) else if (dinosaurDiets[dinoName] === 'leaf') { hungerIncrease = Math.floor(hoursElapsed / 12); } // Default for any remaining dinosaurs (meat eaters not covered above) else { hungerIncrease = Math.floor(hoursElapsed / 24); } dinosaurHunger[dinoName] += hungerIncrease; } } // Update storage without removing any dinosaurs storage.dinosaurCollection = dinosaurCollection; storage.dinosaurHunger = dinosaurHunger; storage.lastFeedingCheck = currentTime; lastFeedingCheck = currentTime; } } function showStarvationNotification(starvedDinosaurs) { gameState = 'starvationNotification'; hideAllMenuUI(); hideAllGameUI(); var notificationTitle = new Text2('DİNOZORLAR AÇLIKTAN ÖLDÜ!', { size: 80, fill: '#FF4444' }); notificationTitle.anchor.set(0.5, 0.5); notificationTitle.x = 1024; notificationTitle.y = 400; game.addChild(notificationTitle); infoUIElements.push(notificationTitle); var starvedText = 'Açlıktan ölen dinozorlar:\n'; for (var i = 0; i < starvedDinosaurs.length; i++) { starvedText += starvedDinosaurs[i] + '\n'; } starvedText += '\nDinozorlarınızı düzenli olarak besleyin!'; var notificationMessage = new Text2(starvedText, { size: 50, fill: '#FFFFFF' }); notificationMessage.anchor.set(0.5, 0.5); notificationMessage.x = 1024; notificationMessage.y = 700; game.addChild(notificationMessage); infoUIElements.push(notificationMessage); var okButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); okButton.x = 1024; okButton.y = 1000; var okButtonText = new Text2('TAMAM', { size: 35, fill: '#FFFFFF' }); okButtonText.anchor.set(0.5, 0.5); okButtonText.x = 1024; okButtonText.y = 1000; game.addChild(okButtonText); infoUIElements.push(okButton, okButtonText); okButton.down = function () { hideInfoScreen(); gameState = 'nickname'; showAllMenuUI(); }; } function feedDinosaur(dinosaurName) { var diet = dinosaurDiets[dinosaurName]; var hungerStatus = getHungerStatus(dinosaurName); var currentHunger = dinosaurHunger[dinosaurName] || 0; // Only allow feeding if dinosaur is hungry (not FED) if (hungerStatus === 'FED') { return false; // Dinosaur is not hungry, refuse food } var hasFood = false; // Define base food consumption amounts for each dinosaur var baseFoodConsumption = { 'TREX': 2.0, 'GIGA': 1.5, 'YUTY': 1.0, 'ALLO': 1.0, 'SPINO': 2.0, 'BARYONYX': 1.0, 'Mutated BARYONYX': 1.5, 'PARASOUROLUPHUS': 0.5, 'TRICERATOPS': 0.7, 'ANKYLOSAURUS': 0.8, 'Mutated PARASAUROLUPHUS': 1.0 }; var baseConsumption = baseFoodConsumption[dinosaurName] || 1.0; // Calculate actual consumption based on hunger level var consumptionMultiplier = 1.0; if (hungerStatus === 'VERY_HUNGRY') { consumptionMultiplier = 2.0; // Eat double when very hungry } else if (hungerStatus === 'HUNGRY') { consumptionMultiplier = 1.5; // Eat 1.5x when hungry } else if (hungerStatus === 'SOMEWHAT_HUNGRY') { consumptionMultiplier = 1.0; // Eat normal amount when somewhat hungry } var actualConsumption = baseConsumption * consumptionMultiplier; // Check if player has the required food type and amount if (diet === 'leaf' && leafFood >= actualConsumption) { leafFood -= actualConsumption; storage.leafFood = leafFood; hasFood = true; } else if (diet === 'meat' && meatFood >= actualConsumption) { meatFood -= actualConsumption; storage.meatFood = meatFood; hasFood = true; } else if (diet === 'fish' && fishFood >= actualConsumption) { fishFood -= actualConsumption; storage.fishFood = fishFood; hasFood = true; } if (hasFood) { // Reduce hunger based on how much food was consumed var hungerReduction = Math.min(currentHunger, Math.floor(actualConsumption * 10)); // Each food unit reduces 10 hunger points dinosaurHunger[dinosaurName] = Math.max(0, currentHunger - hungerReduction); storage.dinosaurHunger = dinosaurHunger; return true; } return false; } function getHungerStatus(dinosaurName) { var hunger = dinosaurHunger[dinosaurName] || 0; if (hunger >= 20) return 'VERY_HUNGRY'; if (hunger >= 12) return 'HUNGRY'; if (hunger >= 6) return 'SOMEWHAT_HUNGRY'; return 'FED'; } function getHungerColor(status) { switch (status) { case 'VERY_HUNGRY': return '#FF0000'; case 'HUNGRY': return '#FF8800'; case 'SOMEWHAT_HUNGRY': return '#FFFF00'; default: return '#00FF00'; } } function getHungerText(status) { switch (status) { case 'VERY_HUNGRY': return 'ÇOK AÇ!'; case 'HUNGRY': return 'AÇ'; case 'SOMEWHAT_HUNGRY': return 'BIRAZ AÇ'; default: return 'TOK'; } } function getPointsBonus(dinosaurName) { // Define points bonus multipliers for each dinosaur type var bonusMultipliers = { 'PARASOUROLUPHUS': 1.0, // No bonus 'TRICERATOPS': 1.1, // 10% bonus 'ANKYLOSAURUS': 1.2, // 20% bonus 'BARYONYX': 1.5, // 50% bonus 'ALLO': 1.6, // 60% bonus 'YUTY': 1.7, // 70% bonus 'TREX': 2.0, // 100% bonus 'SPINO': 1.8, // 80% bonus 'GIGA': 1.9, // 90% bonus 'Mutated BARYONYX': 2.2, // 120% bonus 'Mutated PARASAUROLUPHUS': 2.1 // 110% bonus }; return bonusMultipliers[dinosaurName] || 1.0; // Default to no bonus if dinosaur not found } function canDinosaurUseAbilities(dinosaurName) { var hungerStatus = getHungerStatus(dinosaurName); // Dinosaurs can only use abilities when fed (not hungry) return hungerStatus === 'FED'; } function startGame() { if (playerNickname.length === 0) { return; } // Check dinosaur hunger when starting game checkDinosaurHunger(); storage.playerNickname = playerNickname; gameState = 'playing'; // Hide menu UI elements hideAllMenuUI(); // Show game UI elements timerText.visible = true; scoreText.visible = true; levelText.visible = true; // Show power-up purchase options purchaseOption1.visible = true; purchaseText1.visible = true; purchaseOption2.visible = true; purchaseText2.visible = true; purchaseOption3.visible = true; purchaseText3.visible = true; // Show XRAY use button xrayUseButton.visible = true; xrayUseText.visible = true; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show back to menu button backToMenuButton.visible = true; backToMenuText.visible = true; // Show ability button abilityUseButton.visible = true; abilityUseText.visible = true; // Start from saved level or level 1 if no save exists startLevel(currentLevelNumber); } // Event handlers leftArrow.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } currentLetterIndex = (currentLetterIndex - 1 + alphabet.length) % alphabet.length; updateNicknameDisplay(); }; rightArrow.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } currentLetterIndex = (currentLetterIndex + 1) % alphabet.length; updateNicknameDisplay(); }; addButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } // Add current letter to nickname if (playerNickname.length < 12) { playerNickname += alphabet[currentLetterIndex]; updateNicknameDisplay(); } }; startButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } startGame(); }; deleteButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } if (playerNickname.length > 0) { playerNickname = playerNickname.slice(0, -1); updateNicknameDisplay(); } }; storeButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showStore(); }; sellButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showSell(); }; shopButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showShop(); }; bagButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showBag(); }; tradeButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showTrade(); }; giftsButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showGifts(); }; stockButton.down = function (x, y, obj) { if (gameState !== 'nickname') { return; } showStock(); }; game.down = function (x, y, obj) { // Game down handler for playing state only }; // Game update loop game.update = function () { if (gameState === 'playing') { levelTimer++; timerText.setText('Time: ' + Math.floor(levelTimer / 60)); // Update player level based on current level progression if (currentLevelNumber > playerLevel) { playerLevel = currentLevelNumber; storage.playerLevel = playerLevel; } // Check dinosaur hunger periodically (every 30 seconds in-game) if (levelTimer % 1800 === 0) { checkDinosaurHunger(); } // Generate mock trade requests periodically (every 2 minutes in-game) if (levelTimer % 7200 === 0 && Math.random() < 0.3) { generateMockTradeRequest(); } // Money/score is only decreased when player explicitly spends it // No automatic score reduction over time // Update ability button text based on selected dinosaur and level restrictions if (selectedDinosaur) { var buttonText = selectedDinosaur + ' ÖZELLİĞİ'; var canUse = true; // Check if dinosaur is too hungry to use abilities if (!canDinosaurUseAbilities(selectedDinosaur)) { var hungerStatus = getHungerStatus(selectedDinosaur); buttonText = selectedDinosaur + ' (AÇ - BESLEYİN)'; canUse = false; } else if (selectedDinosaur === 'TREX' && currentLevelNumber % 10 !== 0) { buttonText = 'TREX (' + (10 - currentLevelNumber % 10) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'SPINO' && storage.spinoUsedThisLevel) { buttonText = 'SPINO (kullanıldı)'; canUse = false; } else if (selectedDinosaur === 'GIGA' && currentLevelNumber % 5 !== 0) { buttonText = 'GIGA (' + (5 - currentLevelNumber % 5) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'GIGA') { buttonText = 'GIGA ÖZELLİĞİ'; } else if (selectedDinosaur === 'Mutated BARYONYX' && currentLevelNumber % 4 !== 0) { buttonText = 'M.BARYONYX (' + (4 - currentLevelNumber % 4) + ' seviye)'; canUse = false; } else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') { var currentUsage = storage.mutatedParasaurolophusMatches || 0; if ((currentUsage + 1) % 2 !== 0) { buttonText = 'M.PARASAUR (' + (2 - (currentUsage + 1) % 2) + ' kullanım)'; canUse = false; } } abilityUseText.setText(buttonText); abilityUseButton.alpha = canUse ? 1.0 : 0.5; } else { abilityUseText.setText('DİNOZOR SEÇ'); abilityUseButton.alpha = 0.5; } } }; // Power-up purchase options (shown when game is playing) var purchaseOption1 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption1.x = 1800; purchaseOption1.y = 400; purchaseOption1.visible = false; var purchaseText1 = new Text2('XRAY\n500 Coins', { size: 30, fill: '#FFFFFF' }); purchaseText1.anchor.set(0.5, 0.5); purchaseText1.x = 1800; purchaseText1.y = 400; purchaseText1.visible = false; game.addChild(purchaseText1); var purchaseOption2 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption2.x = 1800; purchaseOption2.y = 520; purchaseOption2.visible = false; var purchaseText2 = new Text2('2X MONEY\n3250 Coins', { size: 30, fill: '#FFFFFF' }); purchaseText2.anchor.set(0.5, 0.5); purchaseText2.x = 1800; purchaseText2.y = 520; purchaseText2.visible = false; game.addChild(purchaseText2); var purchaseOption3 = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); purchaseOption3.x = 1800; purchaseOption3.y = 640; purchaseOption3.visible = false; var purchaseText3 = new Text2('2X LUCK\n1250', { size: 30, fill: '#FFFFFF' }); purchaseText3.anchor.set(0.5, 0.5); purchaseText3.x = 1800; purchaseText3.y = 640; purchaseText3.visible = false; game.addChild(purchaseText3); // Track purchase UI elements as game UI gameUIElements.push(purchaseOption1, purchaseText1, purchaseOption2, purchaseText2, purchaseOption3, purchaseText3); // Purchase event handlers purchaseOption1.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 500) { playerCoins -= 500; storage.playerCoins = playerCoins; xrayLevelsLeft++; storage.xrayLevelsLeft = xrayLevelsLeft; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show all fossils for current level if (currentLevel) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Make blocks with fossils green and animate with tween tween(block, { tint: 0x00FF00 }, { duration: 500, easing: tween.easeOut }); } } } } }; purchaseOption2.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 3250) { playerCoins -= 3250; storage.playerCoins = playerCoins; doubleMoneyLevelsLeft = 999999; // Permanent 2X money effect storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft; } }; purchaseOption3.down = function (x, y, obj) { if (gameState === 'playing' && playerCoins >= 1250) { playerCoins -= 1250; storage.playerCoins = playerCoins; doubleSpawnChanceActive = true; storage.doubleSpawnChanceActive = doubleSpawnChanceActive; } }; // XRAY use button (shown when game is playing) var xrayUseButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); xrayUseButton.x = 524; // Further left with more spacing xrayUseButton.y = 2500; // Bottom of screen xrayUseButton.visible = false; var xrayUseText = new Text2('XRAY (' + xrayLevelsLeft + ')', { size: 30, fill: '#FFFFFF' }); xrayUseText.anchor.set(0.5, 0.5); xrayUseText.x = 524; xrayUseText.y = 2500; xrayUseText.visible = false; game.addChild(xrayUseText); // Back to menu button (shown when game is playing) var backToMenuButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); backToMenuButton.x = 1524; // Further right with more spacing backToMenuButton.y = 2500; // Bottom of screen, same level as XRAY backToMenuButton.visible = false; var backToMenuText = new Text2('MENÜYE GERİ DÖN', { size: 25, fill: '#FFFFFF' }); backToMenuText.anchor.set(0.5, 0.5); backToMenuText.x = 1524; backToMenuText.y = 2500; backToMenuText.visible = false; game.addChild(backToMenuText); // Track XRAY use and back to menu UI elements as game UI gameUIElements.push(xrayUseButton, xrayUseText, backToMenuButton, backToMenuText); // XRAY use button click handler xrayUseButton.down = function (x, y, obj) { if (gameState === 'playing' && xrayLevelsLeft > 0) { xrayLevelsLeft--; storage.xrayLevelsLeft = xrayLevelsLeft; xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')'); // Show all fossils for current level if (currentLevel) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Make blocks with fossils green and animate with tween tween(block, { tint: 0x00FF00 }, { duration: 500, easing: tween.easeOut }); } } } } }; // Dinosaur ability use button (shown when game is playing) var abilityUseButton = game.attachAsset('purchaseButton', { anchorX: 0.5, anchorY: 0.5 }); abilityUseButton.x = 1024; // Center bottom abilityUseButton.y = 2500; // Bottom of screen abilityUseButton.visible = false; var abilityUseText = new Text2('DİNOZOR ÖZELLİĞİ', { size: 25, fill: '#FFFFFF' }); abilityUseText.anchor.set(0.5, 0.5); abilityUseText.x = 1024; abilityUseText.y = 2500; abilityUseText.visible = false; game.addChild(abilityUseText); // Track ability button as game UI gameUIElements.push(abilityUseButton, abilityUseText); // Ability use button click handler abilityUseButton.down = function (x, y, obj) { if (gameState === 'playing' && selectedDinosaur && currentLevel) { // Check if dinosaur can use abilities (not too hungry) if (!canDinosaurUseAbilities(selectedDinosaur)) { // Dinosaur is too hungry to use abilities return; } // Use the selected dinosaur's ability if (selectedDinosaur === 'TREX') { // TREX roars and collects all fossils (only works every 10 levels) if (currentLevelNumber % 10 === 0) { // Create roar effect with screen shake animation var roarEffect = LK.getAsset('TREX', { anchorX: 0.5, anchorY: 0.5, scaleX: 3.0, scaleY: 3.0 }); roarEffect.x = 1024; roarEffect.y = 1000; roarEffect.alpha = 0.7; roarEffect.tint = 0xFF4500; // Orange roar effect currentLevel.addChild(roarEffect); // Animate roar effect with tween tween(roarEffect, { scaleX: 5.0, scaleY: 5.0, alpha: 0 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { roarEffect.destroy(); } }); // Collect all fossils on the level instantly for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { // Instantly reveal and collect the fossil currentLevel.revealFossil(block.fossilType, block.x, block.y); // Mark block as collected block.isCollected = true; block.alpha = 0; } } } } else if (selectedDinosaur === 'SPINO') { // SPINO fossil hunt - automatically finds and collects 3 fossils (1 use per level) if (storage.spinoUsedThisLevel) { // Already used this level, do nothing return; } // Find all blocks with fossils that haven't been collected yet var fossilBlocks = []; for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (block.hasFossil && !block.isCollected) { fossilBlocks.push(block); } } // Use SPINO's fossil finding ability on first available fossil block if (fossilBlocks.length > 0) { fossilBlocks[0].performSpinoCollection(); } else { // No fossils available to find storage.spinoUsedThisLevel = true; } } else if (selectedDinosaur === 'GIGA') { // GIGA fast mining ability - usable every 5 levels if (currentLevelNumber % 5 === 0) { // Activate fast mining mode for the rest of the level gigaFastMiningActive = true; gigaFastMiningLevel = currentLevelNumber; // Create visual effect for GIGA ability var gigaEffect = LK.getAsset('GIGA', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 }); gigaEffect.x = 1024; gigaEffect.y = 1000; gigaEffect.alpha = 0.8; gigaEffect.tint = 0x800080; // Purple effect for GIGA currentLevel.addChild(gigaEffect); // Animate GIGA effect with tween tween(gigaEffect, { scaleX: 4.0, scaleY: 4.0, alpha: 0 }, { duration: 1500, easing: tween.easeOut, onFinish: function onFinish() { gigaEffect.destroy(); } }); // Apply fast mining to all existing blocks for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { // Set fast mining hit requirements: normal 1, hard 2, ultra hard 4 block.hitsRequired = block.blockType === 'ultraHardBlock' ? 4 : block.blockType === 'hardRock' ? 2 : 1; } } } } else if (selectedDinosaur === 'Mutated BARYONYX') { // Mutated BARYONYX ability every 4 levels - reduce hit requirements for all blocks if (currentLevelNumber % 4 === 0) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { // Set reduced hit requirements: normal blocks 1 hit, hard blocks 3 hits, ultra hard blocks 6 hits block.hitsRequired = block.blockType === 'ultraHardBlock' ? 6 : block.blockType === 'hardRock' ? 3 : 1; } } } } else if (selectedDinosaur === 'TRICERATOPS') { // TRICERATOPS head charge - reduce 5 random blocks to 2 hit requirement var availableBlocks = []; for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { availableBlocks.push(block); } } // Select up to 5 random blocks var blocksToWeaken = Math.min(5, availableBlocks.length); var selectedBlocks = []; for (var j = 0; j < blocksToWeaken; j++) { var randomIndex = Math.floor(Math.random() * availableBlocks.length); var selectedBlock = availableBlocks[randomIndex]; selectedBlocks.push(selectedBlock); // Remove from available blocks to avoid duplicates availableBlocks.splice(randomIndex, 1); } // Apply head charge effect to selected blocks for (var k = 0; k < selectedBlocks.length; k++) { var block = selectedBlocks[k]; block.hitsRequired = 2; // Reduce to 2 hits // Visual effect - flash the weakened blocks with blue color for TRICERATOPS tween(block, { tint: 0x32CD32 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(block, { tint: 0xFFFFFF }, { duration: 300, easing: tween.easeOut }); } }); } // Create visual head charge effect var headChargeEffect = LK.getAsset('TRICERATOPS', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); headChargeEffect.x = 1024; headChargeEffect.y = 1000; headChargeEffect.alpha = 0.8; headChargeEffect.tint = 0x32CD32; // Green effect for TRICERATOPS currentLevel.addChild(headChargeEffect); // Animate head charge effect tween(headChargeEffect, { scaleX: 3.5, scaleY: 3.5, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { headChargeEffect.destroy(); } }); } else if (selectedDinosaur === 'ANKYLOSAURUS') { // ANKYLOSAURUS tail strike - reduce 4 random blocks to 1 hit requirement var availableBlocks = []; for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { availableBlocks.push(block); } } // Select up to 4 random blocks var blocksToWeaken = Math.min(4, availableBlocks.length); var selectedBlocks = []; for (var j = 0; j < blocksToWeaken; j++) { var randomIndex = Math.floor(Math.random() * availableBlocks.length); var selectedBlock = availableBlocks[randomIndex]; selectedBlocks.push(selectedBlock); // Remove from available blocks to avoid duplicates availableBlocks.splice(randomIndex, 1); } // Apply tail strike effect to selected blocks for (var k = 0; k < selectedBlocks.length; k++) { var block = selectedBlocks[k]; block.hitsRequired = 1; // Reduce to 1 hit // Visual effect - flash the weakened blocks tween(block, { tint: 0xFFD700 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(block, { tint: 0xFFFFFF }, { duration: 300, easing: tween.easeOut }); } }); } // Create visual tail strike effect var tailStrikeEffect = LK.getAsset('ANKYLOSAURUS', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); tailStrikeEffect.x = 1024; tailStrikeEffect.y = 1000; tailStrikeEffect.alpha = 0.8; tailStrikeEffect.tint = 0x8B4513; // Brown effect for ANKYLOSAURUS currentLevel.addChild(tailStrikeEffect); // Animate tail strike effect tween(tailStrikeEffect, { scaleX: 3.5, scaleY: 3.5, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { tailStrikeEffect.destroy(); } }); } else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') { // Mutated PARASAUROLUPHUS ability every 2 matches with reduced hits var currentUsage = storage.mutatedParasaurolophusMatches || 0; currentUsage++; storage.mutatedParasaurolophusMatches = currentUsage; if (currentUsage % 2 === 0) { for (var i = 0; i < currentLevel.blocks.length; i++) { var block = currentLevel.blocks[i]; if (!block.isCollected) { // Set reduced hit requirements: normal blocks 2 hits, hard blocks 4 hits, ultra hard blocks 7 hits block.hitsRequired = block.blockType === 'ultraHardBlock' ? 7 : block.blockType === 'hardRock' ? 4 : 2; } } } } else { // For other dinosaurs with no special button ability, show message or do nothing } } }; // Back to menu button click handler backToMenuButton.down = function (x, y, obj) { if (gameState === 'playing') { // Clean up current level if (currentLevel) { currentLevel.destroy(); currentLevel = null; } // Reset game state gameState = 'nickname'; // Hide game UI elements hideAllGameUI(); // Show menu UI elements showAllMenuUI(); } }; // Initialize display updateNicknameDisplay(); coinsText.setText('Coins: ' + playerCoins); // Display player crowns if any displayPlayerCrowns(); // Start background music LK.playMusic('backgroundMusic'); function showFoodDinosaursInfo(foodType) { gameState = 'foodInfo'; // Hide all feed UI elements hideAllStoreUI(); // Create food info display var foodTitle = new Text2('BU YİYECEĞİ YIYEN DİNOZORLAR', { size: 60, fill: '#FFFFFF' }); foodTitle.anchor.set(0.5, 0.5); foodTitle.x = 1024; foodTitle.y = 200; game.addChild(foodTitle); infoUIElements.push(foodTitle); var foodTypeText = ''; if (foodType === 'leaf') { foodTypeText = 'YAPRAK YİYEN DİNOZORLAR:'; } else if (foodType === 'meat') { foodTypeText = 'ET YİYEN DİNOZORLAR:'; } else if (foodType === 'fish') { foodTypeText = 'BALIK YİYEN DİNOZORLAR:'; } var foodTypeDisplay = new Text2(foodTypeText, { size: 50, fill: '#FFD700' }); foodTypeDisplay.anchor.set(0.5, 0.5); foodTypeDisplay.x = 1024; foodTypeDisplay.y = 300; game.addChild(foodTypeDisplay); infoUIElements.push(foodTypeDisplay); // Get dinosaurs that eat this food type var dinosaurList = []; for (var dinoName in dinosaurDiets) { if (dinosaurDiets[dinoName] === foodType) { dinosaurList.push(dinoName); } } // Display dinosaur list var startY = 400; for (var i = 0; i < dinosaurList.length; i++) { var dinoText = new Text2('• ' + dinosaurList[i], { size: 40, fill: '#FFFFFF' }); dinoText.anchor.set(0.5, 0.5); dinoText.x = 1024; dinoText.y = startY + i * 60; game.addChild(dinoText); infoUIElements.push(dinoText); } // Back button var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = startY + dinosaurList.length * 60 + 100; var backButtonText = new Text2('GERİ', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = startY + dinosaurList.length * 60 + 100; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showFeedSection(); }; } function showDinosaurInfo(dinosaurName) { gameState = 'dinosaurInfo'; // Hide all bag UI elements hideAllBagUI(); // Create dinosaur info display var infoTitle = new Text2('DİNOZOR BİLGİLERİ', { size: 80, fill: '#FFFFFF' }); infoTitle.anchor.set(0.5, 0.5); infoTitle.x = 1024; infoTitle.y = 200; game.addChild(infoTitle); infoUIElements.push(infoTitle); // Dinosaur name var dinoNameText = new Text2(dinosaurName, { size: 60, fill: '#FFD700' }); dinoNameText.anchor.set(0.5, 0.5); dinoNameText.x = 1024; dinoNameText.y = 400; game.addChild(dinoNameText); infoUIElements.push(dinoNameText); // Dinosaur image var dinoImage = new DinosaurImage(dinosaurName); dinoImage.x = 1024; dinoImage.y = 600; dinoImage.scaleX = 2; dinoImage.scaleY = 2; game.addChild(dinoImage); infoUIElements.push(dinoImage); // Hunger status var hungerStatus = getHungerStatus(dinosaurName); var hungerText = getHungerText(hungerStatus); var hungerColor = getHungerColor(hungerStatus); var hungerDisplay = new Text2('Açlık Durumu: ' + hungerText, { size: 50, fill: hungerColor }); hungerDisplay.anchor.set(0.5, 0.5); hungerDisplay.x = 1024; hungerDisplay.y = 800; game.addChild(hungerDisplay); infoUIElements.push(hungerDisplay); // Feed button var diet = dinosaurDiets[dinosaurName]; var foodText = ''; var hasRequiredFood = false; if (diet === 'leaf') { foodText = 'YAPRAK VER (' + leafFood + ')'; hasRequiredFood = leafFood > 0; } else if (diet === 'meat') { foodText = 'ET VER (' + meatFood + ')'; hasRequiredFood = meatFood > 0; } else if (diet === 'fish') { foodText = 'BALIK VER (' + fishFood + ')'; hasRequiredFood = fishFood > 0; } var feedButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); feedButton.x = 1024; feedButton.y = 1000; if (!hasRequiredFood) { feedButton.alpha = 0.5; } var feedButtonText = new Text2(foodText, { size: 35, fill: hasRequiredFood ? '#FFFFFF' : '#888888' }); feedButtonText.anchor.set(0.5, 0.5); feedButtonText.x = 1024; feedButtonText.y = 1000; game.addChild(feedButtonText); infoUIElements.push(feedButton, feedButtonText); feedButton.down = function () { var hungerStatus = getHungerStatus(dinosaurName); if (hungerStatus === 'FED') { // Show message that dinosaur is not hungry var notHungryMessage = new Text2('Dinozor aç değil!', { size: 40, fill: '#FF4444' }); notHungryMessage.anchor.set(0.5, 0.5); notHungryMessage.x = 1024; notHungryMessage.y = 1250; game.addChild(notHungryMessage); // Remove message after 2 seconds LK.setTimeout(function () { if (notHungryMessage && notHungryMessage.parent) { notHungryMessage.destroy(); } }, 2000); } else if (feedDinosaur(dinosaurName)) { // Refresh display hideInfoScreen(); showDinosaurInfo(dinosaurName); } else { // Show message that there's not enough food var notEnoughFoodMessage = new Text2('Yeterli yiyecek yok!', { size: 40, fill: '#FF4444' }); notEnoughFoodMessage.anchor.set(0.5, 0.5); notEnoughFoodMessage.x = 1024; notEnoughFoodMessage.y = 1250; game.addChild(notEnoughFoodMessage); // Remove message after 2 seconds LK.setTimeout(function () { if (notEnoughFoodMessage && notEnoughFoodMessage.parent) { notEnoughFoodMessage.destroy(); } }, 2000); } }; // Back button var backButton = game.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); backButton.x = 1024; backButton.y = 1150; var backButtonText = new Text2('GERİ', { size: 35, fill: '#FFFFFF' }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 1024; backButtonText.y = 1150; game.addChild(backButtonText); infoUIElements.push(backButton, backButtonText); backButton.down = function () { hideInfoScreen(); showBag(); }; } function getCrownColor(completionCount) { if (completionCount >= 4) return 0x800080; // Purple for 4+ completions if (completionCount >= 3) return 0xFF0000; // Red for 3+ completions if (completionCount >= 2) return 0x00FF00; // Green for 2+ completions if (completionCount >= 1) return 0x0000FF; // Blue for 1+ completions return 0xFFD700; // Gold default (shouldn't be used) } function displayPlayerCrowns() { // Remove existing crown displays for (var i = 0; i < menuUIElements.length; i++) { if (menuUIElements[i].isCrown) { menuUIElements[i].destroy(); menuUIElements.splice(i, 1); i--; } } // Display crowns above player name if any earned if (playerCrowns > 0) { var crownColor = getCrownColor(gameCompletions); var crownSpacing = 60; var startX = 1024 - (playerCrowns - 1) * crownSpacing / 2; for (var i = 0; i < playerCrowns; i++) { var crown = new Text2('♔', { size: 50, fill: crownColor }); crown.anchor.set(0.5, 0.5); crown.x = startX + i * crownSpacing; crown.y = 750; // Above nickname display crown.isCrown = true; game.addChild(crown); menuUIElements.push(crown); } // Add completion count text var completionText = new Text2('Tamamlama: ' + gameCompletions, { size: 30, fill: '#FFD700' }); completionText.anchor.set(0.5, 0.5); completionText.x = 1024; completionText.y = 700; completionText.isCrown = true; game.addChild(completionText); menuUIElements.push(completionText); } } function createStoredTriviaPuzzle(selectedQuestion) { // Create puzzle title var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', { size: 60, fill: '#FFD700' }); puzzleTitle.anchor.set(0.5, 0.5); puzzleTitle.x = 1024; puzzleTitle.y = 300; currentPuzzle.addChild(puzzleTitle); puzzleUIElements.push(puzzleTitle); // Display question var questionText = new Text2(selectedQuestion.question, { size: 50, fill: '#FFFFFF' }); questionText.anchor.set(0.5, 0.5); questionText.x = 1024; questionText.y = 600; currentPuzzle.addChild(questionText); puzzleUIElements.push(questionText); // Create answer buttons for (var a = 0; a < 3; a++) { var answerButton = currentPuzzle.attachAsset('startButton', { anchorX: 0.5, anchorY: 0.5 }); answerButton.x = 1024; answerButton.y = 900 + a * 150; currentPuzzle.addChild(answerButton); puzzleUIElements.push(answerButton); var answerText = new Text2(selectedQuestion.answers[a], { size: 40, fill: '#FFFFFF' }); answerText.anchor.set(0.5, 0.5); answerText.x = 1024; answerText.y = 900 + a * 150; currentPuzzle.addChild(answerText); puzzleUIElements.push(answerText); // Add click handler with closure (function (answerIndex, correctIndex) { answerButton.down = function () { if (answerIndex === correctIndex) { solvePuzzle(); } else { resetTriviaPuzzle(); } }; })(a, selectedQuestion.correct); } }
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var DinosaurImage = Container.expand(function (dinosaurName) {
var self = Container.call(this);
// Main dinosaur body
var dinoBody = self.attachAsset(dinosaurName, {
anchorX: 0.5,
anchorY: 0.5
});
// Add red eyes
var leftEye = self.attachAsset('redEye', {
anchorX: 0.5,
anchorY: 0.5
});
leftEye.x = -30;
leftEye.y = -20;
var rightEye = self.attachAsset('redEye', {
anchorX: 0.5,
anchorY: 0.5
});
rightEye.x = 30;
rightEye.y = -20;
return self;
});
var Fossil = Container.expand(function (fossilType) {
var self = Container.call(this);
var fossilGraphics = self.attachAsset(fossilType, {
anchorX: 0.5,
anchorY: 0.5
});
self.fossilType = fossilType;
self.isCollected = false;
self.points = fossilType === 'rareFossil' ? 500 : 100;
self.down = function (x, y, obj) {
if (!self.isCollected) {
self.collectFossil();
}
};
self.collectFossil = function () {
self.isCollected = true;
LK.getSound('fossilFound').play();
// Apply dinosaur abilities
// Add fossil to inventory
playerInventory.push(self.fossilType);
storage.playerInventory = playerInventory;
// Award points based on extraction speed
var speedBonus = Math.max(0, 100 - Math.floor(levelTimer / 100));
var basePoints = self.points + speedBonus;
// Apply upgrade bonus to points if dinosaur is selected
var totalPoints = basePoints;
if (selectedDinosaur) {
totalPoints = Math.floor(basePoints * getPointsBonus(selectedDinosaur));
}
// Apply 2X MONEY effect if active
if (doubleMoneyLevelsLeft > 0) {
totalPoints *= 2;
}
LK.setScore(LK.getScore() + totalPoints);
scoreText.setText('Score: ' + LK.getScore());
self.animateCollection();
};
self.animateCollection = function () {
// Animate collection
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
currentLevel.fossilsCollected++;
currentLevel.checkLevelComplete();
}
});
};
return self;
});
var Level = Container.expand(function (levelNumber) {
var self = Container.call(this);
self.levelNumber = levelNumber;
self.blocks = [];
self.fossils = [];
self.fossilsCollected = 0;
self.totalFossils = 0;
self.blocksCollected = 0;
self.totalBlocks = 0;
self.createLevel = function () {
// Create excavation site background
var site = self.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
site.x = 1024;
site.y = 1000;
// Get difficulty settings for this level
var difficulty = getLevelDifficulty(levelNumber);
var fossilCount = difficulty.fossilCount;
var blocksPerRow = difficulty.gridWidth;
var rows = difficulty.gridHeight;
var rareChance = difficulty.rareChance;
var fossilTypes = ['fossil1', 'fossil2', 'fossil3'];
// Add rare fossil chance based on level difficulty
if (Math.random() < rareChance) {
fossilTypes.push('rareFossil');
}
self.totalFossils = fossilCount;
// Create limestone blocks grid with scaling difficulty
var startX = 1024 - blocksPerRow * 140 / 2 + 70; // Center the grid
var startY = 600;
var spacing = 140;
var fossilPositions = [];
for (var i = 0; i < fossilCount; i++) {
var randomPos = Math.floor(Math.random() * (blocksPerRow * rows));
while (fossilPositions.indexOf(randomPos) !== -1) {
randomPos = Math.floor(Math.random() * (blocksPerRow * rows));
}
fossilPositions.push(randomPos);
}
var blockIndex = 0;
for (var row = 0; row < rows; row++) {
for (var col = 0; col < blocksPerRow; col++) {
// Determine block type - 25% chance for ultra hard block, 30% chance for hard rock, 45% chance for limestone
var random = Math.random();
var blockType;
if (random < 0.25) {
blockType = 'ultraHardBlock';
} else if (random < 0.55) {
blockType = 'hardRock';
} else {
blockType = 'limestone';
}
var block = new LimestoneBlock(blockType);
block.x = startX + col * spacing;
block.y = startY + row * spacing;
// Check if this block contains a fossil
if (fossilPositions.indexOf(blockIndex) !== -1) {
block.hasFossil = true;
var fossilTypeIndex = Math.floor(Math.random() * fossilTypes.length);
block.fossilType = fossilTypes[fossilTypeIndex];
}
self.blocks.push(block);
self.addChild(block);
blockIndex++;
}
}
self.totalBlocks = self.blocks.length;
};
self.revealFossil = function (fossilType, x, y) {
var fossil = new Fossil(fossilType);
fossil.x = x;
fossil.y = y;
// Animate fossil appearance
fossil.alpha = 0;
fossil.scaleX = 0;
fossil.scaleY = 0;
self.fossils.push(fossil);
self.addChild(fossil);
tween(fossil, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.easeOut
});
};
self.checkBlockCollection = function () {
self.blocksCollected++;
if (self.blocksCollected >= self.totalBlocks) {
// All blocks collected, show any remaining fossils
for (var i = 0; i < self.blocks.length; i++) {
var block = self.blocks[i];
if (block.hasFossil && !block.isCollected) {
self.revealFossil(block.fossilType, block.x, block.y);
}
}
}
};
self.checkLevelComplete = function () {
if (self.fossilsCollected >= self.totalFossils) {
LK.getSound('levelComplete').play();
// Level completion bonus with scaling difficulty
var baseLevelBonus = Math.floor(currentLevelNumber / 10) * 100; // Bonus increases every 10 levels
var timeBonus = Math.max(0, 1000 + baseLevelBonus - Math.floor(levelTimer / 10));
LK.setScore(LK.getScore() + timeBonus);
scoreText.setText('Score: ' + LK.getScore());
// Decrease power-up counters
if (xrayLevelsLeft > 0) {
xrayLevelsLeft--;
storage.xrayLevelsLeft = xrayLevelsLeft;
}
if (doubleMoneyLevelsLeft > 0) {
doubleMoneyLevelsLeft--;
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
}
// Progress to next level after delay
LK.setTimeout(function () {
if (currentLevelNumber < maxLevels) {
// Check if next level is a puzzle level
if (isPuzzleLevel(currentLevelNumber + 1)) {
startPuzzleLevel(currentLevelNumber + 1);
} else {
startLevel(currentLevelNumber + 1);
}
} else {
// Game complete - award crown and reset progress
gameCompletions++;
storage.gameCompletions = gameCompletions;
// Award crown if player has less than 5 crowns
if (playerCrowns < 5) {
playerCrowns++;
storage.playerCrowns = playerCrowns;
}
storage.currentLevelNumber = 1;
currentLevelNumber = 1;
LK.showYouWin();
}
}, 2000);
}
};
return self;
});
var LimestoneBlock = Container.expand(function (blockType) {
var self = Container.call(this);
self.blockType = blockType || 'limestone';
// Use tan colored asset for ultra hard blocks
var assetName = self.blockType === 'ultraHardBlock' ? 'ultraHardRock' : self.blockType;
var blockGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.hasFossil = false;
self.fossilType = null;
self.isCollected = false;
self.hitsRequired = self.blockType === 'ultraHardBlock' ? 10 : self.blockType === 'hardRock' ? 5 : 3;
self.currentHits = 0;
self.down = function (x, y, obj) {
if (!self.isCollected) {
self.currentHits++;
if (self.currentHits >= self.hitsRequired) {
self.collectBlock();
} else {
// Show visual feedback for partial damage
var damageAlpha = 1 - self.currentHits / self.hitsRequired * 0.6;
blockGraphics.alpha = damageAlpha;
LK.getSound('dig').play();
}
}
};
self.collectBlock = function () {
// All dinosaurs now use normal collection - abilities only work via button press
self.performCollection();
};
self.performCollection = function () {
self.isCollected = true;
LK.getSound('dig').play();
// Animate collection
tween(self, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
if (self.hasFossil) {
currentLevel.revealFossil(self.fossilType, self.x, self.y);
}
currentLevel.checkBlockCollection();
}
});
};
self.performTrexCollection = function () {
// TREX roars and collects all fossils (every 10 levels)
if (currentLevelNumber % 10 === 0) {
// Create roar effect with screen shake animation
var roarEffect = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 3.0
});
roarEffect.x = 1024;
roarEffect.y = 1000;
roarEffect.alpha = 0.7;
roarEffect.tint = 0xFF4500; // Orange roar effect
currentLevel.addChild(roarEffect);
// Animate roar effect with tween
tween(roarEffect, {
scaleX: 5.0,
scaleY: 5.0,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
roarEffect.destroy();
}
});
// Collect all fossils on the level instantly
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Instantly reveal and collect the fossil
currentLevel.revealFossil(block.fossilType, block.x, block.y);
// Mark block as collected
block.isCollected = true;
block.alpha = 0;
}
}
// Break current block normally
self.performCollection();
} else {
// Regular collection for non-10th levels
self.performCollection();
}
};
self.performSpinoCollection = function () {
// SPINO ability to automatically find and collect 3 fossils (1 use per level)
if (storage.spinoUsedThisLevel === undefined) storage.spinoUsedThisLevel = false;
if (storage.spinoUsedThisLevel) {
// Already used this level
self.performCollection();
return;
}
storage.spinoUsedThisLevel = true;
// Create visual fossil hunt effect
var fossilHuntEffect = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 3.0
});
fossilHuntEffect.x = 1024; // Center of screen
fossilHuntEffect.y = 1000; // Center of screen
fossilHuntEffect.alpha = 0.9;
fossilHuntEffect.tint = 0x228B22; // Green fossil hunt effect
currentLevel.addChild(fossilHuntEffect);
// Animate fossil hunt effect
tween(fossilHuntEffect, {
scaleX: 6.0,
scaleY: 6.0,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
fossilHuntEffect.destroy();
}
});
// Find all blocks with fossils that haven't been collected yet
var fossilBlocks = [];
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
fossilBlocks.push(block);
}
}
// Select up to 3 fossil blocks to reveal
var blocksToReveal = Math.min(3, fossilBlocks.length);
for (var j = 0; j < blocksToReveal; j++) {
var fossilBlock = fossilBlocks[j];
// Instantly reveal the fossil
currentLevel.revealFossil(fossilBlock.fossilType, fossilBlock.x, fossilBlock.y);
// Mark block as collected
fossilBlock.isCollected = true;
fossilBlock.alpha = 0;
}
// Break current block normally
self.performCollection();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x8B7D6B // Desert sand color
});
/****
* Game Code
****/
// Background rotation system - select different background each time
function selectNextBackground() {
var availableBackgrounds = [0, 1, 2, 3]; // 4 different backgrounds
// Remove last shown background from available options
if (lastBackgroundIndex !== -1) {
var lastIndex = availableBackgrounds.indexOf(lastBackgroundIndex);
if (lastIndex !== -1) {
availableBackgrounds.splice(lastIndex, 1);
}
}
// Select random background from remaining options
currentBackgroundIndex = availableBackgrounds[Math.floor(Math.random() * availableBackgrounds.length)];
// Save current selection as last shown
storage.lastBackgroundIndex = currentBackgroundIndex;
lastBackgroundIndex = currentBackgroundIndex;
}
// Create dynamic backgrounds based on selection
function createBackground(backgroundIndex) {
if (backgroundIndex === 0) {
// 1. Current arid desert with gold and dinosaur bones
var desertBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
desertBackground.x = 1024;
desertBackground.y = 1366;
desertBackground.alpha = 0.3;
desertBackground.tint = 0xD2B48C; // Sandy brown color
// Add scattered dinosaur bones and gold pieces
for (var i = 0; i < 8; i++) {
var bone = LK.getAsset('fossil2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7
});
bone.x = 200 + Math.random() * 1648;
bone.y = 1500 + Math.random() * 1000;
bone.alpha = 0.4;
bone.rotation = Math.random() * Math.PI * 2;
game.addChild(bone);
}
// Add scattered gold pieces
for (var j = 0; j < 6; j++) {
var gold = LK.getAsset('rareFossil', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
});
gold.x = 300 + Math.random() * 1448;
gold.y = 1600 + Math.random() * 900;
gold.alpha = 0.6;
gold.tint = 0xFFD700; // Golden color
game.addChild(gold);
}
} else if (backgroundIndex === 1) {
// 2. Swampy forest with Spinosaurus and Sarcosuchus fossils
var swampBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
swampBackground.x = 1024;
swampBackground.y = 1366;
swampBackground.alpha = 0.3;
swampBackground.tint = 0x228B22; // Forest green color
// Add shore trees along the edges using limestone blocks
for (var t = 0; t < 10; t++) {
var tree = LK.getAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 1.5
});
// Place trees along the shore (top and bottom edges)
if (t < 5) {
// Top shore trees
tree.x = 200 + t * 300;
tree.y = 800 + Math.random() * 200;
} else {
// Bottom shore trees
tree.x = 200 + (t - 5) * 300;
tree.y = 2300 + Math.random() * 200;
}
tree.alpha = 0.4;
tree.tint = 0x8B4513; // Brown color for tree trunks
game.addChild(tree);
}
// Add SPINO fossils scattered around
for (var s = 0; s < 4; s++) {
var spinoFossil = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
spinoFossil.x = 300 + Math.random() * 1448;
spinoFossil.y = 1600 + Math.random() * 800;
spinoFossil.alpha = 0.3;
spinoFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(spinoFossil);
}
// Add crocodile-like fossils (using BARYONYX as substitute for Sarcosuchus)
for (var c = 0; c < 3; c++) {
var crocFossil = LK.getAsset('BARYONYX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
crocFossil.x = 400 + Math.random() * 1248;
crocFossil.y = 1700 + Math.random() * 700;
crocFossil.alpha = 0.3;
crocFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(crocFossil);
}
} else if (backgroundIndex === 2) {
// 3. Snowy mountain with GIGA and Argentavis fossils (white background)
var snowyBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
snowyBackground.x = 1024;
snowyBackground.y = 1366;
snowyBackground.alpha = 0.3;
snowyBackground.tint = 0xFFFFFF; // White color for snowy mountain
// Add GIGA fossils scattered around
for (var g = 0; g < 3; g++) {
var gigaFossil = LK.getAsset('GIGA', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
gigaFossil.x = 300 + Math.random() * 1448;
gigaFossil.y = 1600 + Math.random() * 800;
gigaFossil.alpha = 0.3;
gigaFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(gigaFossil);
}
// Add Argentavis fossils (using YUTY as substitute for Argentavis)
for (var a = 0; a < 2; a++) {
var argentavisFossil = LK.getAsset('YUTY', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
argentavisFossil.x = 400 + Math.random() * 1248;
argentavisFossil.y = 1700 + Math.random() * 700;
argentavisFossil.alpha = 0.3;
argentavisFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(argentavisFossil);
}
// Add snow patches using limestone blocks
for (var s = 0; s < 8; s++) {
var snowPatch = LK.getAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
snowPatch.x = 200 + Math.random() * 1648;
snowPatch.y = 1500 + Math.random() * 1000;
snowPatch.alpha = 0.4;
snowPatch.tint = 0xF0F8FF; // Alice blue for snow patches
snowPatch.rotation = Math.random() * Math.PI * 2;
game.addChild(snowPatch);
}
} else if (backgroundIndex === 3) {
// 4. Ocean floor with Megalodon and Mosasaurus fossils (light blue background)
var oceanBackground = game.attachAsset('excavationSite', {
anchorX: 0.5,
anchorY: 0.5
});
oceanBackground.x = 1024;
oceanBackground.y = 1366;
oceanBackground.alpha = 0.3;
oceanBackground.tint = 0x87CEEB; // Light blue color for ocean
// Add Megalodon fossils (using TREX as substitute for Megalodon)
for (var m = 0; m < 2; m++) {
var megalodonFossil = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
megalodonFossil.x = 300 + Math.random() * 1448;
megalodonFossil.y = 1600 + Math.random() * 800;
megalodonFossil.alpha = 0.3;
megalodonFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(megalodonFossil);
}
// Add Mosasaurus fossils (using SPINO as substitute for Mosasaurus)
for (var mo = 0; mo < 3; mo++) {
var mosasaurusFossil = LK.getAsset('SPINO', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.9,
scaleY: 0.9
});
mosasaurusFossil.x = 400 + Math.random() * 1248;
mosasaurusFossil.y = 1700 + Math.random() * 700;
mosasaurusFossil.alpha = 0.3;
mosasaurusFossil.rotation = Math.random() * Math.PI * 2;
game.addChild(mosasaurusFossil);
}
// Add coral formations using fossil shapes
for (var c = 0; c < 6; c++) {
var coral = LK.getAsset('fossil3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
coral.x = 200 + Math.random() * 1648;
coral.y = 1500 + Math.random() * 1000;
coral.alpha = 0.4;
coral.tint = 0xFF7F50; // Coral color
coral.rotation = Math.random() * Math.PI * 2;
game.addChild(coral);
}
}
}
// Select and create background
selectNextBackground();
createBackground(currentBackgroundIndex);
// Dinosaur images with red eyes and different skin colors
var gameState = 'nickname'; // 'nickname', 'playing'
var playerNickname = storage.playerNickname || '';
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var currentLetterIndex = 0;
var currentLevelNumber = storage.currentLevelNumber || 1;
var maxLevels = 200;
var currentLevel = null;
var levelTimer = 0;
var leaderboardTexts = [];
// Player data storage - Load persistent data from storage
var playerCoins = storage.playerCoins || 0;
var playerInventory = storage.playerInventory || [];
var dinosaurCollection = storage.dinosaurCollection || [];
var selectedDinosaur = storage.selectedDinosaur || null;
var playerLevel = storage.playerLevel || 1;
// Dinosaur hunger system - Load persistent data
var dinosaurHunger = storage.dinosaurHunger || {};
var lastFeedingCheck = storage.lastFeedingCheck || Date.now();
// Food inventory - Load persistent data
var leafFood = storage.leafFood || 0;
var meatFood = storage.meatFood || 0;
var fishFood = storage.fishFood || 0;
// Dinosaur diet mapping based on real-life diets
var dinosaurDiets = {
'PARASOUROLUPHUS': 'leaf',
// Herbivore - ate plants, leaves
'TRICERATOPS': 'leaf',
// Herbivore - ate plants, leaves
'ANKYLOSAURUS': 'leaf',
// Herbivore - ate plants, leaves
'BARYONYX': 'fish',
// Piscivore - fish eater with crocodile-like snout
'ALLO': 'meat',
// Carnivore - large predator
'YUTY': 'meat',
// Carnivore - feathered tyrannosaur
'TREX': 'meat',
// Carnivore - apex predator
'SPINO': 'fish',
// Piscivore - semi-aquatic fish eater
'GIGA': 'meat',
// Carnivore - massive predator
'Mutated BARYONYX': 'fish',
// Piscivore - enhanced fish eater
'Mutated PARASAUROLUPHUS': 'leaf' // Herbivore - enhanced plant eater
};
var feedingCosts = {
'PARASOUROLUPHUS': 50,
'TRICERATOPS': 60,
'ANKYLOSAURUS': 70,
'BARYONYX': 200,
'ALLO': 300,
'YUTY': 400,
'TREX': 800,
'SPINO': 600,
'GIGA': 700,
'Mutated BARYONYX': 500,
'Mutated PARASAUROLUPHUS': 550
};
// Ensure storage is properly initialized
storage.playerCoins = playerCoins;
storage.playerInventory = playerInventory;
storage.dinosaurCollection = dinosaurCollection;
storage.selectedDinosaur = selectedDinosaur;
storage.dinosaurHunger = dinosaurHunger;
storage.lastFeedingCheck = lastFeedingCheck;
// Background rotation system - track last shown background
var lastBackgroundIndex = storage.lastBackgroundIndex || -1;
var currentBackgroundIndex = 0;
// Load persistent gamepass purchases
var xrayLevelsLeft = storage.xrayLevelsLeft || 0;
var doubleMoneyLevelsLeft = 0; // Reset 2X MONEY gamepass bug for everyone
storage.doubleMoneyLevelsLeft = 0; // Save reset value to storage
var doubleValueActive = storage.doubleValueActive || false;
var doubleSpawnChanceActive = storage.doubleSpawnChanceActive || false;
// Load persistent +1 SELECT gamepass purchases
// Note: passPurchases is already loaded from storage in the showBag function
// GIGA fast mining state
var gigaFastMiningActive = false;
var gigaFastMiningLevel = 0;
// Crown system for game completions
var gameCompletions = storage.gameCompletions || 0;
var playerCrowns = storage.playerCrowns || 0; // Number of crowns earned (max 5)
// Daily gifts system - Load persistent data
var lastGiftDate = storage.lastGiftDate || 0;
var currentGiftDay = storage.currentGiftDay || 1;
var dailyGifts = [1000, 2000, 4000, 8000, 10000, 12000, 16000]; // 7 days of gifts
var dailyGiftClaimed = storage.dailyGiftClaimed || false;
// Weekly food rewards system - Load persistent data
var lastFoodGiftDate = storage.lastFoodGiftDate || 0;
var currentFoodGiftDay = storage.currentFoodGiftDay || 1;
var weeklyFoodGifts = [{
leaf: 1,
meat: 1,
fish: 1
},
// Day 1: 1 of each
{
leaf: 2,
meat: 2,
fish: 2
},
// Day 2: 2 of each
{
leaf: 3,
meat: 3,
fish: 3
},
// Day 3: 3 of each
{
leaf: 5,
meat: 5,
fish: 5
},
// Day 4: 5 of each
{
leaf: 7,
meat: 7,
fish: 7
},
// Day 5: 7 of each
{
leaf: 8,
meat: 8,
fish: 8
},
// Day 6: 8 of each
{
leaf: 10,
meat: 10,
fish: 10
} // Day 7: 10 of each
];
var weeklyFoodGiftClaimed = storage.weeklyFoodGiftClaimed || false;
// Trade system - Load persistent data
var dailyTradesLeft = storage.dailyTradesLeft || 5; // 5 trades per day
var lastTradeDate = storage.lastTradeDate || 0;
var currentTradeOffer = storage.currentTradeOffer || null;
var tradeRequestsReceived = storage.tradeRequestsReceived || [];
var activePlayers = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5']; // Mock active players
// Puzzle and difficulty system
var puzzleLevels = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]; // Puzzle every 10 levels
var currentPuzzle = null;
var puzzleUIElements = [];
function isPuzzleLevel(levelNumber) {
return puzzleLevels.indexOf(levelNumber) !== -1;
}
function getLevelDifficulty(levelNumber) {
// Calculate difficulty scaling: more fossils, less time, harder patterns
var baseFossils = 3;
var bonusFossils = Math.floor(levelNumber / 20); // +1 fossil every 20 levels
var totalFossils = Math.min(baseFossils + bonusFossils, 10); // Max 10 fossils
var baseBlocks = 48; // 8x6 grid
var bonusBlocks = Math.floor(levelNumber / 25) * 8; // +8 blocks every 25 levels
var totalBlocks = Math.min(baseBlocks + bonusBlocks, 80); // Max 80 blocks (10x8 grid)
var rareChance = Math.min(0.05 + levelNumber * 0.002, 0.25); // Increase rare fossil chance, max 25%
return {
fossilCount: totalFossils,
blockCount: totalBlocks,
rareChance: rareChance,
gridWidth: Math.min(8 + Math.floor(bonusBlocks / 8), 10),
gridHeight: Math.min(6 + Math.floor(bonusBlocks / 16), 8)
};
}
// Stock system - Load persistent data (coming soon)
var stockUIElements = [];
var fossilRarities = {
'fossil1': 'common',
'fossil2': 'common',
'fossil3': 'common',
'rareFossil': 'rare'
};
var fossilValues = {
'fossil1': 10,
'fossil2': 15,
'fossil3': 20,
'rareFossil': 100
};
var dinosaurRarities = {
'PARASOUROLUPHUS': 'common',
'TRICERATOPS': 'common',
'ANKYLOSAURUS': 'common',
'BARYONYX': 'rare',
'ALLO': 'rare',
'YUTY': 'rare',
'TREX': 'chromatic',
'SPINO': 'legendary',
'GIGA': 'legendary',
'Mutated BARYONYX': 'legendary',
'Mutated PARASAUROLUPHUS': 'legendary'
};
// Dinosaur abilities - Original characteristics restored
var dinosaurAbilities = {
'PARASOUROLUPHUS': 'slow_dig',
// Very slow digging, takes more time to break blocks
'TRICERATOPS': 'head_charge',
// Head charge reduces 5 random blocks to 2 hit requirement
'ANKYLOSAURUS': 'tail_strike',
// Tail strike reduces 4 random blocks to 1 hit requirement
'BARYONYX': 'speed_dig',
// 20% faster digging speed
'YUTY': 'fast_dig',
// 70% faster digging speed
'ALLO': 'medium_speed_dig',
// 40% faster digging speed
'TREX': 'roar_collector',
// Roars every 10 levels and collects all fossils
'SPINO': 'line_breaker',
// Tail strike breaks 3 blocks in horizontal line, 1 use per level
'GIGA': 'fast_mining',
// Fast mining: normal blocks 1 hit, hard blocks 2 hits, ultra hard blocks 4 hits until level ends, usable every 5 levels
'Mutated BARYONYX': 'ultra_fast_dig',
// 90% faster digging speed
'Mutated PARASAUROLUPHUS': 'improved_slow_dig'
// Faster than regular PARASAUROLUPHUS but still slower than others
};
// Dinosaur egg contents
var commonEggDinosaurs = ['PARASOUROLUPHUS', 'TRICERATOPS', 'ANKYLOSAURUS'];
var rareEggDinosaurs = [{
name: 'BARYONYX',
chance: 0.45
}, {
name: 'ALLO',
chance: 0.35
}, {
name: 'YUTY',
chance: 0.20
}];
var legendaryEggDinosaurs = [{
name: 'TREX',
chance: 0.03
}, {
name: 'SPINO',
chance: 0.15
}, {
name: 'GIGA',
chance: 0.22
}, {
name: 'Mutated BARYONYX',
chance: 0.30
}, {
name: 'Mutated PARASAUROLUPHUS',
chance: 0.30
}];
function openEgg(eggType) {
var dinosaurName = '';
if (eggType === 'common') {
// Equal chance for all common dinosaurs
dinosaurName = commonEggDinosaurs[Math.floor(Math.random() * commonEggDinosaurs.length)];
} else if (eggType === 'rare') {
// Weighted random selection for rare dinosaurs - apply 2X LUCK if active
var randomValue = Math.random();
var cumulativeChance = 0;
for (var i = 0; i < rareEggDinosaurs.length; i++) {
var currentChance = rareEggDinosaurs[i].chance;
// Apply 2X LUCK effect if active
if (doubleSpawnChanceActive) {
currentChance *= 2;
}
cumulativeChance += currentChance;
if (randomValue <= cumulativeChance) {
dinosaurName = rareEggDinosaurs[i].name;
break;
}
}
} else if (eggType === 'legendary') {
// Weighted random selection for legendary dinosaurs - apply 2X LUCK if active
var randomValue = Math.random();
var cumulativeChance = 0;
for (var i = 0; i < legendaryEggDinosaurs.length; i++) {
var currentChance = legendaryEggDinosaurs[i].chance;
// Apply 2X LUCK effect if active
if (doubleSpawnChanceActive) {
currentChance *= 2;
}
cumulativeChance += currentChance;
if (randomValue <= cumulativeChance) {
dinosaurName = legendaryEggDinosaurs[i].name;
break;
}
}
}
// Reset 2X LUCK effect after use
if (doubleSpawnChanceActive) {
doubleSpawnChanceActive = false;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
}
// Add to dinosaur collection
dinosaurCollection.push(dinosaurName);
storage.dinosaurCollection = dinosaurCollection;
// Show congratulations popup
showCongratulationsPopup(dinosaurName);
return dinosaurName;
}
function showCongratulationsPopup(dinosaurName) {
gameState = 'congratulations';
// Hide all current UI
hideAllStoreUI();
hideAllMenuUI();
hideAllGameUI();
// Create congratulations display
var congratsTitle = new Text2('TEBRİKLER!', {
size: 100,
fill: '#FFD700'
});
congratsTitle.anchor.set(0.5, 0.5);
congratsTitle.x = 1024;
congratsTitle.y = 600;
game.addChild(congratsTitle);
infoUIElements.push(congratsTitle);
var winMessage = new Text2('KAZANDINIZ!', {
size: 80,
fill: '#FFFFFF'
});
winMessage.anchor.set(0.5, 0.5);
winMessage.x = 1024;
winMessage.y = 800;
game.addChild(winMessage);
infoUIElements.push(winMessage);
// Add dinosaur image
var dinoImage = new DinosaurImage(dinosaurName);
dinoImage.x = 1024;
dinoImage.y = 900;
dinoImage.scaleX = 2;
dinoImage.scaleY = 2;
game.addChild(dinoImage);
infoUIElements.push(dinoImage);
var dinosaurMessage = new Text2(dinosaurName, {
size: 60,
fill: '#32CD32'
});
dinosaurMessage.anchor.set(0.5, 0.5);
dinosaurMessage.x = 1024;
dinosaurMessage.y = 1100;
game.addChild(dinosaurMessage);
infoUIElements.push(dinosaurMessage);
var closeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
closeButton.x = 1024;
closeButton.y = 1300;
var closeButtonText = new Text2('TAMAM', {
size: 35,
fill: '#FFFFFF'
});
closeButtonText.anchor.set(0.5, 0.5);
closeButtonText.x = 1024;
closeButtonText.y = 1300;
game.addChild(closeButtonText);
infoUIElements.push(closeButton, closeButtonText);
closeButton.down = function () {
hideInfoScreen();
gameState = 'nickname';
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
};
}
// UI Element arrays for different game states
var menuUIElements = [];
var gameUIElements = [];
var storeUIElements = [];
var sellUIElements = [];
var bagUIElements = [];
var infoUIElements = [];
var giftsUIElements = [];
var tradeUIElements = [];
var stockUIElements = [];
// UI Elements
var nicknameText = new Text2('Enter Nickname: A', {
size: 80,
fill: '#FFFFFF'
});
nicknameText.anchor.set(0.5, 0.5);
nicknameText.x = 1024;
nicknameText.y = 800;
var instructionText = new Text2('Use arrows to select letters, ADD to add, DELETE to remove', {
size: 45,
fill: '#CCCCCC'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 900;
var scoreText = new Text2('Score: 0', {
size: 60,
fill: '#FFFFFF'
});
scoreText.anchor.set(0, 0);
var levelText = new Text2('Level: 1', {
size: 60,
fill: '#FFFFFF'
});
levelText.anchor.set(1, 0);
var timerText = new Text2('Time: 0', {
size: 50,
fill: '#FFFFFF'
});
timerText.anchor.set(0.5, 0);
// Nickname input elements
var leftArrow = game.attachAsset('arrowLeft', {
anchorX: 0.5,
anchorY: 0.5
});
leftArrow.x = 800;
leftArrow.y = 1000;
var leftArrowSymbol = new Text2('<', {
size: 60,
fill: '#FFFFFF'
});
leftArrowSymbol.anchor.set(0.5, 0.5);
leftArrowSymbol.x = 800;
leftArrowSymbol.y = 1000;
game.addChild(leftArrowSymbol);
var rightArrow = game.attachAsset('arrowRight', {
anchorX: 0.5,
anchorY: 0.5
});
rightArrow.x = 1248;
rightArrow.y = 1000;
var rightArrowSymbol = new Text2('>', {
size: 60,
fill: '#FFFFFF'
});
rightArrowSymbol.anchor.set(0.5, 0.5);
rightArrowSymbol.x = 1248;
rightArrowSymbol.y = 1000;
game.addChild(rightArrowSymbol);
var startButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
startButton.x = 1024;
startButton.y = 1200;
var startButtonText = new Text2('START', {
size: 40,
fill: '#FFFFFF'
});
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = 1024;
startButtonText.y = 1200;
var addButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
addButton.x = 900;
addButton.y = 1100;
var addButtonText = new Text2('ADD', {
size: 35,
fill: '#FFFFFF'
});
addButtonText.anchor.set(0.5, 0.5);
addButtonText.x = 900;
addButtonText.y = 1100;
var deleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
deleteButton.x = 1148;
deleteButton.y = 1100;
var deleteButtonText = new Text2('DELETE', {
size: 35,
fill: '#FFFFFF'
});
deleteButtonText.anchor.set(0.5, 0.5);
deleteButtonText.x = 1148;
deleteButtonText.y = 1100;
var storeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
storeButton.x = 650;
storeButton.y = 1300;
var storeButtonText = new Text2('STORE', {
size: 35,
fill: '#FFFFFF'
});
storeButtonText.anchor.set(0.5, 0.5);
storeButtonText.x = 650;
storeButtonText.y = 1300;
var sellButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellButton.x = 1398;
sellButton.y = 1300;
var sellButtonText = new Text2('SELL', {
size: 35,
fill: '#FFFFFF'
});
sellButtonText.anchor.set(0.5, 0.5);
sellButtonText.x = 1398;
sellButtonText.y = 1300;
var shopButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopButton.x = 1024;
shopButton.y = 1550;
var shopButtonText = new Text2('SHOP', {
size: 35,
fill: '#FFFFFF'
});
shopButtonText.anchor.set(0.5, 0.5);
shopButtonText.x = 1024;
shopButtonText.y = 1550;
var bagButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagButton.x = 1024;
bagButton.y = 1650;
var bagButtonText = new Text2('BAG', {
size: 35,
fill: '#FFFFFF'
});
bagButtonText.anchor.set(0.5, 0.5);
bagButtonText.x = 1024;
bagButtonText.y = 1650;
var tradeButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
tradeButton.x = 650;
tradeButton.y = 1750;
var tradeButtonText = new Text2('TRADE', {
size: 35,
fill: '#FFFFFF'
});
tradeButtonText.anchor.set(0.5, 0.5);
tradeButtonText.x = 650;
tradeButtonText.y = 1750;
var giftsButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
giftsButton.x = 1398;
giftsButton.y = 1750;
var giftsButtonText = new Text2('GIFTS', {
size: 35,
fill: '#FFFFFF'
});
giftsButtonText.anchor.set(0.5, 0.5);
giftsButtonText.x = 1398;
giftsButtonText.y = 1750;
var stockButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
stockButton.x = 1024;
stockButton.y = 1850;
var stockButtonText = new Text2('STOCK', {
size: 35,
fill: '#FFFFFF'
});
stockButtonText.anchor.set(0.5, 0.5);
stockButtonText.x = 1024;
stockButtonText.y = 1850;
var coinsText = new Text2('Coins: ' + playerCoins, {
size: 50,
fill: '#FFD700'
});
coinsText.anchor.set(0.5, 0.5);
coinsText.x = 1024;
coinsText.y = 1400;
// Add nickname UI to game and track as menu elements
game.addChild(nicknameText);
game.addChild(instructionText);
game.addChild(leftArrow);
game.addChild(rightArrow);
game.addChild(addButton);
game.addChild(addButtonText);
game.addChild(deleteButton);
game.addChild(deleteButtonText);
game.addChild(startButton);
game.addChild(startButtonText);
game.addChild(storeButton);
game.addChild(storeButtonText);
game.addChild(sellButton);
game.addChild(sellButtonText);
game.addChild(shopButton);
game.addChild(shopButtonText);
game.addChild(bagButton);
game.addChild(bagButtonText);
game.addChild(tradeButton);
game.addChild(tradeButtonText);
game.addChild(giftsButton);
game.addChild(giftsButtonText);
game.addChild(stockButton);
game.addChild(stockButtonText);
game.addChild(coinsText);
// Track menu UI elements
menuUIElements.push(nicknameText, instructionText, leftArrow, leftArrowSymbol, rightArrow, rightArrowSymbol, addButton, addButtonText, deleteButton, deleteButtonText, startButton, startButtonText, storeButton, storeButtonText, sellButton, sellButtonText, shopButton, shopButtonText, bagButton, bagButtonText, tradeButton, tradeButtonText, giftsButton, giftsButtonText, stockButton, stockButtonText, coinsText);
// Track game UI elements
gameUIElements.push(scoreText, levelText, timerText);
// Add game UI to GUI
LK.gui.topLeft.addChild(scoreText);
scoreText.x = 120;
scoreText.y = 20;
scoreText.visible = false;
LK.gui.topRight.addChild(levelText);
levelText.y = 20;
levelText.visible = false;
LK.gui.top.addChild(timerText);
timerText.y = 100;
timerText.visible = false;
function hideAllMenuUI() {
for (var i = 0; i < menuUIElements.length; i++) {
menuUIElements[i].visible = false;
}
}
function showAllMenuUI() {
for (var i = 0; i < menuUIElements.length; i++) {
menuUIElements[i].visible = true;
}
// Display player crowns
displayPlayerCrowns();
}
function hideAllGameUI() {
for (var i = 0; i < gameUIElements.length; i++) {
gameUIElements[i].visible = false;
}
}
function showAllGameUI() {
for (var i = 0; i < gameUIElements.length; i++) {
gameUIElements[i].visible = true;
}
}
function hideAllStoreUI() {
for (var i = 0; i < storeUIElements.length; i++) {
storeUIElements[i].destroy();
}
storeUIElements = [];
}
function hideAllSellUI() {
for (var i = 0; i < sellUIElements.length; i++) {
sellUIElements[i].destroy();
}
sellUIElements = [];
}
function hideAllBagUI() {
for (var i = 0; i < bagUIElements.length; i++) {
bagUIElements[i].destroy();
}
bagUIElements = [];
}
function hideAllInfoUI() {
for (var i = 0; i < infoUIElements.length; i++) {
infoUIElements[i].destroy();
}
infoUIElements = [];
}
function updateNicknameDisplay() {
var currentLetter = alphabet[currentLetterIndex];
var displayText = 'Enter Nickname: ' + playerNickname + currentLetter;
nicknameText.setText(displayText);
// Update instruction text to show current letter selection
instructionText.setText('Current Letter: ' + currentLetter + ' - Use arrows to select, ADD to add, DELETE to remove');
}
function startLevel(levelNumber) {
// Clean up previous level
if (currentLevel) {
currentLevel.destroy();
}
currentLevelNumber = levelNumber;
storage.currentLevelNumber = currentLevelNumber;
levelTimer = 0;
// Reset SPINO usage for new level
storage.spinoUsedThisLevel = false;
// No special ability resets needed for original abilities
// Create new level
currentLevel = new Level(levelNumber);
currentLevel.createLevel();
game.addChild(currentLevel);
levelText.setText('Level: ' + levelNumber + '/' + maxLevels);
}
function startPuzzleLevel(levelNumber) {
// Clean up previous level
if (currentLevel) {
currentLevel.destroy();
}
if (currentPuzzle) {
currentPuzzle.destroy();
}
currentLevelNumber = levelNumber;
storage.currentLevelNumber = currentLevelNumber;
levelTimer = 0;
levelText.setText('Level: ' + levelNumber + ' (PUZZLE)');
// Create dinosaur trivia puzzle
createPuzzle(0, levelNumber);
}
function createPuzzle(puzzleType, levelNumber) {
currentPuzzle = new Container();
game.addChild(currentPuzzle);
// All puzzles are now dinosaur trivia questions
createDinosaurTriviaPuzzle(levelNumber);
}
function createDinosaurTriviaPuzzle(levelNumber) {
// Create diverse trivia questions with increasing difficulty based on level
var triviaQuestions = [
// Levels 10-30: Basic questions about size, strength, and diet
{
question: "T-Rex'in ısırma gücü ne kadardı?",
answers: ["5,000 PSI", "12,800 PSI", "20,000 PSI"],
correct: 1,
minLevel: 10
}, {
question: "Spinosaurus nasıl yaşardı?",
answers: ["Sadece karada", "Yarı suda yarı karada", "Sadece suda"],
correct: 1,
minLevel: 10
}, {
question: "Giganotosaurus nasıl savaşırdı?",
answers: ["Tek başına", "Grup halinde", "Hiç savaşmazdı"],
correct: 1,
minLevel: 20
}, {
question: "Triceratops'un frill'i ne için kullanılırdı?",
answers: ["Sadece savunma", "Gösteriş ve termoregülasyon", "Uçmak için"],
correct: 1,
minLevel: 20
}, {
question: "Parasaurolophus nasıl iletişim kurardı?",
answers: ["Çıkardığı seslerle", "Renk değiştirerek", "Dans ederek"],
correct: 0,
minLevel: 20
}, {
question: "Allosaurus'un avlama stratejisi neydi?",
answers: ["Hızlı saldırı", "Pusu kurma", "Grup avcılığı"],
correct: 0,
minLevel: 30
},
// Levels 40-70: Intermediate questions about behavior and abilities
{
question: "Velociraptor'un en büyük avantajı neydi?",
answers: ["Büyüklüğü", "Zekası ve çevikliği", "Uçma yeteneği"],
correct: 1,
minLevel: 40
}, {
question: "Baryonyx'in özel beslenme adaptasyonu neydi?",
answers: ["Timsah benzeri çene", "Uzun boyun", "Güçlü bacaklar"],
correct: 0,
minLevel: 40
}, {
question: "Dimetrodon'un sırtındaki yelken ne işe yarardı?",
answers: ["Uçmak için", "Vücut ısısını düzenlemek", "Yüzmek için"],
correct: 1,
minLevel: 50
}, {
question: "Carnotaurus'un koşu hızı ne kadardı?",
answers: ["25 km/s", "55 km/s", "80 km/s"],
correct: 1,
minLevel: 50
}, {
question: "Therizinosaurus'un dev pençeleri ne için kullanılırdı?",
answers: ["Avlamak için", "Bitki toplamak için", "Savaşmak için"],
correct: 1,
minLevel: 60
}, {
question: "Utahraptor'un avlama taktiği neydi?",
answers: ["Tek başına saldırı", "Grup koordinasyonu", "Zehirli ısırık"],
correct: 1,
minLevel: 70
},
// Levels 80-120: Advanced questions about combat and survival
{
question: "Ankylosaurus nasıl kendini savunurdu?",
answers: ["Hızla kaçarak", "Zırhlı vücut ve kuyruk sopası", "Yüksek yerlere tırmanarak"],
correct: 1,
minLevel: 80
}, {
question: "Dilophosaurus'un gerçek silahı neydi?",
answers: ["Zehirli tükürük", "Güçlü çeneleri", "Hızlı pençeleri"],
correct: 1,
minLevel: 80
}, {
question: "Compsognathus'un hayatta kalma stratejisi neydi?",
answers: ["Büyük boyut", "Hız ve çeviklik", "Zehirli ısırık"],
correct: 1,
minLevel: 90
}, {
question: "Stegosaurus'un kuyruk dikenleri nasıl kullanılırdı?",
answers: ["Savunma silahı olarak", "Termoregülasyon için", "Çiftleşme gösterisi"],
correct: 0,
minLevel: 100
}, {
question: "Maiasaura nasıl ebeveynlik yapardı?",
answers: ["Yumurtaları terk ederdi", "Yuva yapıp yavrularını beslerdi", "Sadece erkekler bakardı"],
correct: 1,
minLevel: 110
}, {
question: "Microraptor'un uçma yeteneği nasıldı?",
answers: ["Mükemmel uçucu", "Sadece süzülme", "Hiç uçamaz"],
correct: 1,
minLevel: 120
},
// Levels 130-200: Expert questions about complex behaviors
{
question: "Orodromeus'un en büyük özelliği neydi?",
answers: ["Dev boyut", "İnanılmaz hız", "Güçlü pençeler"],
correct: 1,
minLevel: 130
}, {
question: "Amargasaurus'un boyun dikenleri ne işe yarardı?",
answers: ["Ses çıkarmak", "Savunma", "Gösteriş ve termoregülasyon"],
correct: 2,
minLevel: 140
}, {
question: "Ceratosaurus'un burun boynuzu ne için kullanılırdı?",
answers: ["Çiftleşme ritüelleri", "Savaş", "Her ikisi de"],
correct: 2,
minLevel: 150
}, {
question: "Diplodocus nasıl beslenirdi?",
answers: ["Yüksek ağaç dallarından", "Yerdeki bitkilerden", "Her iki şekilde de"],
correct: 2,
minLevel: 160
}, {
question: "Archaeopteryx'in evrimsel önemi nedir?",
answers: ["İlk dinozor", "Dinozor-kuş geçişi", "En büyük uçan hayvan"],
correct: 1,
minLevel: 170
}, {
question: "Saurophaganax'in avlama stratejisi neydi?",
answers: ["Gece avcılığı", "Su kenarında pusu", "Açık alanda hızlı saldırı"],
correct: 0,
minLevel: 180
}, {
question: "Dracorex'in kafatası yapısı neyi gösterir?",
answers: ["Savaşçı doğa", "Güçlü çene kasları", "Gösteriş amaçlı süsler"],
correct: 2,
minLevel: 190
}, {
question: "Carcharodontosaurus'un ısırma tekniği nasıldı?",
answers: ["Hızlı çoklu ısırık", "Tek güçlü ısırık", "Sallayarak parçalama"],
correct: 0,
minLevel: 200
}];
// Filter questions appropriate for current level
var availableQuestions = [];
for (var i = 0; i < triviaQuestions.length; i++) {
if (levelNumber >= triviaQuestions[i].minLevel) {
availableQuestions.push(triviaQuestions[i]);
}
}
// Select random question from available ones, or use stored question if retrying
var selectedQuestion;
if (storage.currentPuzzleQuestion) {
selectedQuestion = storage.currentPuzzleQuestion;
} else {
selectedQuestion = availableQuestions[Math.floor(Math.random() * availableQuestions.length)];
// Store the question for potential retries
storage.currentPuzzleQuestion = selectedQuestion;
}
// Create puzzle title
var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
// Display question
var questionText = new Text2(selectedQuestion.question, {
size: 50,
fill: '#FFFFFF'
});
questionText.anchor.set(0.5, 0.5);
questionText.x = 1024;
questionText.y = 600;
currentPuzzle.addChild(questionText);
puzzleUIElements.push(questionText);
// Create answer buttons
for (var a = 0; a < 3; a++) {
var answerButton = currentPuzzle.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
answerButton.x = 1024;
answerButton.y = 900 + a * 150;
currentPuzzle.addChild(answerButton);
puzzleUIElements.push(answerButton);
var answerText = new Text2(selectedQuestion.answers[a], {
size: 40,
fill: '#FFFFFF'
});
answerText.anchor.set(0.5, 0.5);
answerText.x = 1024;
answerText.y = 900 + a * 150;
currentPuzzle.addChild(answerText);
puzzleUIElements.push(answerText);
// Add click handler with closure
(function (answerIndex, correctIndex) {
answerButton.down = function () {
if (answerIndex === correctIndex) {
solvePuzzle();
} else {
resetTriviaPuzzle();
}
};
})(a, selectedQuestion.correct);
}
}
function resetTriviaPuzzle() {
// Keep the same question - just reset the UI and regenerate with same question
if (currentPuzzle) {
currentPuzzle.destroy();
}
hideAllPuzzleUI();
// Store the current question before recreating
var storedQuestion = storage.currentPuzzleQuestion || null;
// Create new puzzle container
currentPuzzle = new Container();
game.addChild(currentPuzzle);
// If we have a stored question, use it, otherwise generate new one
if (storedQuestion) {
createStoredTriviaPuzzle(storedQuestion);
} else {
createDinosaurTriviaPuzzle(currentLevelNumber);
}
}
function createSequencePuzzle(levelNumber) {
// Sequence puzzle: Click fossils in correct order
var puzzleTitle = new Text2('SEQUENCE PUZZLE - Click fossils in order!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var sequenceLength = Math.min(3 + Math.floor(levelNumber / 30), 8); // Longer sequences for higher levels
var correctSequence = [];
var playerSequence = [];
var fossils = [];
// Create sequence of fossils
for (var i = 0; i < sequenceLength; i++) {
var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), {
anchorX: 0.5,
anchorY: 0.5
});
fossil.x = 300 + i * 150;
fossil.y = 800;
fossil.sequenceNumber = i + 1;
fossils.push(fossil);
correctSequence.push(i);
puzzleUIElements.push(fossil);
var numberText = new Text2(String(i + 1), {
size: 40,
fill: '#FFFFFF'
});
numberText.anchor.set(0.5, 0.5);
numberText.x = fossil.x;
numberText.y = fossil.y - 80;
currentPuzzle.addChild(numberText);
puzzleUIElements.push(numberText);
// Add click handler
(function (index, fossilObj) {
fossilObj.down = function () {
playerSequence.push(index);
fossilObj.alpha = 0.5;
if (playerSequence.length === sequenceLength) {
checkSequence();
}
};
})(i, fossil);
}
function checkSequence() {
var correct = true;
for (var i = 0; i < sequenceLength; i++) {
if (playerSequence[i] !== correctSequence[i]) {
correct = false;
break;
}
}
if (correct) {
solvePuzzle();
} else {
resetSequencePuzzle();
}
}
function resetSequencePuzzle() {
playerSequence = [];
for (var i = 0; i < fossils.length; i++) {
fossils[i].alpha = 1;
}
}
}
function createPatternPuzzle(levelNumber) {
// Pattern puzzle: Complete the fossil pattern
var puzzleTitle = new Text2('PATTERN PUZZLE - Complete the pattern!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var gridSize = Math.min(3 + Math.floor(levelNumber / 50), 5); // Larger grids for higher levels
var pattern = [];
var playerPattern = [];
// Generate pattern
for (var i = 0; i < gridSize * gridSize; i++) {
pattern.push(Math.random() > 0.5 ? 1 : 0);
}
// Show pattern briefly, then hide half of it
for (var row = 0; row < gridSize; row++) {
for (var col = 0; col < gridSize; col++) {
var index = row * gridSize + col;
var shouldShow = pattern[index] === 1;
var isHidden = (row + col) % 2 === 1; // Checkerboard hiding pattern
var fossil = null;
if (shouldShow && !isHidden) {
fossil = currentPuzzle.attachAsset('fossil1', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (shouldShow && isHidden) {
fossil = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
fossil.isHiddenPattern = true;
fossil.correctPattern = true;
} else if (isHidden) {
fossil = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
fossil.isHiddenPattern = true;
fossil.correctPattern = false;
}
if (fossil) {
fossil.x = 700 + col * 100;
fossil.y = 600 + row * 100;
fossil.gridIndex = index;
puzzleUIElements.push(fossil);
if (fossil.isHiddenPattern) {
(function (fossilObj) {
fossilObj.down = function () {
if (fossilObj.correctPattern) {
fossilObj.destroy();
var correctFossil = currentPuzzle.attachAsset('fossil1', {
anchorX: 0.5,
anchorY: 0.5
});
correctFossil.x = fossilObj.x;
correctFossil.y = fossilObj.y;
currentPuzzle.addChild(correctFossil);
checkPatternComplete();
} else {
resetPatternPuzzle();
}
};
})(fossil);
}
}
}
}
}
function checkPatternComplete() {
// Simple check - if we get here from correct clicks, puzzle is solved
solvePuzzle();
}
function resetPatternPuzzle() {
// Reset puzzle on wrong click
createPatternPuzzle(currentLevelNumber);
}
function createMemoryPuzzle(levelNumber) {
// Memory puzzle: Remember fossil locations
var puzzleTitle = new Text2('MEMORY PUZZLE - Remember the fossil locations!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
var fossilCount = Math.min(3 + Math.floor(levelNumber / 40), 6);
var memoryPositions = [];
var revealedFossils = [];
// Generate random positions
for (var i = 0; i < fossilCount; i++) {
var pos = {
x: 400 + Math.floor(Math.random() * 5) * 150,
y: 600 + Math.floor(Math.random() * 3) * 150
};
memoryPositions.push(pos);
var fossil = currentPuzzle.attachAsset('fossil' + (i % 3 + 1), {
anchorX: 0.5,
anchorY: 0.5
});
fossil.x = pos.x;
fossil.y = pos.y;
fossil.memoryIndex = i;
currentPuzzle.addChild(fossil);
revealedFossils.push(fossil);
puzzleUIElements.push(fossil);
}
// Hide fossils after showing them briefly
LK.setTimeout(function () {
for (var i = 0; i < revealedFossils.length; i++) {
revealedFossils[i].alpha = 0;
}
createMemoryGrid();
}, 2000);
function createMemoryGrid() {
var playerGuesses = 0;
var correctGuesses = 0;
for (var row = 0; row < 3; row++) {
for (var col = 0; col < 5; col++) {
var gridX = 400 + col * 150;
var gridY = 600 + row * 150;
var isCorrectPos = false;
for (var p = 0; p < memoryPositions.length; p++) {
if (memoryPositions[p].x === gridX && memoryPositions[p].y === gridY) {
isCorrectPos = true;
break;
}
}
var gridBlock = currentPuzzle.attachAsset('limestone', {
anchorX: 0.5,
anchorY: 0.5
});
gridBlock.x = gridX;
gridBlock.y = gridY;
gridBlock.isCorrectMemory = isCorrectPos;
currentPuzzle.addChild(gridBlock);
puzzleUIElements.push(gridBlock);
(function (blockObj) {
blockObj.down = function () {
playerGuesses++;
if (blockObj.isCorrectMemory) {
correctGuesses++;
blockObj.tint = 0x00FF00; // Green for correct
} else {
blockObj.tint = 0xFF0000; // Red for wrong
}
if (playerGuesses === fossilCount) {
if (correctGuesses === fossilCount) {
solvePuzzle();
} else {
resetMemoryPuzzle();
}
}
};
})(gridBlock);
}
}
}
}
function resetMemoryPuzzle() {
createMemoryPuzzle(currentLevelNumber);
}
function createLogicPuzzle(levelNumber) {
// Logic puzzle: Mathematical sequence
var puzzleTitle = new Text2('LOGIC PUZZLE - Complete the sequence!', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
// Generate arithmetic sequence
var startNum = Math.floor(Math.random() * 10) + 1;
var step = Math.floor(Math.random() * 5) + 2;
var sequence = [startNum, startNum + step, startNum + step * 2, startNum + step * 3];
var missingIndex = Math.floor(Math.random() * 4);
var correctAnswer = sequence[missingIndex];
// Display sequence with missing number
for (var i = 0; i < 4; i++) {
var numText;
if (i === missingIndex) {
numText = new Text2('?', {
size: 80,
fill: '#FF0000'
});
} else {
numText = new Text2(String(sequence[i]), {
size: 80,
fill: '#FFFFFF'
});
}
numText.anchor.set(0.5, 0.5);
numText.x = 600 + i * 150;
numText.y = 700;
currentPuzzle.addChild(numText);
puzzleUIElements.push(numText);
}
// Create answer options
var options = [correctAnswer];
for (var j = 0; j < 3; j++) {
var wrongAnswer;
do {
wrongAnswer = correctAnswer + (Math.floor(Math.random() * 10) - 5);
} while (options.indexOf(wrongAnswer) !== -1 || wrongAnswer <= 0);
options.push(wrongAnswer);
}
// Shuffle options
for (var k = options.length - 1; k > 0; k--) {
var randomIndex = Math.floor(Math.random() * (k + 1));
var temp = options[k];
options[k] = options[randomIndex];
options[randomIndex] = temp;
}
// Display options
for (var o = 0; o < options.length; o++) {
var optionButton = currentPuzzle.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
optionButton.x = 500 + o * 200;
optionButton.y = 1000;
currentPuzzle.addChild(optionButton);
puzzleUIElements.push(optionButton);
var optionText = new Text2(String(options[o]), {
size: 60,
fill: '#FFFFFF'
});
optionText.anchor.set(0.5, 0.5);
optionText.x = optionButton.x;
optionText.y = optionButton.y;
currentPuzzle.addChild(optionText);
puzzleUIElements.push(optionText);
(function (answer) {
optionButton.down = function () {
if (answer === correctAnswer) {
solvePuzzle();
} else {
resetLogicPuzzle();
}
};
})(options[o]);
}
}
function resetLogicPuzzle() {
createLogicPuzzle(currentLevelNumber);
}
function solvePuzzle() {
// Award bonus points for solving puzzle
var puzzleBonus = 1000 * Math.floor(currentLevelNumber / 15);
LK.setScore(LK.getScore() + puzzleBonus);
scoreText.setText('Score: ' + LK.getScore());
// Clear stored puzzle question since it was solved correctly
storage.currentPuzzleQuestion = null;
// Clean up puzzle
hideAllPuzzleUI();
currentPuzzle.destroy();
currentPuzzle = null;
// Continue to regular level
startLevel(currentLevelNumber);
}
function hideAllPuzzleUI() {
for (var i = 0; i < puzzleUIElements.length; i++) {
puzzleUIElements[i].destroy();
}
puzzleUIElements = [];
}
function showStore() {
gameState = 'store';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create store display
var storeTitle = new Text2('FOSSIL STORE', {
size: 80,
fill: '#FFFFFF'
});
storeTitle.anchor.set(0.5, 0.5);
storeTitle.x = 1024;
storeTitle.y = 200;
game.addChild(storeTitle);
storeUIElements.push(storeTitle);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1500;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1500;
game.addChild(backButtonText);
storeUIElements.push(backButton, backButtonText);
// Sort and display inventory by rarity
var rareFossils = [];
var commonFossils = [];
for (var i = 0; i < playerInventory.length; i++) {
if (fossilRarities[playerInventory[i]] === 'rare') {
rareFossils.push(playerInventory[i]);
} else {
commonFossils.push(playerInventory[i]);
}
}
var allFossils = rareFossils.concat(commonFossils);
var startY = 350;
for (var j = 0; j < allFossils.length; j++) {
var fossilName = allFossils[j];
var rarity = fossilRarities[fossilName];
var color = rarity === 'rare' ? '#FFD700' : '#FFFFFF';
var fossilText = new Text2(fossilName + ' (' + rarity + ')', {
size: 40,
fill: color
});
fossilText.anchor.set(0.5, 0.5);
fossilText.x = 1024;
fossilText.y = startY + j * 60;
game.addChild(fossilText);
storeUIElements.push(fossilText);
}
backButton.down = function () {
hideStore();
};
}
function hideStore() {
gameState = 'nickname';
// Remove all store UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
}
function showSell() {
gameState = 'sell';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create sell display
var sellTitle = new Text2('SELL FOSSILS', {
size: 80,
fill: '#FFFFFF'
});
sellTitle.anchor.set(0.5, 0.5);
sellTitle.x = 1024;
sellTitle.y = 200;
game.addChild(sellTitle);
sellUIElements.push(sellTitle);
var sellAllButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellAllButton.x = 1024;
sellAllButton.y = 1400;
var sellAllButtonText = new Text2('SELL ALL', {
size: 35,
fill: '#FFFFFF'
});
sellAllButtonText.anchor.set(0.5, 0.5);
sellAllButtonText.x = 1024;
sellAllButtonText.y = 1400;
game.addChild(sellAllButtonText);
sellUIElements.push(sellAllButton, sellAllButtonText);
var sellBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
sellBackButton.x = 1024;
sellBackButton.y = 1600;
var sellBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
sellBackButtonText.anchor.set(0.5, 0.5);
sellBackButtonText.x = 1024;
sellBackButtonText.y = 1600;
game.addChild(sellBackButtonText);
// Add 2X MONEY use button
var use2xMoneyButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
use2xMoneyButton.x = 1024;
use2xMoneyButton.y = 1500;
var use2xMoneyButtonText = new Text2('2X MONEY (' + doubleMoneyLevelsLeft + ')', {
size: 35,
fill: '#FFFFFF'
});
use2xMoneyButtonText.anchor.set(0.5, 0.5);
use2xMoneyButtonText.x = 1024;
use2xMoneyButtonText.y = 1500;
game.addChild(use2xMoneyButtonText);
sellUIElements.push(sellBackButton, sellBackButtonText, use2xMoneyButton, use2xMoneyButtonText);
// Calculate total value
var totalValue = 0;
for (var i = 0; i < playerInventory.length; i++) {
var fossilValue = fossilValues[playerInventory[i]];
if (doubleValueActive) {
fossilValue *= 2;
}
totalValue += fossilValue;
}
var totalValueText = new Text2('Total Value: ' + totalValue + ' coins', {
size: 50,
fill: '#FFD700'
});
totalValueText.anchor.set(0.5, 0.5);
totalValueText.x = 1024;
totalValueText.y = 300;
game.addChild(totalValueText);
sellUIElements.push(totalValueText);
sellAllButton.down = function () {
playerCoins += totalValue;
playerInventory = [];
// Reset 2X VALUE effect after use
if (doubleValueActive) {
doubleValueActive = false;
storage.doubleValueActive = doubleValueActive;
}
storage.playerCoins = playerCoins;
storage.playerInventory = playerInventory;
hideSell();
};
use2xMoneyButton.down = function () {
if (doubleMoneyLevelsLeft > 0) {
// Activate 2X MONEY effect for selling
doubleValueActive = true;
storage.doubleValueActive = doubleValueActive;
// Update button text to show remaining uses
use2xMoneyButtonText.setText('2X MONEY (' + doubleMoneyLevelsLeft + ')');
// Recalculate and update total value display
var newTotalValue = 0;
for (var i = 0; i < playerInventory.length; i++) {
var fossilValue = fossilValues[playerInventory[i]];
if (doubleValueActive) {
fossilValue *= 2;
}
newTotalValue += fossilValue;
}
totalValueText.setText('Total Value: ' + newTotalValue + ' coins');
}
};
sellBackButton.down = function () {
hideSell();
};
}
function hideSell() {
gameState = 'nickname';
// Remove all sell UI elements
hideAllSellUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showShop() {
gameState = 'shop';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create shop display
var shopTitle = new Text2('POWER-UP SHOP', {
size: 80,
fill: '#FFFFFF'
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 200;
game.addChild(shopTitle);
storeUIElements.push(shopTitle);
// XRAY Power-up
var xrayButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
xrayButton.x = 1024;
xrayButton.y = 400;
var xrayText = new Text2('XRAY - 500 Coins\nReveals all fossils for 1 level', {
size: 35,
fill: '#FFFFFF'
});
xrayText.anchor.set(0.5, 0.5);
xrayText.x = 1024;
xrayText.y = 400;
// 2X MONEY Power-up
var doubleMoneyButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
doubleMoneyButton.x = 1024;
doubleMoneyButton.y = 550;
var doubleMoneyText = new Text2('2X MONEY - 3250 Coins\nDouble money from fossils', {
size: 35,
fill: '#FFFFFF'
});
doubleMoneyText.anchor.set(0.5, 0.5);
doubleMoneyText.x = 1024;
doubleMoneyText.y = 550;
// 2X VALUE Power-up
var doubleValueButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
doubleValueButton.x = 1024;
doubleValueButton.y = 700;
var doubleValueText = new Text2('2X LUCK - 1250 Coins\nDouble egg chances', {
size: 35,
fill: '#FFFFFF'
});
doubleValueText.anchor.set(0.5, 0.5);
doubleValueText.x = 1024;
doubleValueText.y = 700;
// Common Egg
var commonEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
commonEggButton.x = 1024;
commonEggButton.y = 1400;
var commonEggText = new Text2('Sıradan Yumurta - 500 Coins\nCommon fossil guaranteed', {
size: 35,
fill: '#FFFFFF'
});
commonEggText.anchor.set(0.5, 0.5);
commonEggText.x = 1024;
commonEggText.y = 1400;
// Common Egg Info Button
var commonEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
commonEggInfoButton.anchor.set(0.5, 0.5);
commonEggInfoButton.x = 1350;
commonEggInfoButton.y = 1400;
game.addChild(commonEggInfoButton);
// Rare Egg
var rareEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
rareEggButton.x = 1024;
rareEggButton.y = 1550;
var rareEggText = new Text2('Nadir Yumurta - 2000 Coins\nRare fossil guaranteed', {
size: 35,
fill: '#FFD700'
});
rareEggText.anchor.set(0.5, 0.5);
rareEggText.x = 1024;
rareEggText.y = 1550;
// Rare Egg Info Button
var rareEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
rareEggInfoButton.anchor.set(0.5, 0.5);
rareEggInfoButton.x = 1350;
rareEggInfoButton.y = 1550;
game.addChild(rareEggInfoButton);
// Legendary Egg
var legendaryEggButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
legendaryEggButton.x = 1024;
legendaryEggButton.y = 1700;
var legendaryEggText = new Text2('Destansı - 10000 Coins\nLegendary guaranteed', {
size: 35,
fill: '#FF69B4'
});
legendaryEggText.anchor.set(0.5, 0.5);
legendaryEggText.x = 1024;
legendaryEggText.y = 1700;
// Legendary Egg Info Button
var legendaryEggInfoButton = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
legendaryEggInfoButton.anchor.set(0.5, 0.5);
legendaryEggInfoButton.x = 1350;
legendaryEggInfoButton.y = 1700;
game.addChild(legendaryEggInfoButton);
// FEED button to navigate to food section
var feedSectionButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
feedSectionButton.x = 1024;
feedSectionButton.y = 1000;
var feedSectionButtonText = new Text2('FEED', {
size: 35,
fill: '#FFFFFF'
});
feedSectionButtonText.anchor.set(0.5, 0.5);
feedSectionButtonText.x = 1024;
feedSectionButtonText.y = 1000;
// Back button
var shopBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
shopBackButton.x = 1024;
shopBackButton.y = 1150;
var shopBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
shopBackButtonText.anchor.set(0.5, 0.5);
shopBackButtonText.x = 1024;
shopBackButtonText.y = 1150;
game.addChild(xrayText);
game.addChild(doubleMoneyText);
game.addChild(doubleValueText);
game.addChild(commonEggText);
game.addChild(rareEggText);
game.addChild(legendaryEggText);
game.addChild(feedSectionButtonText);
game.addChild(shopBackButtonText);
storeUIElements.push(xrayButton, xrayText, doubleMoneyButton, doubleMoneyText, doubleValueButton, doubleValueText, commonEggButton, commonEggText, commonEggInfoButton, rareEggButton, rareEggText, rareEggInfoButton, legendaryEggButton, legendaryEggText, legendaryEggInfoButton, feedSectionButton, feedSectionButtonText, shopBackButton, shopBackButtonText);
// Purchase handlers
xrayButton.down = function () {
if (playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
xrayLevelsLeft++;
storage.xrayLevelsLeft = xrayLevelsLeft;
hideShop();
}
};
doubleMoneyButton.down = function () {
if (playerCoins >= 3250) {
playerCoins -= 3250;
storage.playerCoins = playerCoins;
doubleMoneyLevelsLeft = 999999; // Permanent 2X money effect
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
hideShop();
}
};
doubleValueButton.down = function () {
if (playerCoins >= 1250) {
playerCoins -= 1250;
storage.playerCoins = playerCoins;
doubleSpawnChanceActive = true;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
hideShop();
}
};
// Common egg info handler
commonEggInfoButton.down = function () {
showCommonEggInfo();
};
// Egg purchase handlers
commonEggButton.down = function () {
if (playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
// Open common egg and get dinosaur
var dinosaurName = openEgg('common');
}
};
// Rare egg info handler
rareEggInfoButton.down = function () {
showRareEggInfo();
};
rareEggButton.down = function () {
if (playerCoins >= 2000) {
playerCoins -= 2000;
storage.playerCoins = playerCoins;
// Open rare egg and get dinosaur
var dinosaurName = openEgg('rare');
}
};
// Legendary egg info handler
legendaryEggInfoButton.down = function () {
showLegendaryEggInfo();
};
legendaryEggButton.down = function () {
if (playerCoins >= 10000) {
playerCoins -= 10000;
storage.playerCoins = playerCoins;
// Open legendary egg and get dinosaur
var dinosaurName = openEgg('legendary');
}
};
// FEED button click handler - navigate to food section
feedSectionButton.down = function () {
showFeedSection();
};
shopBackButton.down = function () {
hideShop();
};
}
function showFeedSection() {
gameState = 'feed';
// Hide all shop UI elements
hideAllStoreUI();
// Create feed section display
var feedTitle = new Text2('DİNOZOR YİYECEKLERİ', {
size: 80,
fill: '#FFFFFF'
});
feedTitle.anchor.set(0.5, 0.5);
feedTitle.x = 1024;
feedTitle.y = 200;
game.addChild(feedTitle);
storeUIElements.push(feedTitle);
// Dinosaur Food Items
var leafFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
leafFoodButton.x = 1024;
leafFoodButton.y = 400;
var leafFoodText = new Text2('Yaprak Paketi - 15 Coins\n5 adet yaprak (Otçul dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
leafFoodText.anchor.set(0.5, 0.5);
leafFoodText.x = 1024;
leafFoodText.y = 400;
// Add ❗ next to leaf food button
var leafFoodAlert = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
leafFoodAlert.anchor.set(0.5, 0.5);
leafFoodAlert.x = 1350;
leafFoodAlert.y = 400;
game.addChild(leafFoodAlert);
// Add click handler to show which dinosaurs eat leaves
leafFoodAlert.down = function () {
showFoodDinosaursInfo('leaf');
};
var meatFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
meatFoodButton.x = 1024;
meatFoodButton.y = 550;
var meatFoodText = new Text2('Et Paketi - 100 Coins\n5 adet et (Etçil dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
meatFoodText.anchor.set(0.5, 0.5);
meatFoodText.x = 1024;
meatFoodText.y = 550;
// Add ❗ next to meat food button
var meatFoodAlert = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
meatFoodAlert.anchor.set(0.5, 0.5);
meatFoodAlert.x = 1350;
meatFoodAlert.y = 550;
game.addChild(meatFoodAlert);
// Add click handler to show which dinosaurs eat meat
meatFoodAlert.down = function () {
showFoodDinosaursInfo('meat');
};
var fishFoodButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
fishFoodButton.x = 1024;
fishFoodButton.y = 700;
var fishFoodText = new Text2('Balık Paketi - 55 Coins\n5 adet balık (Balık yiyen dinozorlar)', {
size: 35,
fill: '#FFFFFF'
});
fishFoodText.anchor.set(0.5, 0.5);
fishFoodText.x = 1024;
fishFoodText.y = 700;
// Add ❗ next to fish food button
var fishFoodAlert = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
fishFoodAlert.anchor.set(0.5, 0.5);
fishFoodAlert.x = 1350;
fishFoodAlert.y = 700;
game.addChild(fishFoodAlert);
// Add click handler to show which dinosaurs eat fish
fishFoodAlert.down = function () {
showFoodDinosaursInfo('fish');
};
// Back to shop button
var backToShopButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backToShopButton.x = 1024;
backToShopButton.y = 850;
var backToShopButtonText = new Text2('SHOP\'A GERİ DÖN', {
size: 35,
fill: '#FFFFFF'
});
backToShopButtonText.anchor.set(0.5, 0.5);
backToShopButtonText.x = 1024;
backToShopButtonText.y = 850;
// Add BACK text above the back button, centered
var feedBackText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
feedBackText.anchor.set(0.5, 0.5);
feedBackText.x = 1024;
feedBackText.y = 800;
game.addChild(feedBackText);
game.addChild(leafFoodText);
game.addChild(meatFoodText);
game.addChild(fishFoodText);
game.addChild(backToShopButtonText);
storeUIElements.push(leafFoodButton, leafFoodText, leafFoodAlert, meatFoodButton, meatFoodText, meatFoodAlert, fishFoodButton, fishFoodText, fishFoodAlert, backToShopButton, backToShopButtonText, feedBackText);
// Food purchase handlers
leafFoodButton.down = function () {
if (playerCoins >= 15) {
playerCoins -= 15;
storage.playerCoins = playerCoins;
// Add 5 leaf food to inventory
leafFood += 5;
storage.leafFood = leafFood;
hideFeedSection();
}
};
meatFoodButton.down = function () {
if (playerCoins >= 100) {
playerCoins -= 100;
storage.playerCoins = playerCoins;
// Add 5 meat food to inventory
meatFood += 5;
storage.meatFood = meatFood;
hideFeedSection();
}
};
fishFoodButton.down = function () {
if (playerCoins >= 55) {
playerCoins -= 55;
storage.playerCoins = playerCoins;
// Add 5 fish food to inventory
fishFood += 5;
storage.fishFood = fishFood;
hideFeedSection();
}
};
backToShopButton.down = function () {
hideFeedSection();
showShop();
};
}
function hideFeedSection() {
gameState = 'nickname';
// Remove all feed UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function hideShop() {
gameState = 'nickname';
// Remove all shop UI elements
hideAllStoreUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showBag() {
gameState = 'bag';
// Check hunger status when opening bag
checkDinosaurHunger();
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create bag display
var bagTitle = new Text2('DINOSAUR BAG', {
size: 80,
fill: '#FFFFFF'
});
bagTitle.anchor.set(0.5, 0.5);
bagTitle.x = 1024;
bagTitle.y = 200;
game.addChild(bagTitle);
bagUIElements.push(bagTitle);
// Calculate vomit limit (1 base slot only)
var maxVomitSlots = 1;
var vomitText = new Text2('Select Slots: ' + maxVomitSlots + ' available', {
size: 35,
fill: '#FFD700'
});
vomitText.anchor.set(0.5, 0.5);
vomitText.x = 1024;
vomitText.y = 280;
game.addChild(vomitText);
// Add coins display in bag
var bagCoinsText = new Text2('Para: ' + playerCoins + ' coin', {
size: 35,
fill: '#FFD700'
});
bagCoinsText.anchor.set(0.5, 0.5);
bagCoinsText.x = 1024;
bagCoinsText.y = 320;
game.addChild(bagCoinsText);
// Add food inventory display
var foodInventoryText = new Text2('Yiyecekler: Yaprak(' + leafFood + ') Et(' + meatFood + ') Balık(' + fishFood + ')', {
size: 30,
fill: '#32CD32'
});
foodInventoryText.anchor.set(0.5, 0.5);
foodInventoryText.x = 1024;
foodInventoryText.y = 360;
game.addChild(foodInventoryText);
bagUIElements.push(vomitText, bagCoinsText, foodInventoryText);
// Get selected dinosaurs
var selectedDinosaurs = [];
if (storage.selectedDinosaurs && Array.isArray(storage.selectedDinosaurs)) {
selectedDinosaurs = storage.selectedDinosaurs;
} else if (selectedDinosaur) {
selectedDinosaurs = [selectedDinosaur];
}
// Sort dinosaurs by rarity
var chromaticDinos = [];
var legendaryDinos = [];
var rareDinos = [];
var commonDinos = [];
for (var i = 0; i < dinosaurCollection.length; i++) {
var dino = dinosaurCollection[i];
var rarity = dinosaurRarities[dino];
if (rarity === 'chromatic') {
chromaticDinos.push(dino);
} else if (rarity === 'legendary') {
legendaryDinos.push(dino);
} else if (rarity === 'rare') {
rareDinos.push(dino);
} else {
commonDinos.push(dino);
}
}
var allDinos = chromaticDinos.concat(legendaryDinos).concat(rareDinos).concat(commonDinos);
// Reorder dinosaurs to show selected ones at the bottom
var unselectedDinos = [];
var selectedDinosForDisplay = [];
for (var k = 0; k < allDinos.length; k++) {
if (selectedDinosaurs.indexOf(allDinos[k]) !== -1) {
selectedDinosForDisplay.push(allDinos[k]);
} else {
unselectedDinos.push(allDinos[k]);
}
}
var orderedDinos = unselectedDinos.concat(selectedDinosForDisplay);
// Display all dinosaurs - unlimited storage, but limited vomit selection
var startY = 480;
var itemSpacing = 120; // Increased spacing between dinosaur entries
for (var j = 0; j < orderedDinos.length; j++) {
var dinoName = orderedDinos[j];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic
else if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
var isSelected = selectedDinosaurs.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SELECTED]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + j * itemSpacing;
// Add dinosaur image
var dinoImage = new DinosaurImage(dinoName);
dinoImage.x = 700;
dinoImage.y = startY + j * itemSpacing;
dinoImage.scaleX = 0.8;
dinoImage.scaleY = 0.8;
game.addChild(dinoImage);
bagUIElements.push(dinoImage);
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelected ? '#000000' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + j * itemSpacing;
game.addChild(dinoText);
// Add hunger status and feeding button
var hungerStatus = getHungerStatus(dinoName);
var hungerText = getHungerText(hungerStatus);
var hungerColor = getHungerColor(hungerStatus);
var hungerDisplay = new Text2(hungerText, {
size: 25,
fill: hungerColor
});
hungerDisplay.anchor.set(0.5, 0.5);
hungerDisplay.x = 1024;
hungerDisplay.y = startY + j * itemSpacing + 30;
game.addChild(hungerDisplay);
// Add ❗ next to dinosaur for info (larger size)
var dinoInfoAlert = new Text2('❗', {
size: 60,
fill: '#FFD700'
});
dinoInfoAlert.anchor.set(0.5, 0.5);
dinoInfoAlert.x = 1448;
dinoInfoAlert.y = startY + j * itemSpacing;
game.addChild(dinoInfoAlert);
bagUIElements.push(dinoButton, dinoText, hungerDisplay, dinoInfoAlert);
// Create closure for dinosaur info
(function (dinosaurName) {
dinoInfoAlert.down = function () {
showDinosaurInfo(dinosaurName);
};
})(dinoName);
// Create closure for selection - check vomit limit
(function (dinosaurName) {
dinoButton.down = function () {
var currentIndex = selectedDinosaurs.indexOf(dinosaurName);
if (currentIndex !== -1) {
// Remove from selection
selectedDinosaurs.splice(currentIndex, 1);
} else {
// Check if player can select dinosaurs - everyone gets 1 base slot only
// If at selection limit, replace the first selected dinosaur
if (selectedDinosaurs.length >= maxVomitSlots) {
selectedDinosaurs.shift(); // Remove first selected dinosaur
}
selectedDinosaurs.push(dinosaurName); // Add new selection
}
// Update storage and backward compatibility
storage.selectedDinosaurs = selectedDinosaurs;
if (selectedDinosaurs.length > 0) {
selectedDinosaur = selectedDinosaurs[0]; // Keep backward compatibility
storage.selectedDinosaur = selectedDinosaur;
} else {
selectedDinosaur = null;
storage.selectedDinosaur = null;
}
hideBag();
showBag(); // Refresh to show selected at bottom
};
})(dinoName);
}
// Back button
// Delete button
var deleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
deleteButton.x = 700;
deleteButton.y = startY + orderedDinos.length * itemSpacing + 150;
var deleteButtonText = new Text2('DELETE', {
size: 35,
fill: '#FFFFFF'
});
deleteButtonText.anchor.set(0.5, 0.5);
deleteButtonText.x = 700;
deleteButtonText.y = startY + orderedDinos.length * itemSpacing + 150;
game.addChild(deleteButtonText);
bagUIElements.push(deleteButton, deleteButtonText);
var bagBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
bagBackButton.x = 1348;
bagBackButton.y = startY + orderedDinos.length * itemSpacing + 150;
var bagBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
bagBackButtonText.anchor.set(0.5, 0.5);
bagBackButtonText.x = 1348;
bagBackButtonText.y = startY + orderedDinos.length * itemSpacing + 150;
game.addChild(bagBackButtonText);
bagUIElements.push(bagBackButton, bagBackButtonText);
// Delete button handler
deleteButton.down = function () {
showDeleteMode();
};
bagBackButton.down = function () {
hideBag();
};
}
function showDeleteMode() {
gameState = 'deleteMode';
// Hide current bag UI
hideAllBagUI();
// Create delete mode display
var deleteTitle = new Text2('DELETE DINOSAURS', {
size: 80,
fill: '#FF4444'
});
deleteTitle.anchor.set(0.5, 0.5);
deleteTitle.x = 1024;
deleteTitle.y = 200;
game.addChild(deleteTitle);
bagUIElements.push(deleteTitle);
var deleteInstructionText = new Text2('Select dinosaurs to delete:', {
size: 50,
fill: '#FFFFFF'
});
deleteInstructionText.anchor.set(0.5, 0.5);
deleteInstructionText.x = 1024;
deleteInstructionText.y = 280;
game.addChild(deleteInstructionText);
bagUIElements.push(deleteInstructionText);
// Sort dinosaurs by rarity for display
var legendaryDinos = [];
var rareDinos = [];
var commonDinos = [];
for (var i = 0; i < dinosaurCollection.length; i++) {
var dino = dinosaurCollection[i];
var rarity = dinosaurRarities[dino];
if (rarity === 'legendary') {
legendaryDinos.push(dino);
} else if (rarity === 'rare') {
rareDinos.push(dino);
} else {
commonDinos.push(dino);
}
}
var allDinos = legendaryDinos.concat(rareDinos).concat(commonDinos);
// Track selected dinosaurs for deletion
var selectedForDeletion = [];
// Display all dinosaurs with delete option
var startY = 410;
var itemSpacing = 120; // Increased spacing between dinosaur entries
for (var j = 0; j < allDinos.length; j++) {
var dinoName = allDinos[j];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
var isSelectedForDeletion = selectedForDeletion.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelectedForDeletion ? ' [TO DELETE]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + j * itemSpacing;
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelectedForDeletion ? '#FF4444' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + j * itemSpacing;
game.addChild(dinoText);
bagUIElements.push(dinoButton, dinoText);
// Create closure for selection toggle
(function (dinosaurName, textElement) {
dinoButton.down = function () {
var index = selectedForDeletion.indexOf(dinosaurName);
if (index === -1) {
// Add to deletion list
selectedForDeletion.push(dinosaurName);
textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [TO DELETE]');
textElement.fill = '#FF4444';
} else {
// Remove from deletion list
selectedForDeletion.splice(index, 1);
var rarity = dinosaurRarities[dinosaurName];
var color = '#87CEEB'; // Light blue for common/regular dinosaurs
if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
textElement.setText(dinosaurName + ' (' + rarity + ')');
textElement.fill = color;
}
};
})(dinoName, dinoText);
}
// Confirm delete button
var confirmDeleteButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
confirmDeleteButton.x = 700;
confirmDeleteButton.y = startY + allDinos.length * itemSpacing + 100;
var confirmDeleteText = new Text2('CONFIRM DELETE', {
size: 30,
fill: '#FFFFFF'
});
confirmDeleteText.anchor.set(0.5, 0.5);
confirmDeleteText.x = 700;
confirmDeleteText.y = startY + allDinos.length * itemSpacing + 100;
game.addChild(confirmDeleteText);
bagUIElements.push(confirmDeleteButton, confirmDeleteText);
// Cancel delete button
var cancelDeleteButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
cancelDeleteButton.x = 1348;
cancelDeleteButton.y = startY + allDinos.length * itemSpacing + 100;
var cancelDeleteText = new Text2('CANCEL', {
size: 35,
fill: '#FFFFFF'
});
cancelDeleteText.anchor.set(0.5, 0.5);
cancelDeleteText.x = 1348;
cancelDeleteText.y = startY + allDinos.length * itemSpacing + 100;
game.addChild(cancelDeleteText);
bagUIElements.push(cancelDeleteButton, cancelDeleteText);
// Event handlers
confirmDeleteButton.down = function () {
// Remove selected dinosaurs from collection
for (var i = 0; i < selectedForDeletion.length; i++) {
var dinoToDelete = selectedForDeletion[i];
var index = dinosaurCollection.indexOf(dinoToDelete);
if (index !== -1) {
dinosaurCollection.splice(index, 1);
// If deleted dinosaur was selected, clear selection
if (selectedDinosaur === dinoToDelete) {
selectedDinosaur = null;
storage.selectedDinosaur = null;
}
}
}
// Save updated collection
storage.dinosaurCollection = dinosaurCollection;
// Return to bag view
hideAllBagUI();
showBag();
};
cancelDeleteButton.down = function () {
// Return to bag view without deleting
hideAllBagUI();
showBag();
};
}
function hideBag() {
gameState = 'nickname';
// Remove all bag UI elements
hideAllBagUI();
// Restore menu UI elements
showAllMenuUI();
}
function showCommonEggInfo() {
gameState = 'commonEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('SIRADAN YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'PARASOUROLUPHUS - %33.3\n';
infoText += 'Yavaş kazma (1 saniye gecikme)\n\n';
infoText += 'TRICERATOPS - %33.3\n';
infoText += 'Kafa darbesi: 5 bloku 2 tıklamaya indirir\n\n';
infoText += 'ANKYLOSAURUS - %33.3\n';
infoText += 'Kuyruk darbesi: 4 bloku 1 tıklamaya indirir';
var infoDisplay = new Text2(infoText, {
size: 40,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 600;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function showRareEggInfo() {
gameState = 'rareEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('NADİR YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'BARYONYX - %45\n';
infoText += '0.2x daha hızlı kaya kazma\n\n';
infoText += 'ALLO - %35\n';
infoText += '0.4x daha hızlı kaya kazma\n\n';
infoText += 'YUTY - %20\n';
infoText += '0.7x daha hızlı kaya kazma';
var infoDisplay = new Text2(infoText, {
size: 40,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 600;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function showLegendaryEggInfo() {
gameState = 'legendaryEggInfo';
// Hide all shop UI elements
hideAllStoreUI();
// Create info display
var infoTitle = new Text2('DESTANSI YUMURTA İÇERİĞİ', {
size: 60,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
var infoText = 'TREX - %3 (Chromatic)\n';
infoText += '??? ??? ???\n\n';
infoText += 'SPINO - %15\n';
infoText += '?\n\n';
infoText += 'GIGA - %22\n';
infoText += '?\n\n';
infoText += 'Mutasyonlu BARYONYX - %30\n';
infoText += '?\n\n';
infoText += 'Mutasyonlu PARASAUROLUPHUS - %30\n';
infoText += '?';
// Add animated color-changing question marks for TREX ability
var trexQuestionMarks = [];
for (var q = 0; q < 3; q++) {
var questionMark = new Text2('?', {
size: 40,
fill: getRandomColor()
});
questionMark.anchor.set(0.5, 0.5);
questionMark.x = 950 + q * 40;
questionMark.y = 450;
game.addChild(questionMark);
infoUIElements.push(questionMark);
trexQuestionMarks.push(questionMark);
}
// Animate color changes for question marks
var colorChangeTimer = LK.setInterval(function () {
for (var i = 0; i < trexQuestionMarks.length; i++) {
tween(trexQuestionMarks[i], {
fill: getRandomColor()
}, {
duration: 500
});
}
}, 600);
// Store timer reference to clear it when hiding info screen
infoUIElements.colorChangeTimer = colorChangeTimer;
var infoDisplay = new Text2(infoText, {
size: 30,
fill: '#FFFFFF'
});
infoDisplay.anchor.set(0.5, 0.5);
infoDisplay.x = 1024;
infoDisplay.y = 700;
game.addChild(infoDisplay);
infoUIElements.push(infoDisplay);
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1200;
var backButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1200;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showShop();
};
}
function getRandomColor() {
var colors = ['#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#0000FF', '#4B0082', '#9400D3'];
return colors[Math.floor(Math.random() * colors.length)];
}
function hideInfoScreen() {
// Clear color change timer if it exists
if (infoUIElements.colorChangeTimer) {
LK.clearInterval(infoUIElements.colorChangeTimer);
infoUIElements.colorChangeTimer = null;
}
// Remove all info UI elements
hideAllInfoUI();
}
function hideAllGiftsUI() {
for (var i = 0; i < giftsUIElements.length; i++) {
giftsUIElements[i].destroy();
}
giftsUIElements = [];
}
function hideAllTradeUI() {
for (var i = 0; i < tradeUIElements.length; i++) {
tradeUIElements[i].destroy();
}
tradeUIElements = [];
}
function hideAllStockUI() {
for (var i = 0; i < stockUIElements.length; i++) {
stockUIElements[i].destroy();
}
stockUIElements = [];
}
function checkDailyGift() {
var currentDate = new Date();
var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch
var lastDate = storage.lastGiftDate || 0;
if (today > lastDate) {
// New day - reset gift status only when it's actually a new day
storage.dailyGiftClaimed = false;
dailyGiftClaimed = false;
// Check if it's been more than 1 day - reset streak if so
if (today > lastDate + 1) {
storage.currentGiftDay = 1;
currentGiftDay = 1;
}
storage.lastGiftDate = today;
lastGiftDate = today;
} else {
// Same day - load existing gift claimed status from storage
dailyGiftClaimed = storage.dailyGiftClaimed || false;
}
}
function checkWeeklyFoodGift() {
var currentDate = new Date();
var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch
var lastDate = storage.lastFoodGiftDate || 0;
if (today > lastDate) {
// New day - reset food gift status only when it's actually a new day
storage.weeklyFoodGiftClaimed = false;
weeklyFoodGiftClaimed = false;
// Check if it's been more than 1 day - reset streak if so
if (today > lastDate + 1) {
storage.currentFoodGiftDay = 1;
currentFoodGiftDay = 1;
}
storage.lastFoodGiftDate = today;
lastFoodGiftDate = today;
} else {
// Same day - load existing food gift claimed status from storage
weeklyFoodGiftClaimed = storage.weeklyFoodGiftClaimed || false;
}
}
function checkDailyTrades() {
var currentDate = new Date();
var today = Math.floor(currentDate.getTime() / (1000 * 60 * 60 * 24)); // Days since epoch
var lastDate = storage.lastTradeDate || 0;
if (today > lastDate) {
// New day - reset trade count
storage.dailyTradesLeft = 5;
dailyTradesLeft = 5;
storage.lastTradeDate = today;
lastTradeDate = today;
}
}
function canStartTrade() {
checkDailyTrades();
return dailyTradesLeft > 0;
}
function createTradeOffer(targetPlayer, offeredDinosaurs) {
if (!canStartTrade() || offeredDinosaurs.length > 4) {
return false;
}
var tradeOffer = {
fromPlayer: playerNickname,
toPlayer: targetPlayer,
offeredDinosaurs: offeredDinosaurs,
requestedDinosaurs: [],
status: 'pending'
};
storage.currentTradeOffer = tradeOffer;
currentTradeOffer = tradeOffer;
return true;
}
function acceptTradeOffer(tradeOffer) {
if (!canStartTrade()) {
return false;
}
// Execute trade (simplified implementation)
// In real implementation, this would involve server coordination
// For now, we simulate giving random dinosaurs in return
// Remove offered dinosaurs from player's collection (simulate giving them away)
for (var i = 0; i < tradeOffer.offeredDinosaurs.length; i++) {
var dinoToRemove = tradeOffer.offeredDinosaurs[i];
var index = dinosaurCollection.indexOf(dinoToRemove);
if (index !== -1) {
dinosaurCollection.splice(index, 1);
}
}
// Add random dinosaurs as trade return (simulate receiving)
var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO'];
var receivedCount = Math.min(tradeOffer.offeredDinosaurs.length, 3); // Receive up to 3 dinosaurs
for (var j = 0; j < receivedCount; j++) {
var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)];
dinosaurCollection.push(randomDino);
}
// Save updated collection
storage.dinosaurCollection = dinosaurCollection;
// Use one daily trade
dailyTradesLeft--;
storage.dailyTradesLeft = dailyTradesLeft;
// Clear current offer
storage.currentTradeOffer = null;
currentTradeOffer = null;
return true;
}
function showGifts() {
gameState = 'gifts';
checkDailyGift();
checkWeeklyFoodGift();
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create gifts display
var giftsTitle = new Text2('GÜNLÜK HEDİYELER', {
size: 80,
fill: '#FFFFFF'
});
giftsTitle.anchor.set(0.5, 0.5);
giftsTitle.x = 1024;
giftsTitle.y = 150;
game.addChild(giftsTitle);
giftsUIElements.push(giftsTitle);
// Show weekly gift calendar
var weekText = new Text2('Para Döngüsü - Gün ' + currentGiftDay + '/7', {
size: 40,
fill: '#FFD700'
});
weekText.anchor.set(0.5, 0.5);
weekText.x = 1024;
weekText.y = 220;
game.addChild(weekText);
giftsUIElements.push(weekText);
// Display all 7 days for coins
for (var day = 1; day <= 7; day++) {
var dayButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dayButton.x = 200 + (day - 1) * 240;
dayButton.y = 400;
dayButton.scaleX = 0.8;
dayButton.scaleY = 0.8;
var isCurrentDay = day === currentGiftDay;
var canClaim = isCurrentDay && !dailyGiftClaimed;
var isPastDay = day < currentGiftDay;
// Change button color based on status
if (isPastDay) {
dayButton.alpha = 0.5; // Already claimed
} else if (canClaim) {
dayButton.tint = 0x32CD32; // Green for claimable
} else {
dayButton.tint = 0x808080; // Gray for future days
}
var dayText = new Text2('Gün ' + day + '\n' + dailyGifts[day - 1] + ' Para', {
size: 25,
fill: canClaim ? '#000000' : '#FFFFFF'
});
dayText.anchor.set(0.5, 0.5);
dayText.x = 200 + (day - 1) * 240;
dayText.y = 400;
game.addChild(dayText);
var statusText = new Text2(isPastDay ? 'ALındı' : canClaim ? 'AL!' : 'Bekliyor', {
size: 20,
fill: canClaim ? '#000000' : isPastDay ? '#FFD700' : '#CCCCCC'
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 200 + (day - 1) * 240;
statusText.y = 440;
game.addChild(statusText);
giftsUIElements.push(dayButton, dayText, statusText);
// Add click handler for current day
if (canClaim) {
(function (giftAmount, dayNum) {
dayButton.down = function () {
// Claim gift
playerCoins += giftAmount;
storage.playerCoins = playerCoins;
// Mark gift as claimed and save to storage immediately
dailyGiftClaimed = true;
storage.dailyGiftClaimed = true;
// Move to next day, reset to 1 after day 7
if (dayNum >= 7) {
storage.currentGiftDay = 1;
} else {
storage.currentGiftDay = dayNum + 1;
}
currentGiftDay = storage.currentGiftDay;
// Refresh gifts display
hideGifts();
showGifts();
};
})(dailyGifts[day - 1], day);
}
}
// Weekly Food Rewards Section
var foodTitle = new Text2('HAFTALIK YİYECEK ÖDÜLLERİ', {
size: 70,
fill: '#32CD32'
});
foodTitle.anchor.set(0.5, 0.5);
foodTitle.x = 1024;
foodTitle.y = 550;
game.addChild(foodTitle);
giftsUIElements.push(foodTitle);
// Show weekly food gift calendar
var foodWeekText = new Text2('Yiyecek Döngüsü - Gün ' + currentFoodGiftDay + '/7', {
size: 40,
fill: '#32CD32'
});
foodWeekText.anchor.set(0.5, 0.5);
foodWeekText.x = 1024;
foodWeekText.y = 620;
game.addChild(foodWeekText);
giftsUIElements.push(foodWeekText);
// Display all 7 days for food
for (var day = 1; day <= 7; day++) {
var foodDayButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
foodDayButton.x = 200 + (day - 1) * 240;
foodDayButton.y = 800;
foodDayButton.scaleX = 0.8;
foodDayButton.scaleY = 0.8;
var isCurrentFoodDay = day === currentFoodGiftDay;
var canClaimFood = isCurrentFoodDay && !weeklyFoodGiftClaimed;
var isPastFoodDay = day < currentFoodGiftDay;
// Change button color based on status
if (isPastFoodDay) {
foodDayButton.alpha = 0.5; // Already claimed
} else if (canClaimFood) {
foodDayButton.tint = 0x32CD32; // Green for claimable
} else {
foodDayButton.tint = 0x808080; // Gray for future days
}
var currentFoodGift = weeklyFoodGifts[day - 1];
var foodDayText = new Text2('Gün ' + day + '\nY:' + currentFoodGift.leaf + ' E:' + currentFoodGift.meat + ' B:' + currentFoodGift.fish, {
size: 22,
fill: canClaimFood ? '#000000' : '#FFFFFF'
});
foodDayText.anchor.set(0.5, 0.5);
foodDayText.x = 200 + (day - 1) * 240;
foodDayText.y = 800;
game.addChild(foodDayText);
var foodStatusText = new Text2(isPastFoodDay ? 'ALındı' : canClaimFood ? 'AL!' : 'Bekliyor', {
size: 20,
fill: canClaimFood ? '#000000' : isPastFoodDay ? '#32CD32' : '#CCCCCC'
});
foodStatusText.anchor.set(0.5, 0.5);
foodStatusText.x = 200 + (day - 1) * 240;
foodStatusText.y = 840;
game.addChild(foodStatusText);
giftsUIElements.push(foodDayButton, foodDayText, foodStatusText);
// Add click handler for current food day
if (canClaimFood) {
(function (foodGift, dayNum) {
foodDayButton.down = function () {
// Claim food gift
leafFood += foodGift.leaf;
meatFood += foodGift.meat;
fishFood += foodGift.fish;
storage.leafFood = leafFood;
storage.meatFood = meatFood;
storage.fishFood = fishFood;
// Mark food gift as claimed and save to storage immediately
weeklyFoodGiftClaimed = true;
storage.weeklyFoodGiftClaimed = true;
// Move to next day, reset to 1 after day 7
if (dayNum >= 7) {
storage.currentFoodGiftDay = 1;
} else {
storage.currentFoodGiftDay = dayNum + 1;
}
currentFoodGiftDay = storage.currentFoodGiftDay;
// Refresh gifts display
hideGifts();
showGifts();
};
})(weeklyFoodGifts[day - 1], day);
}
}
// Daily Discounted Offers Section
var discountTitle = new Text2('GÜNLÜK İNDİRİMLİ TEKLİFLER', {
size: 60,
fill: '#FF6B35'
});
discountTitle.anchor.set(0.5, 0.5);
discountTitle.x = 1024;
discountTitle.y = 1100;
game.addChild(discountTitle);
giftsUIElements.push(discountTitle);
// Generate daily offers based on current date
var currentDate = new Date();
var dayOfYear = Math.floor((currentDate - new Date(currentDate.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));
var seedValue = dayOfYear; // Use day of year as seed for consistent daily offers
// Define available discounted items
var discountedItems = [{
type: 'egg',
name: 'Sıradan Yumurta',
originalPrice: 500,
icon: 'fossil1'
}, {
type: 'egg',
name: 'Nadir Yumurta',
originalPrice: 2000,
icon: 'fossil2'
}, {
type: 'egg',
name: 'Destansı Yumurta',
originalPrice: 10000,
icon: 'fossil3'
}, {
type: 'gamepass',
name: 'XRAY',
originalPrice: 500,
icon: 'limestone'
}, {
type: 'gamepass',
name: '2X MONEY',
originalPrice: 3250,
icon: 'rareFossil'
}, {
type: 'gamepass',
name: '2X LUCK',
originalPrice: 1250,
icon: 'hardRock'
}];
// Simple seeded random function for consistent daily offers
function seededRandom(seed) {
var x = Math.sin(seed) * 10000;
return x - Math.floor(x);
}
// Select 3 different offers for today
var todaysOffers = [];
var usedIndices = [];
for (var offer = 0; offer < 3; offer++) {
var randomIndex;
do {
randomIndex = Math.floor(seededRandom(seedValue + offer * 7) * discountedItems.length);
} while (usedIndices.indexOf(randomIndex) !== -1);
usedIndices.push(randomIndex);
var selectedItem = discountedItems[randomIndex];
// Generate discount between 20-50%
var discountPercent = 20 + Math.floor(seededRandom(seedValue + offer * 13) * 31); // 20-50%
var discountedPrice = Math.floor(selectedItem.originalPrice * (100 - discountPercent) / 100);
todaysOffers.push({
item: selectedItem,
discount: discountPercent,
discountedPrice: discountedPrice
});
}
// Display the 3 discounted offers
for (var i = 0; i < 3; i++) {
var offerData = todaysOffers[i];
var xPos = 350 + i * 350; // Space offers horizontally
// Offer background
var offerButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
offerButton.x = xPos;
offerButton.y = 1300;
offerButton.scaleX = 0.9;
offerButton.scaleY = 1.2;
offerButton.tint = 0xFF6B35; // Orange tint for discount
// Item icon
var itemIcon = game.attachAsset(offerData.item.icon, {
anchorX: 0.5,
anchorY: 0.5
});
itemIcon.x = xPos;
itemIcon.y = 1240;
itemIcon.scaleX = 0.6;
itemIcon.scaleY = 0.6;
game.addChild(itemIcon);
// Item name
var itemNameText = new Text2(offerData.item.name, {
size: 25,
fill: '#FFFFFF'
});
itemNameText.anchor.set(0.5, 0.5);
itemNameText.x = xPos;
itemNameText.y = 1290;
game.addChild(itemNameText);
// Discount percentage
var discountText = new Text2('-' + offerData.discount + '%', {
size: 30,
fill: '#FFD700'
});
discountText.anchor.set(0.5, 0.5);
discountText.x = xPos;
discountText.y = 1320;
game.addChild(discountText);
// Original price (crossed out effect with smaller text)
var originalPriceText = new Text2(offerData.item.originalPrice + ' Para', {
size: 20,
fill: '#888888'
});
originalPriceText.anchor.set(0.5, 0.5);
originalPriceText.x = xPos;
originalPriceText.y = 1345;
game.addChild(originalPriceText);
// Discounted price
var discountedPriceText = new Text2(offerData.discountedPrice + ' Para', {
size: 28,
fill: '#32CD32'
});
discountedPriceText.anchor.set(0.5, 0.5);
discountedPriceText.x = xPos;
discountedPriceText.y = 1370;
game.addChild(discountedPriceText);
giftsUIElements.push(offerButton, itemIcon, itemNameText, discountText, originalPriceText, discountedPriceText);
// Add purchase functionality
(function (offer, price) {
offerButton.down = function () {
if (playerCoins >= price) {
playerCoins -= price;
storage.playerCoins = playerCoins;
if (offer.item.type === 'egg') {
// Open the corresponding egg
var eggType = offer.item.name === 'Sıradan Yumurta' ? 'common' : offer.item.name === 'Nadir Yumurta' ? 'rare' : 'legendary';
var dinosaurName = openEgg(eggType);
} else if (offer.item.type === 'gamepass') {
// Apply gamepass effect
if (offer.item.name === 'XRAY') {
xrayLevelsLeft++;
storage.xrayLevelsLeft = xrayLevelsLeft;
} else if (offer.item.name === '2X MONEY') {
doubleMoneyLevelsLeft = 999999;
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
} else if (offer.item.name === '2X LUCK') {
doubleSpawnChanceActive = true;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
}
}
// Refresh gifts display
hideGifts();
showGifts();
}
};
})(offerData, offerData.discountedPrice);
}
// Back button
var giftsBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
giftsBackButton.x = 1024;
giftsBackButton.y = 1450; // Moved down to make room for discounted offers
var giftsBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
giftsBackButtonText.anchor.set(0.5, 0.5);
giftsBackButtonText.x = 1024;
giftsBackButtonText.y = 1450;
game.addChild(giftsBackButtonText);
giftsUIElements.push(giftsBackButton, giftsBackButtonText);
giftsBackButton.down = function () {
hideGifts();
};
}
function hideGifts() {
gameState = 'nickname';
// Remove all gifts UI elements
hideAllGiftsUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function showTrade() {
// Check if player meets level requirement
var playerLevel = storage.playerLevel || 1;
if (playerLevel < 50) {
// Show level requirement message
gameState = 'levelRequirement';
hideAllMenuUI();
hideAllGameUI();
var levelReqTitle = new Text2('SEVİYE GEREKSİNİMİ', {
size: 80,
fill: '#FF4444'
});
levelReqTitle.anchor.set(0.5, 0.5);
levelReqTitle.x = 1024;
levelReqTitle.y = 600;
game.addChild(levelReqTitle);
infoUIElements.push(levelReqTitle);
var levelReqMessage = new Text2('Takas yapmak için 50. seviyeye ulaşmalısınız!\nŞu anki seviyeniz: ' + playerLevel, {
size: 50,
fill: '#FFFFFF'
});
levelReqMessage.anchor.set(0.5, 0.5);
levelReqMessage.x = 1024;
levelReqMessage.y = 800;
game.addChild(levelReqMessage);
infoUIElements.push(levelReqMessage);
var okButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
okButton.x = 1024;
okButton.y = 1000;
var okButtonText = new Text2('TAMAM', {
size: 35,
fill: '#FFFFFF'
});
okButtonText.anchor.set(0.5, 0.5);
okButtonText.x = 1024;
okButtonText.y = 1000;
game.addChild(okButtonText);
infoUIElements.push(okButton, okButtonText);
okButton.down = function () {
hideInfoScreen();
gameState = 'nickname';
showAllMenuUI();
};
return;
}
gameState = 'trade';
checkDailyTrades(); // Reset daily trades if new day
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create trade display
var tradeTitle = new Text2('TİCARET SİSTEMİ', {
size: 80,
fill: '#FFFFFF'
});
tradeTitle.anchor.set(0.5, 0.5);
tradeTitle.x = 1024;
tradeTitle.y = 150;
game.addChild(tradeTitle);
tradeUIElements.push(tradeTitle);
// Show daily trades remaining
var tradesLeftText = new Text2('Günlük Takas Hakkı: ' + dailyTradesLeft + '/5', {
size: 40,
fill: '#FFD700'
});
tradesLeftText.anchor.set(0.5, 0.5);
tradesLeftText.x = 1024;
tradesLeftText.y = 220;
game.addChild(tradesLeftText);
tradeUIElements.push(tradesLeftText);
// Show active players for trading
var playersTitle = new Text2('AKTİF OYUNCULAR', {
size: 60,
fill: '#32CD32'
});
playersTitle.anchor.set(0.5, 0.5);
playersTitle.x = 1024;
playersTitle.y = 320;
game.addChild(playersTitle);
tradeUIElements.push(playersTitle);
// Display mock active players
var startY = 420;
for (var i = 0; i < activePlayers.length; i++) {
var playerName = activePlayers[i];
var playerButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
playerButton.x = 1024;
playerButton.y = startY + i * 80;
var playerText = new Text2(playerName + ' (Çevrimiçi)', {
size: 35,
fill: '#FFFFFF'
});
playerText.anchor.set(0.5, 0.5);
playerText.x = 1024;
playerText.y = startY + i * 80;
game.addChild(playerText);
// Add online indicator
var onlineIndicator = new Text2('●', {
size: 30,
fill: '#00FF00'
});
onlineIndicator.anchor.set(0.5, 0.5);
onlineIndicator.x = 800;
onlineIndicator.y = startY + i * 80;
game.addChild(onlineIndicator);
tradeUIElements.push(playerButton, playerText, onlineIndicator);
// Create closure for trade initiation
(function (targetPlayer) {
playerButton.down = function () {
if (dailyTradesLeft > 0) {
showTradeSetup(targetPlayer);
} else {
// Show no trades left message
var noTradesMessage = new Text2('Günlük takas hakkınız kalmadı!', {
size: 40,
fill: '#FF4444'
});
noTradesMessage.anchor.set(0.5, 0.5);
noTradesMessage.x = 1024;
noTradesMessage.y = 1000;
game.addChild(noTradesMessage);
// Remove message after 3 seconds
LK.setTimeout(function () {
if (noTradesMessage && noTradesMessage.parent) {
noTradesMessage.destroy();
}
}, 3000);
}
};
})(playerName);
}
// Show pending trade requests section
var requestsTitle = new Text2('GELEN TAKAS İSTEKLERİ', {
size: 50,
fill: '#FF6B35'
});
requestsTitle.anchor.set(0.5, 0.5);
requestsTitle.x = 1024;
requestsTitle.y = 850;
game.addChild(requestsTitle);
tradeUIElements.push(requestsTitle);
// Display pending trade requests
if (tradeRequestsReceived.length > 0) {
for (var j = 0; j < tradeRequestsReceived.length; j++) {
var request = tradeRequestsReceived[j];
var requestY = 920 + j * 60;
var requestText = new Text2(request.fromPlayer + ' takas teklifi gönderdi', {
size: 30,
fill: '#FFFFFF'
});
requestText.anchor.set(0.5, 0.5);
requestText.x = 700;
requestText.y = requestY;
game.addChild(requestText);
var acceptButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
acceptButton.x = 1200;
acceptButton.y = requestY;
acceptButton.scaleX = 0.7;
acceptButton.scaleY = 0.7;
var acceptText = new Text2('KABUL ET', {
size: 25,
fill: '#FFFFFF'
});
acceptText.anchor.set(0.5, 0.5);
acceptText.x = 1200;
acceptText.y = requestY;
game.addChild(acceptText);
var rejectButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
rejectButton.x = 1350;
rejectButton.y = requestY;
rejectButton.scaleX = 0.7;
rejectButton.scaleY = 0.7;
var rejectText = new Text2('REDDET', {
size: 25,
fill: '#FFFFFF'
});
rejectText.anchor.set(0.5, 0.5);
rejectText.x = 1350;
rejectText.y = requestY;
game.addChild(rejectText);
tradeUIElements.push(requestText, acceptButton, acceptText, rejectButton, rejectText);
// Create closures for accept/reject
(function (tradeRequest, index) {
acceptButton.down = function () {
if (acceptTradeOffer(tradeRequest)) {
// Remove request from list
tradeRequestsReceived.splice(index, 1);
storage.tradeRequestsReceived = tradeRequestsReceived;
// Show success message
var successMessage = new Text2('Takas başarılı!', {
size: 50,
fill: '#32CD32'
});
successMessage.anchor.set(0.5, 0.5);
successMessage.x = 1024;
successMessage.y = 1200;
game.addChild(successMessage);
LK.setTimeout(function () {
if (successMessage && successMessage.parent) {
successMessage.destroy();
}
hideTrade();
showTrade(); // Refresh
}, 2000);
}
};
rejectButton.down = function () {
// Remove request from list
tradeRequestsReceived.splice(index, 1);
storage.tradeRequestsReceived = tradeRequestsReceived;
hideTrade();
showTrade(); // Refresh
};
})(request, j);
}
} else {
var noRequestsText = new Text2('Şu anda takas isteği yok', {
size: 35,
fill: '#888888'
});
noRequestsText.anchor.set(0.5, 0.5);
noRequestsText.x = 1024;
noRequestsText.y = 920;
game.addChild(noRequestsText);
tradeUIElements.push(noRequestsText);
}
// Back button
var tradeBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
tradeBackButton.x = 1024;
tradeBackButton.y = 1400;
var tradeBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
tradeBackButtonText.anchor.set(0.5, 0.5);
tradeBackButtonText.x = 1024;
tradeBackButtonText.y = 1400;
game.addChild(tradeBackButtonText);
tradeUIElements.push(tradeBackButton, tradeBackButtonText);
tradeBackButton.down = function () {
hideTrade();
};
}
function showTradeSetup(targetPlayer) {
gameState = 'tradeSetup';
// Hide current trade UI
hideAllTradeUI();
// Create trade setup display
var setupTitle = new Text2('TAKAS KURULUMU: ' + targetPlayer, {
size: 70,
fill: '#FFFFFF'
});
setupTitle.anchor.set(0.5, 0.5);
setupTitle.x = 1024;
setupTitle.y = 200;
game.addChild(setupTitle);
tradeUIElements.push(setupTitle);
var instructionText = new Text2('Direkt takas gönderiliyor - NPC otomatik karşılık verecek (' + dailyTradesLeft + ' takas hakkı)', {
size: 45,
fill: '#FFD700'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 280;
game.addChild(instructionText);
tradeUIElements.push(instructionText);
// Track selected dinosaurs for trade
var selectedForTrade = [];
// Display available dinosaurs
var startY = 400;
for (var i = 0; i < dinosaurCollection.length; i++) {
var dinoName = dinosaurCollection[i];
var rarity = dinosaurRarities[dinoName];
var color = '#87CEEB';
if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B';
var isSelected = selectedForTrade.indexOf(dinoName) !== -1;
var displayText = dinoName + ' (' + rarity + ')' + (isSelected ? ' [SEÇİLDİ]' : '');
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + i * 80;
var dinoText = new Text2(displayText, {
size: 35,
fill: isSelected ? '#32CD32' : color
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + i * 80;
game.addChild(dinoText);
tradeUIElements.push(dinoButton, dinoText);
// Create closure for selection
(function (dinosaurName, textElement) {
dinoButton.down = function () {
var index = selectedForTrade.indexOf(dinosaurName);
if (index === -1) {
// Add to selection if under limit
if (selectedForTrade.length < 4) {
selectedForTrade.push(dinosaurName);
textElement.setText(dinosaurName + ' (' + dinosaurRarities[dinosaurName] + ') [SEÇİLDİ]');
textElement.fill = '#32CD32';
}
} else {
// Remove from selection
selectedForTrade.splice(index, 1);
var rarity = dinosaurRarities[dinosaurName];
var color = '#87CEEB';
if (rarity === 'chromatic') color = getRandomColor();else if (rarity === 'legendary') color = '#FF0000';else if (rarity === 'rare') color = '#800080';else if (rarity === 'common') color = '#00008B';
textElement.setText(dinosaurName + ' (' + rarity + ')');
textElement.fill = color;
}
};
})(dinoName, dinoText);
}
// Send trade request button
var sendRequestButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
sendRequestButton.x = 700;
sendRequestButton.y = 1500;
var sendRequestText = new Text2('TAKAS İSTEĞİ GÖNDER', {
size: 30,
fill: '#FFFFFF'
});
sendRequestText.anchor.set(0.5, 0.5);
sendRequestText.x = 700;
sendRequestText.y = 1500;
game.addChild(sendRequestText);
tradeUIElements.push(sendRequestButton, sendRequestText);
sendRequestButton.down = function () {
if (selectedForTrade.length > 0) {
// Generate NPC trade offer with value variations
var npcOffer = generateNPCTradeOffer(selectedForTrade);
// Show trade confirmation screen
showTradeConfirmation(targetPlayer, selectedForTrade, npcOffer);
}
};
// Back button
var setupBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
setupBackButton.x = 1348;
setupBackButton.y = 1500;
var setupBackText = new Text2('GERİ', {
size: 35,
fill: '#FFFFFF'
});
setupBackText.anchor.set(0.5, 0.5);
setupBackText.x = 1348;
setupBackText.y = 1500;
game.addChild(setupBackText);
tradeUIElements.push(setupBackButton, setupBackText);
setupBackButton.down = function () {
hideTrade();
showTrade(); // Return to main trade screen
};
}
function generateNPCTradeOffer(playerDinosaurs) {
// Define dinosaur values for trade calculation
var dinosaurValues = {
'PARASOUROLUPHUS': 100,
'BARYONYX': 300,
'ALLO': 400,
'YUTY': 500,
'TREX': 1500,
'SPINO': 800,
'GIGA': 900,
'Mutated BARYONYX': 1200,
'Mutated PARASAUROLUPHUS': 1100
};
var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO', 'YUTY', 'SPINO', 'GIGA'];
// Calculate total value of player's offered dinosaurs
var totalPlayerValue = 0;
for (var i = 0; i < playerDinosaurs.length; i++) {
totalPlayerValue += dinosaurValues[playerDinosaurs[i]] || 100;
}
// NPC offers with value variation - 25% chance for higher value offer
var valueMultiplier;
if (Math.random() < 0.25) {
// 25% chance: Offer higher value (110% to 150% of player's offer)
valueMultiplier = 1.1 + Math.random() * 0.4; // 1.1 to 1.5
} else {
// 75% chance: Standard offer (-30% to +50% of player's offer)
valueMultiplier = 0.7 + Math.random() * 0.8; // 0.7 to 1.5
}
var targetValue = Math.floor(totalPlayerValue * valueMultiplier);
var npcOffer = [];
var currentOfferValue = 0;
var attempts = 0;
var maxAttempts = 20;
// Generate NPC offer to match target value
while (currentOfferValue < targetValue && attempts < maxAttempts && npcOffer.length < 4) {
var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)];
var dinoValue = dinosaurValues[randomDino] || 100;
if (currentOfferValue + dinoValue <= targetValue + 200) {
// Allow some tolerance
npcOffer.push(randomDino);
currentOfferValue += dinoValue;
}
attempts++;
}
// Ensure at least one dinosaur is offered
if (npcOffer.length === 0) {
npcOffer.push(tradableTypes[Math.floor(Math.random() * tradableTypes.length)]);
}
return {
dinosaurs: npcOffer,
playerValue: totalPlayerValue,
npcValue: currentOfferValue,
isGoodDeal: valueMultiplier > 1.0
};
}
function showTradeConfirmation(npcName, playerDinosaurs, npcOffer) {
gameState = 'tradeConfirmation';
hideAllTradeUI();
var confirmTitle = new Text2('TAKAS ONAY', {
size: 80,
fill: '#FFFFFF'
});
confirmTitle.anchor.set(0.5, 0.5);
confirmTitle.x = 1024;
confirmTitle.y = 200;
game.addChild(confirmTitle);
tradeUIElements.push(confirmTitle);
var tradePartnerText = new Text2('NPC: ' + npcName, {
size: 50,
fill: '#FFD700'
});
tradePartnerText.anchor.set(0.5, 0.5);
tradePartnerText.x = 1024;
tradePartnerText.y = 300;
game.addChild(tradePartnerText);
tradeUIElements.push(tradePartnerText);
// Show what player is giving
var playerOfferTitle = new Text2('SİZ VERİYORSUNUZ:', {
size: 45,
fill: '#FF6B35'
});
playerOfferTitle.anchor.set(0.5, 0.5);
playerOfferTitle.x = 512;
playerOfferTitle.y = 400;
game.addChild(playerOfferTitle);
tradeUIElements.push(playerOfferTitle);
for (var i = 0; i < playerDinosaurs.length; i++) {
var playerDinoText = new Text2('• ' + playerDinosaurs[i], {
size: 35,
fill: '#FFFFFF'
});
playerDinoText.anchor.set(0.5, 0.5);
playerDinoText.x = 512;
playerDinoText.y = 450 + i * 40;
game.addChild(playerDinoText);
tradeUIElements.push(playerDinoText);
}
// Show what NPC is offering
var npcOfferTitle = new Text2('NPC VERİYOR:', {
size: 45,
fill: '#32CD32'
});
npcOfferTitle.anchor.set(0.5, 0.5);
npcOfferTitle.x = 1536;
npcOfferTitle.y = 400;
game.addChild(npcOfferTitle);
tradeUIElements.push(npcOfferTitle);
for (var j = 0; j < npcOffer.dinosaurs.length; j++) {
var npcDinoText = new Text2('• ' + npcOffer.dinosaurs[j], {
size: 35,
fill: '#FFFFFF'
});
npcDinoText.anchor.set(0.5, 0.5);
npcDinoText.x = 1536;
npcDinoText.y = 450 + j * 40;
game.addChild(npcDinoText);
tradeUIElements.push(npcDinoText);
}
// Show trade value analysis
var dealQualityText = npcOffer.isGoodDeal ? 'İYİ ANLAŞMA!' : 'ZAYIF ANLAŞMA';
var dealQualityColor = npcOffer.isGoodDeal ? '#32CD32' : '#FF4444';
var dealAnalysis = new Text2('Değer Analizi: ' + dealQualityText + '\nSizin: ' + npcOffer.playerValue + ' | NPC: ' + npcOffer.npcValue, {
size: 35,
fill: dealQualityColor
});
dealAnalysis.anchor.set(0.5, 0.5);
dealAnalysis.x = 1024;
dealAnalysis.y = 700;
game.addChild(dealAnalysis);
tradeUIElements.push(dealAnalysis);
// Confirm button
var confirmTradeButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
confirmTradeButton.x = 700;
confirmTradeButton.y = 850;
var confirmTradeText = new Text2('TAKASI ONAYLA', {
size: 30,
fill: '#FFFFFF'
});
confirmTradeText.anchor.set(0.5, 0.5);
confirmTradeText.x = 700;
confirmTradeText.y = 850;
game.addChild(confirmTradeText);
tradeUIElements.push(confirmTradeButton, confirmTradeText);
// Cancel button
var cancelTradeButton = game.attachAsset('deleteButton', {
anchorX: 0.5,
anchorY: 0.5
});
cancelTradeButton.x = 1348;
cancelTradeButton.y = 850;
var cancelTradeText = new Text2('İPTAL ET', {
size: 30,
fill: '#FFFFFF'
});
cancelTradeText.anchor.set(0.5, 0.5);
cancelTradeText.x = 1348;
cancelTradeText.y = 850;
game.addChild(cancelTradeText);
tradeUIElements.push(cancelTradeButton, cancelTradeText);
confirmTradeButton.down = function () {
// Execute the trade
executeTrade(playerDinosaurs, npcOffer.dinosaurs);
};
cancelTradeButton.down = function () {
hideTrade();
showTrade();
};
}
function executeTrade(playerDinosaurs, npcDinosaurs) {
// Remove player's dinosaurs
for (var i = 0; i < playerDinosaurs.length; i++) {
var index = dinosaurCollection.indexOf(playerDinosaurs[i]);
if (index !== -1) {
dinosaurCollection.splice(index, 1);
}
}
// Add NPC's dinosaurs
for (var j = 0; j < npcDinosaurs.length; j++) {
dinosaurCollection.push(npcDinosaurs[j]);
}
// Update storage
storage.dinosaurCollection = dinosaurCollection;
// Use daily trade
dailyTradesLeft--;
storage.dailyTradesLeft = dailyTradesLeft;
// Show success message
var successMessage = new Text2('Takas başarılı!', {
size: 60,
fill: '#32CD32'
});
successMessage.anchor.set(0.5, 0.5);
successMessage.x = 1024;
successMessage.y = 1000;
game.addChild(successMessage);
LK.setTimeout(function () {
if (successMessage && successMessage.parent) {
successMessage.destroy();
}
hideTrade();
showTrade();
}, 2000);
}
function generateMockTradeRequest() {
// Generate mock trade requests from other players
var mockTraders = ['Player1', 'Player2', 'Player3', 'Player4', 'Player5'];
var randomTrader = mockTraders[Math.floor(Math.random() * mockTraders.length)];
// Generate random offered dinosaurs
var tradableTypes = ['PARASOUROLUPHUS', 'BARYONYX', 'ALLO', 'YUTY'];
var offerCount = Math.floor(Math.random() * 3) + 1; // 1-3 dinosaurs
var offeredDinosaurs = [];
for (var i = 0; i < offerCount; i++) {
var randomDino = tradableTypes[Math.floor(Math.random() * tradableTypes.length)];
offeredDinosaurs.push(randomDino);
}
var mockRequest = {
fromPlayer: randomTrader,
toPlayer: playerNickname,
offeredDinosaurs: offeredDinosaurs,
timestamp: Date.now(),
status: 'pending'
};
// Add to received requests
tradeRequestsReceived.push(mockRequest);
storage.tradeRequestsReceived = tradeRequestsReceived;
}
function hideTrade() {
gameState = 'nickname';
// Remove all trade UI elements
hideAllTradeUI();
// Restore menu UI elements
showAllMenuUI();
}
function showStock() {
gameState = 'stock';
// Hide all menu and game UI elements
hideAllMenuUI();
hideAllGameUI();
// Create stock display
var stockTitle = new Text2('DİNOZOR STOKU', {
size: 80,
fill: '#FFFFFF'
});
stockTitle.anchor.set(0.5, 0.5);
stockTitle.x = 1024;
stockTitle.y = 200;
game.addChild(stockTitle);
stockUIElements.push(stockTitle);
// Define dinosaur buy prices based on rarity and value (higher than sell prices)
var dinosaurBuyPrices = {
'PARASOUROLUPHUS': 1200,
'BARYONYX': 3750,
'ALLO': 4500,
'YUTY': 5250,
'SPINO': 12000,
'GIGA': 15000,
'Mutated BARYONYX': 18000,
'Mutated PARASAUROLUPHUS': 27000
};
// Get all purchasable dinosaurs (all except TREX) - ordered by expensive dinosaur hierarchy
// SPINO (1st), GIGA (2nd), Mutated DIMETRODON (3rd), Mutated BARYONYX (4th), then others by price
var allDinosaurs = ['SPINO', 'GIGA', 'Mutated BARYONYX', 'Mutated PARASAUROLUPHUS', 'YUTY', 'ALLO', 'BARYONYX', 'PARASOUROLUPHUS'];
// No need to sort as we've manually ordered them by hierarchy
// Show current coins
var coinsDisplayText = new Text2('Mevcut Para: ' + playerCoins + ' coin', {
size: 50,
fill: '#FFD700'
});
coinsDisplayText.anchor.set(0.5, 0.5);
coinsDisplayText.x = 1024;
coinsDisplayText.y = 280;
game.addChild(coinsDisplayText);
stockUIElements.push(coinsDisplayText);
// Show instruction
var instructionText = new Text2('Satın almak istediğiniz dinozorları seçin (TREX satın alınamaz)', {
size: 40,
fill: '#CCCCCC'
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 340;
game.addChild(instructionText);
stockUIElements.push(instructionText);
// Track selected dinosaurs for buying
var selectedForBuying = [];
// Display purchasable dinosaurs
var startY = 500;
var itemSpacing = 120; // Increased spacing between dinosaur entries
for (var n = 0; n < allDinosaurs.length; n++) {
var dinoName = allDinosaurs[n];
var rarity = dinosaurRarities[dinoName];
var price = dinosaurBuyPrices[dinoName];
// Get rarity color
var color = '#87CEEB'; // Light blue for common
if (rarity === 'chromatic') color = getRandomColor(); // Rainbow for chromatic
else if (rarity === 'legendary') color = '#FF0000'; // Red for legendary
else if (rarity === 'rare') color = '#800080'; // Purple for rare
else if (rarity === 'common') color = '#00008B'; // Dark blue for common
var displayText = dinoName + ' (' + rarity + ') - ' + price + ' coin';
var canAfford = playerCoins >= price;
var dinoButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
dinoButton.x = 1024;
dinoButton.y = startY + n * itemSpacing;
// Dim button if can't afford
if (!canAfford) {
dinoButton.alpha = 0.5;
}
// Add dinosaur image
var dinoImage = new DinosaurImage(dinoName);
dinoImage.x = 400;
dinoImage.y = startY + n * itemSpacing;
dinoImage.scaleX = 0.6;
dinoImage.scaleY = 0.6;
if (!canAfford) {
dinoImage.alpha = 0.5;
}
game.addChild(dinoImage);
stockUIElements.push(dinoImage);
var dinoText = new Text2(displayText, {
size: 35,
fill: canAfford ? color : '#666666'
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + n * itemSpacing;
game.addChild(dinoText);
var statusText = new Text2(canAfford ? 'SATIN ALINABILìR' : 'YETERSìZ PARA', {
size: 25,
fill: canAfford ? '#32CD32' : '#FF4444'
});
statusText.anchor.set(0.5, 0.5);
statusText.x = 1024;
statusText.y = startY + n * itemSpacing + 25;
game.addChild(statusText);
stockUIElements.push(dinoButton, dinoText, statusText);
// Create closure for purchase
(function (dinosaurName, buyPrice, textElement, buttonElement, statusElement, imageElement) {
dinoButton.down = function () {
if (playerCoins >= buyPrice) {
// Purchase dinosaur
playerCoins -= buyPrice;
storage.playerCoins = playerCoins;
// Add dinosaur to collection
dinosaurCollection.push(dinosaurName);
storage.dinosaurCollection = dinosaurCollection;
// Update display
coinsDisplayText.setText('Mevcut Para: ' + playerCoins + ' coin');
// Refresh stock display
hideStock();
showStock();
}
};
})(dinoName, price, dinoText, dinoButton, statusText, dinoImage);
}
// Back button centered
var stockBackButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
stockBackButton.x = 1024;
stockBackButton.y = startY + allDinosaurs.length * itemSpacing + 50;
var stockBackButtonText = new Text2('BACK', {
size: 35,
fill: '#FFFFFF'
});
stockBackButtonText.anchor.set(0.5, 0.5);
stockBackButtonText.x = 1024;
stockBackButtonText.y = startY + allDinosaurs.length * itemSpacing + 50;
game.addChild(stockBackButtonText);
stockUIElements.push(stockBackButton, stockBackButtonText);
// Event handlers
stockBackButton.down = function () {
hideStock();
};
}
function hideStock() {
gameState = 'nickname';
// Remove all stock UI elements
hideAllStockUI();
// Restore menu UI elements
showAllMenuUI();
coinsText.setText('Coins: ' + playerCoins);
}
function checkDinosaurHunger() {
var currentTime = Date.now();
var timePassed = currentTime - lastFeedingCheck;
// Check hunger every hour (3600000 ms)
if (timePassed >= 3600000) {
var hoursElapsed = Math.floor(timePassed / 3600000);
// Initialize hunger for new dinosaurs and increase hunger for existing ones
for (var i = 0; i < dinosaurCollection.length; i++) {
var dinoName = dinosaurCollection[i];
if (!dinosaurHunger[dinoName]) {
dinosaurHunger[dinoName] = 0; // New dinosaurs start with 0 hunger
} else {
// Calculate hunger increase based on dinosaur feeding schedule
var hungerIncrease = 0;
// TREX, GIGA, and SPINO eat every 2 days (48 hours)
if (dinoName === 'TREX' || dinoName === 'GIGA' || dinoName === 'SPINO') {
hungerIncrease = Math.floor(hoursElapsed / 48);
}
// All mutated dinosaurs except Mutated PARASAUROLUPHUS eat daily (24 hours)
else if (dinoName.indexOf('Mutated') === 0 && dinoName !== 'Mutated PARASAUROLUPHUS') {
hungerIncrease = Math.floor(hoursElapsed / 24);
}
// Mutated PARASAUROLUPHUS eats every 2 days (48 hours)
else if (dinoName === 'Mutated PARASAUROLUPHUS') {
hungerIncrease = Math.floor(hoursElapsed / 48);
}
// All fish-eating dinosaurs except SPINO eat twice daily (12 hours)
else if (dinosaurDiets[dinoName] === 'fish' && dinoName !== 'SPINO') {
hungerIncrease = Math.floor(hoursElapsed / 12);
}
// All herbivorous dinosaurs eat twice daily (12 hours)
else if (dinosaurDiets[dinoName] === 'leaf') {
hungerIncrease = Math.floor(hoursElapsed / 12);
}
// Default for any remaining dinosaurs (meat eaters not covered above)
else {
hungerIncrease = Math.floor(hoursElapsed / 24);
}
dinosaurHunger[dinoName] += hungerIncrease;
}
}
// Update storage without removing any dinosaurs
storage.dinosaurCollection = dinosaurCollection;
storage.dinosaurHunger = dinosaurHunger;
storage.lastFeedingCheck = currentTime;
lastFeedingCheck = currentTime;
}
}
function showStarvationNotification(starvedDinosaurs) {
gameState = 'starvationNotification';
hideAllMenuUI();
hideAllGameUI();
var notificationTitle = new Text2('DİNOZORLAR AÇLIKTAN ÖLDÜ!', {
size: 80,
fill: '#FF4444'
});
notificationTitle.anchor.set(0.5, 0.5);
notificationTitle.x = 1024;
notificationTitle.y = 400;
game.addChild(notificationTitle);
infoUIElements.push(notificationTitle);
var starvedText = 'Açlıktan ölen dinozorlar:\n';
for (var i = 0; i < starvedDinosaurs.length; i++) {
starvedText += starvedDinosaurs[i] + '\n';
}
starvedText += '\nDinozorlarınızı düzenli olarak besleyin!';
var notificationMessage = new Text2(starvedText, {
size: 50,
fill: '#FFFFFF'
});
notificationMessage.anchor.set(0.5, 0.5);
notificationMessage.x = 1024;
notificationMessage.y = 700;
game.addChild(notificationMessage);
infoUIElements.push(notificationMessage);
var okButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
okButton.x = 1024;
okButton.y = 1000;
var okButtonText = new Text2('TAMAM', {
size: 35,
fill: '#FFFFFF'
});
okButtonText.anchor.set(0.5, 0.5);
okButtonText.x = 1024;
okButtonText.y = 1000;
game.addChild(okButtonText);
infoUIElements.push(okButton, okButtonText);
okButton.down = function () {
hideInfoScreen();
gameState = 'nickname';
showAllMenuUI();
};
}
function feedDinosaur(dinosaurName) {
var diet = dinosaurDiets[dinosaurName];
var hungerStatus = getHungerStatus(dinosaurName);
var currentHunger = dinosaurHunger[dinosaurName] || 0;
// Only allow feeding if dinosaur is hungry (not FED)
if (hungerStatus === 'FED') {
return false; // Dinosaur is not hungry, refuse food
}
var hasFood = false;
// Define base food consumption amounts for each dinosaur
var baseFoodConsumption = {
'TREX': 2.0,
'GIGA': 1.5,
'YUTY': 1.0,
'ALLO': 1.0,
'SPINO': 2.0,
'BARYONYX': 1.0,
'Mutated BARYONYX': 1.5,
'PARASOUROLUPHUS': 0.5,
'TRICERATOPS': 0.7,
'ANKYLOSAURUS': 0.8,
'Mutated PARASAUROLUPHUS': 1.0
};
var baseConsumption = baseFoodConsumption[dinosaurName] || 1.0;
// Calculate actual consumption based on hunger level
var consumptionMultiplier = 1.0;
if (hungerStatus === 'VERY_HUNGRY') {
consumptionMultiplier = 2.0; // Eat double when very hungry
} else if (hungerStatus === 'HUNGRY') {
consumptionMultiplier = 1.5; // Eat 1.5x when hungry
} else if (hungerStatus === 'SOMEWHAT_HUNGRY') {
consumptionMultiplier = 1.0; // Eat normal amount when somewhat hungry
}
var actualConsumption = baseConsumption * consumptionMultiplier;
// Check if player has the required food type and amount
if (diet === 'leaf' && leafFood >= actualConsumption) {
leafFood -= actualConsumption;
storage.leafFood = leafFood;
hasFood = true;
} else if (diet === 'meat' && meatFood >= actualConsumption) {
meatFood -= actualConsumption;
storage.meatFood = meatFood;
hasFood = true;
} else if (diet === 'fish' && fishFood >= actualConsumption) {
fishFood -= actualConsumption;
storage.fishFood = fishFood;
hasFood = true;
}
if (hasFood) {
// Reduce hunger based on how much food was consumed
var hungerReduction = Math.min(currentHunger, Math.floor(actualConsumption * 10)); // Each food unit reduces 10 hunger points
dinosaurHunger[dinosaurName] = Math.max(0, currentHunger - hungerReduction);
storage.dinosaurHunger = dinosaurHunger;
return true;
}
return false;
}
function getHungerStatus(dinosaurName) {
var hunger = dinosaurHunger[dinosaurName] || 0;
if (hunger >= 20) return 'VERY_HUNGRY';
if (hunger >= 12) return 'HUNGRY';
if (hunger >= 6) return 'SOMEWHAT_HUNGRY';
return 'FED';
}
function getHungerColor(status) {
switch (status) {
case 'VERY_HUNGRY':
return '#FF0000';
case 'HUNGRY':
return '#FF8800';
case 'SOMEWHAT_HUNGRY':
return '#FFFF00';
default:
return '#00FF00';
}
}
function getHungerText(status) {
switch (status) {
case 'VERY_HUNGRY':
return 'ÇOK AÇ!';
case 'HUNGRY':
return 'AÇ';
case 'SOMEWHAT_HUNGRY':
return 'BIRAZ AÇ';
default:
return 'TOK';
}
}
function getPointsBonus(dinosaurName) {
// Define points bonus multipliers for each dinosaur type
var bonusMultipliers = {
'PARASOUROLUPHUS': 1.0,
// No bonus
'TRICERATOPS': 1.1,
// 10% bonus
'ANKYLOSAURUS': 1.2,
// 20% bonus
'BARYONYX': 1.5,
// 50% bonus
'ALLO': 1.6,
// 60% bonus
'YUTY': 1.7,
// 70% bonus
'TREX': 2.0,
// 100% bonus
'SPINO': 1.8,
// 80% bonus
'GIGA': 1.9,
// 90% bonus
'Mutated BARYONYX': 2.2,
// 120% bonus
'Mutated PARASAUROLUPHUS': 2.1 // 110% bonus
};
return bonusMultipliers[dinosaurName] || 1.0; // Default to no bonus if dinosaur not found
}
function canDinosaurUseAbilities(dinosaurName) {
var hungerStatus = getHungerStatus(dinosaurName);
// Dinosaurs can only use abilities when fed (not hungry)
return hungerStatus === 'FED';
}
function startGame() {
if (playerNickname.length === 0) {
return;
}
// Check dinosaur hunger when starting game
checkDinosaurHunger();
storage.playerNickname = playerNickname;
gameState = 'playing';
// Hide menu UI elements
hideAllMenuUI();
// Show game UI elements
timerText.visible = true;
scoreText.visible = true;
levelText.visible = true;
// Show power-up purchase options
purchaseOption1.visible = true;
purchaseText1.visible = true;
purchaseOption2.visible = true;
purchaseText2.visible = true;
purchaseOption3.visible = true;
purchaseText3.visible = true;
// Show XRAY use button
xrayUseButton.visible = true;
xrayUseText.visible = true;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show back to menu button
backToMenuButton.visible = true;
backToMenuText.visible = true;
// Show ability button
abilityUseButton.visible = true;
abilityUseText.visible = true;
// Start from saved level or level 1 if no save exists
startLevel(currentLevelNumber);
}
// Event handlers
leftArrow.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
currentLetterIndex = (currentLetterIndex - 1 + alphabet.length) % alphabet.length;
updateNicknameDisplay();
};
rightArrow.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
currentLetterIndex = (currentLetterIndex + 1) % alphabet.length;
updateNicknameDisplay();
};
addButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
// Add current letter to nickname
if (playerNickname.length < 12) {
playerNickname += alphabet[currentLetterIndex];
updateNicknameDisplay();
}
};
startButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
startGame();
};
deleteButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
if (playerNickname.length > 0) {
playerNickname = playerNickname.slice(0, -1);
updateNicknameDisplay();
}
};
storeButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showStore();
};
sellButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showSell();
};
shopButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showShop();
};
bagButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showBag();
};
tradeButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showTrade();
};
giftsButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showGifts();
};
stockButton.down = function (x, y, obj) {
if (gameState !== 'nickname') {
return;
}
showStock();
};
game.down = function (x, y, obj) {
// Game down handler for playing state only
};
// Game update loop
game.update = function () {
if (gameState === 'playing') {
levelTimer++;
timerText.setText('Time: ' + Math.floor(levelTimer / 60));
// Update player level based on current level progression
if (currentLevelNumber > playerLevel) {
playerLevel = currentLevelNumber;
storage.playerLevel = playerLevel;
}
// Check dinosaur hunger periodically (every 30 seconds in-game)
if (levelTimer % 1800 === 0) {
checkDinosaurHunger();
}
// Generate mock trade requests periodically (every 2 minutes in-game)
if (levelTimer % 7200 === 0 && Math.random() < 0.3) {
generateMockTradeRequest();
}
// Money/score is only decreased when player explicitly spends it
// No automatic score reduction over time
// Update ability button text based on selected dinosaur and level restrictions
if (selectedDinosaur) {
var buttonText = selectedDinosaur + ' ÖZELLİĞİ';
var canUse = true;
// Check if dinosaur is too hungry to use abilities
if (!canDinosaurUseAbilities(selectedDinosaur)) {
var hungerStatus = getHungerStatus(selectedDinosaur);
buttonText = selectedDinosaur + ' (AÇ - BESLEYİN)';
canUse = false;
} else if (selectedDinosaur === 'TREX' && currentLevelNumber % 10 !== 0) {
buttonText = 'TREX (' + (10 - currentLevelNumber % 10) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'SPINO' && storage.spinoUsedThisLevel) {
buttonText = 'SPINO (kullanıldı)';
canUse = false;
} else if (selectedDinosaur === 'GIGA' && currentLevelNumber % 5 !== 0) {
buttonText = 'GIGA (' + (5 - currentLevelNumber % 5) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'GIGA') {
buttonText = 'GIGA ÖZELLİĞİ';
} else if (selectedDinosaur === 'Mutated BARYONYX' && currentLevelNumber % 4 !== 0) {
buttonText = 'M.BARYONYX (' + (4 - currentLevelNumber % 4) + ' seviye)';
canUse = false;
} else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') {
var currentUsage = storage.mutatedParasaurolophusMatches || 0;
if ((currentUsage + 1) % 2 !== 0) {
buttonText = 'M.PARASAUR (' + (2 - (currentUsage + 1) % 2) + ' kullanım)';
canUse = false;
}
}
abilityUseText.setText(buttonText);
abilityUseButton.alpha = canUse ? 1.0 : 0.5;
} else {
abilityUseText.setText('DİNOZOR SEÇ');
abilityUseButton.alpha = 0.5;
}
}
};
// Power-up purchase options (shown when game is playing)
var purchaseOption1 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption1.x = 1800;
purchaseOption1.y = 400;
purchaseOption1.visible = false;
var purchaseText1 = new Text2('XRAY\n500 Coins', {
size: 30,
fill: '#FFFFFF'
});
purchaseText1.anchor.set(0.5, 0.5);
purchaseText1.x = 1800;
purchaseText1.y = 400;
purchaseText1.visible = false;
game.addChild(purchaseText1);
var purchaseOption2 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption2.x = 1800;
purchaseOption2.y = 520;
purchaseOption2.visible = false;
var purchaseText2 = new Text2('2X MONEY\n3250 Coins', {
size: 30,
fill: '#FFFFFF'
});
purchaseText2.anchor.set(0.5, 0.5);
purchaseText2.x = 1800;
purchaseText2.y = 520;
purchaseText2.visible = false;
game.addChild(purchaseText2);
var purchaseOption3 = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
purchaseOption3.x = 1800;
purchaseOption3.y = 640;
purchaseOption3.visible = false;
var purchaseText3 = new Text2('2X LUCK\n1250', {
size: 30,
fill: '#FFFFFF'
});
purchaseText3.anchor.set(0.5, 0.5);
purchaseText3.x = 1800;
purchaseText3.y = 640;
purchaseText3.visible = false;
game.addChild(purchaseText3);
// Track purchase UI elements as game UI
gameUIElements.push(purchaseOption1, purchaseText1, purchaseOption2, purchaseText2, purchaseOption3, purchaseText3);
// Purchase event handlers
purchaseOption1.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 500) {
playerCoins -= 500;
storage.playerCoins = playerCoins;
xrayLevelsLeft++;
storage.xrayLevelsLeft = xrayLevelsLeft;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show all fossils for current level
if (currentLevel) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Make blocks with fossils green and animate with tween
tween(block, {
tint: 0x00FF00
}, {
duration: 500,
easing: tween.easeOut
});
}
}
}
}
};
purchaseOption2.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 3250) {
playerCoins -= 3250;
storage.playerCoins = playerCoins;
doubleMoneyLevelsLeft = 999999; // Permanent 2X money effect
storage.doubleMoneyLevelsLeft = doubleMoneyLevelsLeft;
}
};
purchaseOption3.down = function (x, y, obj) {
if (gameState === 'playing' && playerCoins >= 1250) {
playerCoins -= 1250;
storage.playerCoins = playerCoins;
doubleSpawnChanceActive = true;
storage.doubleSpawnChanceActive = doubleSpawnChanceActive;
}
};
// XRAY use button (shown when game is playing)
var xrayUseButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
xrayUseButton.x = 524; // Further left with more spacing
xrayUseButton.y = 2500; // Bottom of screen
xrayUseButton.visible = false;
var xrayUseText = new Text2('XRAY (' + xrayLevelsLeft + ')', {
size: 30,
fill: '#FFFFFF'
});
xrayUseText.anchor.set(0.5, 0.5);
xrayUseText.x = 524;
xrayUseText.y = 2500;
xrayUseText.visible = false;
game.addChild(xrayUseText);
// Back to menu button (shown when game is playing)
var backToMenuButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
backToMenuButton.x = 1524; // Further right with more spacing
backToMenuButton.y = 2500; // Bottom of screen, same level as XRAY
backToMenuButton.visible = false;
var backToMenuText = new Text2('MENÜYE GERİ DÖN', {
size: 25,
fill: '#FFFFFF'
});
backToMenuText.anchor.set(0.5, 0.5);
backToMenuText.x = 1524;
backToMenuText.y = 2500;
backToMenuText.visible = false;
game.addChild(backToMenuText);
// Track XRAY use and back to menu UI elements as game UI
gameUIElements.push(xrayUseButton, xrayUseText, backToMenuButton, backToMenuText);
// XRAY use button click handler
xrayUseButton.down = function (x, y, obj) {
if (gameState === 'playing' && xrayLevelsLeft > 0) {
xrayLevelsLeft--;
storage.xrayLevelsLeft = xrayLevelsLeft;
xrayUseText.setText('XRAY (' + xrayLevelsLeft + ')');
// Show all fossils for current level
if (currentLevel) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Make blocks with fossils green and animate with tween
tween(block, {
tint: 0x00FF00
}, {
duration: 500,
easing: tween.easeOut
});
}
}
}
}
};
// Dinosaur ability use button (shown when game is playing)
var abilityUseButton = game.attachAsset('purchaseButton', {
anchorX: 0.5,
anchorY: 0.5
});
abilityUseButton.x = 1024; // Center bottom
abilityUseButton.y = 2500; // Bottom of screen
abilityUseButton.visible = false;
var abilityUseText = new Text2('DİNOZOR ÖZELLİĞİ', {
size: 25,
fill: '#FFFFFF'
});
abilityUseText.anchor.set(0.5, 0.5);
abilityUseText.x = 1024;
abilityUseText.y = 2500;
abilityUseText.visible = false;
game.addChild(abilityUseText);
// Track ability button as game UI
gameUIElements.push(abilityUseButton, abilityUseText);
// Ability use button click handler
abilityUseButton.down = function (x, y, obj) {
if (gameState === 'playing' && selectedDinosaur && currentLevel) {
// Check if dinosaur can use abilities (not too hungry)
if (!canDinosaurUseAbilities(selectedDinosaur)) {
// Dinosaur is too hungry to use abilities
return;
}
// Use the selected dinosaur's ability
if (selectedDinosaur === 'TREX') {
// TREX roars and collects all fossils (only works every 10 levels)
if (currentLevelNumber % 10 === 0) {
// Create roar effect with screen shake animation
var roarEffect = LK.getAsset('TREX', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3.0,
scaleY: 3.0
});
roarEffect.x = 1024;
roarEffect.y = 1000;
roarEffect.alpha = 0.7;
roarEffect.tint = 0xFF4500; // Orange roar effect
currentLevel.addChild(roarEffect);
// Animate roar effect with tween
tween(roarEffect, {
scaleX: 5.0,
scaleY: 5.0,
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
roarEffect.destroy();
}
});
// Collect all fossils on the level instantly
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
// Instantly reveal and collect the fossil
currentLevel.revealFossil(block.fossilType, block.x, block.y);
// Mark block as collected
block.isCollected = true;
block.alpha = 0;
}
}
}
} else if (selectedDinosaur === 'SPINO') {
// SPINO fossil hunt - automatically finds and collects 3 fossils (1 use per level)
if (storage.spinoUsedThisLevel) {
// Already used this level, do nothing
return;
}
// Find all blocks with fossils that haven't been collected yet
var fossilBlocks = [];
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (block.hasFossil && !block.isCollected) {
fossilBlocks.push(block);
}
}
// Use SPINO's fossil finding ability on first available fossil block
if (fossilBlocks.length > 0) {
fossilBlocks[0].performSpinoCollection();
} else {
// No fossils available to find
storage.spinoUsedThisLevel = true;
}
} else if (selectedDinosaur === 'GIGA') {
// GIGA fast mining ability - usable every 5 levels
if (currentLevelNumber % 5 === 0) {
// Activate fast mining mode for the rest of the level
gigaFastMiningActive = true;
gigaFastMiningLevel = currentLevelNumber;
// Create visual effect for GIGA ability
var gigaEffect = LK.getAsset('GIGA', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
gigaEffect.x = 1024;
gigaEffect.y = 1000;
gigaEffect.alpha = 0.8;
gigaEffect.tint = 0x800080; // Purple effect for GIGA
currentLevel.addChild(gigaEffect);
// Animate GIGA effect with tween
tween(gigaEffect, {
scaleX: 4.0,
scaleY: 4.0,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
gigaEffect.destroy();
}
});
// Apply fast mining to all existing blocks
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
// Set fast mining hit requirements: normal 1, hard 2, ultra hard 4
block.hitsRequired = block.blockType === 'ultraHardBlock' ? 4 : block.blockType === 'hardRock' ? 2 : 1;
}
}
}
} else if (selectedDinosaur === 'Mutated BARYONYX') {
// Mutated BARYONYX ability every 4 levels - reduce hit requirements for all blocks
if (currentLevelNumber % 4 === 0) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
// Set reduced hit requirements: normal blocks 1 hit, hard blocks 3 hits, ultra hard blocks 6 hits
block.hitsRequired = block.blockType === 'ultraHardBlock' ? 6 : block.blockType === 'hardRock' ? 3 : 1;
}
}
}
} else if (selectedDinosaur === 'TRICERATOPS') {
// TRICERATOPS head charge - reduce 5 random blocks to 2 hit requirement
var availableBlocks = [];
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
availableBlocks.push(block);
}
}
// Select up to 5 random blocks
var blocksToWeaken = Math.min(5, availableBlocks.length);
var selectedBlocks = [];
for (var j = 0; j < blocksToWeaken; j++) {
var randomIndex = Math.floor(Math.random() * availableBlocks.length);
var selectedBlock = availableBlocks[randomIndex];
selectedBlocks.push(selectedBlock);
// Remove from available blocks to avoid duplicates
availableBlocks.splice(randomIndex, 1);
}
// Apply head charge effect to selected blocks
for (var k = 0; k < selectedBlocks.length; k++) {
var block = selectedBlocks[k];
block.hitsRequired = 2; // Reduce to 2 hits
// Visual effect - flash the weakened blocks with blue color for TRICERATOPS
tween(block, {
tint: 0x32CD32
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(block, {
tint: 0xFFFFFF
}, {
duration: 300,
easing: tween.easeOut
});
}
});
}
// Create visual head charge effect
var headChargeEffect = LK.getAsset('TRICERATOPS', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
headChargeEffect.x = 1024;
headChargeEffect.y = 1000;
headChargeEffect.alpha = 0.8;
headChargeEffect.tint = 0x32CD32; // Green effect for TRICERATOPS
currentLevel.addChild(headChargeEffect);
// Animate head charge effect
tween(headChargeEffect, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
headChargeEffect.destroy();
}
});
} else if (selectedDinosaur === 'ANKYLOSAURUS') {
// ANKYLOSAURUS tail strike - reduce 4 random blocks to 1 hit requirement
var availableBlocks = [];
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
availableBlocks.push(block);
}
}
// Select up to 4 random blocks
var blocksToWeaken = Math.min(4, availableBlocks.length);
var selectedBlocks = [];
for (var j = 0; j < blocksToWeaken; j++) {
var randomIndex = Math.floor(Math.random() * availableBlocks.length);
var selectedBlock = availableBlocks[randomIndex];
selectedBlocks.push(selectedBlock);
// Remove from available blocks to avoid duplicates
availableBlocks.splice(randomIndex, 1);
}
// Apply tail strike effect to selected blocks
for (var k = 0; k < selectedBlocks.length; k++) {
var block = selectedBlocks[k];
block.hitsRequired = 1; // Reduce to 1 hit
// Visual effect - flash the weakened blocks
tween(block, {
tint: 0xFFD700
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(block, {
tint: 0xFFFFFF
}, {
duration: 300,
easing: tween.easeOut
});
}
});
}
// Create visual tail strike effect
var tailStrikeEffect = LK.getAsset('ANKYLOSAURUS', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
tailStrikeEffect.x = 1024;
tailStrikeEffect.y = 1000;
tailStrikeEffect.alpha = 0.8;
tailStrikeEffect.tint = 0x8B4513; // Brown effect for ANKYLOSAURUS
currentLevel.addChild(tailStrikeEffect);
// Animate tail strike effect
tween(tailStrikeEffect, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
tailStrikeEffect.destroy();
}
});
} else if (selectedDinosaur === 'Mutated PARASAUROLUPHUS') {
// Mutated PARASAUROLUPHUS ability every 2 matches with reduced hits
var currentUsage = storage.mutatedParasaurolophusMatches || 0;
currentUsage++;
storage.mutatedParasaurolophusMatches = currentUsage;
if (currentUsage % 2 === 0) {
for (var i = 0; i < currentLevel.blocks.length; i++) {
var block = currentLevel.blocks[i];
if (!block.isCollected) {
// Set reduced hit requirements: normal blocks 2 hits, hard blocks 4 hits, ultra hard blocks 7 hits
block.hitsRequired = block.blockType === 'ultraHardBlock' ? 7 : block.blockType === 'hardRock' ? 4 : 2;
}
}
}
} else {
// For other dinosaurs with no special button ability, show message or do nothing
}
}
};
// Back to menu button click handler
backToMenuButton.down = function (x, y, obj) {
if (gameState === 'playing') {
// Clean up current level
if (currentLevel) {
currentLevel.destroy();
currentLevel = null;
}
// Reset game state
gameState = 'nickname';
// Hide game UI elements
hideAllGameUI();
// Show menu UI elements
showAllMenuUI();
}
};
// Initialize display
updateNicknameDisplay();
coinsText.setText('Coins: ' + playerCoins);
// Display player crowns if any
displayPlayerCrowns();
// Start background music
LK.playMusic('backgroundMusic');
function showFoodDinosaursInfo(foodType) {
gameState = 'foodInfo';
// Hide all feed UI elements
hideAllStoreUI();
// Create food info display
var foodTitle = new Text2('BU YİYECEĞİ YIYEN DİNOZORLAR', {
size: 60,
fill: '#FFFFFF'
});
foodTitle.anchor.set(0.5, 0.5);
foodTitle.x = 1024;
foodTitle.y = 200;
game.addChild(foodTitle);
infoUIElements.push(foodTitle);
var foodTypeText = '';
if (foodType === 'leaf') {
foodTypeText = 'YAPRAK YİYEN DİNOZORLAR:';
} else if (foodType === 'meat') {
foodTypeText = 'ET YİYEN DİNOZORLAR:';
} else if (foodType === 'fish') {
foodTypeText = 'BALIK YİYEN DİNOZORLAR:';
}
var foodTypeDisplay = new Text2(foodTypeText, {
size: 50,
fill: '#FFD700'
});
foodTypeDisplay.anchor.set(0.5, 0.5);
foodTypeDisplay.x = 1024;
foodTypeDisplay.y = 300;
game.addChild(foodTypeDisplay);
infoUIElements.push(foodTypeDisplay);
// Get dinosaurs that eat this food type
var dinosaurList = [];
for (var dinoName in dinosaurDiets) {
if (dinosaurDiets[dinoName] === foodType) {
dinosaurList.push(dinoName);
}
}
// Display dinosaur list
var startY = 400;
for (var i = 0; i < dinosaurList.length; i++) {
var dinoText = new Text2('• ' + dinosaurList[i], {
size: 40,
fill: '#FFFFFF'
});
dinoText.anchor.set(0.5, 0.5);
dinoText.x = 1024;
dinoText.y = startY + i * 60;
game.addChild(dinoText);
infoUIElements.push(dinoText);
}
// Back button
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = startY + dinosaurList.length * 60 + 100;
var backButtonText = new Text2('GERİ', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = startY + dinosaurList.length * 60 + 100;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showFeedSection();
};
}
function showDinosaurInfo(dinosaurName) {
gameState = 'dinosaurInfo';
// Hide all bag UI elements
hideAllBagUI();
// Create dinosaur info display
var infoTitle = new Text2('DİNOZOR BİLGİLERİ', {
size: 80,
fill: '#FFFFFF'
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 1024;
infoTitle.y = 200;
game.addChild(infoTitle);
infoUIElements.push(infoTitle);
// Dinosaur name
var dinoNameText = new Text2(dinosaurName, {
size: 60,
fill: '#FFD700'
});
dinoNameText.anchor.set(0.5, 0.5);
dinoNameText.x = 1024;
dinoNameText.y = 400;
game.addChild(dinoNameText);
infoUIElements.push(dinoNameText);
// Dinosaur image
var dinoImage = new DinosaurImage(dinosaurName);
dinoImage.x = 1024;
dinoImage.y = 600;
dinoImage.scaleX = 2;
dinoImage.scaleY = 2;
game.addChild(dinoImage);
infoUIElements.push(dinoImage);
// Hunger status
var hungerStatus = getHungerStatus(dinosaurName);
var hungerText = getHungerText(hungerStatus);
var hungerColor = getHungerColor(hungerStatus);
var hungerDisplay = new Text2('Açlık Durumu: ' + hungerText, {
size: 50,
fill: hungerColor
});
hungerDisplay.anchor.set(0.5, 0.5);
hungerDisplay.x = 1024;
hungerDisplay.y = 800;
game.addChild(hungerDisplay);
infoUIElements.push(hungerDisplay);
// Feed button
var diet = dinosaurDiets[dinosaurName];
var foodText = '';
var hasRequiredFood = false;
if (diet === 'leaf') {
foodText = 'YAPRAK VER (' + leafFood + ')';
hasRequiredFood = leafFood > 0;
} else if (diet === 'meat') {
foodText = 'ET VER (' + meatFood + ')';
hasRequiredFood = meatFood > 0;
} else if (diet === 'fish') {
foodText = 'BALIK VER (' + fishFood + ')';
hasRequiredFood = fishFood > 0;
}
var feedButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
feedButton.x = 1024;
feedButton.y = 1000;
if (!hasRequiredFood) {
feedButton.alpha = 0.5;
}
var feedButtonText = new Text2(foodText, {
size: 35,
fill: hasRequiredFood ? '#FFFFFF' : '#888888'
});
feedButtonText.anchor.set(0.5, 0.5);
feedButtonText.x = 1024;
feedButtonText.y = 1000;
game.addChild(feedButtonText);
infoUIElements.push(feedButton, feedButtonText);
feedButton.down = function () {
var hungerStatus = getHungerStatus(dinosaurName);
if (hungerStatus === 'FED') {
// Show message that dinosaur is not hungry
var notHungryMessage = new Text2('Dinozor aç değil!', {
size: 40,
fill: '#FF4444'
});
notHungryMessage.anchor.set(0.5, 0.5);
notHungryMessage.x = 1024;
notHungryMessage.y = 1250;
game.addChild(notHungryMessage);
// Remove message after 2 seconds
LK.setTimeout(function () {
if (notHungryMessage && notHungryMessage.parent) {
notHungryMessage.destroy();
}
}, 2000);
} else if (feedDinosaur(dinosaurName)) {
// Refresh display
hideInfoScreen();
showDinosaurInfo(dinosaurName);
} else {
// Show message that there's not enough food
var notEnoughFoodMessage = new Text2('Yeterli yiyecek yok!', {
size: 40,
fill: '#FF4444'
});
notEnoughFoodMessage.anchor.set(0.5, 0.5);
notEnoughFoodMessage.x = 1024;
notEnoughFoodMessage.y = 1250;
game.addChild(notEnoughFoodMessage);
// Remove message after 2 seconds
LK.setTimeout(function () {
if (notEnoughFoodMessage && notEnoughFoodMessage.parent) {
notEnoughFoodMessage.destroy();
}
}, 2000);
}
};
// Back button
var backButton = game.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
backButton.x = 1024;
backButton.y = 1150;
var backButtonText = new Text2('GERİ', {
size: 35,
fill: '#FFFFFF'
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 1024;
backButtonText.y = 1150;
game.addChild(backButtonText);
infoUIElements.push(backButton, backButtonText);
backButton.down = function () {
hideInfoScreen();
showBag();
};
}
function getCrownColor(completionCount) {
if (completionCount >= 4) return 0x800080; // Purple for 4+ completions
if (completionCount >= 3) return 0xFF0000; // Red for 3+ completions
if (completionCount >= 2) return 0x00FF00; // Green for 2+ completions
if (completionCount >= 1) return 0x0000FF; // Blue for 1+ completions
return 0xFFD700; // Gold default (shouldn't be used)
}
function displayPlayerCrowns() {
// Remove existing crown displays
for (var i = 0; i < menuUIElements.length; i++) {
if (menuUIElements[i].isCrown) {
menuUIElements[i].destroy();
menuUIElements.splice(i, 1);
i--;
}
}
// Display crowns above player name if any earned
if (playerCrowns > 0) {
var crownColor = getCrownColor(gameCompletions);
var crownSpacing = 60;
var startX = 1024 - (playerCrowns - 1) * crownSpacing / 2;
for (var i = 0; i < playerCrowns; i++) {
var crown = new Text2('♔', {
size: 50,
fill: crownColor
});
crown.anchor.set(0.5, 0.5);
crown.x = startX + i * crownSpacing;
crown.y = 750; // Above nickname display
crown.isCrown = true;
game.addChild(crown);
menuUIElements.push(crown);
}
// Add completion count text
var completionText = new Text2('Tamamlama: ' + gameCompletions, {
size: 30,
fill: '#FFD700'
});
completionText.anchor.set(0.5, 0.5);
completionText.x = 1024;
completionText.y = 700;
completionText.isCrown = true;
game.addChild(completionText);
menuUIElements.push(completionText);
}
}
function createStoredTriviaPuzzle(selectedQuestion) {
// Create puzzle title
var puzzleTitle = new Text2('DİNOZOR BİLGİ YARIŞMASI', {
size: 60,
fill: '#FFD700'
});
puzzleTitle.anchor.set(0.5, 0.5);
puzzleTitle.x = 1024;
puzzleTitle.y = 300;
currentPuzzle.addChild(puzzleTitle);
puzzleUIElements.push(puzzleTitle);
// Display question
var questionText = new Text2(selectedQuestion.question, {
size: 50,
fill: '#FFFFFF'
});
questionText.anchor.set(0.5, 0.5);
questionText.x = 1024;
questionText.y = 600;
currentPuzzle.addChild(questionText);
puzzleUIElements.push(questionText);
// Create answer buttons
for (var a = 0; a < 3; a++) {
var answerButton = currentPuzzle.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
answerButton.x = 1024;
answerButton.y = 900 + a * 150;
currentPuzzle.addChild(answerButton);
puzzleUIElements.push(answerButton);
var answerText = new Text2(selectedQuestion.answers[a], {
size: 40,
fill: '#FFFFFF'
});
answerText.anchor.set(0.5, 0.5);
answerText.x = 1024;
answerText.y = 900 + a * 150;
currentPuzzle.addChild(answerText);
puzzleUIElements.push(answerText);
// Add click handler with closure
(function (answerIndex, correctIndex) {
answerButton.down = function () {
if (answerIndex === correctIndex) {
solvePuzzle();
} else {
resetTriviaPuzzle();
}
};
})(a, selectedQuestion.correct);
}
}