User prompt
make the bisnesses go to the bottem
User prompt
make the upgrads go to the old position
User prompt
make the text that says the bisnesses go to the bottem
User prompt
make the text for upgrades go to the bottrm
User prompt
put all upgrades at the bottem
User prompt
when the game resets make all states 0
User prompt
make the game also reset when u reset reload the game or u are new
User prompt
make the game reset when u leave
User prompt
make the upgrades more expensive and make the more expensive upgrade way more expenncive
User prompt
make all upgrades bisness upgrads
User prompt
make the auto Eff upgrade bisness upgrade
User prompt
make way more business upgrades
User prompt
make the structures
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'getCurrentCost')' in or related to this line: 'var cost = business.getCurrentCost();' Line Number: 251
Code edit (1 edits merged)
Please save this source code
User prompt
Tap Empire: Build Your Business
Initial prompt
make a tycoon
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Business = Container.expand(function (type, baseCost, baseIncome) { var self = Container.call(this); self.type = type; self.baseCost = baseCost; self.baseIncome = baseIncome; self.level = 0; self.owned = false; self.hasManager = false; self.managerCost = baseCost * 10; self.upgradeCost = baseCost; self.lastEarning = 0; // New upgrade types self.efficiencyLevel = 0; self.automationLevel = 0; self.marketingLevel = 0; self.prestigeUpgradeLevel = 0; // Upgrade costs self.efficiencyCost = baseCost * 25; self.automationCost = baseCost * 100; self.marketingCost = baseCost * 500; self.prestigeUpgradeCost = baseCost * 2500; var icon = self.attachAsset('businessIcon', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2(type, { size: 30, fill: 0xFFFFFF }); nameText.anchor.set(0, 0.5); nameText.x = 50; nameText.y = 0; self.addChild(nameText); var levelText = new Text2('Level: 0', { size: 24, fill: 0xCCCCCC }); levelText.anchor.set(0, 0.5); levelText.x = 50; levelText.y = 25; self.addChild(levelText); var incomeText = new Text2('$0/tap', { size: 20, fill: 0x00FF00 }); incomeText.anchor.set(0, 0.5); incomeText.x = 50; incomeText.y = -25; self.addChild(incomeText); self.updateDisplay = function () { levelText.setText('Level: ' + self.level); var income = self.getCurrentIncome(); incomeText.setText('$' + formatNumber(income) + '/tap'); if (self.hasManager) { icon.tint = 0x00ff00; } else if (self.owned) { icon.tint = 0xffffff; } else { icon.tint = 0x666666; } }; self.getCurrentIncome = function () { if (!self.owned) return 0; var baseIncome = self.baseIncome * Math.pow(1.5, self.level); var efficiencyMultiplier = 1 + self.efficiencyLevel * 0.25; var automationMultiplier = 1 + self.automationLevel * 0.5; var marketingMultiplier = 1 + self.marketingLevel * 0.75; var prestigeMultiplier = 1 + self.prestigeUpgradeLevel * 1.0; var autoEfficiencyMultiplier = 1 + self.autoEfficiencyLevel * 0.3; // Business upgrade bonus for auto efficiency return Math.floor(baseIncome * efficiencyMultiplier * automationMultiplier * marketingMultiplier * prestigeMultiplier * autoEfficiencyMultiplier); }; self.getEfficiencyCost = function () { return Math.floor(self.efficiencyCost * Math.pow(1.8, self.efficiencyLevel)); }; self.getAutomationCost = function () { return Math.floor(self.automationCost * Math.pow(2.2, self.automationLevel)); }; self.getMarketingCost = function () { return Math.floor(self.marketingCost * Math.pow(2.8, self.marketingLevel)); }; self.getPrestigeUpgradeCost = function () { return Math.floor(self.prestigeUpgradeCost * Math.pow(3.5, self.prestigeUpgradeLevel)); }; self.canAffordEfficiency = function (money) { return money >= self.getEfficiencyCost() && self.owned; }; self.canAffordAutomation = function (money) { return money >= self.getAutomationCost() && self.owned; }; self.canAffordMarketing = function (money) { return money >= self.getMarketingCost() && self.owned; }; self.canAffordPrestigeUpgrade = function (money) { return money >= self.getPrestigeUpgradeCost() && self.owned; }; // Auto Efficiency upgrade system self.autoEfficiencyLevel = 0; self.autoEfficiencyCost = baseCost * 10000; self.getAutoEfficiencyCost = function () { return Math.floor(self.autoEfficiencyCost * Math.pow(10.0, self.autoEfficiencyLevel)); }; self.canAffordAutoEfficiency = function (money) { return money >= self.getAutoEfficiencyCost() && self.owned; }; self.purchaseAutoEfficiency = function () { self.autoEfficiencyLevel++; self.updateDisplay(); }; // Auto efficiency upgrade logic removed - now purely a manual business upgrade self.purchaseEfficiency = function () { self.efficiencyLevel++; self.updateDisplay(); }; self.purchaseAutomation = function () { self.automationLevel++; self.updateDisplay(); }; self.purchaseMarketing = function () { self.marketingLevel++; self.updateDisplay(); }; self.purchasePrestigeUpgrade = function () { self.prestigeUpgradeLevel++; self.updateDisplay(); }; self.getCurrentCost = function () { return Math.floor(self.baseCost * Math.pow(1.15, self.level)); }; self.canAfford = function (money) { return money >= self.getCurrentCost(); }; self.purchase = function () { if (!self.owned) { self.owned = true; self.level = 1; } else { self.level++; } self.upgradeCost = self.getCurrentCost(); self.updateDisplay(); }; self.hireManager = function () { self.hasManager = true; self.updateDisplay(); }; self.canAffordManager = function (money) { return money >= self.managerCost && !self.hasManager && self.owned; }; self.autoEarn = function () { if (self.hasManager && self.owned) { var income = self.getCurrentIncome(); self.lastEarning = income; return income; } return 0; }; self.updateDisplay(); return self; }); var Structure = Container.expand(function (businessType, businessIndex) { var self = Container.call(this); self.businessType = businessType; self.businessIndex = businessIndex; self.structureAssets = []; // Foundation for all structures var foundation = self.attachAsset('foundation', { anchorX: 0.5, anchorY: 1 }); foundation.y = 0; self.structureAssets.push(foundation); // Main structure based on business type var structureAssetName = getStructureAssetName(businessType); var mainStructure = self.attachAsset(structureAssetName, { anchorX: 0.5, anchorY: 1 }); mainStructure.y = -20; self.structureAssets.push(mainStructure); // Initially hidden self.alpha = 0.3; self.scaleX = 0.5; self.scaleY = 0.5; self.updateStructure = function (business) { if (!business.owned) { self.alpha = 0.3; self.scaleX = 0.5; self.scaleY = 0.5; } else { self.alpha = 1.0; var scale = Math.min(1.0 + (business.level - 1) * 0.1, 2.0); self.scaleX = scale; self.scaleY = scale; // Change color based on manager status if (business.hasManager) { mainStructure.tint = 0x00ff00; // Green when managed } else { mainStructure.tint = 0xffffff; // White when owned but not managed } } }; function getStructureAssetName(businessType) { switch (businessType) { case 'Lemonade Stand': return 'lemonadeStand'; case 'Food Truck': return 'foodTruck'; case 'Restaurant': return 'restaurant'; case 'Tech Startup': return 'techStartup'; default: return 'lemonadeStand'; } } return self; }); var TapButton = Container.expand(function () { var self = Container.call(this); var button = self.attachAsset('tapButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('TAP TO EARN!', { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { tween(button, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); tween(button, { scaleX: 1.1, scaleY: 1.1 }, { duration: 100, onFinish: function onFinish() { tween(button, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); var totalIncome = calculateTapIncome(); addMoney(totalIncome); LK.getSound('tap').play(); showFloatingText('+$' + formatNumber(totalIncome), self.x, self.y - 50); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Game state variables var money = storage.money || 0; var totalEarned = storage.totalEarned || 0; var prestigeLevel = storage.prestigeLevel || 0; var prestigeMultiplier = 1 + prestigeLevel * 0.5; // Business definitions var businessTypes = [{ name: 'Lemonade Stand', cost: 10, income: 1 }, { name: 'Food Truck', cost: 100, income: 5 }, { name: 'Restaurant', cost: 1000, income: 25 }, { name: 'Tech Startup', cost: 10000, income: 100 }]; var businesses = []; var structures = []; var floatingTexts = []; // UI Elements var moneyText = new Text2('$0', { size: 60, fill: 0x00FF00 }); moneyText.anchor.set(0.5, 0); LK.gui.top.addChild(moneyText); var totalEarnedText = new Text2('Total: $0', { size: 30, fill: 0xFFFF00 }); totalEarnedText.anchor.set(0.5, 0); totalEarnedText.y = 80; LK.gui.top.addChild(totalEarnedText); var prestigeText = new Text2('Prestige Level: 0', { size: 25, fill: 0xFF00FF }); prestigeText.anchor.set(1, 0); LK.gui.topRight.addChild(prestigeText); // Create tap button var tapButton = game.addChild(new TapButton()); tapButton.x = 1024; tapButton.y = 400; // Create businesses for (var i = 0; i < businessTypes.length; i++) { var businessData = businessTypes[i]; var business = new Business(businessData.name, businessData.cost, businessData.income); business.x = 200; business.y = 600 + i * 120; businesses.push(business); game.addChild(business); // Load saved state var savedBusiness = storage['business_' + i]; if (savedBusiness) { business.level = savedBusiness.level || 0; business.owned = savedBusiness.owned || false; business.hasManager = savedBusiness.hasManager || false; business.efficiencyLevel = savedBusiness.efficiencyLevel || 0; business.automationLevel = savedBusiness.automationLevel || 0; business.marketingLevel = savedBusiness.marketingLevel || 0; business.prestigeUpgradeLevel = savedBusiness.prestigeUpgradeLevel || 0; business.autoEfficiencyLevel = savedBusiness.autoEfficiencyLevel || 0; business.updateDisplay(); } } // Create visual structures for the cityscape for (var i = 0; i < businessTypes.length; i++) { var businessData = businessTypes[i]; var structure = new Structure(businessData.name, i); structure.x = 1200 + i * 150; structure.y = 1000; structures.push(structure); game.addChild(structure); // Initialize structure display structure.updateStructure(businesses[i]); } // Create upgrade buttons at bottom of screen var upgradeButtons = []; var efficiencyButtons = []; var automationButtons = []; var marketingButtons = []; var prestigeUpgradeButtons = []; var autoEfficiencyButtons = []; // Start at bottom of screen var bottomStartY = 1600; for (var i = 0; i < businesses.length; i++) { // Main upgrade button var upgradeButton = LK.getAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); upgradeButton.x = 300; upgradeButton.y = bottomStartY + i * 130; upgradeButton.businessIndex = i; game.addChild(upgradeButton); upgradeButtons.push(upgradeButton); var upgradeText = new Text2('Buy', { size: 24, fill: 0xFFFFFF }); upgradeText.anchor.set(0.5, 0.5); upgradeButton.addChild(upgradeText); upgradeButton.costText = upgradeText; upgradeButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; var cost = business.getCurrentCost(); if (money >= cost) { money -= cost; var wasFirstPurchase = !business.owned; business.purchase(); LK.getSound('purchase').play(); updateUI(); // Animate structure growth if (wasFirstPurchase) { var structure = structures[this.businessIndex]; tween(structure, { scaleX: structure.scaleX * 1.2, scaleY: structure.scaleY * 1.2 }, { duration: 200, onFinish: function onFinish() { tween(structure, { scaleX: structure.scaleX / 1.2, scaleY: structure.scaleY / 1.2 }, { duration: 200 }); } }); } } }; // Efficiency upgrade button var efficiencyButton = LK.getAsset('efficiencyUpgrade', { anchorX: 0.5, anchorY: 0.5 }); efficiencyButton.x = 500; efficiencyButton.y = bottomStartY + i * 130; efficiencyButton.businessIndex = i; game.addChild(efficiencyButton); efficiencyButtons.push(efficiencyButton); var efficiencyText = new Text2('Efficiency', { size: 18, fill: 0xFFFFFF }); efficiencyText.anchor.set(0.5, 0.5); efficiencyButton.addChild(efficiencyText); efficiencyButton.costText = efficiencyText; efficiencyButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordEfficiency(money)) { money -= business.getEfficiencyCost(); business.purchaseEfficiency(); LK.getSound('purchase').play(); updateUI(); } }; // Automation upgrade button var automationButton = LK.getAsset('automationUpgrade', { anchorX: 0.5, anchorY: 0.5 }); automationButton.x = 700; automationButton.y = bottomStartY + i * 130; automationButton.businessIndex = i; game.addChild(automationButton); automationButtons.push(automationButton); var automationText = new Text2('Automation', { size: 18, fill: 0xFFFFFF }); automationText.anchor.set(0.5, 0.5); automationButton.addChild(automationText); automationButton.costText = automationText; automationButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordAutomation(money)) { money -= business.getAutomationCost(); business.purchaseAutomation(); LK.getSound('purchase').play(); updateUI(); } }; // Marketing upgrade button var marketingButton = LK.getAsset('marketingUpgrade', { anchorX: 0.5, anchorY: 0.5 }); marketingButton.x = 900; marketingButton.y = bottomStartY + i * 130; marketingButton.businessIndex = i; game.addChild(marketingButton); marketingButtons.push(marketingButton); var marketingText = new Text2('Marketing', { size: 18, fill: 0xFFFFFF }); marketingText.anchor.set(0.5, 0.5); marketingButton.addChild(marketingText); marketingButton.costText = marketingText; marketingButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordMarketing(money)) { money -= business.getMarketingCost(); business.purchaseMarketing(); LK.getSound('purchase').play(); updateUI(); } }; // Prestige upgrade button var prestigeUpgradeButton = LK.getAsset('prestigeUpgrade', { anchorX: 0.5, anchorY: 0.5 }); prestigeUpgradeButton.x = 1100; prestigeUpgradeButton.y = bottomStartY + i * 130; prestigeUpgradeButton.businessIndex = i; game.addChild(prestigeUpgradeButton); prestigeUpgradeButtons.push(prestigeUpgradeButton); var prestigeUpgradeText = new Text2('Prestige+', { size: 18, fill: 0xFFFFFF }); prestigeUpgradeText.anchor.set(0.5, 0.5); prestigeUpgradeButton.addChild(prestigeUpgradeText); prestigeUpgradeButton.costText = prestigeUpgradeText; prestigeUpgradeButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordPrestigeUpgrade(money)) { money -= business.getPrestigeUpgradeCost(); business.purchasePrestigeUpgrade(); LK.getSound('purchase').play(); updateUI(); } }; // Auto Efficiency upgrade button var autoEfficiencyButton = LK.getAsset('autoEfficiencyUpgrade', { anchorX: 0.5, anchorY: 0.5 }); autoEfficiencyButton.x = 1300; autoEfficiencyButton.y = bottomStartY + i * 130; autoEfficiencyButton.businessIndex = i; game.addChild(autoEfficiencyButton); autoEfficiencyButtons.push(autoEfficiencyButton); var autoEfficiencyText = new Text2('Auto Eff', { size: 18, fill: 0xFFFFFF }); autoEfficiencyText.anchor.set(0.5, 0.5); autoEfficiencyButton.addChild(autoEfficiencyText); autoEfficiencyButton.costText = autoEfficiencyText; autoEfficiencyButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordAutoEfficiency(money)) { money -= business.getAutoEfficiencyCost(); business.purchaseAutoEfficiency(); LK.getSound('purchase').play(); updateUI(); } }; } // Create manager buttons at bottom of screen var managerButtons = []; for (var i = 0; i < businesses.length; i++) { var managerButton = LK.getAsset('managerButton', { anchorX: 0.5, anchorY: 0.5 }); managerButton.x = 1500; managerButton.y = bottomStartY + i * 130; managerButton.businessIndex = i; game.addChild(managerButton); managerButtons.push(managerButton); var managerText = new Text2('Manager', { size: 20, fill: 0xFFFFFF }); managerText.anchor.set(0.5, 0.5); managerButton.addChild(managerText); managerButton.costText = managerText; managerButton.down = function (x, y, obj) { var business = businesses[this.businessIndex]; if (business.canAffordManager(money)) { money -= business.managerCost; business.hireManager(); LK.getSound('purchase').play(); updateUI(); } }; } // Create prestige button at bottom of screen var prestigeButton = LK.getAsset('prestigeButton', { anchorX: 0.5, anchorY: 0.5 }); prestigeButton.x = 1024; prestigeButton.y = 2200; game.addChild(prestigeButton); var prestigeButtonText = new Text2('PRESTIGE', { size: 30, fill: 0xFFFFFF }); prestigeButtonText.anchor.set(0.5, 0.5); prestigeButton.addChild(prestigeButtonText); prestigeButton.down = function (x, y, obj) { if (totalEarned >= 100000) { prestige(); } }; // Game functions function calculateTapIncome() { var income = 0; for (var i = 0; i < businesses.length; i++) { if (businesses[i].owned) { income += businesses[i].getCurrentIncome(); } } return Math.max(1, Math.floor(income * prestigeMultiplier)); } function addMoney(amount) { money += amount; totalEarned += amount; updateUI(); } function formatNumber(num) { if (num >= 1000000000) { return (num / 1000000000).toFixed(1) + 'B'; } else if (num >= 1000000) { return (num / 1000000).toFixed(1) + 'M'; } else if (num >= 1000) { return (num / 1000).toFixed(1) + 'K'; } return num.toString(); } function updateUI() { moneyText.setText('$' + formatNumber(money)); totalEarnedText.setText('Total: $' + formatNumber(totalEarned)); prestigeText.setText('Prestige Level: ' + prestigeLevel); // Update business displays for (var i = 0; i < businesses.length; i++) { businesses[i].updateDisplay(); } // Update structure visuals for (var i = 0; i < structures.length; i++) { structures[i].updateStructure(businesses[i]); } // Update upgrade button texts for (var i = 0; i < upgradeButtons.length; i++) { var business = businesses[i]; var cost = business.getCurrentCost(); var canAfford = business.canAfford(money); if (!business.owned) { upgradeButtons[i].costText.setText('Buy\n$' + formatNumber(cost)); } else { upgradeButtons[i].costText.setText('Upgrade\n$' + formatNumber(cost)); } upgradeButtons[i].costText.anchor.set(0.5, 1); upgradeButtons[i].alpha = canAfford ? 1.0 : 0.5; } // Update efficiency buttons for (var i = 0; i < efficiencyButtons.length; i++) { var business = businesses[i]; var cost = business.getEfficiencyCost(); var canAfford = business.canAffordEfficiency(money); efficiencyButtons[i].costText.setText('Eff L' + business.efficiencyLevel + '\n$' + formatNumber(cost)); efficiencyButtons[i].costText.anchor.set(0.5, 1); efficiencyButtons[i].alpha = canAfford ? 1.0 : 0.3; } // Update automation buttons for (var i = 0; i < automationButtons.length; i++) { var business = businesses[i]; var cost = business.getAutomationCost(); var canAfford = business.canAffordAutomation(money); automationButtons[i].costText.setText('Auto L' + business.automationLevel + '\n$' + formatNumber(cost)); automationButtons[i].costText.anchor.set(0.5, 1); automationButtons[i].alpha = canAfford ? 1.0 : 0.3; } // Update marketing buttons for (var i = 0; i < marketingButtons.length; i++) { var business = businesses[i]; var cost = business.getMarketingCost(); var canAfford = business.canAffordMarketing(money); marketingButtons[i].costText.setText('Mark L' + business.marketingLevel + '\n$' + formatNumber(cost)); marketingButtons[i].costText.anchor.set(0.5, 1); marketingButtons[i].alpha = canAfford ? 1.0 : 0.3; } // Update prestige upgrade buttons for (var i = 0; i < prestigeUpgradeButtons.length; i++) { var business = businesses[i]; var cost = business.getPrestigeUpgradeCost(); var canAfford = business.canAffordPrestigeUpgrade(money); prestigeUpgradeButtons[i].costText.setText('Pres+ L' + business.prestigeUpgradeLevel + '\n$' + formatNumber(cost)); prestigeUpgradeButtons[i].costText.anchor.set(0.5, 1); prestigeUpgradeButtons[i].alpha = canAfford ? 1.0 : 0.3; } // Update auto efficiency buttons for (var i = 0; i < autoEfficiencyButtons.length; i++) { var business = businesses[i]; var cost = business.getAutoEfficiencyCost(); var canAfford = business.canAffordAutoEfficiency(money); autoEfficiencyButtons[i].costText.setText('Super Eff L' + business.autoEfficiencyLevel + '\n$' + formatNumber(cost)); autoEfficiencyButtons[i].costText.anchor.set(0.5, 1); autoEfficiencyButtons[i].alpha = canAfford ? 1.0 : 0.3; } // Update manager button texts for (var i = 0; i < managerButtons.length; i++) { var business = businesses[i]; var canAfford = business.canAffordManager(money); if (business.hasManager) { managerButtons[i].costText.setText('Hired'); managerButtons[i].alpha = 0.3; } else if (business.owned) { managerButtons[i].costText.setText('$' + formatNumber(business.managerCost)); managerButtons[i].alpha = canAfford ? 1.0 : 0.5; } else { managerButtons[i].costText.setText('Locked'); managerButtons[i].alpha = 0.3; } } // Update prestige button prestigeButton.alpha = totalEarned >= 100000 ? 1.0 : 0.5; } function showFloatingText(text, x, y) { var floatingText = new Text2(text, { size: 36, fill: 0x00FF00 }); floatingText.anchor.set(0.5, 0.5); floatingText.x = x + (Math.random() - 0.5) * 100; floatingText.y = y; game.addChild(floatingText); floatingTexts.push(floatingText); tween(floatingText, { y: y - 100, alpha: 0 }, { duration: 1500, onFinish: function onFinish() { floatingText.destroy(); var index = floatingTexts.indexOf(floatingText); if (index > -1) { floatingTexts.splice(index, 1); } } }); } function prestige() { prestigeLevel++; prestigeMultiplier = 1 + prestigeLevel * 0.5; // Reset game state money = 0; totalEarned = 0; for (var i = 0; i < businesses.length; i++) { businesses[i].level = 0; businesses[i].owned = false; businesses[i].hasManager = false; businesses[i].efficiencyLevel = 0; businesses[i].automationLevel = 0; businesses[i].marketingLevel = 0; businesses[i].prestigeUpgradeLevel = 0; businesses[i].autoEfficiencyLevel = 0; businesses[i].updateDisplay(); } // Reset structure visuals for (var i = 0; i < structures.length; i++) { structures[i].updateStructure(businesses[i]); } LK.getSound('unlock').play(); showFloatingText('PRESTIGE +' + prestigeLevel + '!', 1024, 600); updateUI(); saveGame(); } function saveGame() { storage.money = money; storage.totalEarned = totalEarned; storage.prestigeLevel = prestigeLevel; for (var i = 0; i < businesses.length; i++) { storage['business_' + i] = { level: businesses[i].level, owned: businesses[i].owned, hasManager: businesses[i].hasManager, efficiencyLevel: businesses[i].efficiencyLevel, automationLevel: businesses[i].automationLevel, marketingLevel: businesses[i].marketingLevel, prestigeUpgradeLevel: businesses[i].prestigeUpgradeLevel, autoEfficiencyLevel: businesses[i].autoEfficiencyLevel }; } } // Auto-save timer var autoSaveTimer = LK.setInterval(function () { saveGame(); }, 5000); // Manager auto-earning timer var managerTimer = LK.setInterval(function () { var totalAutoIncome = 0; for (var i = 0; i < businesses.length; i++) { totalAutoIncome += businesses[i].autoEarn(); } if (totalAutoIncome > 0) { totalAutoIncome = Math.floor(totalAutoIncome * prestigeMultiplier); addMoney(totalAutoIncome); } // Auto efficiency purchasing removed - all upgrades are now manual business upgrades updateUI(); }, 1000); // Reset game when user leaves function resetGameOnLeave() { // Reset all game state to 0 money = 0; totalEarned = 0; prestigeLevel = 0; prestigeMultiplier = 1; // Reset all businesses to 0 for (var i = 0; i < businesses.length; i++) { businesses[i].level = 0; businesses[i].owned = false; businesses[i].hasManager = false; businesses[i].efficiencyLevel = 0; businesses[i].automationLevel = 0; businesses[i].marketingLevel = 0; businesses[i].prestigeUpgradeLevel = 0; businesses[i].autoEfficiencyLevel = 0; businesses[i].updateDisplay(); } // Reset structure visuals to 0 state for (var i = 0; i < structures.length; i++) { structures[i].updateStructure(businesses[i]); } // Clear storage to 0 values storage.money = 0; storage.totalEarned = 0; storage.prestigeLevel = 0; for (var i = 0; i < businesses.length; i++) { storage['business_' + i] = { level: 0, owned: false, hasManager: false, efficiencyLevel: 0, automationLevel: 0, marketingLevel: 0, prestigeUpgradeLevel: 0, autoEfficiencyLevel: 0 }; } updateUI(); } // Add event listeners for page visibility and beforeunload LK.on('beforeunload', function () { resetGameOnLeave(); }); LK.on('visibilitychange', function () { if (document.hidden) { resetGameOnLeave(); } }); // Check if this is a new user or page reload and reset game function checkAndResetOnLoad() { // Check if this is a new session (no saved data or page was reloaded) var hasExistingData = storage.money !== undefined && storage.money !== null; // If no existing data or this is a fresh load, reset the game if (!hasExistingData) { resetGameOnLeave(); } } // Call reset check on game initialization checkAndResetOnLoad(); // Initialize UI updateUI(); game.update = function () { // Clean up destroyed floating texts for (var i = floatingTexts.length - 1; i >= 0; i--) { if (floatingTexts[i].destroyed) { floatingTexts.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -635,52 +635,58 @@
var business = businesses[i];
var cost = business.getCurrentCost();
var canAfford = business.canAfford(money);
if (!business.owned) {
- upgradeButtons[i].costText.setText('Buy $' + formatNumber(cost));
+ upgradeButtons[i].costText.setText('Buy\n$' + formatNumber(cost));
} else {
- upgradeButtons[i].costText.setText('Upgrade $' + formatNumber(cost));
+ upgradeButtons[i].costText.setText('Upgrade\n$' + formatNumber(cost));
}
+ upgradeButtons[i].costText.anchor.set(0.5, 1);
upgradeButtons[i].alpha = canAfford ? 1.0 : 0.5;
}
// Update efficiency buttons
for (var i = 0; i < efficiencyButtons.length; i++) {
var business = businesses[i];
var cost = business.getEfficiencyCost();
var canAfford = business.canAffordEfficiency(money);
efficiencyButtons[i].costText.setText('Eff L' + business.efficiencyLevel + '\n$' + formatNumber(cost));
+ efficiencyButtons[i].costText.anchor.set(0.5, 1);
efficiencyButtons[i].alpha = canAfford ? 1.0 : 0.3;
}
// Update automation buttons
for (var i = 0; i < automationButtons.length; i++) {
var business = businesses[i];
var cost = business.getAutomationCost();
var canAfford = business.canAffordAutomation(money);
automationButtons[i].costText.setText('Auto L' + business.automationLevel + '\n$' + formatNumber(cost));
+ automationButtons[i].costText.anchor.set(0.5, 1);
automationButtons[i].alpha = canAfford ? 1.0 : 0.3;
}
// Update marketing buttons
for (var i = 0; i < marketingButtons.length; i++) {
var business = businesses[i];
var cost = business.getMarketingCost();
var canAfford = business.canAffordMarketing(money);
marketingButtons[i].costText.setText('Mark L' + business.marketingLevel + '\n$' + formatNumber(cost));
+ marketingButtons[i].costText.anchor.set(0.5, 1);
marketingButtons[i].alpha = canAfford ? 1.0 : 0.3;
}
// Update prestige upgrade buttons
for (var i = 0; i < prestigeUpgradeButtons.length; i++) {
var business = businesses[i];
var cost = business.getPrestigeUpgradeCost();
var canAfford = business.canAffordPrestigeUpgrade(money);
prestigeUpgradeButtons[i].costText.setText('Pres+ L' + business.prestigeUpgradeLevel + '\n$' + formatNumber(cost));
+ prestigeUpgradeButtons[i].costText.anchor.set(0.5, 1);
prestigeUpgradeButtons[i].alpha = canAfford ? 1.0 : 0.3;
}
// Update auto efficiency buttons
for (var i = 0; i < autoEfficiencyButtons.length; i++) {
var business = businesses[i];
var cost = business.getAutoEfficiencyCost();
var canAfford = business.canAffordAutoEfficiency(money);
autoEfficiencyButtons[i].costText.setText('Super Eff L' + business.autoEfficiencyLevel + '\n$' + formatNumber(cost));
+ autoEfficiencyButtons[i].costText.anchor.set(0.5, 1);
autoEfficiencyButtons[i].alpha = canAfford ? 1.0 : 0.3;
}
// Update manager button texts
for (var i = 0; i < managerButtons.length; i++) {