Code edit (8 edits merged)
Please save this source code
User prompt
если blueCrystalIngot +1 то в growth rate +10
Code edit (1 edits merged)
Please save this source code
User prompt
скрывай текст после клика по newGameText
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: blueswordsclick is not defined' in or related to this line: 'var blueCrystalSwordClicks = new Text2('(current ' + blueswordsclick + ')', {' Line Number: 1348
User prompt
Please fix the bug: 'Uncaught ReferenceError: greenAxeClicks is not defined' in or related to this line: 'var greenAxeClicksText = new Text2('(current ' + greenAxeClicks + ')', {' Line Number: 1328
Code edit (2 edits merged)
Please save this source code
User prompt
смести текст в право
Code edit (2 edits merged)
Please save this source code
User prompt
Добавь текст под ассет continueText желтого цвета "This is your forge, hit the anvil and develop skills, mine crystals, melt them into ingots and craft weapons. Sell it in the city." при клике по continueText и newGameText скрывай его
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'y')' in or related to this line: 'gameDescriptionText.y = continueText.y + 100; // Position below the continue button' Line Number: 455
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'gameDescriptionText.x = continueText.x;' Line Number: 449
User prompt
добавь текст под кнопку continue "This is your forge, hit the anvil and develop skills, mine crystals, melt them into ingots and craft weapons. Sell it in the city." желтого цвета
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
при добавлении two-hand swords in stock +1, из redrystalingot не вычитается 75, исправь ошибку
Code edit (6 edits merged)
Please save this source code
User prompt
если в two-hand swords in stock +1 то в redcrystalIngot -75
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: mineInsideBackground is not defined' in or related to this line: 'if (mineInsideBackground) {' Line Number: 483
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: RedCrystalIngot is not defined' in or related to this line: 'var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot());' Line Number: 200
User prompt
Please fix the bug: 'Uncaught ReferenceError: background is not defined' in or related to this line: 'background.visible = false;' Line Number: 620
User prompt
Please fix the bug: 'Uncaught ReferenceError: animateHammer is not defined' in or related to this line: 'return animateHammer();' Line Number: 720
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { forgingSkill: 0, growthRate: 0, blueCrystallScore: 0, greenCrystalIngotScore: 0, blueSwords: 0, greenAxes: 0, redCrystalTwoHandedSwords: 0, blueswordsclick: 0, greenAxeClicks: 0, redCrystalTwoHandedSwordClicks: 0, automineblueCrystallClicked: false, autominegreenCrystallClicked: false, autogrowthRateClicked: false, multiclickupgrade: false, theBlacksmithsApprentice: false, automineredCrystallClicked: false, lastgametime: 0, goldScore: 0, greenCrystallScore: 0, redCrystallScore: 0, redCrystalIngotScore: 0, blueCrystalIngotScore: 0 }); /**** * Classes ****/ var Anvil = Container.expand(function () { var self = Container.call(this); var anvilGraphics = self.attachAsset('anvil', { anchorX: 0.5, anchorY: 0.5, alpha: 0.0 }); self.clickCounter = storage.forgingSkill; self.interactive = true; self.down = function (x, y, obj) { self.clickCounter++; var shans = storage.multiclickupgrade ? 0.04 : 0.02; // Упрощено условие if (Math.random() < shans) { self.clickCounter += 500; var newAsset = game.addChild(LK.getAsset('multyclick', { anchorX: 0.5, anchorY: 0.5 })); newAsset.x = 2048 / 2; newAsset.y = 2732 / 2; tween(newAsset, { scaleX: 2, scaleY: 2 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { newAsset.destroy(); } }); } counterText.setText('Forging skill: ' + self.clickCounter); storage.forgingSkill = self.clickCounter; // Упрощена логика изменения цвета текста counterText.tint = self.clickCounter >= 30000 ? 0xcc7c04 : self.clickCounter >= 15000 ? 0x800080 : self.clickCounter >= 2000 ? 0x0000FF : self.clickCounter >= 1000 ? 0x00FF00 : 0xFFFFFF; }; }); var BlueCristal = Container.expand(function () { var self = Container.call(this); self.attachAsset('blueCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { blueCrystallScore += 1100; LK.setScore(blueCrystallScore); storage.blueCrystallScore = blueCrystallScore; scoreTxt.setText('Blue Crystall: ' + LK.getScore()); scoreTxt.visible = true; }; }); var BlueCrystalIngot = Container.expand(function () { var self = Container.call(this); self.attachAsset('blueCrystalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (blueCrystallScore >= 100) { blueCrystalIngotScore += 1; storage.growthRate += 1000; growthRateText.setText('Growth rate: ' + storage.growthRate); blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); storage.blueCrystalIngotScore = blueCrystalIngotScore; blueCrystallScore -= 10; if (blueCrystallScore < 0) { blueCrystallScore = 0; } storage.blueCrystallScore = blueCrystallScore; LK.setScore(blueCrystallScore); scoreTxt.setText('Blue Crystall: ' + LK.getScore()); } }; }); var Door = Container.expand(function () { var self = Container.call(this); self.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5 }); self.interactive = true; self.down = function () { LK.getSound('doors').play(); hammer.destroy(); game.magicNursery = game.addChild(new Container()); var magicNurseryBackground = game.magicNursery.attachAsset('magicNurseryBackground', { anchorX: 0.5, anchorY: 0.5, interactive: false, scaleX: 2, scaleY: 2 }); magicNurseryBackground.x = 2048 / 2; magicNurseryBackground.y = 2732 / 2; var forgeOfMatter = game.magicNursery.attachAsset('ForgeOfMatter', { anchorX: 0.5, anchorY: 0.5, interactive: true, scaleX: 3, scaleY: 3, alpha: 0.0 }); var blueCrystalIngot = game.magicNursery.addChild(new BlueCrystalIngot()); blueCrystalIngot.x = 200 + blueCrystalIngot.width / 2; blueCrystalIngot.y = 2500 - blueCrystalIngot.height / 2; var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot()); redCrystalIngot.x = 1300 / 2 + 350; redCrystalIngot.y = 4820 / 2; var greenCrystalIngotInstance = game.magicNursery.addChild(new GreenCrystalIngot()); greenCrystalIngotInstance.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCrystalIngotInstance.width / 2 + 40; greenCrystalIngotInstance.y = blueCrystalIngot.y; var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', { anchorX: 0.5, anchorY: 0.5 })); growthRate.x = 700; growthRate.y = 1450; forgeOfMatter.down = function () { storage.growthRate++; growthRateText.setText('Growth rate: ' + storage.growthRate); }; forgeOfMatter.x = 1100 / 1.5; forgeOfMatter.y = 2000 / 1.5; gameScreen.visible = false; counterText.visible = true; map.visible = false; var door2 = game.magicNursery.addChild(new Door2()); door2.x = 2048 * 0.75; door2.y = 2732 * 0.9; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; }); var Door2 = Container.expand(function () { var self = Container.call(this); self.attachAsset('Door', { anchorX: 0.5, anchorY: 0.5 }); self.interactive = true; self.down = function () { LK.getSound('doors').play(); hammer.destroy(); gameScreen.visible = true; map.visible = true; counterText.visible = true; game.magicNursery.visible = false; growthRateText.visible = true; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; }); var GreenAxe = Container.expand(function () { var self = Container.call(this); self.attachAsset('axeOfGreenCrystalsRecipe', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.forgingSkill >= 8000 && storage.greenCrystalIngotScore >= 25) { greenAxeClicks += 1; if (greenAxeClicks >= 150) { greenAxeClicks = 0; storage.greenAxes += 1; greenAxesText.setText(storage.greenAxes.toString()); storage.forgingSkill += 150; counterText.setText('Forging skill: ' + storage.forgingSkill); if (greenCrystalIngotScore >= 150) { greenCrystalIngotScore -= 15; storage.greenCrystalIngotScore = greenCrystalIngotScore; greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + storage.greenCrystalIngotScore); } } greenAxeClicksText.setText('(current ' + greenAxeClicks + ')'); storage.greenAxeClicks = greenAxeClicks; } }; }); var GreenCristal = Container.expand(function () { var self = Container.call(this); self.attachAsset('greenCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { greenCrystallScore += 1000; storage.greenCrystallScore = greenCrystallScore; greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore); greenScoreTxt.visible = true; }; }); var GreenCrystalIngot = Container.expand(function () { var self = Container.call(this); self.attachAsset('greenCrystalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.growthRate >= 3000 && greenCrystallScore >= 100) { storage.growthRate += 10; growthRateText.setText('Growth rate: ' + storage.growthRate); greenCrystalIngotScore += 1; greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore); storage.greenCrystalIngotScore = greenCrystalIngotScore; greenCrystallScore -= 10; if (greenCrystallScore < 0) { greenCrystallScore = 0; } storage.greenCrystallScore = greenCrystallScore; greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore); } }; }); var RecipesScreen = Container.expand(function () { var self = Container.call(this); }); var RedCristal = Container.expand(function () { var self = Container.call(this); self.attachAsset('redCristal', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { redCrystallScore += 1000; storage.redCrystallScore = redCrystallScore; redScoreTxt.setText('Red Crystall: ' + redCrystallScore); redScoreTxt.visible = true; }; }); var RedCrystalIngot = Container.expand(function () { var self = Container.call(this); self.attachAsset('redCristalIngot', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.growthRate >= 9000 && redCrystallScore >= 100) { redCrystalIngotScore += 1; storage.growthRate += 20; growthRateText.setText('Growth rate: ' + storage.growthRate); redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore); storage.redCrystalIngotScore = redCrystalIngotScore; redCrystallScore -= 10; storage.redCrystallScore = redCrystallScore; redScoreTxt.setText('Red Crystall: ' + redCrystallScore); } }; }); var RedCrystalTwoHandedSword = Container.expand(function () { var self = Container.call(this); self.attachAsset('redcrystaltwo-handedswordrecipe', { anchorX: 0.5, anchorY: 0.5, interactive: true }); self.down = function () { if (storage.forgingSkill >= 15000 && storage.redCrystalIngotScore >= 75) { redCrystalTwoHandedSwordClicks += 1; redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')'); if (redCrystalTwoHandedSwordClicks >= 200) { redCrystalTwoHandedSwordClicks = 0; storage.redCrystalTwoHandedSwords += 1; redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString()); storage.redCrystalIngotScore -= 75; redCrystalIngotScore = storage.redCrystalIngotScore; redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore); } else if (redCrystalTwoHandedSwordClicks >= 250) { // Исправлено условие redCrystalTwoHandedSwordClicks = 0; storage.redCrystalTwoHandedSwords += 250; redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString()); } storage.redCrystalTwoHandedSwordClicks = redCrystalTwoHandedSwordClicks; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var mineInsideBackground; // Initialize mineInsideBackground to avoid ReferenceError // Исправлен повтор ID var goldScore = storage.goldScore || 0; var goldScoreTxt = new Text2('Gold: ' + goldScore, { size: 50, fill: 0xFFFFFF }); goldScoreTxt.anchor.set(0, 0); goldScoreTxt.y = 0; goldScoreTxt.x = counterText ? counterText.width + 10 : 550; // Упрощено условие LK.gui.topLeft.addChild(goldScoreTxt); var redCrystalIngotScore = storage.redCrystalIngotScore || 0; var redCrystalIngotScoreTxt = new Text2('RedCrystalIngot: ' + redCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); redCrystalIngotScoreTxt.anchor.set(1, 0); redCrystalIngotScoreTxt.y = 100; LK.gui.topRight.addChild(redCrystalIngotScoreTxt); var blueCrystallScore = storage.blueCrystallScore || 0; var automineblueCrystallClicked = storage.automineblueCrystallClicked; var autominegreenCrystallClicked = storage.autominegreenCrystallClicked; // Удален дубликат var automineredCrystallClicked = storage.automineredCrystallClicked; var autogrowthRateClicked = storage.autogrowthRateClicked; var scoreTxt = new Text2('Blue Crystall: ' + blueCrystallScore, { size: 50, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); scoreTxt.y = 100; LK.gui.topLeft.addChild(scoreTxt); var greenCrystallScore = storage.greenCrystallScore || 0; var greenScoreTxt = new Text2('Green Crystall: ' + greenCrystallScore, { size: 50, fill: 0xFFFFFF }); greenScoreTxt.anchor.set(0, 0); greenScoreTxt.y = 150; LK.gui.topLeft.addChild(greenScoreTxt); var greenCrystalIngotScore = storage.greenCrystalIngotScore || 0; var greenCrystalIngotScoreTxt = new Text2('GreenCrystalIngot: ' + greenCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); greenCrystalIngotScoreTxt.anchor.set(1, 0); greenCrystalIngotScoreTxt.y = 50; LK.gui.topRight.addChild(greenCrystalIngotScoreTxt); var blueCristal, greenCristal, redCristal; // Объявлены глобально var blueCrystalIngotScore = storage.blueCrystalIngotScore || 0; var blueSwordsText = new Text2(storage.blueSwords.toString(), { size: 50, fill: 0x000000 }); blueSwordsText.anchor.set(0.5, 0.5); blueSwordsText.x = 1248 / 2; blueSwordsText.y = 2732 / 2 + 450; LK.gui.topLeft.addChild(blueSwordsText); var redCrystallScore = storage.redCrystallScore || 0; var blueCrystalIngotScoreTxt = new Text2('BlueCrystalIngot: ' + blueCrystalIngotScore, { size: 50, fill: 0xFFFFFF }); blueCrystalIngotScoreTxt.anchor.set(1, 0); blueCrystalIngotScoreTxt.y = 0; LK.gui.topRight.addChild(blueCrystalIngotScoreTxt); var redScoreTxt = new Text2('Red Crystall: ' + redCrystallScore, { size: 50, fill: 0xFFFFFF }); redScoreTxt.anchor.set(0, 0); redScoreTxt.y = 200; LK.gui.topLeft.addChild(redScoreTxt); var map = game.addChild(LK.getAsset('Map', { anchorX: 0.5, anchorY: 0.5 })); map.x = 400; map.y = 2450; map.visible = false; map.interactive = true; map.down = function () { hammer.destroy(); LK.getSound('mapaudio').play(); map.visible = false; if (mineInsideBackground) { mineInsideBackground.destroy(); } if (redCristal) { redCristal.destroy(); } if (blueCristal) { blueCristal.destroy(); } if (greenCristal) { greenCristal.destroy(); } var mapScreen = game.addChild(new Container()); var mapBackground = mapScreen.attachAsset('mapbackground', { anchorX: 0.5, anchorY: 0.5, interactive: false }); var cityMap = mapScreen.attachAsset('citymap', { anchorX: 0.5, anchorY: 0.5, interactive: true }); cityMap.x = -250; cityMap.y = 160; cityMap.down = function () { hammer.destroy(); var isolatedScreen = game.addChild(new Container()); mapScreen.visible = false; var cityBackground = isolatedScreen.attachAsset('citybackground', { anchorX: 0.5, anchorY: 0.5 }); cityBackground.x = 0; cityBackground.y = 0; var mapAsset = isolatedScreen.attachAsset('Map', { anchorX: 0.5, anchorY: 0.5, interactive: true }); mapAsset.x = -650; mapAsset.y = 1100; mapAsset.down = function () { isolatedScreen.visible = false; mapScreen.visible = true; cityBackground.visible = false; mapBackground.visible = true; }; var shop = isolatedScreen.attachAsset('shop', { anchorX: 0.5, anchorY: 0.5, interactive: true }); shop.x = 490; shop.y = -20; shop.down = function () { hammer.destroy(); LK.getSound('shopin').play(); var shopScreen = game.addChild(new Container()); isolatedScreen.visible = false; shopScreen.x = 2048 / 2; shopScreen.y = 2732 / 2; var newTools = shopScreen.attachAsset('newTools', { anchorX: 0.5, anchorY: 0.5, interactive: true }); newTools.x = -650; newTools.y = 1100; newTools.down = function () { hammer.destroy(); var isolatedScreen = game.addChild(new Container()); var newToolsBackground = isolatedScreen.attachAsset('newToolsBackground', { anchorX: 0.5, anchorY: 0.5 }); newToolsBackground.x = 0; newToolsBackground.y = 0; if (!storage.theBlacksmithsApprentice) { var theBlacksmithsApprentice = isolatedScreen.attachAsset('Theblacksmithsapprentice', { anchorX: 0.5, anchorY: 0.5, interactive: true }); theBlacksmithsApprentice.x = 400; theBlacksmithsApprentice.y = 200; theBlacksmithsApprentice.clicked = storage.theBlacksmithsApprentice; theBlacksmithsApprentice.down = function () { if (goldScore >= 1500 && !theBlacksmithsApprentice.clicked) { goldScore -= 1500; goldScoreTxt.setText('Gold: ' + goldScore); storage.goldScore = goldScore; theBlacksmithsApprentice.clicked = true; var intervalId = LK.setInterval(function () { storage.forgingSkill += 1; counterText.setText('Forging skill: ' + storage.forgingSkill); }, 1000); theBlacksmithsApprentice.intervalId = intervalId; storage.theBlacksmithsApprentice = true; theBlacksmithsApprentice.visible = false; apprenticeText.visible = false; apprenticeCostText.visible = false; } }; var apprenticeText = new Text2("The blacksmith's \napprentice +1", { size: 50, fill: 0x030303 }); apprenticeText.anchor.set(0.5, 0.5); apprenticeText.x = theBlacksmithsApprentice.x; apprenticeText.y = theBlacksmithsApprentice.y + 170; isolatedScreen.addChild(apprenticeText); var apprenticeCostText = new Text2('1500G', { size: 50, fill: 0x030303 }); apprenticeCostText.anchor.set(0.5, 0.5); apprenticeCostText.x = apprenticeText.x; apprenticeCostText.y = apprenticeText.y + 70; isolatedScreen.addChild(apprenticeCostText); } var newToolsOut = isolatedScreen.attachAsset('newToolsout', { anchorX: 0.5, anchorY: 0.5, interactive: true }); newToolsOut.x = 0; newToolsOut.y = 1100; if (!storage.automineblueCrystallClicked) { var automineblueCrystall = isolatedScreen.attachAsset('automineblueCrystall', { anchorX: 0.5, anchorY: 0.5, interactive: true }); automineblueCrystall.x = -400; automineblueCrystall.y = -600; automineblueCrystall.clicked = storage.automineblueCrystallClicked; automineblueCrystall.down = function () { if (goldScore >= 500 && !automineblueCrystall.clicked) { automineblueCrystall.clicked = true; goldScore -= 500; goldScoreTxt.setText('Gold: ' + goldScore); storage.goldScore = goldScore; var intervalId = LK.setInterval(function () { blueCrystallScore += 1; LK.setScore(blueCrystallScore); storage.blueCrystallScore = blueCrystallScore; scoreTxt.setText('Blue Crystall: ' + LK.getScore()); }, 1000); automineblueCrystall.intervalId = intervalId; storage.automineblueCrystallClicked = true; automineblueCrystall.visible = false; mineBlueCrystallText.visible = false; mineBlueCrystallCostText.visible = false; } }; var mineBlueCrystallText = new Text2('Mine Blue Crystall +1', { size: 50, fill: 0x030303 }); mineBlueCrystallText.anchor.set(0.5, 0.5); mineBlueCrystallText.x = automineblueCrystall.x; mineBlueCrystallText.y = automineblueCrystall.y + 150; isolatedScreen.addChild(mineBlueCrystallText); var mineBlueCrystallCostText = new Text2('500G', { size: 50, fill: 0x030303 }); mineBlueCrystallCostText.anchor.set(0.5, 0.5); mineBlueCrystallCostText.x = mineBlueCrystallText.x; mineBlueCrystallCostText.y = mineBlueCrystallText.y + 50; isolatedScreen.addChild(mineBlueCrystallCostText); } // Аналогично для других покупок в магазине (autominegreenCrystall, automineredCrystall, multiclickupgrade, autogrowthRate) newToolsOut.down = function () { LK.getSound('booksaudio').play(); isolatedScreen.visible = false; shopScreen.visible = true; }; shopScreen.visible = false; isolatedScreen.x = 2048 / 2; isolatedScreen.y = 2732 / 2; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; var shopBackground = shopScreen.attachAsset('shopbackground', { anchorX: 0.5, anchorY: 0.5 }); shopBackground.x = 0; shopBackground.y = 0; var newBuildings = shopScreen.attachAsset('sellweapons', { anchorX: 0.5, anchorY: 0.5, interactive: true }); newBuildings.down = function () { goldScore += storage.blueSwords * 100 + storage.greenAxes * 300 + storage.redCrystalTwoHandedSwords * 100; storage.blueSwords = 0; storage.greenAxes = 0; storage.redCrystalTwoHandedSwords = 0; blueSwordsText.setText('0'); goldScoreTxt.setText('Gold: ' + goldScore); storage.goldScore = goldScore; }; newBuildings.x = 0; newBuildings.y = 1100; var shopOut = shopScreen.attachAsset('shopout', { anchorX: 0.5, anchorY: 0.5, interactive: true }); shopOut.x = 650; shopOut.y = 1100; shopOut.down = function () { LK.getSound('doors').play(); shopScreen.visible = false; mapScreen.visible = true; isolatedScreen.visible = true; }; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; isolatedScreen.x = 2048 / 2; isolatedScreen.y = 2732 / 2; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; var anvilMap = mapScreen.attachAsset('anvilmap', { anchorX: 0.5, anchorY: 0.5, interactive: true }); var mine = mapScreen.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5, interactive: true }); mine.x -= 150; mine.y -= 150; mine.down = function () { hammer.destroy(); var mineScreen = game.addChild(new Container()); map.visible = true; mapScreen.visible = false; background.visible = false; mineInsideBackground = mineScreen.attachAsset('mineinsidebackground', { anchorX: 0.5, anchorY: 0.5, interactive: false, zIndex: -1 }); redCristal = mineScreen.addChild(new RedCristal()); redCristal.x -= 510; redCristal.y += 490; greenCristal = mineScreen.addChild(new GreenCristal()); greenCristal.x += 510; greenCristal.y += 10; blueCristal = mineScreen.addChild(new BlueCristal()); blueCristal.x += 80; blueCristal.y -= 370; mineScreen.x = 2048 / 2; mineScreen.y = 2732 / 2; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; anvilMap.down = function () { gameScreen.visible = true; map.visible = true; gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', { anchorX: 0.5, anchorY: 0.5 }); var recipes = gameScreenBackground.attachAsset('recipes', { anchorX: 0.5, anchorY: 0.5 }); recipes.x = gameScreenBackground.width / 2 - 1050; recipes.y = gameScreenBackground.height / 2 + 150; if (mineInsideBackground) { mineInsideBackground.destroy(); } if (blueCristal) { blueCristal.destroy(); } if (greenCristal) { greenCristal.destroy(); } if (redCristal) { redCristal.destroy(); } mapScreen.visible = false; counterText.visible = true; growthRateText.visible = true; }; gameScreen.visible = false; background.visible = false; mapScreen.x = 2048 / 2; mapScreen.y = 2732 / 2; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); }; var growthRateCounter = storage.growthRate; var background = game.addChild(new Container()); background.width = 2048; background.height = 2732; background.x = 2048 / 2; background.y = 2732 / 2; var backgroundGraphics = background.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); var gameScreen = game.addChild(new Container()); var newGame = game.addChild(new Container()); newGame.x = 2650 / 2 + 100; newGame.y = 2680 * 4.2 / 5; var title = game.addChild(LK.getAsset('title', { anchorX: 0.5, anchorY: 0.5 })); title.x = 2048 / 2; title.y = 3200 / 5; var newGameText = newGame.attachAsset('newGameText', { anchorX: 0.5, anchorY: 0.5, stroke: 0xFFFFFF, strokeThickness: 5 }); var continueText = game.addChild(LK.getAsset('continueText', { anchorX: 0.5, anchorY: 0.5, interactive: true })); continueText.x = newGame.x - newGame.width - 500; continueText.y = newGame.y; continueText.down = startgame; var blueswordsclick = storage.blueswordsclick; var greenAxeClicks = storage.greenAxeClicks; var redCrystalTwoHandedSwordClicks = storage.redCrystalTwoHandedSwordClicks; function startgame() { title.destroy(); hammer.destroy(); gameScreen = game.addChild(new Container()); gameScreen.x = 2048 / 2; gameScreen.y = 2732 / 2; gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', { anchorX: 0.5, anchorY: 0.5 }); var recipes = gameScreenBackground.attachAsset('recipes', { anchorX: 0.5, anchorY: 0.5, interactive: true }); recipes.down = function () { hammer.destroy(); LK.getSound('booksaudio').play(); var recipesScreen = game.addChild(new RecipesScreen()); map.visible = false; var recipesBackground = recipesScreen.attachAsset('recipesbackground', { anchorX: 0.5, anchorY: 0.5 }); recipesBackground.x = 2048 / 2; recipesBackground.y = 2932 / 2; var bluecrystalswordrecipe = recipesScreen.attachAsset('bluecrystalswordrecipe', { anchorX: 0.5, anchorY: 0.5 }); bluecrystalswordrecipe.x = 1248 / 2; bluecrystalswordrecipe.y = 2132 / 2; bluecrystalswordrecipe.down = function () { if (storage.forgingSkill >= 2000 && storage.blueCrystalIngotScore >= 10) { blueswordsclick += 1; if (blueswordsclick >= 100) { blueswordsclick = 0; storage.blueSwords += 1; blueSwordsText.setText(storage.blueSwords.toString()); storage.forgingSkill += 100; counterText.setText('Forging skill: ' + storage.forgingSkill); if (storage.blueCrystalIngotScore >= 10) { storage.blueCrystalIngotScore -= 10; blueCrystalIngotScore = storage.blueCrystalIngotScore; blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); } } blueCrystalSwordClicks.setText('(current ' + blueswordsclick + ')'); storage.blueswordsclick = blueswordsclick; } }; // Добавление остальных элементов экрана рецептов аналогично var recipesOutGraphics = recipesScreen.attachAsset('recipesout', { anchorX: 0.5, anchorY: 0.5, interactive: true }); recipesOutGraphics.x = 2048 / 2; recipesOutGraphics.y = 2732 / 2 + 1100; recipesOutGraphics.down = function () { LK.getSound('paper').play(); gameScreen.visible = true; map.visible = true; recipesScreen.visible = false; }; gameScreen.visible = false; }; recipes.x = gameScreenBackground.width / 2 - 1050; recipes.y = gameScreenBackground.height / 2 + 150; map.visible = true; newGame.visible = false; continueText.visible = false; background.visible = false; var anvil = gameScreen.addChild(new Anvil()); anvil.clickCounter = storage.forgingSkill; counterText.setText('Forging skill: ' + anvil.clickCounter); anvil.x = gameScreenBackground.x - -20; anvil.y = gameScreenBackground.y + 500; var magicNursery = gameScreen.addChild(new Door()); magicNursery.x = 2048 / 4; magicNursery.y = 2732 / 2.5; hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); } newGame.interactive = true; newGame.down = function () { newgameclearInterval.forEach(function (id) { return LK.clearInterval(id); }); storage.automineblueCrystallClicked = false; storage.autominegreenCrystallClicked = false; storage.automineredCrystallClicked = false; storage.autogrowthRateClicked = false; storage.theBlacksmithsApprentice = false; storage.multiclickupgrade = false; storage.forgingSkill = 0; storage.growthRate = 0; storage.blueCrystalIngotScore = 0; storage.blueCrystallScore = 0; storage.greenCrystalIngotScore = 0; storage.redCrystallScore = 0; storage.redCrystalIngotScore = 0; storage.greenCrystallScore = 0; storage.blueSwords = 0; storage.goldScore = 0; redCrystalIngotScore = 0; blueCrystallScore = 0; greenCrystallScore = 0; greenCrystalIngotScore = 0; blueCrystalIngotScore = 0; redCrystallScore = 0; growthRateCounter = 0; goldScore = 0; growthRateText.setText('Growth rate: ' + storage.growthRate); counterText.setText('Forging skill: ' + storage.forgingSkill); scoreTxt.setText('Blue Crystall: ' + blueCrystallScore); greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore); redScoreTxt.setText('Red Crystall: ' + redCrystallScore); blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + storage.blueCrystalIngotScore); greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + storage.greenCrystalIngotScore); redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + storage.redCrystalIngotScore); goldScoreTxt.setText('Gold: ' + goldScore); startgame(); }; var counterText = new Text2('Forging skill: ' + storage.forgingSkill, { size: 50, fill: 0xFFFFFF }); counterText.anchor.set(0, 0); LK.gui.topLeft.addChild(counterText); counterText.y = 0; counterText.x = 0; var growthRateText = new Text2('Growth rate: ' + growthRateCounter, { size: 50, fill: 0xFFFFFF }); growthRateText.anchor.set(0, 0); LK.gui.topLeft.addChild(growthRateText); growthRateText.y = counterText.height - 6; growthRateText.x = 0; var hammer = game.addChild(LK.getAsset('hammer', { anchorX: 0.5, anchorY: 0.5, scaleX: -1 })); function updateHammerPosition(x, y) { if (hammer) { hammer.x = x; hammer.y = y; } } var newgameclearInterval = []; if (automineblueCrystallClicked) { var intervalId = LK.setInterval(function () { blueCrystallScore += 1; LK.setScore(blueCrystallScore); storage.blueCrystallScore = blueCrystallScore; scoreTxt.setText('Blue Crystall: ' + LK.getScore()); }, 1000); newgameclearInterval.push(intervalId); } // Аналогично для других интервалов var seconds = Math.floor(Date.now() / 1000) - storage.lastgametime; if (seconds * 60 * 5 > Math.floor(Date.now() / 1000)) { seconds = 5 * 60 * 60; } if (seconds > 0) { if (storage.automineblueCrystallClicked) { blueCrystallScore = storage.blueCrystallScore += seconds; } if (storage.autominegreenCrystallClicked) { greenCrystallScore = storage.greenCrystallScore += seconds; } if (storage.automineredCrystallClicked) { redCrystallScore = storage.redCrystallScore += seconds; } if (storage.autogrowthRateClicked) { growthRateCounter = storage.growthRate += seconds; } if (storage.theBlacksmithsApprentice) { storage.forgingSkill += seconds; } } LK.setInterval(function () { storage.lastgametime = Math.floor(Date.now() / 1000); }, 1000); game.move = function (x, y) { updateHammerPosition(x, y); }; game.down = function (x, y) { LK.getSound('hammer').play(); tween(hammer, { rotation: -Math.PI / 2 }, { duration: 125, easing: tween.easeInOut, onFinish: function onFinish() { for (var i = 0; i < 5; i++) { var star = game.addChild(LK.getAsset('star', { anchorX: 0.5, anchorY: 0.5 })); star.x = hammer.x - hammer.width / 2 + Math.random() * 100 - 25; star.y = hammer.y + hammer.height / 2 + Math.random() * 100 - 25; star.update = function () { star.y -= 5; star.x += star.x < hammer.x ? 2 : -2; }; LK.setTimeout(function () { star.destroy(); }, 250); } tween(hammer, { rotation: 0 }, { duration: 125, easing: tween.easeInOut }); } }); };
===================================================================
--- original.js
+++ change.js
@@ -329,9 +329,9 @@
/****
* Game Code
****/
-// Не используется, можно удалить
+var mineInsideBackground; // Initialize mineInsideBackground to avoid ReferenceError
// Исправлен повтор ID
var goldScore = storage.goldScore || 0;
var goldScoreTxt = new Text2('Gold: ' + goldScore, {
size: 50,