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
});
/****
* Classes
****/
// Create a new class for the anvil object
var Anvil = Container.expand(function () {
var self = Container.call(this);
// Attach 'anvil' asset to the 'Anvil' object
var anvilGraphics = self.attachAsset('anvil', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.0 // Make the anvil fully transparent
});
// Initialize the click counter
self.clickCounter = storage.forgingSkill;
// Make the 'Anvil' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
// Increment the click counter
self.clickCounter++;
// Add a 5% chance for a multi-click event to increase forging skill by 5
var shans = 0.02;
if (storage.multiclickupgrade) {
shans += 0.02;
}
if (Math.random() < 0.02) {
self.clickCounter += 5;
// Create a new asset at the center of the screen
var newAsset = game.addChild(LK.getAsset('multyclick', {
anchorX: 0.5,
anchorY: 0.5
}));
// Position the new asset at the center of the screen
newAsset.x = 2048 / 2;
newAsset.y = 2732 / 2;
// Animate the scaling of the new asset
tween(newAsset, {
scaleX: 2,
scaleY: 2
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
newAsset.destroy(); // Remove the asset after the animation
}
});
}
// Update the text object with the click counter and label
counterText.setText('Forging skill: ' + self.clickCounter);
// Persist the click counter
storage.forgingSkill = self.clickCounter;
// Change the color of the counter text based on the click counter
if (self.clickCounter >= 1000 && self.clickCounter < 2000) {
counterText.tint = 0x00FF00; // Green
} else if (self.clickCounter >= 2000 && self.clickCounter < 15000) {
counterText.tint = 0x0000FF; // Blue
} else if (self.clickCounter >= 15000 && self.clickCounter < 30000) {
counterText.tint = 0x800080; // Purple
} else if (self.clickCounter >= 30000) {
counterText.tint = 0xcc7c04; // Purple
}
};
});
// Create a new class for the BlueCristal object
var BlueCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'blueCristal' asset to the 'BlueCristal' object
var blueCristalGraphics = self.attachAsset('blueCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the blueCristal interactive
});
// Define the 'down' event handler for blueCristal
self.down = function (x, y, obj) {
// Increment the score by 1
blueCrystallScore += 1;
LK.setScore(blueCrystallScore);
storage.blueCrystallScore = blueCrystallScore;
// Update the score text
scoreTxt.setText('Blue Crystall: ' + LK.getScore());
scoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the BlueCrystalIngot object
var BlueCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'blueCrystalIngot' asset to the 'BlueCrystalIngot' object
var blueCrystalIngotGraphics = self.attachAsset('blueCrystalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the blueCrystalIngot interactive
});
// Define the 'down' event handler for blueCrystalIngot
self.down = function (x, y, obj) {
// Logic for what happens when the blueCrystalIngot is clicked
if (blueCrystallScore >= 1) {
blueCrystalIngotScore += 1; //{y.1}
storage.growthRate += 10; // Increment growth rate by 10
growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
storage.growthRate += 10; // Increment growth rate by 10
growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); //{y.2}
storage.blueCrystalIngotScore = blueCrystalIngotScore;
blueCrystallScore -= 10;
if (blueCrystallScore < 0) {
blueCrystallScore = 0;
}
storage.blueCrystallScore = blueCrystallScore; // Persist the decrement
LK.setScore(blueCrystallScore);
scoreTxt.setText('Blue Crystall: ' + LK.getScore());
}
};
});
// Create a new class for the Door object
var Door = Container.expand(function () {
var self = Container.call(this);
// Attach 'Door' asset to the 'Door' object
var doorGraphics = self.attachAsset('Door', {
anchorX: 0.5,
anchorY: 0.5
});
// Make the 'Door' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
LK.getSound('doors').play();
// Remove the existing hammer
hammer.destroy();
// Create a new screen
game.magicNursery = game.addChild(new Container());
// Attach 'magicNurseryBackground' asset to the 'magicNursery' object
var magicNurseryBackground = game.magicNursery.attachAsset('magicNurseryBackground', {
anchorX: 0.5,
anchorY: 0.5,
interactive: false,
// Disable interactivity to prevent blurring on click
scaleX: 2,
// Double the size horizontally
scaleY: 2 // Double the size vertically
});
// Recreate the hammer asset
magicNurseryBackground.x = 2048 / 2;
magicNurseryBackground.y = 2732 / 2;
// Attach 'ForgeOfMatter' asset to the 'magicNursery' object
var forgeOfMatter = game.magicNursery.attachAsset('ForgeOfMatter', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true,
scaleX: 3,
// Increase the size horizontally
scaleY: 3,
// Increase the size vertically
alpha: 0.0 // Make the ForgeOfMatter fully transparent
});
// Create and add a new instance of the BlueCrystalIngot class
var blueCrystalIngot = game.magicNursery.addChild(new BlueCrystalIngot()); //{P.1}
// Position the blueCrystalIngot asset in the bottom-left corner
blueCrystalIngot.x = 200 + blueCrystalIngot.width / 2;
blueCrystalIngot.y = 2500 - blueCrystalIngot.height / 2;
// Create and add a new instance of the RedCrystalIngot class
var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot());
// Center the redCrystalIngot asset in the magicNursery screen
redCrystalIngot.x = 1300 / 2 + 350; // Move the redCristalIngot asset 100 pixels to the right
redCrystalIngot.y = 4820 / 2;
// Create and add a new instance of the GreenCrystalIngot class
var greenCrystalIngotInstance = game.magicNursery.addChild(new GreenCrystalIngot());
// Position the greenCrystalIngotInstance asset to the right of the blueCrystalIngot asset
greenCrystalIngotInstance.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCrystalIngotInstance.width / 2 + 40;
greenCrystalIngotInstance.y = blueCrystalIngot.y;
// Center the growthRate asset in the magicNursery screen
var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', {
anchorX: 0.5,
anchorY: 0.5
}));
growthRate.x = 700;
growthRate.y = 1450;
// Define the 'down' event handler for ForgeOfMatter
forgeOfMatter.down = function (x, y, obj) {
// Increment the click counter
storage.growthRate++;
// Update the text object with the click counter and label
growthRateText.setText('Growth rate: ' + storage.growthRate);
};
forgeOfMatter.x = 1100 / 1.5;
forgeOfMatter.y = 2000 / 1.5;
// Hide the game screen
gameScreen.visible = false;
// Show the forging skill counter when transitioning to magicNursery
counterText.visible = true;
// Hide the map when switching to the magic nursery screen
map.visible = false;
// Add a new object 'Door2'
var door2 = game.magicNursery.addChild(new Door2());
// Position 'Door2' to the right, between the center and the edge of the screen
door2.x = 2048 * 0.75;
door2.y = 2732 * 0.9;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
});
// Create a new class for the Door2 object
var Door2 = Container.expand(function () {
var self = Container.call(this);
// Attach 'Door' asset to the 'Door2' object
var doorGraphics = self.attachAsset('Door', {
anchorX: 0.5,
anchorY: 0.5
});
// Make the 'Door2' object interactive
self.interactive = true;
// Define the 'down' event handler
self.down = function (x, y, obj) {
LK.getSound('doors').play();
// Remove the existing hammer
hammer.destroy();
// Show the Anvil screen
gameScreen.visible = true;
// Show the map only on the anvil screen
map.visible = true;
// Show the counter display
counterText.visible = true;
// Hide the Magic Nursery screen
game.magicNursery.visible = false;
// Show the Growth rate counter when transitioning to anvil
growthRateText.visible = true;
// Recreate the hammer asset
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
});
// Create a new class for the GreenCristal object
var GreenCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'greenCristal' asset to the 'GreenCristal' object
var greenCristalGraphics = self.attachAsset('greenCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the greenCristal interactive
});
// Define the 'down' event handler for greenCristal
self.down = function (x, y, obj) {
// Increment the score by 1
greenCrystallScore += 1;
LK.setScore(greenCrystallScore);
storage.greenCrystallScore = greenCrystallScore;
// Update the score text
greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
greenScoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the GreenCrystalIngot object
var GreenCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'greenCrystalIngot' asset to the 'GreenCrystalIngot' object
var greenCrystalIngotGraphics = self.attachAsset('greenCrystalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the greenCrystalIngot interactive
});
// Define the 'down' event handler for greenCrystalIngot
self.down = function (x, y, obj) {
if (storage.growthRate >= 3000 && greenCrystallScore >= 100) {
storage.growthRate += 10; // Increment growth rate by 10
growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
// Increment the GreenCrystalIngot score by 1
greenCrystalIngotScore += 1;
greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore);
storage.greenCrystalIngotScore = greenCrystalIngotScore;
// Decrement the GreenCristal score by 100
greenCrystallScore -= 10;
if (greenCrystallScore < 0) {
greenCrystallScore = 0;
}
storage.greenCrystallScore = greenCrystallScore; // Persist the decrement
greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
}
};
});
// Create a new class for the RecipesScreen object
var RecipesScreen = Container.expand(function () {
var self = Container.call(this);
});
// Create a new class for the RedCristal object
var RedCristal = Container.expand(function () {
var self = Container.call(this);
// Attach 'redCristal' asset to the 'RedCristal' object
var redCristalGraphics = self.attachAsset('redCristal', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCristal interactive
});
// Define the 'down' event handler for redCristal
self.down = function (x, y, obj) {
// Increment the score by 1
redCrystallScore += 1;
LK.setScore(redCrystallScore);
storage.redCrystallScore = redCrystallScore;
// Update the score text
redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
redScoreTxt.visible = true; // Ensure the score text remains visible
};
});
// Create a new class for the RedCrystalIngot object
var RedCrystalIngot = Container.expand(function () {
var self = Container.call(this);
// Attach 'redCristalIngot' asset to the 'RedCrystalIngot' object
var redCrystalIngotGraphics = self.attachAsset('redCristalIngot', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCrystalIngot interactive
});
// Define the 'down' event handler for redCrystalIngot
self.down = function (x, y, obj) {
// Decrement the RedCristal score by 100
if (storage.growthRate >= 9000 && redCrystallScore >= 100) {
// Increment the RedCrystalIngot score by 1
redCrystalIngotScore += 1;
storage.growthRate += 20; // Increment growth rate by 20
growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore);
storage.redCrystalIngotScore = redCrystalIngotScore;
redCrystallScore -= 10;
storage.redCrystallScore = redCrystallScore; // Persist the decrement
redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
}
};
});
var RedCrystalTwoHandedSword = Container.expand(function () {
var self = Container.call(this);
// Attach 'redcrystaltwo-handedswordrecipe' asset to the 'RedCrystalTwoHandedSword' object
var redCrystalTwoHandedSwordGraphics = self.attachAsset('redcrystaltwo-handedswordrecipe', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the redCrystalTwoHandedSword interactive
});
});
/****
* Initialize Game
****/
// Create a new text object to display the click counter
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
//{0.1}
//{0.1}
var goldScore = storage.goldScore || 0;
var goldScoreTxt = new Text2('Gold: ' + goldScore, {
size: 50,
fill: 0xFFFFFF
});
goldScoreTxt.anchor.set(0, 0);
goldScoreTxt.y = 0;
if (typeof counterText !== 'undefined') {
goldScoreTxt.x = counterText.width + 10; // Position to the right of the Forging skill counter
} else {
goldScoreTxt.x = 550; // Default position if counterText is undefined
}
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; // Position below the GreenCrystalIngot score
LK.gui.topRight.addChild(redCrystalIngotScoreTxt);
//{0.1}
// Removed the 'current underfiend' text from the screen
var mineInsideBackground;
var blueCrystallScore = storage.blueCrystallScore || 0;
var automineblueCrystallClicked = storage.automineblueCrystallClicked;
var autominegreenCrystallClicked = storage.autominegreenCrystallClicked;
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; // Move the score text 100 pixels down
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; // Position below the Blue Crystall score
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; // Position below the BlueCrystalIngot score
LK.gui.topRight.addChild(greenCrystalIngotScoreTxt);
var blueCristal; // Define blueCristal in the global scope to fix the reference error
var greenCristal; // Define greenCristal in the global scope to fix the reference error
var redCristal; // Define redCristal in the global scope to fix the reference error
var blueCrystalIngotScore = storage.blueCrystalIngotScore || 0; //{1Z.1}
var blueSwordsText = new Text2(storage.blueSwords.toString(), {
size: 50,
fill: 0x000000 // Black color
});
blueSwordsText.anchor.set(0.5, 0.5);
blueSwordsText.x = 1248 / 2;
blueSwordsText.y = 2732 / 2 + 450; // Position below the 'Swords in stock' text
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; // Position below the Green Crystall score
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; // Initialize the map as invisible
// Make the map interactive
map.interactive = true;
// Define the 'down' event handler for the map
map.down = function (x, y, obj) {
hammer.destroy();
// Hide the map asset when transitioning to the map screen
LK.getSound('mapaudio').play();
map.visible = false;
// Hide the mineInsideBackground if it exists
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (redCristal) {
redCristal.visible = false; //{1Z.1}
redCristal.destroy(); // Ensure it is completely removed
} //{1Z.3}
if (blueCristal) {
blueCristal.visible = false; //{1X.1}
blueCristal.destroy(); // Ensure it is completely removed
} //{1X.3}
if (greenCristal) {
greenCristal.visible = false; //{1Y.1}
greenCristal.destroy(); // Ensure it is completely removed
} //{1Y.3}
var mapScreen = game.addChild(new Container());
// Attach 'mapbackground' asset to the mapScreen
var mapBackground = mapScreen.attachAsset('mapbackground', {
anchorX: 0.5,
//{1h.1}
anchorY: 0.5,
//{1h.2}
interactive: false // Ensure mapbackground does not block cursor interaction
}); //{1h.3}
// Add 'citymap' asset to the center of the screen
var cityMap = mapScreen.attachAsset('citymap', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'citymap' asset interactive
});
cityMap.x = -250;
cityMap.y = 160;
// Define the 'down' event handler for cityMap
cityMap.down = function (x, y, obj) {
hammer.destroy();
// Create a new screen without background
var isolatedScreen = game.addChild(new Container());
// Hide the current map screen
mapScreen.visible = false;
// Add 'citybackground' asset to the center of the isolatedScreen
var cityBackground = isolatedScreen.attachAsset('citybackground', {
anchorX: 0.5,
anchorY: 0.5
});
cityBackground.x = 0;
cityBackground.y = 0;
// Add 'map' asset to the isolatedScreen
var mapAsset = isolatedScreen.attachAsset('Map', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'map' asset interactive
});
mapAsset.x = -650;
mapAsset.y = 1100;
// Define the 'down' event handler for mapAsset
mapAsset.down = function (x, y, obj) {
// Transition back to the citymap screen
isolatedScreen.visible = false; // Hide the current isolated screen
mapScreen.visible = true; // Show the citymap screen
cityBackground.visible = false; // Ensure citybackground is hidden
mapBackground.visible = true;
};
// Add 'shop' asset to the center of the isolatedScreen
var shop = isolatedScreen.attachAsset('shop', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'shop' asset interactive
});
shop.x = 490;
shop.y = -20;
// Define the 'down' event handler for shop
shop.down = function (x, y, obj) {
hammer.destroy();
LK.getSound('shopin').play();
// Create a new screen without background
var shopScreen = game.addChild(new Container());
// Hide the current isolated screen
isolatedScreen.visible = false;
// Position the shopScreen at the center
shopScreen.x = 2048 / 2;
shopScreen.y = 2732 / 2;
// Add 'new tools' asset to the center of the shopScreen
var newTools = shopScreen.attachAsset('newTools', {
anchorX: 0.5,
anchorY: 0.5
});
newTools.x = -650;
newTools.y = 1100;
newTools.interactive = true; // Make the newTools asset interactive
newTools.down = function (x, y, obj) {
hammer.destroy();
// Create a new isolated screen without a background
var isolatedScreen = game.addChild(new Container());
// Attach 'newToolsBackground' asset to the isolatedScreen
var newToolsBackground = isolatedScreen.attachAsset('newToolsBackground', {
anchorX: 0.5,
anchorY: 0.5
});
newToolsBackground.x = 0;
newToolsBackground.y = 0;
if (!storage.theBlacksmithsApprentice) {
// Attach 'Theblacksmithsapprentice' asset to the center of the isolatedScreen
var theBlacksmithsApprentice = isolatedScreen.attachAsset('Theblacksmithsapprentice', {
anchorX: 0.5,
//{4C.1}
anchorY: 0.5,
//{4C.2}
interactive: true // Make the Theblacksmithsapprentice interactive
}); //{4C.3}
theBlacksmithsApprentice.x = 400;
theBlacksmithsApprentice.y = 200;
theBlacksmithsApprentice.clicked = storage.theBlacksmithsApprentice;
// Define the 'down' event handler for theBlacksmithsApprentice
theBlacksmithsApprentice.down = function (x, y, obj) {
// Increment forgingSkill by 1 every second
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);
// Store the intervalId in the theBlacksmithsApprentice object for potential future use
theBlacksmithsApprentice.intervalId = intervalId;
storage.theBlacksmithsApprentice = true;
theBlacksmithsApprentice.visible = false;
apprenticeText.visible = false;
apprenticeCostText.visible = false;
}
};
// Add text "The blacksmith's apprentice +1" below the Theblacksmithsapprentice asset
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; // Position below the Theblacksmithsapprentice asset
isolatedScreen.addChild(apprenticeText);
// Add text "1500G" below the 'The blacksmith's apprentice +1' text
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; // Position below the 'The blacksmith's apprentice +1' text
isolatedScreen.addChild(apprenticeCostText);
}
// Attach 'newToolsout' asset to the center of the isolatedScreen
var newToolsOut = isolatedScreen.attachAsset('newToolsout', {
anchorX: 0.5,
anchorY: 0.5
});
newToolsOut.x = 0;
newToolsOut.y = 1100;
newToolsOut.interactive = true; // Make the newToolsOut asset interactive//{4F.1}
if (!storage.automineblueCrystallClicked) {
// Attach 'automineblueCrystall' asset to the center of the isolatedScreen
var automineblueCrystall = isolatedScreen.attachAsset('automineblueCrystall', {
anchorX: 0.5,
//{4F.2}
anchorY: 0.5,
//{4F.3}
interactive: true // Make the automineblueCrystall interactive
}); //{4F.4}
automineblueCrystall.x = -400;
automineblueCrystall.y = -600;
automineblueCrystall.clicked = storage.automineblueCrystallClicked;
// Define the 'down' event handler for automineblueCrystall
automineblueCrystall.down = function (x, y, obj) {
// Increment blueCrystallScore by 1 every second
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);
// Store the intervalId in the automineblueCrystall object for potential future use
automineblueCrystall.intervalId = intervalId;
storage.automineblueCrystallClicked = true; // Persist the click state
automineblueCrystall.visible = false;
mineBlueCrystallText.visible = false;
mineBlueCrystallCostText.visible = false;
}
};
// Add text "Mine Blue Crystall +1" below the automineblueCrystall asset
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; // Position below the automineblueCrystall asset
isolatedScreen.addChild(mineBlueCrystallText);
// Add text "500G" below the 'Mine Blue Crystall +1' text
var mineBlueCrystallCostText = new Text2('500G', {
size: 50,
//{58.1}
fill: 0x030303 //{58.2}
}); //{58.3}
mineBlueCrystallCostText.anchor.set(0.5, 0.5);
mineBlueCrystallCostText.x = mineBlueCrystallText.x;
mineBlueCrystallCostText.y = mineBlueCrystallText.y + 50; // Position below the 'Mine Blue Crystall +1' text
isolatedScreen.addChild(mineBlueCrystallCostText);
}
if (!storage.autominegreenCrystallClicked) {
// Attach 'autominegreenCrystall' asset to the center of the isolatedScreen
var autominegreenCrystall = isolatedScreen.attachAsset('autominegreenCrystall', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the autominegreenCrystall interactive
});
autominegreenCrystall.x = -400;
autominegreenCrystall.y = -200;
// Define the 'down' event handler for autominegreenCrystall
autominegreenCrystall.clicked = storage.autominegreenCrystallClicked;
autominegreenCrystall.down = function (x, y, obj) {
// Increment greenCrystallScore by 1 every second
if (goldScore >= 1000 && !autominegreenCrystall.clicked) {
autominegreenCrystall.clicked = true;
goldScore -= 1000;
goldScoreTxt.setText('Gold: ' + goldScore);
storage.goldScore = goldScore;
var intervalId = LK.setInterval(function () {
greenCrystallScore += 1;
storage.greenCrystallScore = greenCrystallScore;
greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
}, 1000);
// Store the intervalId in the autominegreenCrystall object for potential future use
autominegreenCrystall.intervalId = intervalId;
storage.autominegreenCrystallClicked = true; // Persist the click state
autominegreenCrystall.visible = false;
mineGreenCrystallText.visible = false;
mineGreenCrystallCostText.visible = false;
}
};
// Add text "Mine Green Crystall +1" below the autominegreenCrystall asset
var mineGreenCrystallText = new Text2('Mine Green Crystall +1', {
size: 50,
fill: 0x030303
});
mineGreenCrystallText.anchor.set(0.5, 0.5);
mineGreenCrystallText.x = autominegreenCrystall.x;
mineGreenCrystallText.y = autominegreenCrystall.y + 150; // Lower the position below the autominegreenCrystall asset
isolatedScreen.addChild(mineGreenCrystallText);
// Add text "1000G" below the 'Mine Green Crystall +1' text
var mineGreenCrystallCostText = new Text2('1000G', {
size: 50,
//{5c.1}
fill: 0x030303 //{5c.2}
}); //{5c.3}
mineGreenCrystallCostText.anchor.set(0.5, 0.5);
mineGreenCrystallCostText.x = mineGreenCrystallText.x;
mineGreenCrystallCostText.y = mineGreenCrystallText.y + 50; // Position below the 'Mine Green Crystall +1' text
isolatedScreen.addChild(mineGreenCrystallCostText);
}
if (!storage.automineredCrystallClicked) {
// Attach 'automineredCrystall' asset to the center of the isolatedScreen
var automineredCrystall = isolatedScreen.attachAsset('automineredCrystall', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the automineredCrystall interactive
});
automineredCrystall.x = -400;
automineredCrystall.y = 200;
// Define the 'down' event handler for automineredCrystall
automineredCrystall.down = function (x, y, obj) {
// Increment redCrystallScore by 1 every second
if (goldScore >= 2000 && !automineredCrystall.clicked) {
automineredCrystall.clicked = true;
goldScore -= 2000;
goldScoreTxt.setText('Gold: ' + goldScore);
storage.goldScore = goldScore;
var intervalId = LK.setInterval(function () {
redCrystallScore += 1;
storage.redCrystallScore = redCrystallScore;
redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
}, 1000);
// Store the intervalId in the automineredCrystall object for potential future use
automineredCrystall.intervalId = intervalId;
storage.automineredCrystallClicked = true; // Persist the click state
automineredCrystall.visible = false;
mineRedCrystallText.visible = false;
mineRedCrystallCostText.visible = false;
}
};
// Add text "Mine Red Crystall +1" below the automineredCrystall asset
var mineRedCrystallText = new Text2('Mine Red Crystall +1', {
size: 50,
fill: 0x030303
});
mineRedCrystallText.anchor.set(0.5, 0.5);
mineRedCrystallText.x = automineredCrystall.x;
mineRedCrystallText.y = automineredCrystall.y + 140; // Position below the automineredCrystall asset
isolatedScreen.addChild(mineRedCrystallText);
// Add text "2000G" below the 'Mine Red Crystall +1' text
var mineRedCrystallCostText = new Text2('2000G', {
size: 50,
//{55.1}
fill: 0x030303 //{55.2}
}); //{55.3}
mineRedCrystallCostText.anchor.set(0.5, 0.5);
mineRedCrystallCostText.x = mineRedCrystallText.x;
mineRedCrystallCostText.y = mineRedCrystallText.y + 50; // Position below the 'Mine Red Crystall +1' text
isolatedScreen.addChild(mineRedCrystallCostText);
}
if (!storage.multiclickupgrade) {
// Attach 'multiclickupgrade' asset to the center of the isolatedScreen
var multiclickupgrade = isolatedScreen.attachAsset('multiclickupgrade', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the multiclickupgrade interactive
});
multiclickupgrade.x = 400;
multiclickupgrade.y = -200;
// Define the 'down' event handler for multiclickupgrade
multiclickupgrade.down = function (x, y, obj) {
// Deduct 700 gold when clicked
if (goldScore >= 700 && !storage.multiclickupgrade) {
goldScore -= 700;
goldScoreTxt.setText('Gold: ' + goldScore);
storage.goldScore = goldScore;
storage.multiclickupgrade = true;
multiclickupgrade.visible = false;
increasedChanceText.visible = false;
increasedChanceCostText.visible = false;
}
};
// Add text "Increased chance of successful forging +5%" below the multiclickupgrade asset
var increasedChanceText = new Text2('Increased chance of \nsuccessful forging +5%', {
size: 50,
fill: 0x030303
});
increasedChanceText.anchor.set(0.5, 0.5);
increasedChanceText.x = multiclickupgrade.x;
increasedChanceText.y = multiclickupgrade.y + 170; // Position below the multiclickupgrade asset
isolatedScreen.addChild(increasedChanceText);
// Add text "700G" below the 'Increased chance of successful forging +5%' text
var increasedChanceCostText = new Text2('700G', {
size: 50,
//{4Z.1}
fill: 0x030303 //{4Z.2}
}); //{4Z.3}
increasedChanceCostText.anchor.set(0.5, 0.5);
increasedChanceCostText.x = increasedChanceText.x;
increasedChanceCostText.y = increasedChanceText.y + 70; // Position below the 'Increased chance of successful forging +5%' text
isolatedScreen.addChild(increasedChanceCostText);
}
if (!storage.autogrowthRateClicked) {
// Attach 'autogrowthRate' asset to the center of the isolatedScreen
var autogrowthRate = isolatedScreen.attachAsset('autogrowthRate', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the autogrowthRate interactive
});
autogrowthRate.x = 400;
autogrowthRate.y = -600;
autogrowthRate.clicked = storage.autogrowthRateClicked;
// Define the 'down' event handler for autogrowthRate
autogrowthRate.down = function (x, y, obj) {
// Increment growthRateCounter by 1 every second
if (goldScore >= 2000 && !autogrowthRate.clicked) {
autogrowthRate.clicked = true;
goldScore -= 2000;
goldScoreTxt.setText('Gold: ' + goldScore);
storage.goldScore = goldScore;
var intervalId = LK.setInterval(function () {
growthRateCounter += 1;
growthRateText.setText('Growth rate: ' + growthRateCounter);
storage.growthRate = growthRateCounter;
}, 1000);
// Store the intervalId in the autogrowthRate object for potential future use
autogrowthRate.intervalId = intervalId;
storage.autogrowthRateClicked = true; // Persist the click state
autogrowthRate.visible = false;
automaticMeltingText.visible = false;
automaticMeltingCostText.visible = false;
}
};
// Add text "Automatic melting +1" below the autogrowthRate asset
var automaticMeltingText = new Text2('Automatic melting +1', {
size: 50,
fill: 0x030303
});
automaticMeltingText.anchor.set(0.5, 0.5);
automaticMeltingText.x = autogrowthRate.x;
automaticMeltingText.y = autogrowthRate.y + 150; // Position below the autogrowthRate asset
isolatedScreen.addChild(automaticMeltingText);
// Add text "2000G" below the 'Automatic melting +1' text
var automaticMeltingCostText = new Text2('2000G', {
size: 50,
fill: 0x030303
});
automaticMeltingCostText.anchor.set(0.5, 0.5);
automaticMeltingCostText.x = automaticMeltingText.x;
automaticMeltingCostText.y = automaticMeltingText.y + 50; // Position below the 'Automatic melting +1' text
isolatedScreen.addChild(automaticMeltingCostText);
}
newToolsOut.down = function (x, y, obj) {
LK.getSound('booksaudio').play();
// Transition to the newTools screen
isolatedScreen.visible = false; // Hide the current isolated screen
shopScreen.visible = true; // Show the newTools screen
};
// Hide the current shop screen
shopScreen.visible = false;
// Position the isolatedScreen at the center
isolatedScreen.x = 2048 / 2;
isolatedScreen.y = 2732 / 2;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
// Add 'shopout' asset to the shopScreen
var shopBackground = shopScreen.attachAsset('shopbackground', {
anchorX: 0.5,
anchorY: 0.5
});
shopBackground.x = 0;
shopBackground.y = 0;
// Add 'new buildings' asset to the center of the shopScreen
var newBuildings = shopScreen.attachAsset('sellweapons', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'sellweapons' asset interactive
});
// Define the 'down' event handler for sellweapons
newBuildings.down = function (x, y, obj) {
console.log("Sell weapons asset clicked at", x, y);
// Reset 'Swords in stock' counter and add +50 to Gold for each sword
goldScore += storage.blueSwords * 50;
storage.blueSwords = 0;
blueSwordsText.setText('0');
goldScore += storage.greenAxes * 150;
storage.greenAxes = 0;
goldScore += storage.redCrystalTwoHandedSwords * 600;
storage.redCrystalTwoHandedSwords = 0;
goldScoreTxt.setText('Gold: ' + goldScore);
storage.goldScore = goldScore;
};
newBuildings.x = 0;
newBuildings.y = 1100;
// Add 'shopout' asset to the shopScreen
var shopOut = shopScreen.attachAsset('shopout', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'shopout' asset interactive
});
shopOut.x = 650;
shopOut.y = 1100;
// Define the 'down' event handler for shopOut
shopOut.down = function (x, y, obj) {
LK.getSound('doors').play();
shopScreen.visible = false; // Hide the current shop screen
mapBackground.visible = false; // Ensure the mapbackground asset is hidden
mapScreen.visible = true; // Show the citymap screen
isolatedScreen.visible = true; // Ensure the isolated screen is visible
};
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
// Position the isolatedScreen at the center
isolatedScreen.x = 2048 / 2;
isolatedScreen.y = 2732 / 2;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
// Attach 'anvilmap' asset to the mapScreen on the top layer
var anvilMap = mapScreen.attachAsset('anvilmap', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true
});
// Attach 'mine' asset to the mapScreen on the top layer
var mine = mapScreen.attachAsset('mine', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true
});
mine.x -= 150; // Move the mine asset 150 pixels to the left
mine.y -= 150; // Move the mine asset 150 pixels higher
// Make mine interactive and define the 'down' event handler
mine.down = function (x, y, obj) {
hammer.destroy();
// Create a new screen for the mine
var mineScreen = game.addChild(new Container());
// Make the map visible after transitioning to the mine screen
map.visible = true;
// Hide the current map screen
mapScreen.visible = false;
// Disable the active background
background.visible = false;
// Attach 'mineinsidebackground' asset to the mineScreen on the bottom layer
mineInsideBackground = mineScreen.attachAsset('mineinsidebackground', {
anchorX: 0.5,
anchorY: 0.5,
interactive: false,
zIndex: -1 // Ensure it is on the bottom layer
});
// Create and add a new instance of the RedCristal class
redCristal = mineScreen.addChild(new RedCristal());
// Position the redCristal asset
redCristal.x -= 510; // Move 100 pixels to the left
redCristal.y += 490; // Move 100 pixels lower
// Create and add a new instance of the GreenCristal class
greenCristal = mineScreen.addChild(new GreenCristal());
// Position the greenCristal asset
greenCristal.x -= -510; // Move 100 pixels to the left
greenCristal.y += 10; // Move 100 pixels lower
// Create and add a new instance of the BlueCristal class
blueCristal = mineScreen.addChild(new BlueCristal());
// Position the blueCristal asset
blueCristal.x += 490; // Move 100 pixels to the right
blueCristal.y += -60; // Move 100 pixels lower
// Position the blueCristal asset
blueCristal.x -= 410; // Move 100 pixels to the left
blueCristal.y -= 310; // Move 100 pixels lower
// Position the mineScreen at the center
mineScreen.x = 2048 / 2; //{1E.1}
mineScreen.y = 2732 / 2; //{1E.2}
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
// Make anvilMap interactive and define the 'down' event handler
anvilMap.down = function (x, y, obj) {
// Show the Anvil screen
gameScreen.visible = true;
// Make the map visible after transitioning to the anvil map
map.visible = true;
// Attach 'gameScreenBackground' asset to the 'gameScreen' object
gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Attach 'recipes' asset to the 'gameScreenBackground' object
var recipes = gameScreenBackground.attachAsset('recipes', {
anchorX: 0.5,
anchorY: 0.5
});
// Center the 'recipes' asset on the gameScreenBackground
recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
// Hide the mineinsidebackground when exiting the mine screen
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (mineInsideBackground) {
mineInsideBackground.visible = false;
mineInsideBackground.destroy(); // Ensure it is completely removed
}
if (blueCristal) {
blueCristal.visible = false; //{1X.1}
blueCristal.destroy(); // Ensure it is completely removed
} //{1X.3}
if (greenCristal) {
greenCristal.visible = false; //{1Y.1}
greenCristal.destroy(); // Ensure it is completely removed
} //{1Y.3}
if (redCristal) {
redCristal.visible = false; //{1Z.1}
redCristal.destroy(); // Ensure it is completely removed
} //{1Z.3}
// Hide the map screen
mapScreen.visible = false;
// Show the counter display
counterText.visible = true;
// Show the Growth rate counter when transitioning to anvilmap
growthRateText.visible = true;
};
// Hide the current game screen
gameScreen.visible = false;
// Disable the active background
background.visible = false;
// Attach a new background or asset to the mapScreen if needed
// Example: mapScreen.attachAsset('newBackground', { anchorX: 0.5, anchorY: 0.5 });
// Position the mapScreen at the center
mapScreen.x = 2048 / 2;
mapScreen.y = 2732 / 2;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
var growthRateText;
var growthRateCounter = storage.growthRate; // Initialize growth rate counter from storage
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()); //{1h.1}
var newGame = game.addChild(new Container());
newGame.x = 2650 / 2 + 100; //{3d.1}
newGame.y = 2680 * 4.2 / 5; //{3d.1}
// Attach 'title' asset to the start screen
var title = game.addChild(LK.getAsset('title', {
anchorX: 0.5,
anchorY: 0.5
}));
title.x = 2048 / 2;
title.y = 3200 / 5;
// Attach 'newGameText' asset to the 'New Game' object
var newGameText = newGame.attachAsset('newGameText', {
anchorX: 0.5,
anchorY: 0.5,
stroke: 0xFFFFFF,
// White color
strokeThickness: 5 // 5px thickness
});
// Attach 'continueText' asset to the game object
var continueText = game.addChild(LK.getAsset('continueText', {
anchorX: 0.5,
anchorY: 0.5
}));
continueText.x = newGame.x - newGame.width - 500; // Increase the distance between newGame and continueText
continueText.y = newGame.y; // Align vertically with newGame
continueText.interactive = true;
continueText.down = function (x, y, obj) {
startgame();
};
var blueswordsclick = storage.blueswordsclick;
var greenAxeClicks = storage.greenAxeClicks;
var redCrystalTwoHandedSwordClicks = storage.redCrystalTwoHandedSwordClicks;
function startgame() {
title.destroy();
hammer.destroy();
// Create a new game screen
gameScreen = game.addChild(new Container());
gameScreen.x = 2048 / 2;
gameScreen.y = 2732 / 2;
// Attach 'gameScreenBackground' asset to the 'gameScreen' object
gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Attach 'recipes' asset to the 'gameScreenBackground' object
var recipes = gameScreenBackground.attachAsset('recipes', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the recipes asset interactive
});
// Remove 'continueText' asset when transitioning to new game
// Define the 'down' event handler for recipes
recipes.down = function (x, y, obj) {
hammer.destroy();
LK.getSound('booksaudio').play();
// Create a new screen for the recipes
var recipesScreen = game.addChild(new RecipesScreen());
map.visible = false; // Hide the map asset after transitioning to the recipes screen
// Add 'recipesbackground' asset to the center of the screen
var recipesBackground = recipesScreen.attachAsset('recipesbackground', {
anchorX: 0.5,
anchorY: 0.5
});
recipesBackground.x = 2048 / 2;
recipesBackground.y = 2932 / 2;
// Add 'bluecrystalswordrecipe' asset to the center of the screen
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; // Отнимаем 10, но теперь в `storage`
blueCrystalIngotScore = storage.blueCrystalIngotScore; // Обновляем локальную переменную
blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore);
}
}
blueCrystalSwordClicks.setText('(current ' + blueswordsclick + ')');
storage.blueswordsclick = blueswordsclick;
};
// Add 'Swords in stock' text asset to the center of the screen
var swordsInStockText = new Text2('Swords in stock', {
size: 50,
fill: 0x000000 // Black color
});
swordsInStockText.anchor.set(0.5, 0.5);
swordsInStockText.x = 1248 / 2;
swordsInStockText.y = 2732 / 2 + 400;
var axeInStockText = new Text2('Axe in stock', {
size: 50,
fill: 0x000000 // Black color
});
axeInStockText.anchor.set(0.5, 0.5);
axeInStockText.x = 2848 / 2;
axeInStockText.y = 2732 / 2 + 400; // Align with 'Swords in stock' text
recipesScreen.addChild(axeInStockText);
recipesScreen.addChild(swordsInStockText);
// Display the number of blue swords in stock
var blueSwordsText = new Text2(storage.blueSwords.toString(), {
size: 50,
fill: 0x000000 // Black color
});
blueSwordsText.anchor.set(0.5, 0.5);
blueSwordsText.x = 1248 / 2;
blueSwordsText.y = swordsInStockText.y + 80; // Position below the 'Swords in stock' text
recipesScreen.addChild(blueSwordsText);
// Add 'Axe of Green Crystals recipe' asset to the center of the screen
var axeOfGreenCrystalsRecipe = recipesScreen.attachAsset('axeOfGreenCrystalsRecipe', {
anchorX: 0.5,
anchorY: 0.5
});
axeOfGreenCrystalsRecipe.x = 2848 / 2;
axeOfGreenCrystalsRecipe.y = 2132 / 2;
axeOfGreenCrystalsRecipe.down = function () {
if (storage.forgingSkill >= 8000 && storage.greenCrystalIngotScore >= 15) {
greenAxeClicks += 1;
}
if (greenAxeClicks >= 150) {
greenAxeClicks = 0;
storage.greenAxes += 1; // Увеличиваем количество зелёных топоров в хранилище
greenAxesText.setText(storage.greenAxes.toString());
storage.forgingSkill += 150; // Добавляем 150 к навыку ковки
counterText.setText('Forging skill: ' + storage.forgingSkill); // Обновляем отображение навыка ковки
if (storage.greenCrystalIngotScore >= 15) {
storage.greenCrystalIngotScore -= 15; // Вычитаем 15 из greenCrystalIngotScore
greenCrystalIngotScore = storage.greenCrystalIngotScore; // Сохраняем новое значение в хранилище
greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore); // Обновляем текстовое отображение
}
}
greenAxeClicksText.setText('(current ' + greenAxeClicks + ')');
storage.greenAxeClicks = greenAxeClicks;
};
// Add 'Axe in stock' text asset to the center of the screen
var axeInStockText = new Text2('Axe in stock', {
size: 50,
fill: 0x000000 // Black color
});
axeInStockText.anchor.set(0.5, 0.5);
axeInStockText.x = 2848 / 2;
recipesScreen.addChild(axeInStockText);
// Display the number of green axes in stock
var greenAxesText = new Text2(storage.greenAxes.toString(), {
size: 50,
fill: 0x000000 // Black color
});
greenAxesText.anchor.set(0.5, 0.5);
greenAxesText.x = 2848 / 2;
greenAxesText.y = swordsInStockText.y + 80; // Position below the 'Swords in stock' text
recipesScreen.addChild(greenAxesText);
// Add 'Green Axe clicks' text asset to the center of the screen
var greenAxeClicksText = new Text2('(current ' + greenAxeClicks + ')', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
greenAxeClicksText.anchor.set(0.5, 0.5);
greenAxeClicksText.x = 2848 / 2 - 150;
greenAxeClicksText.y = 2732 / 2 + 330;
recipesScreen.addChild(greenAxeClicksText);
// Add 'Blue crystal sword description' text asset to the center of the screen
var blueCrystalSwordDescription = new Text2('"Blue Crystal Sword"\n Forging Skill 2k.\n 10 blue crystal ingots +\n 100 clicks on the recipe', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
blueCrystalSwordDescription.anchor.set(0.5, 0.5);
blueCrystalSwordDescription.x = 1248 / 2;
blueCrystalSwordDescription.y = 2732 / 2 + 200;
recipesScreen.addChild(blueCrystalSwordDescription);
var blueCrystalSwordClicks = new Text2('(current ' + blueswordsclick + ')', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
blueCrystalSwordClicks.anchor.set(0.5, 0.5);
blueCrystalSwordClicks.x = 1248 / 2 - 150;
blueCrystalSwordClicks.y = 2732 / 2 + 330;
recipesScreen.addChild(blueCrystalSwordClicks);
// Add 'axeOfGreenCrystals description' text asset to the center of the screen
var axeOfGreenCrystalsDescription = new Text2('"Axe of Green Crystals"\n Forging Skill 8k.\n 15 green crystal ingots +\n 150 clicks on the recipe', {
size: 50,
fill: 0x000000,
alpha: 0.5 // Set transparency
});
axeOfGreenCrystalsDescription.anchor.set(0.5, 0.5);
axeOfGreenCrystalsDescription.x = 2890 / 2;
axeOfGreenCrystalsDescription.y = 2732 / 2 + 200;
recipesScreen.addChild(axeOfGreenCrystalsDescription);
// Add 'recipesnext' asset to the center of the screen
var recipesNext = recipesScreen.attachAsset('recipesnext', {
anchorX: 0.5,
anchorY: 0.5 //{4F.1}
}); //{4G.1}
recipesNext.x = 3248 / 2;
recipesNext.y = 5000 / 2;
// Make the 'recipesnext' asset interactive
recipesNext.interactive = true;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
// Define the 'down' event handler for recipesNext
recipesNext.down = function (x, y, obj) {
// Create a new screen for the next section
var nextScreen = game.addChild(new Container());
LK.getSound('paper').play();
// Remove the current background
recipesScreen.visible = false;
// Add 'recipesnextbackgr1' asset to the center of the screen
var recipesNextBackgr1 = nextScreen.attachAsset('recipesnextbackgr1', {
anchorX: 0.5,
anchorY: 0.5
});
recipesNextBackgr1.x = 2048 / 2;
recipesNextBackgr1.y = 2732 / 2;
// Remove the existing hammer
hammer.destroy();
// Add 'recipesprev' asset to the center of the screen
var recipesPrev = nextScreen.attachAsset('recipesprev', {
anchorX: 0.5,
anchorY: 0.5,
interactive: true // Make the 'recipesprev' asset interactive
});
recipesPrev.x = 888 / 2;
recipesPrev.y = 5000 / 2;
// Define the 'down' event handler for recipesPrev
recipesPrev.down = function (x, y, obj) {
LK.getSound('paper').play();
// Transition back to the recipes screen
nextScreen.visible = false; // Hide the current screen
recipesScreen.visible = true; // Show the recipes screen
};
// Add 'blueingotrecipe' asset to the center of the screen
var blueingotrecipe = nextScreen.attachAsset('blueingotrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
blueingotrecipe.x = 1450;
blueingotrecipe.y = 750;
// Add text under the 'blueingotrecipe' asset
var blueIngotRecipeText = new Text2('"BlueCrystalIngot"\n Growth rate 500.\n 10 Blue Crystal', {
size: 50,
fill: 0x000000 // Black color
});
blueIngotRecipeText.anchor.set(0.5, 0.5);
blueIngotRecipeText.x = blueingotrecipe.x;
blueIngotRecipeText.y = blueingotrecipe.y + 150; // Position below the 'blueingotrecipe' asset
nextScreen.addChild(blueIngotRecipeText);
// Add 'greeningotrecipe' asset to the center of the screen
var greeningotrecipe = nextScreen.attachAsset('greeningotrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
greeningotrecipe.x = 1450;
greeningotrecipe.y = 1150;
// Add text under the 'greeningotrecipe' asset
var greeningotrecipeText = new Text2('"Greeningotrecipe"\n Growth rate 3000.\n 10 Green Crystal', {
size: 50,
fill: 0x000000 // Black color
});
greeningotrecipeText.anchor.set(0.5, 0.5);
greeningotrecipeText.x = greeningotrecipe.x;
greeningotrecipeText.y = greeningotrecipe.y + 160; // Position below the 'greeningotrecipe' asset
nextScreen.addChild(greeningotrecipeText);
// Add 'redingotrecipe' asset to the center of the screen
var redingotrecipe = nextScreen.attachAsset('redingotrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
redingotrecipe.x = 1450;
redingotrecipe.y = 1500;
// Add text under the 'redingotrecipe' asset
var redingotrecipeText = new Text2('"Redingotrecipe"\n Growth rate 9000.\n 10 Green Crystal', {
size: 50,
fill: 0x000000 // Black color
});
redingotrecipeText.anchor.set(0.5, 0.5);
redingotrecipeText.x = redingotrecipe.x;
redingotrecipeText.y = redingotrecipe.y + 150; // Position below the 'redingotrecipe' asset
nextScreen.addChild(redingotrecipeText);
// Add 'redcrystaltwo-handedswordrecipe' asset to the center of the screen
var redCrystalTwoHandedSwordRecipe = nextScreen.attachAsset('redcrystaltwo-handedswordrecipe', {
anchorX: 0.5,
anchorY: 0.5
});
redCrystalTwoHandedSwordRecipe.x = 1248 / 2;
redCrystalTwoHandedSwordRecipe.y = 2132 / 2;
redCrystalTwoHandedSwordRecipe.down = function () {
if (storage.forgingSkill >= 15000 && storage.redCrystalIngotScore >= 75) {
redCrystalTwoHandedSwordClicks += 1;
}
if (redCrystalTwoHandedSwordClicks >= 200) {
redCrystalTwoHandedSwordClicks = 0;
storage.redCrystalTwoHandedSwords += 1; // Увеличение количества мечей в storage
redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString());
storage.forgingSkill += 210; // Добавление опыта кузнечного дела
counterText.setText('Forging skill: ' + storage.forgingSkill);
storage.redCrystalIngotScore -= 75; // Вычитаем 75 инготов из storage
redCrystalIngotScore = storage.redCrystalIngotScore; // Обновляем локальную переменную
redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore); // Обновляем отображение
}
redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')');
storage.redCrystalTwoHandedSwordClicks = redCrystalTwoHandedSwordClicks;
};
// Add 'Red Crystal Two-Handed Sword in stock' text asset to the center of the screen
var redCrystalTwoHandedSwordsText = new Text2(storage.redCrystalTwoHandedSwords.toString(), {
size: 50,
fill: 0x000000 // Black color
});
redCrystalTwoHandedSwordsText.anchor.set(0.5, 0.5);
redCrystalTwoHandedSwordsText.x = 1248 / 2;
var redCrystalTwoHandedSwordDescription = new Text2('"Redcrystaltwo-\n handedswordrecipe"\n Forging Skill 15k.\n 75 red crystal ingots +\n 200 clicks on the anvil', {
size: 50,
fill: 0x000000 // Black color
});
redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5);
redCrystalTwoHandedSwordDescription.x = 1248 / 2;
redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 100;
nextScreen.addChild(redCrystalTwoHandedSwordDescription);
// Add 'Two-hand Swords in stock' text asset to the center of the screen
var twoHandSwordsInStockText = new Text2('Two-hand Swords in stock', {
size: 50,
fill: 0x000000 // Black color
});
twoHandSwordsInStockText.anchor.set(0.5, 0.5);
twoHandSwordsInStockText.x = 1248 / 2;
twoHandSwordsInStockText.y = redCrystalTwoHandedSwordDescription.y + 250; // Position below the description
nextScreen.addChild(twoHandSwordsInStockText);
redCrystalTwoHandedSwordsText.y = redCrystalTwoHandedSwordDescription.y + 300; // Position further below the description
nextScreen.addChild(redCrystalTwoHandedSwordsText);
// Add a new text box with black text under the 'redcrystaltwo-handedswordrecipe' asset
var redCrystalTwoHandedSwordClicksText = new Text2('(current ' + redCrystalTwoHandedSwordClicks + ')', {
size: 50,
fill: 0x000000,
alpha: 0.5
});
redCrystalTwoHandedSwordClicksText.anchor.set(0.5, 0.5);
redCrystalTwoHandedSwordClicksText.x = 1248 / 2 - 135;
redCrystalTwoHandedSwordClicksText.y = 2732 / 2 + 260;
nextScreen.addChild(redCrystalTwoHandedSwordClicksText);
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
};
// Attach 'recipesout' asset to the 'RecipesScreen' object
var recipesOutGraphics = recipesScreen.attachAsset('recipesout', {
anchorX: 0.5,
anchorY: 0.5
});
// Center the 'recipesout' asset on the screen
recipesOutGraphics.x = 2048 / 2;
recipesOutGraphics.y = 2732 / 2 + 1100;
// Make the 'recipesout' asset interactive
recipesOutGraphics.interactive = true;
LK.getSound('paper').play();
// Define the 'down' event handler for recipesOutGraphics
recipesOutGraphics.down = function (x, y, obj) {
// Hide the 'recipesout' asset
recipesOutGraphics.visible = false;
// Transition to the 'gameScreen'
gameScreen.visible = true;
// Make the map visible after transitioning to the recipesout screen
map.visible = true;
// Hide the current recipes screen
recipesScreen.visible = false;
};
// Hide the current game screen
gameScreen.visible = false;
};
// Center the 'recipes' asset on the gameScreenBackground
recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
// Make the map visible when 'New Game' is clicked
map.visible = true;
// Hide the main menu
newGame.visible = false;
continueText.visible = false;
// Disable the background
background.visible = false;
// Create a new instance of the Anvil class
var anvil = gameScreen.addChild(new Anvil());
// Initialize the anvil click counter from storage
anvil.clickCounter = storage.forgingSkill;
counterText.setText('Forging skill: ' + anvil.clickCounter);
// Position 'The anvil' at the location of the anvil on the gameScreenBackground
anvil.x = gameScreenBackground.x - -20; // Adjust x-coordinate based on the anvil's position on the background
anvil.y = gameScreenBackground.y + 500; // Adjust y-coordinate based on the anvil's position on the background
// Add a new object 'Magic Nursery'
var magicNursery = gameScreen.addChild(new Door());
// Position 'Magic Nursery' to the left and up
magicNursery.x = 2048 / 4;
magicNursery.y = 2732 / 2.5;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
}
// Make the 'New Game' object clickable
newGame.interactive = true;
newGame.down = function (x, y, obj) {
if (newgameclearInterval.length > 0) {
for (var i = 0; i < newgameclearInterval.length; i++) {
LK.clearInterval(newgameclearInterval[i]);
}
}
storage.automineblueCrystallClicked = false;
storage.autominegreenCrystallClicked = false;
storage.automineredCrystallClicked = false;
storage.autogrowthRateClicked = false;
storage.theBlacksmithsApprentice = false;
storage.multiclickupgrade = false;
// Reset all saved data
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.greenCrystalIngotScore = 0;
storage.blueSwords = 0;
storage.goldScore = 0;
// Reset current variables
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.redCrystallScore);
goldScoreTxt.setText('Gold: ' + goldScore);
startgame();
};
// Create a new text object to display the click counter
var counterText = new Text2('Forging skill: ' + storage.forgingSkill, {
size: 50,
fill: 0xFFFFFF
});
// Position the text object at the top right corner of the screen
counterText.anchor.set(0, 0);
LK.gui.topLeft.addChild(counterText);
counterText.y = 0;
counterText.x = 0;
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; // Move the growth rate text 2 pixels higher
growthRateText.x = 0;
// Initialize hammer asset
var hammer;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
// Function to make the hammer follow the mouse/touch position
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);
}
if (autominegreenCrystallClicked) {
var intervalId = LK.setInterval(function () {
greenCrystallScore += 1;
storage.greenCrystallScore = greenCrystallScore;
greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
}, 1000);
newgameclearInterval.push(intervalId);
}
if (automineredCrystallClicked) {
var intervalId = LK.setInterval(function () {
redCrystallScore += 1;
storage.redCrystallScore = redCrystallScore;
redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
}, 1000);
newgameclearInterval.push(intervalId);
}
if (autogrowthRateClicked) {
var intervalId = LK.setInterval(function () {
growthRateCounter += 1;
growthRateText.setText('Growth rate: ' + growthRateCounter);
storage.growthRate = growthRateCounter;
}, 1000);
newgameclearInterval.push(intervalId);
}
if (storage.theBlacksmithsApprentice) {
var intervalId = LK.setInterval(function () {
storage.forgingSkill += 1;
counterText.setText('Forging skill: ' + storage.forgingSkill);
}, 1000);
newgameclearInterval.push(intervalId);
}
var seconds = Math.floor(Date.now() / 1000);
seconds = seconds - storage.lastgametime;
if (seconds * 60 * 5 > Math.floor(Date.now() / 1000)) {
seconds = 5 * 60 * 60;
}
if (seconds > 0) {
if (storage.automineblueCrystallClicked) {
blueCrystallScore += seconds;
storage.blueCrystallScore += seconds;
}
if (storage.autominegreenCrystallClicked) {
greenCrystallScore += seconds;
storage.greenCrystallScore += seconds;
}
if (storage.automineredCrystallClicked) {
redCrystallScore += seconds;
storage.redCrystallScore += seconds;
}
if (storage.autogrowthRateClicked) {
growthRateCounter += seconds;
storage.growthRate += seconds;
}
if (storage.theBlacksmithsApprentice) {
storage.forgingSkill += seconds;
}
}
var intervalId = LK.setInterval(function () {
storage.lastgametime = Math.floor(Date.now() / 1000);
console.log(storage.lastgametime);
}, 1000);
// Make the cursor follow the mouse/touch position
game.move = function (x, y, obj) {
updateHammerPosition(x, y);
};
// Animate cursor rotation on click
game.down = function (x, y, obj) {
LK.getSound('hammer').play();
tween(hammer, {
rotation: -Math.PI / 2
}, {
duration: 125,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Create stars around the hammer for 0.25 seconds
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;
(function (star) {
// Make the star move upwards
star.update = function () {
star.y -= 5; // Move the star upwards by 5 pixels per frame
if (star.x < hammer.x) {
star.x += 2; // Move the star slightly to the right if on the left side of the hammer
} else {
star.x -= 2; // Move the star slightly to the left if on the right side of the hammer
}
};
LK.setTimeout(function () {
star.destroy();
}, 250);
})(star);
}
tween(hammer, {
rotation: 0
}, {
duration: 125,
easing: tween.easeInOut
});
}
});
}; ===================================================================
--- original.js
+++ change.js
@@ -5,978 +5,1690 @@
var storage = LK.import("@upit/storage.v1", {
forgingSkill: 0,
growthRate: 0,
blueCrystallScore: 0,
- greenCrystallScore: 0,
- redCrystallScore: 0,
- blueCrystalIngotScore: 0,
greenCrystalIngotScore: 0,
- redCrystalIngotScore: 0,
blueSwords: 0,
greenAxes: 0,
redCrystalTwoHandedSwords: 0,
blueswordsclick: 0,
greenAxeClicks: 0,
redCrystalTwoHandedSwordClicks: 0,
automineblueCrystallClicked: false,
autominegreenCrystallClicked: false,
- automineredCrystallClicked: false,
autogrowthRateClicked: false,
multiclickupgrade: false,
theBlacksmithsApprentice: false,
- goldScore: 0,
+ automineredCrystallClicked: false,
lastgametime: 0
});
/****
+* Classes
+****/
+// Create a new class for the anvil object
+var Anvil = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'anvil' asset to the 'Anvil' object
+ var anvilGraphics = self.attachAsset('anvil', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.0 // Make the anvil fully transparent
+ });
+ // Initialize the click counter
+ self.clickCounter = storage.forgingSkill;
+ // Make the 'Anvil' object interactive
+ self.interactive = true;
+ // Define the 'down' event handler
+ self.down = function (x, y, obj) {
+ // Increment the click counter
+ self.clickCounter++;
+ // Add a 5% chance for a multi-click event to increase forging skill by 5
+ var shans = 0.02;
+ if (storage.multiclickupgrade) {
+ shans += 0.02;
+ }
+ if (Math.random() < 0.02) {
+ self.clickCounter += 5;
+ // Create a new asset at the center of the screen
+ var newAsset = game.addChild(LK.getAsset('multyclick', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ // Position the new asset at the center of the screen
+ newAsset.x = 2048 / 2;
+ newAsset.y = 2732 / 2;
+ // Animate the scaling of the new asset
+ tween(newAsset, {
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ newAsset.destroy(); // Remove the asset after the animation
+ }
+ });
+ }
+ // Update the text object with the click counter and label
+ counterText.setText('Forging skill: ' + self.clickCounter);
+ // Persist the click counter
+ storage.forgingSkill = self.clickCounter;
+ // Change the color of the counter text based on the click counter
+ if (self.clickCounter >= 1000 && self.clickCounter < 2000) {
+ counterText.tint = 0x00FF00; // Green
+ } else if (self.clickCounter >= 2000 && self.clickCounter < 15000) {
+ counterText.tint = 0x0000FF; // Blue
+ } else if (self.clickCounter >= 15000 && self.clickCounter < 30000) {
+ counterText.tint = 0x800080; // Purple
+ } else if (self.clickCounter >= 30000) {
+ counterText.tint = 0xcc7c04; // Purple
+ }
+ };
+});
+// Create a new class for the BlueCristal object
+var BlueCristal = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'blueCristal' asset to the 'BlueCristal' object
+ var blueCristalGraphics = self.attachAsset('blueCristal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the blueCristal interactive
+ });
+ // Define the 'down' event handler for blueCristal
+ self.down = function (x, y, obj) {
+ // Increment the score by 1
+ blueCrystallScore += 1;
+ LK.setScore(blueCrystallScore);
+ storage.blueCrystallScore = blueCrystallScore;
+ // Update the score text
+ scoreTxt.setText('Blue Crystall: ' + LK.getScore());
+ scoreTxt.visible = true; // Ensure the score text remains visible
+ };
+});
+// Create a new class for the BlueCrystalIngot object
+var BlueCrystalIngot = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'blueCrystalIngot' asset to the 'BlueCrystalIngot' object
+ var blueCrystalIngotGraphics = self.attachAsset('blueCrystalIngot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the blueCrystalIngot interactive
+ });
+ // Define the 'down' event handler for blueCrystalIngot
+ self.down = function (x, y, obj) {
+ // Logic for what happens when the blueCrystalIngot is clicked
+ if (blueCrystallScore >= 1) {
+ blueCrystalIngotScore += 1; //{y.1}
+ storage.growthRate += 10; // Increment growth rate by 10
+ growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
+ storage.growthRate += 10; // Increment growth rate by 10
+ growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
+ blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore); //{y.2}
+ storage.blueCrystalIngotScore = blueCrystalIngotScore;
+ blueCrystallScore -= 10;
+ if (blueCrystallScore < 0) {
+ blueCrystallScore = 0;
+ }
+ storage.blueCrystallScore = blueCrystallScore; // Persist the decrement
+ LK.setScore(blueCrystallScore);
+ scoreTxt.setText('Blue Crystall: ' + LK.getScore());
+ }
+ };
+});
+// Create a new class for the Door object
+var Door = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'Door' asset to the 'Door' object
+ var doorGraphics = self.attachAsset('Door', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Make the 'Door' object interactive
+ self.interactive = true;
+ // Define the 'down' event handler
+ self.down = function (x, y, obj) {
+ LK.getSound('doors').play();
+ // Remove the existing hammer
+ hammer.destroy();
+ // Create a new screen
+ game.magicNursery = game.addChild(new Container());
+ // Attach 'magicNurseryBackground' asset to the 'magicNursery' object
+ var magicNurseryBackground = game.magicNursery.attachAsset('magicNurseryBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: false,
+ // Disable interactivity to prevent blurring on click
+ scaleX: 2,
+ // Double the size horizontally
+ scaleY: 2 // Double the size vertically
+ });
+ // Recreate the hammer asset
+ magicNurseryBackground.x = 2048 / 2;
+ magicNurseryBackground.y = 2732 / 2;
+ // Attach 'ForgeOfMatter' asset to the 'magicNursery' object
+ var forgeOfMatter = game.magicNursery.attachAsset('ForgeOfMatter', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true,
+ scaleX: 3,
+ // Increase the size horizontally
+ scaleY: 3,
+ // Increase the size vertically
+ alpha: 0.0 // Make the ForgeOfMatter fully transparent
+ });
+ // Create and add a new instance of the BlueCrystalIngot class
+ var blueCrystalIngot = game.magicNursery.addChild(new BlueCrystalIngot()); //{P.1}
+ // Position the blueCrystalIngot asset in the bottom-left corner
+ blueCrystalIngot.x = 200 + blueCrystalIngot.width / 2;
+ blueCrystalIngot.y = 2500 - blueCrystalIngot.height / 2;
+ // Create and add a new instance of the RedCrystalIngot class
+ var redCrystalIngot = game.magicNursery.addChild(new RedCrystalIngot());
+ // Center the redCrystalIngot asset in the magicNursery screen
+ redCrystalIngot.x = 1300 / 2 + 350; // Move the redCristalIngot asset 100 pixels to the right
+ redCrystalIngot.y = 4820 / 2;
+ // Create and add a new instance of the GreenCrystalIngot class
+ var greenCrystalIngotInstance = game.magicNursery.addChild(new GreenCrystalIngot());
+ // Position the greenCrystalIngotInstance asset to the right of the blueCrystalIngot asset
+ greenCrystalIngotInstance.x = blueCrystalIngot.x + blueCrystalIngot.width + greenCrystalIngotInstance.width / 2 + 40;
+ greenCrystalIngotInstance.y = blueCrystalIngot.y;
+ // Center the growthRate asset in the magicNursery screen
+ var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ growthRate.x = 700;
+ growthRate.y = 1450;
+ // Define the 'down' event handler for ForgeOfMatter
+ forgeOfMatter.down = function (x, y, obj) {
+ // Increment the click counter
+ storage.growthRate++;
+ // Update the text object with the click counter and label
+ growthRateText.setText('Growth rate: ' + storage.growthRate);
+ };
+ forgeOfMatter.x = 1100 / 1.5;
+ forgeOfMatter.y = 2000 / 1.5;
+ // Hide the game screen
+ gameScreen.visible = false;
+ // Show the forging skill counter when transitioning to magicNursery
+ counterText.visible = true;
+ // Hide the map when switching to the magic nursery screen
+ map.visible = false;
+ // Add a new object 'Door2'
+ var door2 = game.magicNursery.addChild(new Door2());
+ // Position 'Door2' to the right, between the center and the edge of the screen
+ door2.x = 2048 * 0.75;
+ door2.y = 2732 * 0.9;
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ };
+});
+// Create a new class for the Door2 object
+var Door2 = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'Door' asset to the 'Door2' object
+ var doorGraphics = self.attachAsset('Door', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Make the 'Door2' object interactive
+ self.interactive = true;
+ // Define the 'down' event handler
+ self.down = function (x, y, obj) {
+ LK.getSound('doors').play();
+ // Remove the existing hammer
+ hammer.destroy();
+ // Show the Anvil screen
+ gameScreen.visible = true;
+ // Show the map only on the anvil screen
+ map.visible = true;
+ // Show the counter display
+ counterText.visible = true;
+ // Hide the Magic Nursery screen
+ game.magicNursery.visible = false;
+ // Show the Growth rate counter when transitioning to anvil
+ growthRateText.visible = true;
+ // Recreate the hammer asset
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ };
+});
+// Create a new class for the GreenCristal object
+var GreenCristal = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'greenCristal' asset to the 'GreenCristal' object
+ var greenCristalGraphics = self.attachAsset('greenCristal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the greenCristal interactive
+ });
+ // Define the 'down' event handler for greenCristal
+ self.down = function (x, y, obj) {
+ // Increment the score by 1
+ greenCrystallScore += 1;
+ LK.setScore(greenCrystallScore);
+ storage.greenCrystallScore = greenCrystallScore;
+ // Update the score text
+ greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
+ greenScoreTxt.visible = true; // Ensure the score text remains visible
+ };
+});
+// Create a new class for the GreenCrystalIngot object
+var GreenCrystalIngot = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'greenCrystalIngot' asset to the 'GreenCrystalIngot' object
+ var greenCrystalIngotGraphics = self.attachAsset('greenCrystalIngot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the greenCrystalIngot interactive
+ });
+ // Define the 'down' event handler for greenCrystalIngot
+ self.down = function (x, y, obj) {
+ if (storage.growthRate >= 3000 && greenCrystallScore >= 100) {
+ storage.growthRate += 10; // Increment growth rate by 10
+ growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
+ // Increment the GreenCrystalIngot score by 1
+ greenCrystalIngotScore += 1;
+ greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore);
+ storage.greenCrystalIngotScore = greenCrystalIngotScore;
+ // Decrement the GreenCristal score by 100
+ greenCrystallScore -= 10;
+ if (greenCrystallScore < 0) {
+ greenCrystallScore = 0;
+ }
+ storage.greenCrystallScore = greenCrystallScore; // Persist the decrement
+ greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
+ }
+ };
+});
+// Create a new class for the RecipesScreen object
+var RecipesScreen = Container.expand(function () {
+ var self = Container.call(this);
+});
+// Create a new class for the RedCristal object
+var RedCristal = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'redCristal' asset to the 'RedCristal' object
+ var redCristalGraphics = self.attachAsset('redCristal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the redCristal interactive
+ });
+ // Define the 'down' event handler for redCristal
+ self.down = function (x, y, obj) {
+ // Increment the score by 1
+ redCrystallScore += 1;
+ LK.setScore(redCrystallScore);
+ storage.redCrystallScore = redCrystallScore;
+ // Update the score text
+ redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
+ redScoreTxt.visible = true; // Ensure the score text remains visible
+ };
+});
+// Create a new class for the RedCrystalIngot object
+var RedCrystalIngot = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'redCristalIngot' asset to the 'RedCrystalIngot' object
+ var redCrystalIngotGraphics = self.attachAsset('redCristalIngot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the redCrystalIngot interactive
+ });
+ // Define the 'down' event handler for redCrystalIngot
+ self.down = function (x, y, obj) {
+ // Decrement the RedCristal score by 100
+ if (storage.growthRate >= 9000 && redCrystallScore >= 100) {
+ // Increment the RedCrystalIngot score by 1
+ redCrystalIngotScore += 1;
+ storage.growthRate += 20; // Increment growth rate by 20
+ growthRateText.setText('Growth rate: ' + storage.growthRate); // Update the growth rate display
+ redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore);
+ storage.redCrystalIngotScore = redCrystalIngotScore;
+ redCrystallScore -= 10;
+ storage.redCrystallScore = redCrystallScore; // Persist the decrement
+ redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
+ }
+ };
+});
+var RedCrystalTwoHandedSword = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach 'redcrystaltwo-handedswordrecipe' asset to the 'RedCrystalTwoHandedSword' object
+ var redCrystalTwoHandedSwordGraphics = self.attachAsset('redcrystaltwo-handedswordrecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the redCrystalTwoHandedSword interactive
+ });
+});
+
+/****
* Initialize Game
****/
-/**** Game Initialization ****/
+// Create a new text object to display the click counter
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
-/**** Assets Definition ****/
-function _typeof(o) {
- "@babel/helpers - typeof";
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
- return typeof o;
- } : function (o) {
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
- }, _typeof(o);
+//{0.1}
+//{0.1}
+var goldScore = storage.goldScore || 0;
+var goldScoreTxt = new Text2('Gold: ' + goldScore, {
+ size: 50,
+ fill: 0xFFFFFF
+});
+goldScoreTxt.anchor.set(0, 0);
+goldScoreTxt.y = 0;
+if (typeof counterText !== 'undefined') {
+ goldScoreTxt.x = counterText.width + 10; // Position to the right of the Forging skill counter
+} else {
+ goldScoreTxt.x = 550; // Default position if counterText is undefined
}
-function _defineProperties(e, r) {
- for (var t = 0; t < r.length; t++) {
- var o = r[t];
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
- }
-}
-function _createClass(e, r, t) {
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
- writable: !1
- }), e;
-}
-function _classCallCheck(a, n) {
- if (!(a instanceof n)) {
- throw new TypeError("Cannot call a class as a function");
- }
-}
-function _callSuper(t, o, e) {
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
-}
-function _possibleConstructorReturn(t, e) {
- if (e && ("object" == _typeof(e) || "function" == typeof e)) {
- return e;
- }
- if (void 0 !== e) {
- throw new TypeError("Derived constructors may only return object or undefined");
- }
- return _assertThisInitialized(t);
-}
-function _assertThisInitialized(e) {
- if (void 0 === e) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return e;
-}
-function _isNativeReflectConstruct() {
- try {
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
- } catch (t) {}
- return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
- return !!t;
- })();
-}
-function _getPrototypeOf(t) {
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
- return t.__proto__ || Object.getPrototypeOf(t);
- }, _getPrototypeOf(t);
-}
-function _inherits(t, e) {
- if ("function" != typeof e && null !== e) {
- throw new TypeError("Super expression must either be null or a function");
- }
- t.prototype = Object.create(e && e.prototype, {
- constructor: {
- value: t,
- writable: !0,
- configurable: !0
- }
- }), Object.defineProperty(t, "prototype", {
- writable: !1
- }), e && _setPrototypeOf(t, e);
-}
-function _setPrototypeOf(t, e) {
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
- return t.__proto__ = e, t;
- }, _setPrototypeOf(t, e);
-}
-function ownKeys(e, r) {
- var t = Object.keys(e);
- if (Object.getOwnPropertySymbols) {
- var o = Object.getOwnPropertySymbols(e);
- r && (o = o.filter(function (r) {
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
- })), t.push.apply(t, o);
- }
- return t;
-}
-function _objectSpread(e) {
- for (var r = 1; r < arguments.length; r++) {
- var t = null != arguments[r] ? arguments[r] : {};
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
- _defineProperty(e, r, t[r]);
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
- });
- }
- return e;
-}
-function _defineProperty(e, r, t) {
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
- value: t,
- enumerable: !0,
- configurable: !0,
- writable: !0
- }) : e[r] = t, e;
-}
-function _toPropertyKey(t) {
- var i = _toPrimitive(t, "string");
- return "symbol" == _typeof(i) ? i : i + "";
-}
-function _toPrimitive(t, r) {
- if ("object" != _typeof(t) || !t) {
- return t;
- }
- var e = t[Symbol.toPrimitive];
- if (void 0 !== e) {
- var i = e.call(t, r || "default");
- if ("object" != _typeof(i)) {
- return i;
- }
- throw new TypeError("@@toPrimitive must return a primitive value.");
- }
- return ("string" === r ? String : Number)(t);
-}
-function _slicedToArray(r, e) {
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
-}
-function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
-}
-function _unsupportedIterableToArray(r, a) {
- if (r) {
- if ("string" == typeof r) {
- return _arrayLikeToArray(r, a);
- }
- var t = {}.toString.call(r).slice(8, -1);
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
- }
-}
-function _arrayLikeToArray(r, a) {
- (null == a || a > r.length) && (a = r.length);
- for (var e = 0, n = Array(a); e < a; e++) {
- n[e] = r[e];
- }
- return n;
-}
-function _iterableToArrayLimit(r, l) {
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
- if (null != t) {
- var e,
- n,
- i,
- u,
- a = [],
- f = !0,
- o = !1;
- try {
- if (i = (t = t.call(r)).next, 0 === l) {
- if (Object(t) !== t) {
- return;
- }
- f = !1;
- } else {
- for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
- ;
- }
- }
- } catch (r) {
- o = !0, n = r;
- } finally {
- try {
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
- return;
- }
- } finally {
- if (o) {
- throw n;
- }
- }
- }
- return a;
- }
-}
-function _arrayWithHoles(r) {
- if (Array.isArray(r)) {
- return r;
- }
-}
-var SHAPES = {
- Gold: {
- width: 100,
- height: 100,
- color: 0xba3e24,
- shape: 'box'
- },
- anvil: {
- width: 550,
- height: 330,
- color: 0x90b8f4,
- shape: 'box'
- },
- hint: {
- width: 100,
- height: 100,
- color: 0x9eec73,
- shape: 'box'
- },
- hintbook: {
- width: 150,
- height: 200,
- color: 0xf4a5c5,
- shape: 'box'
- }
-};
-var IMAGES = {
- Door: {
- width: 300,
- height: 300,
- id: '6794cd7686e5290db4ef0f61'
- },
- Map: {
- width: 300,
- height: 300,
- id: '67960d5478a5ca831e38e79f'
- },
- Theblacksmithsapprentice: {
- width: 250,
- height: 250,
- id: '67b872b7f35062e15c95627b'
- },
- additionalAssetId: {
- width: 100,
- height: 100,
- id: '67b35cb8a9534c1274453a27'
- },
- anvilmap: {
- width: 100,
- height: 100,
- id: '6796204778a5ca831e38e7db'
- },
- autogrowthRate: {
- width: 360,
- height: 300,
- id: '67b4c3c752a1da49713d524a'
- },
- automineblueCrystall: {
- width: 250,
- height: 250,
- id: '67b4bd8952a1da49713d51e5'
- },
- autominegreenCrystall: {
- width: 250,
- height: 250,
- id: '67b4be1152a1da49713d51fa'
- },
- automineredCrystall: {
- width: 250,
- height: 250,
- id: '67b4ba73345af481077a5a3a'
- },
- axeOfGreenCrystalsRecipe: {
- width: 300,
- height: 500,
- id: '67991a67090093ccb7744bb4'
- },
- background: {
- width: 2000,
- height: 2000,
- id: '67b07ea12e29576e5caf3b79'
- },
- blueCristal: {
- width: 300,
- height: 300,
- id: '67b89f3ddacac0208c8f6e0e'
- },
- blueCrystalIngot: {
- width: 200,
- height: 180,
- id: '67966dd1690fa8a090669322'
- },
- bluecrystalswordrecipe: {
- width: 400,
- height: 400,
- id: '67991043090093ccb7744b1a',
- flipX: 1,
- flipY: 1,
- orientation: 3
- },
- blueingotrecipe: {
- width: 200,
- height: 150,
- id: '67bf46c527fc48d849e4e932'
- },
- citybackground: {
- width: 2000,
- height: 2000,
- id: '67a0d50d52a2e35ca0eb5c70'
- },
- citymap: {
- width: 150,
- height: 150,
- id: '679f607e55b87b3a41d5d55a'
- },
- continueText: {
- width: 300,
- height: 370,
- id: '67b060fe2e29576e5caf3af2'
- },
- gameScreenBackground: {
- width: 2000,
- height: 1900,
- id: '67b8ba062d0daaf579fc58d0'
- },
- greenCristal: {
- width: 300,
- height: 300,
- id: '67b8a0c4dacac0208c8f6e47'
- },
- greenCrystalIngot: {
- width: 210,
- height: 190,
- id: '67967631690fa8a090669346'
- },
- greeningotrecipe: {
- width: 200,
- height: 190.48,
- id: '67967631690fa8a090669346'
- },
- growthRate: {
- width: 300,
- height: 300,
- id: '67b8aa3cdacac0208c8f6ea0'
- },
- hammer: {
- width: 150,
- height: 150,
- id: '6794cebe86e5290db4ef0f74'
- },
- inventory: {
- width: 100,
- height: 100,
- id: '6796366278a5ca831e38e8f9'
- },
- magicNurseryBackground: {
- width: 1000,
- height: 1000,
- id: '67965c40690fa8a090669227'
- },
- mapbackground: {
- width: 1900,
- height: 1900,
- id: '67960c7078a5ca831e38e78c'
- },
- mine: {
- width: 80,
- height: 100,
- id: '6796224378a5ca831e38e807'
- },
- mineinsidebackground: {
- width: 1850,
- height: 1850,
- id: '679625c578a5ca831e38e821'
- },
- multiclickupgrade: {
- width: 280,
- height: 280,
- id: '67b4d29752a1da49713d526e'
- },
- multyclick: {
- width: 200,
- height: 200,
- id: '67a38faeec1e8c186c4e68aa'
- },
- newGameText: {
- width: 300,
- height: 400,
- id: '67b0610c2e29576e5caf3af6'
- },
- newTools: {
- width: 200,
- height: 200,
- id: '67a4ed1a15483cfd543c1702'
- },
- newToolsBackground: {
- width: 2000,
- height: 2000,
- id: '679905e1090093ccb7744b04'
- },
- newToolsout: {
- width: 300,
- height: 300,
- id: '6797a530690fa8a090669c76'
- },
- recipes: {
- width: 350,
- height: 350,
- id: '6797a530690fa8a090669c76'
- },
- recipesbackground: {
- width: 2000,
- height: 2000,
- id: '679905e1090093ccb7744b04'
- },
- recipesnext: {
- width: 350,
- height: 350,
- id: '679b9f5d0f1a2ec74003f873'
- },
- recipesprev: {
- width: 350,
- height: 350,
- id: '679b9f5d0f1a2ec74003f873',
- flipX: 1
- },
- redCristal: {
- width: 500,
- height: 600,
- id: '67b8a15bdacac0208c8f6e55'
- },
- redCristalIngot: {
- width: 210,
- height: 190,
- id: '67967c31690fa8a0906693e7'
- },
- redcrystaltwohandedswordrecipe: {
- width: 400,
- height: 400,
- id: '67adcc78e366fb4797fc38c0'
- },
- redingotrecipe: {
- width: 250,
- height: 180,
- id: '67bf4c3827fc48d849e4e955'
- },
- sellweapons: {
- width: 300,
- height: 300,
- id: '67b35cb8a9534c1274453a27'
- },
- shop: {
- width: 400,
- height: 400,
- id: '67be174fc61ffecc5503a69d'
- },
- shopbackground: {
- width: 2000,
- height: 2000,
- id: '67a0f8b752a2e35ca0eb5fdf'
- },
- shopout: {
- width: 300,
- height: 300,
- id: '6794cd7686e5290db4ef0f61'
- },
- star: {
- width: 50,
- height: 50,
- id: '6794fd2986e5290db4ef104a'
- },
- title: {
- width: 900,
- height: 400,
- id: '67b8af589837459f356f3e4b'
- }
-};
-var SOUNDS = {
- booksaudio: {
- volume: 1,
- start: 0,
- end: 1,
- id: '67b8a6c6dacac0208c8f6e80'
- },
- doors: {
- volume: 1,
- start: 0,
- end: 1,
- id: '67b8a3d2dacac0208c8f6e73'
- },
- hammer: {
- volume: 1,
- start: 0,
- end: 0.862,
- id: '6794fd6d86e5290db4ef1050'
- },
- mapaudio: {
- volume: 1,
- start: 0,
- end: 1,
- id: '67b8a489dacac0208c8f6e79'
- },
- paper: {
- volume: 1,
- start: 0,
- end: 1,
- id: '67b8a489dacac0208c8f6e79'
- },
- shopin: {
- volume: 1,
- start: 0,
- end: 0.776,
- id: '67b8a891dacac0208c8f6e8a'
- }
-};
-// Initialize assets
-Object.entries(SHAPES).forEach(function (_ref) {
- var _ref2 = _slicedToArray(_ref, 2),
- name = _ref2[0],
- config = _ref2[1];
+LK.gui.topLeft.addChild(goldScoreTxt);
+var redCrystalIngotScore = storage.redCrystalIngotScore || 0;
+var redCrystalIngotScoreTxt = new Text2('RedCrystalIngot: ' + redCrystalIngotScore, {
+ size: 50,
+ fill: 0xFFFFFF
});
-Object.entries(IMAGES).forEach(function (_ref3) {
- var _ref4 = _slicedToArray(_ref3, 2),
- name = _ref4[0],
- config = _ref4[1];
+redCrystalIngotScoreTxt.anchor.set(1, 0);
+redCrystalIngotScoreTxt.y = 100; // Position below the GreenCrystalIngot score
+LK.gui.topRight.addChild(redCrystalIngotScoreTxt);
+//{0.1}
+// Removed the 'current underfiend' text from the screen
+var mineInsideBackground;
+var blueCrystallScore = storage.blueCrystallScore || 0;
+var automineblueCrystallClicked = storage.automineblueCrystallClicked;
+var autominegreenCrystallClicked = storage.autominegreenCrystallClicked;
+var autominegreenCrystallClicked = storage.autominegreenCrystallClicked;
+var automineredCrystallClicked = storage.automineredCrystallClicked;
+var autogrowthRateClicked = storage.autogrowthRateClicked;
+var scoreTxt = new Text2('Blue Crystall: ' + blueCrystallScore, {
+ size: 50,
+ fill: 0xFFFFFF
});
-Object.entries(SOUNDS).forEach(function (_ref5) {
- var _ref6 = _slicedToArray(_ref5, 2),
- name = _ref6[0],
- config = _ref6[1];
+scoreTxt.anchor.set(0, 0);
+scoreTxt.y = 100; // Move the score text 100 pixels down
+LK.gui.topLeft.addChild(scoreTxt);
+var greenCrystallScore = storage.greenCrystallScore || 0;
+var greenScoreTxt = new Text2('Green Crystall: ' + greenCrystallScore, {
+ size: 50,
+ fill: 0xFFFFFF
});
-/**** Plugins ****/
-/**** Utility Functions ****/
-var createText = function createText(text) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var txt = new Text2(text, _objectSpread({
- size: 50,
- fill: 0xFFFFFF
- }, options));
- txt.anchor.set(options.anchorX || 0, options.anchorY || 0);
- return txt;
-};
-var centerAsset = function centerAsset(asset) {
- var parentWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2048;
- var parentHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2732;
- asset.x = parentWidth / 2;
- asset.y = parentHeight / 2;
-};
-/**** Classes ****/
-var InteractiveContainer = /*#__PURE__*/function (_Container) {
- function InteractiveContainer(assetName) {
- var _this;
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- _classCallCheck(this, InteractiveContainer);
- _this = _callSuper(this, InteractiveContainer);
- _this.interactive = true;
- _this.asset = _this.attachAsset(assetName, {});
- return _this;
+greenScoreTxt.anchor.set(0, 0);
+greenScoreTxt.y = 150; // Position below the Blue Crystall score
+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; // Position below the BlueCrystalIngot score
+LK.gui.topRight.addChild(greenCrystalIngotScoreTxt);
+var blueCristal; // Define blueCristal in the global scope to fix the reference error
+var greenCristal; // Define greenCristal in the global scope to fix the reference error
+var redCristal; // Define redCristal in the global scope to fix the reference error
+var blueCrystalIngotScore = storage.blueCrystalIngotScore || 0; //{1Z.1}
+var blueSwordsText = new Text2(storage.blueSwords.toString(), {
+ size: 50,
+ fill: 0x000000 // Black color
+});
+blueSwordsText.anchor.set(0.5, 0.5);
+blueSwordsText.x = 1248 / 2;
+blueSwordsText.y = 2732 / 2 + 450; // Position below the 'Swords in stock' text
+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; // Position below the Green Crystall score
+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; // Initialize the map as invisible
+// Make the map interactive
+map.interactive = true;
+// Define the 'down' event handler for the map
+map.down = function (x, y, obj) {
+ hammer.destroy();
+ // Hide the map asset when transitioning to the map screen
+ LK.getSound('mapaudio').play();
+ map.visible = false;
+ // Hide the mineInsideBackground if it exists
+ if (mineInsideBackground) {
+ mineInsideBackground.visible = false;
+ mineInsideBackground.destroy(); // Ensure it is completely removed
}
- _inherits(InteractiveContainer, _Container);
- return _createClass(InteractiveContainer);
-}(Container);
-var Anvil = /*#__PURE__*/function (_InteractiveContainer) {
- function Anvil() {
- var _this2;
- _classCallCheck(this, Anvil);
- _this2 = _callSuper(this, Anvil, ['anvil', {
- alpha: 0
- }]);
- _this2.clickCounter = storage.forgingSkill;
- return _this2;
- }
- _inherits(Anvil, _InteractiveContainer);
- return _createClass(Anvil, [{
- key: "down",
- value: function down(x, y) {
- this.clickCounter++;
- var multiClickChance = storage.multiclickupgrade ? 0.04 : 0.02;
- if (Math.random() < multiClickChance) {
- this.clickCounter += 500;
- var multiClick = game.addChild(LK.getAsset('multyclick', {
+ if (redCristal) {
+ redCristal.visible = false; //{1Z.1}
+ redCristal.destroy(); // Ensure it is completely removed
+ } //{1Z.3}
+ if (blueCristal) {
+ blueCristal.visible = false; //{1X.1}
+ blueCristal.destroy(); // Ensure it is completely removed
+ } //{1X.3}
+ if (greenCristal) {
+ greenCristal.visible = false; //{1Y.1}
+ greenCristal.destroy(); // Ensure it is completely removed
+ } //{1Y.3}
+ var mapScreen = game.addChild(new Container());
+ // Attach 'mapbackground' asset to the mapScreen
+ var mapBackground = mapScreen.attachAsset('mapbackground', {
+ anchorX: 0.5,
+ //{1h.1}
+ anchorY: 0.5,
+ //{1h.2}
+ interactive: false // Ensure mapbackground does not block cursor interaction
+ }); //{1h.3}
+ // Add 'citymap' asset to the center of the screen
+ var cityMap = mapScreen.attachAsset('citymap', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'citymap' asset interactive
+ });
+ cityMap.x = -250;
+ cityMap.y = 160;
+ // Define the 'down' event handler for cityMap
+ cityMap.down = function (x, y, obj) {
+ hammer.destroy();
+ // Create a new screen without background
+ var isolatedScreen = game.addChild(new Container());
+ // Hide the current map screen
+ mapScreen.visible = false;
+ // Add 'citybackground' asset to the center of the isolatedScreen
+ var cityBackground = isolatedScreen.attachAsset('citybackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ cityBackground.x = 0;
+ cityBackground.y = 0;
+ // Add 'map' asset to the isolatedScreen
+ var mapAsset = isolatedScreen.attachAsset('Map', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'map' asset interactive
+ });
+ mapAsset.x = -650;
+ mapAsset.y = 1100;
+ // Define the 'down' event handler for mapAsset
+ mapAsset.down = function (x, y, obj) {
+ // Transition back to the citymap screen
+ isolatedScreen.visible = false; // Hide the current isolated screen
+ mapScreen.visible = true; // Show the citymap screen
+ cityBackground.visible = false; // Ensure citybackground is hidden
+ mapBackground.visible = true;
+ };
+ // Add 'shop' asset to the center of the isolatedScreen
+ var shop = isolatedScreen.attachAsset('shop', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'shop' asset interactive
+ });
+ shop.x = 490;
+ shop.y = -20;
+ // Define the 'down' event handler for shop
+ shop.down = function (x, y, obj) {
+ hammer.destroy();
+ LK.getSound('shopin').play();
+ // Create a new screen without background
+ var shopScreen = game.addChild(new Container());
+ // Hide the current isolated screen
+ isolatedScreen.visible = false;
+ // Position the shopScreen at the center
+ shopScreen.x = 2048 / 2;
+ shopScreen.y = 2732 / 2;
+ // Add 'new tools' asset to the center of the shopScreen
+ var newTools = shopScreen.attachAsset('newTools', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ newTools.x = -650;
+ newTools.y = 1100;
+ newTools.interactive = true; // Make the newTools asset interactive
+ newTools.down = function (x, y, obj) {
+ hammer.destroy();
+ // Create a new isolated screen without a background
+ var isolatedScreen = game.addChild(new Container());
+ // Attach 'newToolsBackground' asset to the isolatedScreen
+ var newToolsBackground = isolatedScreen.attachAsset('newToolsBackground', {
anchorX: 0.5,
anchorY: 0.5
- }));
- centerAsset(multiClick);
- tween(multiClick, {
- scaleX: 2,
- scaleY: 2
- }, {
- duration: 500,
- easing: tween.easeInOut,
- onFinish: function onFinish() {
- return multiClick.destroy();
- }
});
- }
- storage.forgingSkill = this.clickCounter;
- counterText.setText("Forging skill: ".concat(this.clickCounter));
- this.updateCounterColor();
- }
- }, {
- key: "updateCounterColor",
- value: function updateCounterColor() {
- var colors = [{
- threshold: 30000,
- color: 0xcc7c04
- }, {
- threshold: 15000,
- color: 0x800080
- }, {
- threshold: 2000,
- color: 0x0000FF
- }, {
- threshold: 1000,
- color: 0x00FF00
- }];
- for (var _i = 0, _colors = colors; _i < _colors.length; _i++) {
- var _colors$_i = _colors[_i],
- threshold = _colors$_i.threshold,
- color = _colors$_i.color;
- if (this.clickCounter >= threshold) {
- counterText.tint = color;
- break;
+ newToolsBackground.x = 0;
+ newToolsBackground.y = 0;
+ if (!storage.theBlacksmithsApprentice) {
+ // Attach 'Theblacksmithsapprentice' asset to the center of the isolatedScreen
+ var theBlacksmithsApprentice = isolatedScreen.attachAsset('Theblacksmithsapprentice', {
+ anchorX: 0.5,
+ //{4C.1}
+ anchorY: 0.5,
+ //{4C.2}
+ interactive: true // Make the Theblacksmithsapprentice interactive
+ }); //{4C.3}
+ theBlacksmithsApprentice.x = 400;
+ theBlacksmithsApprentice.y = 200;
+ theBlacksmithsApprentice.clicked = storage.theBlacksmithsApprentice;
+ // Define the 'down' event handler for theBlacksmithsApprentice
+ theBlacksmithsApprentice.down = function (x, y, obj) {
+ // Increment forgingSkill by 1 every second
+ 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);
+ // Store the intervalId in the theBlacksmithsApprentice object for potential future use
+ theBlacksmithsApprentice.intervalId = intervalId;
+ storage.theBlacksmithsApprentice = true;
+ theBlacksmithsApprentice.visible = false;
+ apprenticeText.visible = false;
+ apprenticeCostText.visible = false;
+ }
+ };
+ // Add text "The blacksmith's apprentice +1" below the Theblacksmithsapprentice asset
+ 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; // Position below the Theblacksmithsapprentice asset
+ isolatedScreen.addChild(apprenticeText);
+ // Add text "1500G" below the 'The blacksmith's apprentice +1' text
+ 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; // Position below the 'The blacksmith's apprentice +1' text
+ isolatedScreen.addChild(apprenticeCostText);
}
- }
- }
- }]);
-}(InteractiveContainer);
-var Crystal = /*#__PURE__*/function (_InteractiveContainer2) {
- function Crystal(type, scoreKey, textObj) {
- var _this3;
- _classCallCheck(this, Crystal);
- _this3 = _callSuper(this, Crystal, ["".concat(type, "Cristal"), {
- interactive: true
- }]);
- _this3.type = type;
- _this3.scoreKey = scoreKey;
- _this3.textObj = textObj;
- return _this3;
- }
- _inherits(Crystal, _InteractiveContainer2);
- return _createClass(Crystal, [{
- key: "down",
- value: function down() {
- storage[this.scoreKey]++;
- LK.setScore(storage[this.scoreKey]);
- this.textObj.setText("".concat(this.type, " Crystall: ").concat(storage[this.scoreKey]));
- this.textObj.visible = true;
- }
- }]);
-}(InteractiveContainer);
-var CrystalIngot = /*#__PURE__*/function (_InteractiveContainer3) {
- function CrystalIngot(type, config) {
- var _this4;
- _classCallCheck(this, CrystalIngot);
- _this4 = _callSuper(this, CrystalIngot, ["".concat(type, "CrystalIngot"), {
- interactive: true
- }]);
- _this4.type = type;
- _this4.config = config;
- return _this4;
- }
- _inherits(CrystalIngot, _InteractiveContainer3);
- return _createClass(CrystalIngot, [{
- key: "down",
- value: function down() {
- var _this$config = this.config,
- crystalScore = _this$config.crystalScore,
- ingotScore = _this$config.ingotScore,
- growthRateThreshold = _this$config.growthRateThreshold,
- growthRateInc = _this$config.growthRateInc,
- cost = _this$config.cost;
- if (storage.growthRate >= growthRateThreshold && storage[crystalScore] >= cost) {
- storage[ingotScore]++;
- storage.growthRate += growthRateInc;
- storage[crystalScore] = Math.max(0, storage[crystalScore] - cost);
- growthRateText.setText("Growth rate: ".concat(storage.growthRate));
- this.config.ingotText.setText("".concat(this.type, "CrystalIngot: ").concat(storage[ingotScore]));
- this.config.crystalText.setText("".concat(this.type, " Crystall: ").concat(storage[crystalScore]));
- }
- }
- }]);
-}(InteractiveContainer);
-var Door = /*#__PURE__*/function (_InteractiveContainer4) {
- function Door() {
- var _this5;
- var isReturn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- _classCallCheck(this, Door);
- _this5 = _callSuper(this, Door, ['Door']);
- _this5.isReturn = isReturn;
- return _this5;
- }
- _inherits(Door, _InteractiveContainer4);
- return _createClass(Door, [{
- key: "down",
- value: function down() {
- LK.getSound('doors').play();
- hammer.destroy();
- if (this.isReturn) {
- gameScreen.visible = true;
- map.visible = true;
- counterText.visible = true;
- game.magicNursery.visible = false;
- } else {
- game.magicNursery = game.addChild(new Container());
- var bg = game.magicNursery.attachAsset('magicNurseryBackground', {
+ // Attach 'newToolsout' asset to the center of the isolatedScreen
+ var newToolsOut = isolatedScreen.attachAsset('newToolsout', {
anchorX: 0.5,
- anchorY: 0.5,
- interactive: false,
- scaleX: 2,
- scaleY: 2
+ anchorY: 0.5
});
- centerAsset(bg);
- var forge = game.magicNursery.attachAsset('ForgeOfMatter', {
+ newToolsOut.x = 0;
+ newToolsOut.y = 1100;
+ newToolsOut.interactive = true; // Make the newToolsOut asset interactive//{4F.1}
+ if (!storage.automineblueCrystallClicked) {
+ // Attach 'automineblueCrystall' asset to the center of the isolatedScreen
+ var automineblueCrystall = isolatedScreen.attachAsset('automineblueCrystall', {
+ anchorX: 0.5,
+ //{4F.2}
+ anchorY: 0.5,
+ //{4F.3}
+ interactive: true // Make the automineblueCrystall interactive
+ }); //{4F.4}
+ automineblueCrystall.x = -400;
+ automineblueCrystall.y = -600;
+ automineblueCrystall.clicked = storage.automineblueCrystallClicked;
+ // Define the 'down' event handler for automineblueCrystall
+ automineblueCrystall.down = function (x, y, obj) {
+ // Increment blueCrystallScore by 1 every second
+ 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);
+ // Store the intervalId in the automineblueCrystall object for potential future use
+ automineblueCrystall.intervalId = intervalId;
+ storage.automineblueCrystallClicked = true; // Persist the click state
+ automineblueCrystall.visible = false;
+ mineBlueCrystallText.visible = false;
+ mineBlueCrystallCostText.visible = false;
+ }
+ };
+ // Add text "Mine Blue Crystall +1" below the automineblueCrystall asset
+ 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; // Position below the automineblueCrystall asset
+ isolatedScreen.addChild(mineBlueCrystallText);
+ // Add text "500G" below the 'Mine Blue Crystall +1' text
+ var mineBlueCrystallCostText = new Text2('500G', {
+ size: 50,
+ //{58.1}
+ fill: 0x030303 //{58.2}
+ }); //{58.3}
+ mineBlueCrystallCostText.anchor.set(0.5, 0.5);
+ mineBlueCrystallCostText.x = mineBlueCrystallText.x;
+ mineBlueCrystallCostText.y = mineBlueCrystallText.y + 50; // Position below the 'Mine Blue Crystall +1' text
+ isolatedScreen.addChild(mineBlueCrystallCostText);
+ }
+ if (!storage.autominegreenCrystallClicked) {
+ // Attach 'autominegreenCrystall' asset to the center of the isolatedScreen
+ var autominegreenCrystall = isolatedScreen.attachAsset('autominegreenCrystall', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the autominegreenCrystall interactive
+ });
+ autominegreenCrystall.x = -400;
+ autominegreenCrystall.y = -200;
+ // Define the 'down' event handler for autominegreenCrystall
+ autominegreenCrystall.clicked = storage.autominegreenCrystallClicked;
+ autominegreenCrystall.down = function (x, y, obj) {
+ // Increment greenCrystallScore by 1 every second
+ if (goldScore >= 1000 && !autominegreenCrystall.clicked) {
+ autominegreenCrystall.clicked = true;
+ goldScore -= 1000;
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ storage.goldScore = goldScore;
+ var intervalId = LK.setInterval(function () {
+ greenCrystallScore += 1;
+ storage.greenCrystallScore = greenCrystallScore;
+ greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
+ }, 1000);
+ // Store the intervalId in the autominegreenCrystall object for potential future use
+ autominegreenCrystall.intervalId = intervalId;
+ storage.autominegreenCrystallClicked = true; // Persist the click state
+ autominegreenCrystall.visible = false;
+ mineGreenCrystallText.visible = false;
+ mineGreenCrystallCostText.visible = false;
+ }
+ };
+ // Add text "Mine Green Crystall +1" below the autominegreenCrystall asset
+ var mineGreenCrystallText = new Text2('Mine Green Crystall +1', {
+ size: 50,
+ fill: 0x030303
+ });
+ mineGreenCrystallText.anchor.set(0.5, 0.5);
+ mineGreenCrystallText.x = autominegreenCrystall.x;
+ mineGreenCrystallText.y = autominegreenCrystall.y + 150; // Lower the position below the autominegreenCrystall asset
+ isolatedScreen.addChild(mineGreenCrystallText);
+ // Add text "1000G" below the 'Mine Green Crystall +1' text
+ var mineGreenCrystallCostText = new Text2('1000G', {
+ size: 50,
+ //{5c.1}
+ fill: 0x030303 //{5c.2}
+ }); //{5c.3}
+ mineGreenCrystallCostText.anchor.set(0.5, 0.5);
+ mineGreenCrystallCostText.x = mineGreenCrystallText.x;
+ mineGreenCrystallCostText.y = mineGreenCrystallText.y + 50; // Position below the 'Mine Green Crystall +1' text
+ isolatedScreen.addChild(mineGreenCrystallCostText);
+ }
+ if (!storage.automineredCrystallClicked) {
+ // Attach 'automineredCrystall' asset to the center of the isolatedScreen
+ var automineredCrystall = isolatedScreen.attachAsset('automineredCrystall', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the automineredCrystall interactive
+ });
+ automineredCrystall.x = -400;
+ automineredCrystall.y = 200;
+ // Define the 'down' event handler for automineredCrystall
+ automineredCrystall.down = function (x, y, obj) {
+ // Increment redCrystallScore by 1 every second
+ if (goldScore >= 2000 && !automineredCrystall.clicked) {
+ automineredCrystall.clicked = true;
+ goldScore -= 2000;
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ storage.goldScore = goldScore;
+ var intervalId = LK.setInterval(function () {
+ redCrystallScore += 1;
+ storage.redCrystallScore = redCrystallScore;
+ redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
+ }, 1000);
+ // Store the intervalId in the automineredCrystall object for potential future use
+ automineredCrystall.intervalId = intervalId;
+ storage.automineredCrystallClicked = true; // Persist the click state
+ automineredCrystall.visible = false;
+ mineRedCrystallText.visible = false;
+ mineRedCrystallCostText.visible = false;
+ }
+ };
+ // Add text "Mine Red Crystall +1" below the automineredCrystall asset
+ var mineRedCrystallText = new Text2('Mine Red Crystall +1', {
+ size: 50,
+ fill: 0x030303
+ });
+ mineRedCrystallText.anchor.set(0.5, 0.5);
+ mineRedCrystallText.x = automineredCrystall.x;
+ mineRedCrystallText.y = automineredCrystall.y + 140; // Position below the automineredCrystall asset
+ isolatedScreen.addChild(mineRedCrystallText);
+ // Add text "2000G" below the 'Mine Red Crystall +1' text
+ var mineRedCrystallCostText = new Text2('2000G', {
+ size: 50,
+ //{55.1}
+ fill: 0x030303 //{55.2}
+ }); //{55.3}
+ mineRedCrystallCostText.anchor.set(0.5, 0.5);
+ mineRedCrystallCostText.x = mineRedCrystallText.x;
+ mineRedCrystallCostText.y = mineRedCrystallText.y + 50; // Position below the 'Mine Red Crystall +1' text
+ isolatedScreen.addChild(mineRedCrystallCostText);
+ }
+ if (!storage.multiclickupgrade) {
+ // Attach 'multiclickupgrade' asset to the center of the isolatedScreen
+ var multiclickupgrade = isolatedScreen.attachAsset('multiclickupgrade', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the multiclickupgrade interactive
+ });
+ multiclickupgrade.x = 400;
+ multiclickupgrade.y = -200;
+ // Define the 'down' event handler for multiclickupgrade
+ multiclickupgrade.down = function (x, y, obj) {
+ // Deduct 700 gold when clicked
+ if (goldScore >= 700 && !storage.multiclickupgrade) {
+ goldScore -= 700;
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ storage.goldScore = goldScore;
+ storage.multiclickupgrade = true;
+ multiclickupgrade.visible = false;
+ increasedChanceText.visible = false;
+ increasedChanceCostText.visible = false;
+ }
+ };
+ // Add text "Increased chance of successful forging +5%" below the multiclickupgrade asset
+ var increasedChanceText = new Text2('Increased chance of \nsuccessful forging +5%', {
+ size: 50,
+ fill: 0x030303
+ });
+ increasedChanceText.anchor.set(0.5, 0.5);
+ increasedChanceText.x = multiclickupgrade.x;
+ increasedChanceText.y = multiclickupgrade.y + 170; // Position below the multiclickupgrade asset
+ isolatedScreen.addChild(increasedChanceText);
+ // Add text "700G" below the 'Increased chance of successful forging +5%' text
+ var increasedChanceCostText = new Text2('700G', {
+ size: 50,
+ //{4Z.1}
+ fill: 0x030303 //{4Z.2}
+ }); //{4Z.3}
+ increasedChanceCostText.anchor.set(0.5, 0.5);
+ increasedChanceCostText.x = increasedChanceText.x;
+ increasedChanceCostText.y = increasedChanceText.y + 70; // Position below the 'Increased chance of successful forging +5%' text
+ isolatedScreen.addChild(increasedChanceCostText);
+ }
+ if (!storage.autogrowthRateClicked) {
+ // Attach 'autogrowthRate' asset to the center of the isolatedScreen
+ var autogrowthRate = isolatedScreen.attachAsset('autogrowthRate', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the autogrowthRate interactive
+ });
+ autogrowthRate.x = 400;
+ autogrowthRate.y = -600;
+ autogrowthRate.clicked = storage.autogrowthRateClicked;
+ // Define the 'down' event handler for autogrowthRate
+ autogrowthRate.down = function (x, y, obj) {
+ // Increment growthRateCounter by 1 every second
+ if (goldScore >= 2000 && !autogrowthRate.clicked) {
+ autogrowthRate.clicked = true;
+ goldScore -= 2000;
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ storage.goldScore = goldScore;
+ var intervalId = LK.setInterval(function () {
+ growthRateCounter += 1;
+ growthRateText.setText('Growth rate: ' + growthRateCounter);
+ storage.growthRate = growthRateCounter;
+ }, 1000);
+ // Store the intervalId in the autogrowthRate object for potential future use
+ autogrowthRate.intervalId = intervalId;
+ storage.autogrowthRateClicked = true; // Persist the click state
+ autogrowthRate.visible = false;
+ automaticMeltingText.visible = false;
+ automaticMeltingCostText.visible = false;
+ }
+ };
+ // Add text "Automatic melting +1" below the autogrowthRate asset
+ var automaticMeltingText = new Text2('Automatic melting +1', {
+ size: 50,
+ fill: 0x030303
+ });
+ automaticMeltingText.anchor.set(0.5, 0.5);
+ automaticMeltingText.x = autogrowthRate.x;
+ automaticMeltingText.y = autogrowthRate.y + 150; // Position below the autogrowthRate asset
+ isolatedScreen.addChild(automaticMeltingText);
+ // Add text "2000G" below the 'Automatic melting +1' text
+ var automaticMeltingCostText = new Text2('2000G', {
+ size: 50,
+ fill: 0x030303
+ });
+ automaticMeltingCostText.anchor.set(0.5, 0.5);
+ automaticMeltingCostText.x = automaticMeltingText.x;
+ automaticMeltingCostText.y = automaticMeltingText.y + 50; // Position below the 'Automatic melting +1' text
+ isolatedScreen.addChild(automaticMeltingCostText);
+ }
+ newToolsOut.down = function (x, y, obj) {
+ LK.getSound('booksaudio').play();
+ // Transition to the newTools screen
+ isolatedScreen.visible = false; // Hide the current isolated screen
+ shopScreen.visible = true; // Show the newTools screen
+ };
+ // Hide the current shop screen
+ shopScreen.visible = false;
+ // Position the isolatedScreen at the center
+ isolatedScreen.x = 2048 / 2;
+ isolatedScreen.y = 2732 / 2;
+ hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
- interactive: true,
- scaleX: 3,
- scaleY: 3,
- alpha: 0
- });
- forge.x = 1100 / 1.5;
- forge.y = 2000 / 1.5;
- forge.down = function () {
- storage.growthRate++;
- growthRateText.setText("Growth rate: ".concat(storage.growthRate));
- };
- this.addCrystals();
- gameScreen.visible = false;
- map.visible = false;
- var door2 = game.magicNursery.addChild(new Door(true));
- door2.x = 2048 * 0.75;
- door2.y = 2732 * 0.9;
- }
+ scaleX: -1
+ }));
+ };
+ // Add 'shopout' asset to the shopScreen
+ var shopBackground = shopScreen.attachAsset('shopbackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ shopBackground.x = 0;
+ shopBackground.y = 0;
+ // Add 'new buildings' asset to the center of the shopScreen
+ var newBuildings = shopScreen.attachAsset('sellweapons', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'sellweapons' asset interactive
+ });
+ // Define the 'down' event handler for sellweapons
+ newBuildings.down = function (x, y, obj) {
+ console.log("Sell weapons asset clicked at", x, y);
+ // Reset 'Swords in stock' counter and add +50 to Gold for each sword
+ goldScore += storage.blueSwords * 50;
+ storage.blueSwords = 0;
+ blueSwordsText.setText('0');
+ goldScore += storage.greenAxes * 150;
+ storage.greenAxes = 0;
+ goldScore += storage.redCrystalTwoHandedSwords * 600;
+ storage.redCrystalTwoHandedSwords = 0;
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ storage.goldScore = goldScore;
+ };
+ newBuildings.x = 0;
+ newBuildings.y = 1100;
+ // Add 'shopout' asset to the shopScreen
+ var shopOut = shopScreen.attachAsset('shopout', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'shopout' asset interactive
+ });
+ shopOut.x = 650;
+ shopOut.y = 1100;
+ // Define the 'down' event handler for shopOut
+ shopOut.down = function (x, y, obj) {
+ LK.getSound('doors').play();
+ shopScreen.visible = false; // Hide the current shop screen
+ mapBackground.visible = false; // Ensure the mapbackground asset is hidden
+ mapScreen.visible = true; // Show the citymap screen
+ isolatedScreen.visible = true; // Ensure the isolated screen is visible
+ };
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
+ };
+ // Position the isolatedScreen at the center
+ isolatedScreen.x = 2048 / 2;
+ isolatedScreen.y = 2732 / 2;
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ };
+ // Attach 'anvilmap' asset to the mapScreen on the top layer
+ var anvilMap = mapScreen.attachAsset('anvilmap', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true
+ });
+ // Attach 'mine' asset to the mapScreen on the top layer
+ var mine = mapScreen.attachAsset('mine', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true
+ });
+ mine.x -= 150; // Move the mine asset 150 pixels to the left
+ mine.y -= 150; // Move the mine asset 150 pixels higher
+ // Make mine interactive and define the 'down' event handler
+ mine.down = function (x, y, obj) {
+ hammer.destroy();
+ // Create a new screen for the mine
+ var mineScreen = game.addChild(new Container());
+ // Make the map visible after transitioning to the mine screen
+ map.visible = true;
+ // Hide the current map screen
+ mapScreen.visible = false;
+ // Disable the active background
+ background.visible = false;
+ // Attach 'mineinsidebackground' asset to the mineScreen on the bottom layer
+ mineInsideBackground = mineScreen.attachAsset('mineinsidebackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: false,
+ zIndex: -1 // Ensure it is on the bottom layer
+ });
+ // Create and add a new instance of the RedCristal class
+ redCristal = mineScreen.addChild(new RedCristal());
+ // Position the redCristal asset
+ redCristal.x -= 510; // Move 100 pixels to the left
+ redCristal.y += 490; // Move 100 pixels lower
+ // Create and add a new instance of the GreenCristal class
+ greenCristal = mineScreen.addChild(new GreenCristal());
+ // Position the greenCristal asset
+ greenCristal.x -= -510; // Move 100 pixels to the left
+ greenCristal.y += 10; // Move 100 pixels lower
+ // Create and add a new instance of the BlueCristal class
+ blueCristal = mineScreen.addChild(new BlueCristal());
+ // Position the blueCristal asset
+ blueCristal.x += 490; // Move 100 pixels to the right
+ blueCristal.y += -60; // Move 100 pixels lower
+ // Position the blueCristal asset
+ blueCristal.x -= 410; // Move 100 pixels to the left
+ blueCristal.y -= 310; // Move 100 pixels lower
+ // Position the mineScreen at the center
+ mineScreen.x = 2048 / 2; //{1E.1}
+ mineScreen.y = 2732 / 2; //{1E.2}
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ };
+ // Make anvilMap interactive and define the 'down' event handler
+ anvilMap.down = function (x, y, obj) {
+ // Show the Anvil screen
+ gameScreen.visible = true;
+ // Make the map visible after transitioning to the anvil map
+ map.visible = true;
+ // Attach 'gameScreenBackground' asset to the 'gameScreen' object
+ gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Attach 'recipes' asset to the 'gameScreenBackground' object
+ var recipes = gameScreenBackground.attachAsset('recipes', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Center the 'recipes' asset on the gameScreenBackground
+ recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
+ recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
+ // Hide the mineinsidebackground when exiting the mine screen
+ if (mineInsideBackground) {
+ mineInsideBackground.visible = false;
+ mineInsideBackground.destroy(); // Ensure it is completely removed
}
- }, {
- key: "addCrystals",
- value: function addCrystals() {
- var blueIngot = game.magicNursery.addChild(new CrystalIngot('blue', CRYSTAL_CONFIGS.blue));
- blueIngot.x = 200 + blueIngot.width / 2;
- blueIngot.y = 2500 - blueIngot.height / 2;
- var greenIngot = game.magicNursery.addChild(new CrystalIngot('green', CRYSTAL_CONFIGS.green));
- greenIngot.x = blueIngot.x + blueIngot.width + greenIngot.width / 2 + 40;
- greenIngot.y = blueIngot.y;
- var redIngot = game.magicNursery.addChild(new CrystalIngot('red', CRYSTAL_CONFIGS.red));
- redIngot.x = 1300 / 2 + 350;
- redIngot.y = 4820 / 2;
- var growthRate = game.magicNursery.addChild(LK.getAsset('growthRate', {
- anchorX: 0.5,
- anchorY: 0.5
- }));
- growthRate.x = 700;
- growthRate.y = 1450;
+ if (mineInsideBackground) {
+ mineInsideBackground.visible = false;
+ mineInsideBackground.destroy(); // Ensure it is completely removed
}
- }]);
-}(InteractiveContainer);
-var CRYSTAL_CONFIGS = {
- blue: {
- crystalScore: 'blueCrystallScore',
- ingotScore: 'blueCrystalIngotScore',
- growthRateThreshold: 0,
- growthRateInc: 1000,
- cost: 10
- },
- green: {
- crystalScore: 'greenCrystallScore',
- ingotScore: 'greenCrystalIngotScore',
- growthRateThreshold: 3000,
- growthRateInc: 10,
- cost: 10
- },
- red: {
- crystalScore: 'redCrystallScore',
- ingotScore: 'redCrystalIngotScore',
- growthRateThreshold: 9000,
- growthRateInc: 20,
- cost: 10
- }
+ if (blueCristal) {
+ blueCristal.visible = false; //{1X.1}
+ blueCristal.destroy(); // Ensure it is completely removed
+ } //{1X.3}
+ if (greenCristal) {
+ greenCristal.visible = false; //{1Y.1}
+ greenCristal.destroy(); // Ensure it is completely removed
+ } //{1Y.3}
+ if (redCristal) {
+ redCristal.visible = false; //{1Z.1}
+ redCristal.destroy(); // Ensure it is completely removed
+ } //{1Z.3}
+ // Hide the map screen
+ mapScreen.visible = false;
+ // Show the counter display
+ counterText.visible = true;
+ // Show the Growth rate counter when transitioning to anvilmap
+ growthRateText.visible = true;
+ };
+ // Hide the current game screen
+ gameScreen.visible = false;
+ // Disable the active background
+ background.visible = false;
+ // Attach a new background or asset to the mapScreen if needed
+ // Example: mapScreen.attachAsset('newBackground', { anchorX: 0.5, anchorY: 0.5 });
+ // Position the mapScreen at the center
+ mapScreen.x = 2048 / 2;
+ mapScreen.y = 2732 / 2;
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
};
-var counterText = createText("Forging skill: ".concat(storage.forgingSkill));
-LK.gui.topLeft.addChild(counterText);
-var growthRateText = createText("Growth rate: ".concat(storage.growthRate), {
- y: counterText.height - 6
-});
-LK.gui.topLeft.addChild(growthRateText);
-var scoreTexts = {
- blue: createText("Blue Crystall: ".concat(storage.blueCrystallScore), {
- y: 100
- }),
- green: createText("Green Crystall: ".concat(storage.greenCrystallScore), {
- y: 150
- }),
- red: createText("Red Crystall: ".concat(storage.redCrystallScore), {
- y: 200
- }),
- gold: createText("Gold: ".concat(storage.goldScore || 0), {
- x: counterText.width + 10
- })
-};
-Object.values(scoreTexts).forEach(function (txt) {
- return LK.gui.topLeft.addChild(txt);
-});
-var ingotTexts = {
- blue: createText("BlueCrystalIngot: ".concat(storage.blueCrystalIngotScore), {
- anchorX: 1,
- y: 0
- }),
- green: createText("GreenCrystalIngot: ".concat(storage.greenCrystalIngotScore), {
- anchorX: 1,
- y: 50
- }),
- red: createText("RedCrystalIngot: ".concat(storage.redCrystalIngotScore), {
- anchorX: 1,
- y: 100
- })
-};
-Object.values(ingotTexts).forEach(function (txt) {
- return LK.gui.topRight.addChild(txt);
-});
-CRYSTAL_CONFIGS.blue.crystalText = scoreTexts.blue;
-CRYSTAL_CONFIGS.blue.ingotText = ingotTexts.blue;
-CRYSTAL_CONFIGS.green.crystalText = scoreTexts.green;
-CRYSTAL_CONFIGS.green.ingotText = ingotTexts.green;
-CRYSTAL_CONFIGS.red.crystalText = scoreTexts.red;
-CRYSTAL_CONFIGS.red.ingotText = ingotTexts.red;
-var hammer = game.addChild(LK.getAsset('hammer', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: -1
-}));
+var growthRateText;
+var growthRateCounter = storage.growthRate; // Initialize growth rate counter from storage
var background = game.addChild(new Container());
-background.attachAsset('background', {
+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
});
-centerAsset(background);
-var map = game.addChild(LK.getAsset('Map', {
- anchorX: 0.5,
- anchorY: 0.5,
- interactive: true
-}));
-map.x = 400;
-map.y = 2450;
-map.visible = false;
-var gameScreen = game.addChild(new Container());
+var gameScreen = game.addChild(new Container()); //{1h.1}
var newGame = game.addChild(new Container());
-newGame.x = 2650 / 2 + 100;
-newGame.y = 2680 * 4.2 / 5;
-newGame.interactive = true;
-newGame.attachAsset('newGameText', {
- anchorX: 0.5,
- anchorY: 0.5,
- stroke: 0xFFFFFF,
- strokeThickness: 5
-});
+newGame.x = 2650 / 2 + 100; //{3d.1}
+newGame.y = 2680 * 4.2 / 5; //{3d.1}
+// Attach 'title' asset to the start screen
var title = game.addChild(LK.getAsset('title', {
anchorX: 0.5,
anchorY: 0.5
}));
title.x = 2048 / 2;
title.y = 3200 / 5;
-var continueText = game.addChild(LK.getAsset('continueText', {
+// Attach 'newGameText' asset to the 'New Game' object
+var newGameText = newGame.attachAsset('newGameText', {
anchorX: 0.5,
anchorY: 0.5,
- interactive: true
+ stroke: 0xFFFFFF,
+ // White color
+ strokeThickness: 5 // 5px thickness
+});
+// Attach 'continueText' asset to the game object
+var continueText = game.addChild(LK.getAsset('continueText', {
+ anchorX: 0.5,
+ anchorY: 0.5
}));
-continueText.x = newGame.x - newGame.width - 500;
-continueText.y = newGame.y;
-continueText.down = startGame;
-/**** Game Logic ****/
-function startGame() {
+continueText.x = newGame.x - newGame.width - 500; // Increase the distance between newGame and continueText
+continueText.y = newGame.y; // Align vertically with newGame
+continueText.interactive = true;
+continueText.down = function (x, y, obj) {
+ startgame();
+};
+var blueswordsclick = storage.blueswordsclick;
+var greenAxeClicks = storage.greenAxeClicks;
+var redCrystalTwoHandedSwordClicks = storage.redCrystalTwoHandedSwordClicks;
+function startgame() {
title.destroy();
hammer.destroy();
- newGame.visible = false;
- continueText.visible = false;
- background.visible = false;
- map.visible = true;
+ // Create a new game screen
+ gameScreen = game.addChild(new Container());
gameScreen.x = 2048 / 2;
gameScreen.y = 2732 / 2;
- var bg = gameScreen.attachAsset('gameScreenBackground', {
+ // Attach 'gameScreenBackground' asset to the 'gameScreen' object
+ gameScreenBackground = gameScreen.attachAsset('gameScreenBackground', {
anchorX: 0.5,
anchorY: 0.5
});
+ // Attach 'recipes' asset to the 'gameScreenBackground' object
+ var recipes = gameScreenBackground.attachAsset('recipes', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the recipes asset interactive
+ });
+ // Remove 'continueText' asset when transitioning to new game
+ // Define the 'down' event handler for recipes
+ recipes.down = function (x, y, obj) {
+ hammer.destroy();
+ LK.getSound('booksaudio').play();
+ // Create a new screen for the recipes
+ var recipesScreen = game.addChild(new RecipesScreen());
+ map.visible = false; // Hide the map asset after transitioning to the recipes screen
+ // Add 'recipesbackground' asset to the center of the screen
+ var recipesBackground = recipesScreen.attachAsset('recipesbackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ recipesBackground.x = 2048 / 2;
+ recipesBackground.y = 2932 / 2;
+ // Add 'bluecrystalswordrecipe' asset to the center of the screen
+ 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; // Отнимаем 10, но теперь в `storage`
+ blueCrystalIngotScore = storage.blueCrystalIngotScore; // Обновляем локальную переменную
+ blueCrystalIngotScoreTxt.setText('BlueCrystalIngot: ' + blueCrystalIngotScore);
+ }
+ }
+ blueCrystalSwordClicks.setText('(current ' + blueswordsclick + ')');
+ storage.blueswordsclick = blueswordsclick;
+ };
+ // Add 'Swords in stock' text asset to the center of the screen
+ var swordsInStockText = new Text2('Swords in stock', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ swordsInStockText.anchor.set(0.5, 0.5);
+ swordsInStockText.x = 1248 / 2;
+ swordsInStockText.y = 2732 / 2 + 400;
+ var axeInStockText = new Text2('Axe in stock', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ axeInStockText.anchor.set(0.5, 0.5);
+ axeInStockText.x = 2848 / 2;
+ axeInStockText.y = 2732 / 2 + 400; // Align with 'Swords in stock' text
+ recipesScreen.addChild(axeInStockText);
+ recipesScreen.addChild(swordsInStockText);
+ // Display the number of blue swords in stock
+ var blueSwordsText = new Text2(storage.blueSwords.toString(), {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ blueSwordsText.anchor.set(0.5, 0.5);
+ blueSwordsText.x = 1248 / 2;
+ blueSwordsText.y = swordsInStockText.y + 80; // Position below the 'Swords in stock' text
+ recipesScreen.addChild(blueSwordsText);
+ // Add 'Axe of Green Crystals recipe' asset to the center of the screen
+ var axeOfGreenCrystalsRecipe = recipesScreen.attachAsset('axeOfGreenCrystalsRecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ axeOfGreenCrystalsRecipe.x = 2848 / 2;
+ axeOfGreenCrystalsRecipe.y = 2132 / 2;
+ axeOfGreenCrystalsRecipe.down = function () {
+ if (storage.forgingSkill >= 8000 && storage.greenCrystalIngotScore >= 15) {
+ greenAxeClicks += 1;
+ }
+ if (greenAxeClicks >= 150) {
+ greenAxeClicks = 0;
+ storage.greenAxes += 1; // Увеличиваем количество зелёных топоров в хранилище
+ greenAxesText.setText(storage.greenAxes.toString());
+ storage.forgingSkill += 150; // Добавляем 150 к навыку ковки
+ counterText.setText('Forging skill: ' + storage.forgingSkill); // Обновляем отображение навыка ковки
+ if (storage.greenCrystalIngotScore >= 15) {
+ storage.greenCrystalIngotScore -= 15; // Вычитаем 15 из greenCrystalIngotScore
+ greenCrystalIngotScore = storage.greenCrystalIngotScore; // Сохраняем новое значение в хранилище
+ greenCrystalIngotScoreTxt.setText('GreenCrystalIngot: ' + greenCrystalIngotScore); // Обновляем текстовое отображение
+ }
+ }
+ greenAxeClicksText.setText('(current ' + greenAxeClicks + ')');
+ storage.greenAxeClicks = greenAxeClicks;
+ };
+ // Add 'Axe in stock' text asset to the center of the screen
+ var axeInStockText = new Text2('Axe in stock', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ axeInStockText.anchor.set(0.5, 0.5);
+ axeInStockText.x = 2848 / 2;
+ recipesScreen.addChild(axeInStockText);
+ // Display the number of green axes in stock
+ var greenAxesText = new Text2(storage.greenAxes.toString(), {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ greenAxesText.anchor.set(0.5, 0.5);
+ greenAxesText.x = 2848 / 2;
+ greenAxesText.y = swordsInStockText.y + 80; // Position below the 'Swords in stock' text
+ recipesScreen.addChild(greenAxesText);
+ // Add 'Green Axe clicks' text asset to the center of the screen
+ var greenAxeClicksText = new Text2('(current ' + greenAxeClicks + ')', {
+ size: 50,
+ fill: 0x000000,
+ alpha: 0.5 // Set transparency
+ });
+ greenAxeClicksText.anchor.set(0.5, 0.5);
+ greenAxeClicksText.x = 2848 / 2 - 150;
+ greenAxeClicksText.y = 2732 / 2 + 330;
+ recipesScreen.addChild(greenAxeClicksText);
+ // Add 'Blue crystal sword description' text asset to the center of the screen
+ var blueCrystalSwordDescription = new Text2('"Blue Crystal Sword"\n Forging Skill 2k.\n 10 blue crystal ingots +\n 100 clicks on the recipe', {
+ size: 50,
+ fill: 0x000000,
+ alpha: 0.5 // Set transparency
+ });
+ blueCrystalSwordDescription.anchor.set(0.5, 0.5);
+ blueCrystalSwordDescription.x = 1248 / 2;
+ blueCrystalSwordDescription.y = 2732 / 2 + 200;
+ recipesScreen.addChild(blueCrystalSwordDescription);
+ var blueCrystalSwordClicks = new Text2('(current ' + blueswordsclick + ')', {
+ size: 50,
+ fill: 0x000000,
+ alpha: 0.5 // Set transparency
+ });
+ blueCrystalSwordClicks.anchor.set(0.5, 0.5);
+ blueCrystalSwordClicks.x = 1248 / 2 - 150;
+ blueCrystalSwordClicks.y = 2732 / 2 + 330;
+ recipesScreen.addChild(blueCrystalSwordClicks);
+ // Add 'axeOfGreenCrystals description' text asset to the center of the screen
+ var axeOfGreenCrystalsDescription = new Text2('"Axe of Green Crystals"\n Forging Skill 8k.\n 15 green crystal ingots +\n 150 clicks on the recipe', {
+ size: 50,
+ fill: 0x000000,
+ alpha: 0.5 // Set transparency
+ });
+ axeOfGreenCrystalsDescription.anchor.set(0.5, 0.5);
+ axeOfGreenCrystalsDescription.x = 2890 / 2;
+ axeOfGreenCrystalsDescription.y = 2732 / 2 + 200;
+ recipesScreen.addChild(axeOfGreenCrystalsDescription);
+ // Add 'recipesnext' asset to the center of the screen
+ var recipesNext = recipesScreen.attachAsset('recipesnext', {
+ anchorX: 0.5,
+ anchorY: 0.5 //{4F.1}
+ }); //{4G.1}
+ recipesNext.x = 3248 / 2;
+ recipesNext.y = 5000 / 2;
+ // Make the 'recipesnext' asset interactive
+ recipesNext.interactive = true;
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ // Define the 'down' event handler for recipesNext
+ recipesNext.down = function (x, y, obj) {
+ // Create a new screen for the next section
+ var nextScreen = game.addChild(new Container());
+ LK.getSound('paper').play();
+ // Remove the current background
+ recipesScreen.visible = false;
+ // Add 'recipesnextbackgr1' asset to the center of the screen
+ var recipesNextBackgr1 = nextScreen.attachAsset('recipesnextbackgr1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ recipesNextBackgr1.x = 2048 / 2;
+ recipesNextBackgr1.y = 2732 / 2;
+ // Remove the existing hammer
+ hammer.destroy();
+ // Add 'recipesprev' asset to the center of the screen
+ var recipesPrev = nextScreen.attachAsset('recipesprev', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ interactive: true // Make the 'recipesprev' asset interactive
+ });
+ recipesPrev.x = 888 / 2;
+ recipesPrev.y = 5000 / 2;
+ // Define the 'down' event handler for recipesPrev
+ recipesPrev.down = function (x, y, obj) {
+ LK.getSound('paper').play();
+ // Transition back to the recipes screen
+ nextScreen.visible = false; // Hide the current screen
+ recipesScreen.visible = true; // Show the recipes screen
+ };
+ // Add 'blueingotrecipe' asset to the center of the screen
+ var blueingotrecipe = nextScreen.attachAsset('blueingotrecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ blueingotrecipe.x = 1450;
+ blueingotrecipe.y = 750;
+ // Add text under the 'blueingotrecipe' asset
+ var blueIngotRecipeText = new Text2('"BlueCrystalIngot"\n Growth rate 500.\n 10 Blue Crystal', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ blueIngotRecipeText.anchor.set(0.5, 0.5);
+ blueIngotRecipeText.x = blueingotrecipe.x;
+ blueIngotRecipeText.y = blueingotrecipe.y + 150; // Position below the 'blueingotrecipe' asset
+ nextScreen.addChild(blueIngotRecipeText);
+ // Add 'greeningotrecipe' asset to the center of the screen
+ var greeningotrecipe = nextScreen.attachAsset('greeningotrecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ greeningotrecipe.x = 1450;
+ greeningotrecipe.y = 1150;
+ // Add text under the 'greeningotrecipe' asset
+ var greeningotrecipeText = new Text2('"Greeningotrecipe"\n Growth rate 3000.\n 10 Green Crystal', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ greeningotrecipeText.anchor.set(0.5, 0.5);
+ greeningotrecipeText.x = greeningotrecipe.x;
+ greeningotrecipeText.y = greeningotrecipe.y + 160; // Position below the 'greeningotrecipe' asset
+ nextScreen.addChild(greeningotrecipeText);
+ // Add 'redingotrecipe' asset to the center of the screen
+ var redingotrecipe = nextScreen.attachAsset('redingotrecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ redingotrecipe.x = 1450;
+ redingotrecipe.y = 1500;
+ // Add text under the 'redingotrecipe' asset
+ var redingotrecipeText = new Text2('"Redingotrecipe"\n Growth rate 9000.\n 10 Green Crystal', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ redingotrecipeText.anchor.set(0.5, 0.5);
+ redingotrecipeText.x = redingotrecipe.x;
+ redingotrecipeText.y = redingotrecipe.y + 150; // Position below the 'redingotrecipe' asset
+ nextScreen.addChild(redingotrecipeText);
+ // Add 'redcrystaltwo-handedswordrecipe' asset to the center of the screen
+ var redCrystalTwoHandedSwordRecipe = nextScreen.attachAsset('redcrystaltwo-handedswordrecipe', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ redCrystalTwoHandedSwordRecipe.x = 1248 / 2;
+ redCrystalTwoHandedSwordRecipe.y = 2132 / 2;
+ redCrystalTwoHandedSwordRecipe.down = function () {
+ if (storage.forgingSkill >= 15000 && storage.redCrystalIngotScore >= 75) {
+ redCrystalTwoHandedSwordClicks += 1;
+ }
+ if (redCrystalTwoHandedSwordClicks >= 200) {
+ redCrystalTwoHandedSwordClicks = 0;
+ storage.redCrystalTwoHandedSwords += 1; // Увеличение количества мечей в storage
+ redCrystalTwoHandedSwordsText.setText(storage.redCrystalTwoHandedSwords.toString());
+ storage.forgingSkill += 210; // Добавление опыта кузнечного дела
+ counterText.setText('Forging skill: ' + storage.forgingSkill);
+ storage.redCrystalIngotScore -= 75; // Вычитаем 75 инготов из storage
+ redCrystalIngotScore = storage.redCrystalIngotScore; // Обновляем локальную переменную
+ redCrystalIngotScoreTxt.setText('RedCrystalIngot: ' + redCrystalIngotScore); // Обновляем отображение
+ }
+ redCrystalTwoHandedSwordClicksText.setText('(current ' + redCrystalTwoHandedSwordClicks + ')');
+ storage.redCrystalTwoHandedSwordClicks = redCrystalTwoHandedSwordClicks;
+ };
+ // Add 'Red Crystal Two-Handed Sword in stock' text asset to the center of the screen
+ var redCrystalTwoHandedSwordsText = new Text2(storage.redCrystalTwoHandedSwords.toString(), {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ redCrystalTwoHandedSwordsText.anchor.set(0.5, 0.5);
+ redCrystalTwoHandedSwordsText.x = 1248 / 2;
+ var redCrystalTwoHandedSwordDescription = new Text2('"Redcrystaltwo-\n handedswordrecipe"\n Forging Skill 15k.\n 75 red crystal ingots +\n 200 clicks on the anvil', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ redCrystalTwoHandedSwordDescription.anchor.set(0.5, 0.5);
+ redCrystalTwoHandedSwordDescription.x = 1248 / 2;
+ redCrystalTwoHandedSwordDescription.y = 2732 / 2 + 100;
+ nextScreen.addChild(redCrystalTwoHandedSwordDescription);
+ // Add 'Two-hand Swords in stock' text asset to the center of the screen
+ var twoHandSwordsInStockText = new Text2('Two-hand Swords in stock', {
+ size: 50,
+ fill: 0x000000 // Black color
+ });
+ twoHandSwordsInStockText.anchor.set(0.5, 0.5);
+ twoHandSwordsInStockText.x = 1248 / 2;
+ twoHandSwordsInStockText.y = redCrystalTwoHandedSwordDescription.y + 250; // Position below the description
+ nextScreen.addChild(twoHandSwordsInStockText);
+ redCrystalTwoHandedSwordsText.y = redCrystalTwoHandedSwordDescription.y + 300; // Position further below the description
+ nextScreen.addChild(redCrystalTwoHandedSwordsText);
+ // Add a new text box with black text under the 'redcrystaltwo-handedswordrecipe' asset
+ var redCrystalTwoHandedSwordClicksText = new Text2('(current ' + redCrystalTwoHandedSwordClicks + ')', {
+ size: 50,
+ fill: 0x000000,
+ alpha: 0.5
+ });
+ redCrystalTwoHandedSwordClicksText.anchor.set(0.5, 0.5);
+ redCrystalTwoHandedSwordClicksText.x = 1248 / 2 - 135;
+ redCrystalTwoHandedSwordClicksText.y = 2732 / 2 + 260;
+ nextScreen.addChild(redCrystalTwoHandedSwordClicksText);
+ hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+ }));
+ };
+ // Attach 'recipesout' asset to the 'RecipesScreen' object
+ var recipesOutGraphics = recipesScreen.attachAsset('recipesout', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Center the 'recipesout' asset on the screen
+ recipesOutGraphics.x = 2048 / 2;
+ recipesOutGraphics.y = 2732 / 2 + 1100;
+ // Make the 'recipesout' asset interactive
+ recipesOutGraphics.interactive = true;
+ LK.getSound('paper').play();
+ // Define the 'down' event handler for recipesOutGraphics
+ recipesOutGraphics.down = function (x, y, obj) {
+ // Hide the 'recipesout' asset
+ recipesOutGraphics.visible = false;
+ // Transition to the 'gameScreen'
+ gameScreen.visible = true;
+ // Make the map visible after transitioning to the recipesout screen
+ map.visible = true;
+ // Hide the current recipes screen
+ recipesScreen.visible = false;
+ };
+ // Hide the current game screen
+ gameScreen.visible = false;
+ };
+ // Center the 'recipes' asset on the gameScreenBackground
+ recipes.x = gameScreenBackground.width / 2 - 1050; //{3u.1}
+ recipes.y = gameScreenBackground.height / 2 + 150; //{3v.1}
+ // Make the map visible when 'New Game' is clicked
+ map.visible = true;
+ // Hide the main menu
+ newGame.visible = false;
+ continueText.visible = false;
+ // Disable the background
+ background.visible = false;
+ // Create a new instance of the Anvil class
var anvil = gameScreen.addChild(new Anvil());
- anvil.x = bg.x - -20;
- anvil.y = bg.y + 500;
- var door = gameScreen.addChild(new Door());
- door.x = 2048 / 4;
- door.y = 2732 / 2.5;
+ // Initialize the anvil click counter from storage
+ anvil.clickCounter = storage.forgingSkill;
+ counterText.setText('Forging skill: ' + anvil.clickCounter);
+ // Position 'The anvil' at the location of the anvil on the gameScreenBackground
+ anvil.x = gameScreenBackground.x - -20; // Adjust x-coordinate based on the anvil's position on the background
+ anvil.y = gameScreenBackground.y + 500; // Adjust y-coordinate based on the anvil's position on the background
+ // Add a new object 'Magic Nursery'
+ var magicNursery = gameScreen.addChild(new Door());
+ // Position 'Magic Nursery' to the left and up
+ magicNursery.x = 2048 / 4;
+ magicNursery.y = 2732 / 2.5;
hammer = game.addChild(LK.getAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: -1
}));
}
-newGame.down = function () {
- // Reset game state
- Object.keys(storage).forEach(function (key) {
- if (typeof storage[key] === 'number') {
- storage[key] = 0;
- } else if (typeof storage[key] === 'boolean') {
- storage[key] = false;
+// Make the 'New Game' object clickable
+newGame.interactive = true;
+newGame.down = function (x, y, obj) {
+ if (newgameclearInterval.length > 0) {
+ for (var i = 0; i < newgameclearInterval.length; i++) {
+ LK.clearInterval(newgameclearInterval[i]);
}
- });
- // Update UI
- counterText.setText("Forging skill: ".concat(storage.forgingSkill));
- growthRateText.setText("Growth rate: ".concat(storage.growthRate));
- Object.entries(scoreTexts).forEach(function (_ref7) {
- var _ref8 = _slicedToArray(_ref7, 2),
- type = _ref8[0],
- txt = _ref8[1];
- return txt.setText("".concat(type.charAt(0).toUpperCase() + type.slice(1), " Crystall: ").concat(storage["".concat(type, "CrystallScore")]));
- });
- Object.entries(ingotTexts).forEach(function (_ref9) {
- var _ref10 = _slicedToArray(_ref9, 2),
- type = _ref10[0],
- txt = _ref10[1];
- return txt.setText("".concat(type.charAt(0).toUpperCase() + type.slice(1), "CrystalIngot: ").concat(storage["".concat(type, "CrystalIngotScore")]));
- });
- startGame();
+ }
+ storage.automineblueCrystallClicked = false;
+ storage.autominegreenCrystallClicked = false;
+ storage.automineredCrystallClicked = false;
+ storage.autogrowthRateClicked = false;
+ storage.theBlacksmithsApprentice = false;
+ storage.multiclickupgrade = false;
+ // Reset all saved data
+ 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.greenCrystalIngotScore = 0;
+ storage.blueSwords = 0;
+ storage.goldScore = 0;
+ // Reset current variables
+ 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.redCrystallScore);
+ goldScoreTxt.setText('Gold: ' + goldScore);
+ startgame();
};
-/**** Event Handlers ****/
-game.move = function (x, y) {
- return hammer && (hammer.x = x, hammer.y = y);
+// Create a new text object to display the click counter
+var counterText = new Text2('Forging skill: ' + storage.forgingSkill, {
+ size: 50,
+ fill: 0xFFFFFF
+});
+// Position the text object at the top right corner of the screen
+counterText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(counterText);
+counterText.y = 0;
+counterText.x = 0;
+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; // Move the growth rate text 2 pixels higher
+growthRateText.x = 0;
+// Initialize hammer asset
+var hammer;
+hammer = game.addChild(LK.getAsset('hammer', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1
+}));
+// Function to make the hammer follow the mouse/touch position
+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);
+}
+if (autominegreenCrystallClicked) {
+ var intervalId = LK.setInterval(function () {
+ greenCrystallScore += 1;
+ storage.greenCrystallScore = greenCrystallScore;
+ greenScoreTxt.setText('Green Crystall: ' + greenCrystallScore);
+ }, 1000);
+ newgameclearInterval.push(intervalId);
+}
+if (automineredCrystallClicked) {
+ var intervalId = LK.setInterval(function () {
+ redCrystallScore += 1;
+ storage.redCrystallScore = redCrystallScore;
+ redScoreTxt.setText('Red Crystall: ' + redCrystallScore);
+ }, 1000);
+ newgameclearInterval.push(intervalId);
+}
+if (autogrowthRateClicked) {
+ var intervalId = LK.setInterval(function () {
+ growthRateCounter += 1;
+ growthRateText.setText('Growth rate: ' + growthRateCounter);
+ storage.growthRate = growthRateCounter;
+ }, 1000);
+ newgameclearInterval.push(intervalId);
+}
+if (storage.theBlacksmithsApprentice) {
+ var intervalId = LK.setInterval(function () {
+ storage.forgingSkill += 1;
+ counterText.setText('Forging skill: ' + storage.forgingSkill);
+ }, 1000);
+ newgameclearInterval.push(intervalId);
+}
+var seconds = Math.floor(Date.now() / 1000);
+seconds = seconds - storage.lastgametime;
+if (seconds * 60 * 5 > Math.floor(Date.now() / 1000)) {
+ seconds = 5 * 60 * 60;
+}
+if (seconds > 0) {
+ if (storage.automineblueCrystallClicked) {
+ blueCrystallScore += seconds;
+ storage.blueCrystallScore += seconds;
+ }
+ if (storage.autominegreenCrystallClicked) {
+ greenCrystallScore += seconds;
+ storage.greenCrystallScore += seconds;
+ }
+ if (storage.automineredCrystallClicked) {
+ redCrystallScore += seconds;
+ storage.redCrystallScore += seconds;
+ }
+ if (storage.autogrowthRateClicked) {
+ growthRateCounter += seconds;
+ storage.growthRate += seconds;
+ }
+ if (storage.theBlacksmithsApprentice) {
+ storage.forgingSkill += seconds;
+ }
+}
+var intervalId = LK.setInterval(function () {
+ storage.lastgametime = Math.floor(Date.now() / 1000);
+ console.log(storage.lastgametime);
+}, 1000);
+// Make the cursor follow the mouse/touch position
+game.move = function (x, y, obj) {
+ updateHammerPosition(x, y);
};
-game.down = function (x, y) {
+// Animate cursor rotation on click
+game.down = function (x, y, obj) {
LK.getSound('hammer').play();
tween(hammer, {
rotation: -Math.PI / 2
}, {
duration: 125,
easing: tween.easeInOut,
onFinish: function onFinish() {
+ // Create stars around the hammer for 0.25 seconds
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 () {
- return star.destroy();
- }, 250);
+ (function (star) {
+ // Make the star move upwards
+ star.update = function () {
+ star.y -= 5; // Move the star upwards by 5 pixels per frame
+ if (star.x < hammer.x) {
+ star.x += 2; // Move the star slightly to the right if on the left side of the hammer
+ } else {
+ star.x -= 2; // Move the star slightly to the left if on the right side of the hammer
+ }
+ };
+ LK.setTimeout(function () {
+ star.destroy();
+ }, 250);
+ })(star);
}
tween(hammer, {
rotation: 0
}, {
@@ -984,30 +1696,5 @@
easing: tween.easeInOut
});
}
});
-};
-/**** Auto-Updates ****/
-var intervals = [];
-['blueCrystall', 'greenCrystall', 'redCrystall'].forEach(function (type) {
- if (storage["automine".concat(type, "Clicked")]) {
- intervals.push(LK.setInterval(function () {
- storage["".concat(type, "Score")]++;
- scoreTexts[type.split(/(?=[A-Z])/)[0].toLowerCase()].setText("".concat(type.charAt(0).toUpperCase() + type.slice(1), " Crystall: ").concat(storage["".concat(type, "Score")]));
- }, 1000));
- }
-});
-if (storage.autogrowthRateClicked) {
- intervals.push(LK.setInterval(function () {
- storage.growthRate++;
- growthRateText.setText("Growth rate: ".concat(storage.growthRate));
- }, 1000));
-}
-if (storage.theBlacksmithsApprentice) {
- intervals.push(LK.setInterval(function () {
- storage.forgingSkill++;
- counterText.setText("Forging skill: ".concat(storage.forgingSkill));
- }, 1000));
-}
-LK.setInterval(function () {
- return storage.lastgametime = Math.floor(Date.now() / 1000);
-}, 1000);
\ No newline at end of file
+};
\ No newline at end of file