User prompt
oyunun bitişini farklı birşey yap
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.warehouseCapacity = undefined;' Line Number: 1544 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
alınan krediyi geri ödeme butonu ekle
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'toFixed')' in or related to this line: 'var creditText = new Text2('Credit Debt: $' + creditDebt.toFixed(2), {' Line Number: 902
User prompt
oyuna birde kredi sistemi ekleyelim. Kredi borcu hergün %15 artmalı. borç 4 gün içinde ödenmezse borç +%60 değerinde mevcut paradan ve stoktaki ürünlerden alınmalı. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
ürünlerin kilidini açma butonlarını biraz büyült
User prompt
yeni ürünlerin kilidini açamıyorum sanırsam bir bug oluştu düzeltir misin ?
User prompt
sıradaki güne geçildiğinde ekrana çıkan bilgilendirme ekranındaki bilgilerin boyutunu büyült.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Customer = Container.expand(function () { var self = Container.call(this); // Select random customer type var customerTypes = ['customer', 'customer_red', 'customer_green', 'customer_yellow', 'customer_purple', 'customer_orange']; var randomType = customerTypes[Math.floor(Math.random() * customerTypes.length)]; var customerGraphics = self.attachAsset(randomType, { anchorX: 0.5, anchorY: 1.0 }); self.targetProduct = null; self.buyingChance = 0; self.moveSpeed = 2; self.state = 'entering'; // entering, shopping, leaving self.timer = 0; self.update = function () { self.timer++; if (self.state === 'entering') { self.x += self.moveSpeed; if (self.x > 400) { self.state = 'shopping'; self.timer = 0; self.selectProduct(); } } else if (self.state === 'shopping') { if (self.timer > 120) { // 2 seconds at 60fps self.attemptPurchase(); self.state = 'leaving'; } } else if (self.state === 'leaving') { self.x += self.moveSpeed; if (self.x > 2200) { self.destroy(); customers.splice(customers.indexOf(self), 1); } } }; self.selectProduct = function () { var availableProducts = products.filter(function (p) { return p.stock > 0 && p.isUnlocked; }); if (availableProducts.length > 0) { self.targetProduct = availableProducts[Math.floor(Math.random() * availableProducts.length)]; // Calculate buying chance based on price vs market var priceRatio = self.targetProduct.retailPrice / self.targetProduct.marketPrice; if (priceRatio <= 0.9) { self.buyingChance = 0.8; // High chance for good deals } else if (priceRatio <= 1.1) { self.buyingChance = 0.5; // Medium chance for fair prices } else { self.buyingChance = 0.2; // Low chance for overpriced items } } }; self.attemptPurchase = function () { if (self.targetProduct && Math.random() < self.buyingChance) { if (self.targetProduct.sellItem()) { var profit = self.targetProduct.retailPrice - self.targetProduct.wholesalePrice; money += self.targetProduct.retailPrice; totalProfit += profit; LK.setScore(Math.floor(totalProfit)); LK.getSound('sell_sound').play(); updateMoneyDisplay(); // Show purchased product on customer self.showPurchasedProduct(self.targetProduct.type); } } }; self.showPurchasedProduct = function (productType) { // Create product icon on customer var productIcon; if (productType === 'apple') { productIcon = self.attachAsset('product_apple', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } else if (productType === 'bread') { productIcon = self.attachAsset('product_bread', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } else if (productType === 'milk') { productIcon = self.attachAsset('product_milk', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } else if (productType === 'cheese') { productIcon = self.attachAsset('product_cheese', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } else if (productType === 'fish') { productIcon = self.attachAsset('product_fish', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } else if (productType === 'cake') { productIcon = self.attachAsset('product_cake', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80, scaleX: 0.5, scaleY: 0.5 }); } if (productIcon) { // Add floating animation to the product icon tween(productIcon, { y: -90 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(productIcon, { y: -80 }, { duration: 1000, easing: tween.easeInOut }); } }); } }; return self; }); var PriceChangesPanel = Container.expand(function (priceChanges) { var self = Container.call(this); var panel = self.attachAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.9 }); panel.tint = 0xe6f3ff; self.titleText = new Text2('PRICE CHANGES - DAY ' + day, { size: 64, fill: '#000000' }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -300; self.addChild(self.titleText); // Create price change list var yPosition = -200; for (var i = 0; i < priceChanges.length; i++) { var change = priceChanges[i]; var changeText = ''; var color = '#000000'; if (change.type === 'increase') { changeText = change.productName + ' WHOLESALE: $' + change.oldPrice.toFixed(2) + ' → $' + change.newPrice.toFixed(2) + ' (+' + change.change.toFixed(2) + ')'; color = '#ff0000'; // Red for price increases } else { changeText = change.productName + ' WHOLESALE: $' + change.oldPrice.toFixed(2) + ' → $' + change.newPrice.toFixed(2) + ' (' + change.change.toFixed(2) + ')'; color = '#00aa00'; // Green for price decreases } var priceText = new Text2(changeText, { size: 36, fill: color }); priceText.anchor.set(0.5, 0.5); priceText.y = yPosition; self.addChild(priceText); yPosition += 50; } // OK button self.okButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 250, scaleX: 1.5, scaleY: 1.5, color: 0x44aa44 })); var okButtonText = new Text2('OK', { size: 40, fill: '#ffffff' }); okButtonText.anchor.set(0.5, 0.5); self.okButton.addChild(okButtonText); self.okButton.isOkButton = true; return self; }); var Product = Container.expand(function (type, wholesalePrice, marketPrice, unlockCost) { var self = Container.call(this); self.type = type; self.wholesalePrice = wholesalePrice; self.marketPrice = marketPrice; self.retailPrice = marketPrice; self.stock = 0; self.sold = 0; self.unlockCost = unlockCost || 0; self.isUnlocked = unlockCost === 0; // Products with no unlock cost are unlocked by default var slot = self.attachAsset('product_slot', { anchorX: 0.5, anchorY: 0.5 }); var productIcon; if (type === 'apple') { productIcon = self.attachAsset('product_apple', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } else if (type === 'bread') { productIcon = self.attachAsset('product_bread', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } else if (type === 'milk') { productIcon = self.attachAsset('product_milk', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } else if (type === 'cheese') { productIcon = self.attachAsset('product_cheese', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } else if (type === 'fish') { productIcon = self.attachAsset('product_fish', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } else if (type === 'cake') { productIcon = self.attachAsset('product_cake', { anchorX: 0.5, anchorY: 0.5, y: -20 }); } self.nameText = new Text2(type.toUpperCase(), { size: 32, fill: '#000000' }); self.nameText.anchor.set(0.5, 0.5); self.nameText.y = -80; self.addChild(self.nameText); self.priceText = new Text2('$' + self.retailPrice.toFixed(2), { size: 28, fill: '#000000' }); self.priceText.anchor.set(0.5, 0.5); self.priceText.y = 60; self.addChild(self.priceText); self.stockText = new Text2('Stock: ' + self.stock, { size: 24, fill: '#000000' }); self.stockText.anchor.set(0.5, 0.5); self.stockText.y = 90; self.addChild(self.stockText); // Unlock button for locked products self.unlockButton = null; if (!self.isUnlocked && self.unlockCost > 0) { self.unlockButton = self.addChild(LK.getAsset('unlock_button', { anchorX: 0.5, anchorY: 0.5, y: 120 })); self.unlockButtonText = new Text2('UNLOCK\n$' + self.unlockCost, { size: 24, fill: '#ffffff' }); self.unlockButtonText.anchor.set(0.5, 0.5); self.unlockButton.addChild(self.unlockButtonText); } // Lock overlay for locked products self.lockOverlay = null; if (!self.isUnlocked) { self.lockOverlay = self.attachAsset('product_slot', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); self.lockOverlay.tint = 0x666666; self.lockText = new Text2('LOCKED', { size: 28, fill: '#ffffff' }); self.lockText.anchor.set(0.5, 0.5); self.lockText.y = -20; self.lockOverlay.addChild(self.lockText); } self.updateDisplay = function () { if (self.isUnlocked) { self.priceText.setText('$' + self.retailPrice.toFixed(2)); self.stockText.setText('Stock: ' + self.stock); // Color coding based on price vs market var newColor = '#000000'; // Default black if (self.retailPrice > self.marketPrice * 1.1) { newColor = '#ff0000'; // Red for overpriced } else if (self.retailPrice < self.marketPrice * 0.9) { newColor = '#00ff00'; // Green for underpriced } // Remove old price text and create new one with correct color self.removeChild(self.priceText); self.priceText = new Text2('$' + self.retailPrice.toFixed(2), { size: 28, fill: newColor }); self.priceText.anchor.set(0.5, 0.5); self.priceText.y = 60; self.addChild(self.priceText); } else { self.priceText.setText('LOCKED'); self.stockText.setText('Stock: 0'); } }; self.unlock = function () { if (!self.isUnlocked && money >= self.unlockCost) { money -= self.unlockCost; self.isUnlocked = true; // Remove lock overlay if (self.lockOverlay) { self.removeChild(self.lockOverlay); self.lockOverlay = null; } // Remove unlock button if (self.unlockButton) { self.removeChild(self.unlockButton); self.unlockButton = null; } self.updateDisplay(); updateMoneyDisplay(); LK.getSound('buy_sound').play(); return true; } return false; }; self.adjustPrice = function (amount) { self.retailPrice = Math.max(0.5, self.retailPrice + amount); self.updateDisplay(); }; self.addStock = function (amount) { // Check if adding this amount would exceed warehouse capacity var currentTotal = 0; for (var i = 0; i < products.length; i++) { currentTotal += products[i].stock; } var availableSpace = warehouseCapacity - currentTotal; var actualAmount = Math.min(amount, availableSpace); if (actualAmount > 0) { self.stock += actualAmount; self.updateDisplay(); } return actualAmount; // Return how much was actually added }; self.sellItem = function () { if (self.stock > 0) { self.stock--; self.sold++; self.updateDisplay(); return true; } return false; }; return self; }); var ResetConfirmation = Container.expand(function () { var self = Container.call(this); var panel = self.attachAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.5 }); panel.tint = 0xffcccc; self.titleText = new Text2('RESET GAME', { size: 36, fill: '#000000' }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -80; self.addChild(self.titleText); self.messageText = new Text2('Are you sure you want to reset the game?\nAll progress will be lost!', { size: 24, fill: '#000000' }); self.messageText.anchor.set(0.5, 0.5); self.messageText.y = -20; self.addChild(self.messageText); // Confirm button self.confirmButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: -100, y: 60, scaleX: 1.2, scaleY: 1.2, color: 0xaa4444 })); var confirmButtonText = new Text2('YES', { size: 20, fill: '#ffffff' }); confirmButtonText.anchor.set(0.5, 0.5); self.confirmButton.addChild(confirmButtonText); self.confirmButton.isConfirmButton = true; // Cancel button self.cancelButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 100, y: 60, scaleX: 1.2, scaleY: 1.2, color: 0x44aa44 })); var cancelButtonText = new Text2('NO', { size: 20, fill: '#ffffff' }); cancelButtonText.anchor.set(0.5, 0.5); self.cancelButton.addChild(cancelButtonText); self.cancelButton.isCancelButton = true; return self; }); var SettingsPanel = Container.expand(function () { var self = Container.call(this); var panel = self.attachAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.6 }); panel.tint = 0xdddddd; self.titleText = new Text2('SETTINGS', { size: 48, fill: '#000000' }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -150; self.addChild(self.titleText); // Reset game button self.resetButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 0, scaleX: 1.5, scaleY: 1.5, color: 0xaa4444 })); var resetButtonText = new Text2('RESET GAME', { size: 24, fill: '#ffffff' }); resetButtonText.anchor.set(0.5, 0.5); self.resetButton.addChild(resetButtonText); self.resetButton.isResetButton = true; // Close button self.closeButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 100, scaleX: 1.2, scaleY: 1.2, color: 0x44aa44 })); var closeButtonText = new Text2('CLOSE', { size: 24, fill: '#ffffff' }); closeButtonText.anchor.set(0.5, 0.5); self.closeButton.addChild(closeButtonText); self.closeButton.isCloseButton = true; return self; }); var TutorialOverlay = Container.expand(function () { var self = Container.call(this); // Semi-transparent background var overlay = self.attachAsset('shop_bg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); overlay.tint = 0x000000; // Tutorial text background var textBg = self.attachAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 0.8 }); // Tutorial text self.tutorialText = new Text2('', { size: 32, fill: '#000000' }); self.tutorialText.anchor.set(0.5, 0.5); self.tutorialText.y = -50; self.addChild(self.tutorialText); // Next button self.nextButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 150, scaleX: 1.5, scaleY: 1.5 })); self.nextButtonText = new Text2('NEXT', { size: 24, fill: '#ffffff' }); self.nextButtonText.anchor.set(0.5, 0.5); self.nextButton.addChild(self.nextButtonText); // Language toggle button self.langButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 250, scaleX: 1.2, scaleY: 1.2, color: 0x444444 })); self.langButtonText = new Text2('TR', { size: 20, fill: '#ffffff' }); self.langButtonText.anchor.set(0.5, 0.5); self.langButton.addChild(self.langButtonText); // Skip button self.skipButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 350, scaleX: 1.2, scaleY: 1.2, color: 0xaa4444 })); self.skipButtonText = new Text2('SKIP', { size: 20, fill: '#ffffff' }); self.skipButtonText.anchor.set(0.5, 0.5); self.skipButton.addChild(self.skipButtonText); self.updateText = function (text, nextText, langText) { self.tutorialText.setText(text); self.nextButtonText.setText(nextText); self.langButtonText.setText(langText); var skipText = currentLanguage === 'en' ? 'SKIP' : 'ATLA'; self.skipButtonText.setText(skipText); }; return self; }); var WholesalePanel = Container.expand(function () { var self = Container.call(this); var panel = self.attachAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5 }); self.titleText = new Text2('WHOLESALE MARKET', { size: 64, fill: '#000000' }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -350; self.addChild(self.titleText); self.buttons = []; // Calculate grid layout for more products var cols = 3; var rows = Math.ceil(products.length / cols); for (var i = 0; i < products.length; i++) { var product = products[i]; var col = i % cols; var row = Math.floor(i / cols); var button = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: (col - 1) * 300, y: -200 + row * 120, scaleX: 1.5, scaleY: 1.5 })); var buttonText; if (product.isUnlocked) { buttonText = new Text2('BUY ' + product.type.toUpperCase() + '\n$' + product.wholesalePrice.toFixed(2), { size: 32, fill: '#ffffff' }); } else { buttonText = new Text2(product.type.toUpperCase() + '\nLOCKED', { size: 32, fill: '#cccccc' }); button.tint = 0x666666; } buttonText.anchor.set(0.5, 0.5); button.addChild(buttonText); button.productIndex = i; button.buttonText = buttonText; self.buttons.push(button); } var closeButton = self.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 300, color: 0xaa4444, scaleX: 1.5, scaleY: 1.5 })); var closeText = new Text2('CLOSE', { size: 36, fill: '#ffffff' }); closeText.anchor.set(0.5, 0.5); closeButton.addChild(closeText); closeButton.isCloseButton = true; self.buttons.push(closeButton); self.updatePrices = function () { for (var i = 0; i < products.length; i++) { var product = products[i]; var button = self.buttons[i]; if (product.isUnlocked) { button.removeChild(button.buttonText); button.buttonText = new Text2('BUY ' + product.type.toUpperCase() + '\n$' + product.wholesalePrice.toFixed(2), { size: 32, fill: '#ffffff' }); button.buttonText.anchor.set(0.5, 0.5); button.addChild(button.buttonText); button.tint = 0xffffff; } else { button.removeChild(button.buttonText); button.buttonText = new Text2(product.type.toUpperCase() + '\nLOCKED', { size: 32, fill: '#cccccc' }); button.buttonText.anchor.set(0.5, 0.5); button.addChild(button.buttonText); button.tint = 0x666666; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var money = 50; var totalProfit = 0; var day = 1; var currentHour = 8; // Start at 8 AM var maxHour = 18; // Store closes at 6 PM var customers = []; var products = []; var wholesalePanel = null; var showingWholesale = false; var tutorialActive = true; var tutorialStep = 0; var tutorialOverlay = null; var tutorialText = null; var tutorialButton = null; var currentLanguage = 'en'; // 'en' for English, 'tr' for Turkish // Credit system variables var creditDebt = storage.creditDebt || 0; // Current debt amount var creditDaysOverdue = storage.creditDaysOverdue || 0; // Days debt has been overdue var maxCreditDays = 4; // Maximum days before forced collection var dailyInterestRate = 0.15; // 15% daily interest var forcedCollectionPenalty = 0.60; // 60% penalty for forced collection // Warehouse storage system var warehouseCapacity = storage.warehouseCapacity || 50; // Default capacity var warehouseLevel = storage.warehouseLevel || 1; // Storage level var warehouseUpgradeCost = storage.warehouseUpgradeCost || 100; // Cost to upgrade var totalStockStored = 0; // Current total stock across all products // Bills system var lastElectricityBillDay = storage.lastElectricityBillDay || 0; var lastTaxBillDay = storage.lastTaxBillDay || 0; var electricityBillInterval = 7; // Every 7 days var taxBillInterval = 14; // Every 14 days var hasPendingElectricityBill = false; var hasPendingTaxBill = false; var pendingElectricityAmount = 0; var pendingTaxAmount = 0; var electricityBillDaysOverdue = storage.electricityBillDaysOverdue || 0; var taxBillDaysOverdue = storage.taxBillDaysOverdue || 0; // Tutorial content var tutorialContent = { en: [{ text: "Welcome to Market Tycoon!\n\nYou are a shop owner. Your goal is to buy\nproducts wholesale and sell them to\ncustomers for profit.", next: "NEXT" }, { text: "You start with 3 unlocked products:\nApple, Bread, and Milk.\n\nOther products (Cheese, Fish, Cake)\ncan be unlocked with money.", next: "NEXT" }, { text: "Each product has three prices:\n• Wholesale Price (your cost)\n• Market Price (average selling price)\n• Your Retail Price (what you charge)", next: "NEXT" }, { text: "Click on products to adjust prices:\n• Click upper half: Increase price\n• Click lower half: Decrease price\n\nPrice colors show competitiveness!", next: "NEXT" }, { text: "Customers appear with 6 different looks.\nThey buy based on your prices:\n• Above market price = fewer sales\n• At/below market price = more sales", next: "NEXT" }, { text: "When customers buy products,\nthe product icon appears above them\nshowing what they purchased!", next: "NEXT" }, { text: "Use the WHOLESALE button to buy\nmore inventory. You need money to\nbuy products and stock to sell!", next: "NEXT" }, { text: "To unlock new products, click the\nUNLOCK button when you have enough\nmoney. New products = more profit!", next: "NEXT" }, { text: "Your store opens at 8:00 and closes at 18:00.\nCustomers only come during open hours.\nTime advances automatically every 10 seconds.", next: "NEXT" }, { text: "Use NEXT DAY to advance time.\nPrices change daily - watch the market!\n\nReach $100 profit to win!", next: "START GAME" }], tr: [{ text: "Market Tycoon'a Hoşgeldiniz!\n\nSiz bir dükkan sahibisiniz. Amacınız\nürünleri toptan alıp müşterilere\nkâr ile satmaktır.", next: "İLERİ" }, { text: "3 açık ürünle başlıyorsunuz:\nElma, Ekmek ve Süt.\n\nDiğer ürünler (Peynir, Balık, Pasta)\nparayla açılabilir.", next: "İLERİ" }, { text: "Her ürünün üç fiyatı vardır:\n• Toptan Fiyat (sizin maliyetiniz)\n• Piyasa Fiyatı (ortalama satış fiyatı)\n• Perakende Fiyatınız (sizin fiyatınız)", next: "İLERİ" }, { text: "Fiyat ayarlamak için ürünlere tıklayın:\n• Üst yarıya tıklayın: Fiyat arttır\n• Alt yarıya tıklayın: Fiyat azalt\n\nFiyat renkleri rekabetçiliği gösterir!", next: "İLERİ" }, { text: "Müşteriler 6 farklı görünümde gelir.\nFiyatlarınıza göre alışveriş yaparlar:\n• Piyasa fiyatının üstü = az satış\n• Piyasa fiyatında/altı = çok satış", next: "İLERİ" }, { text: "Müşteriler ürün aldığında,\nürün ikonu müşterinin üstünde\nbelirerek ne aldıklarını gösterir!", next: "İLERİ" }, { text: "Daha fazla stok almak için TOPTAN\ndüğmesini kullanın. Ürün almak için\nparanız, satmak için stokunuz olmalı!", next: "İLERİ" }, { text: "Yeni ürünleri açmak için yeterli\nparanız olduğunda KİLİDİ AÇ düğmesine\ntıklayın. Yeni ürünler = daha çok kâr!", next: "İLERİ" }, { text: "Dükkanınız 8:00'da açılır, 18:00'da kapanır.\nMüşteriler sadece açık saatlerde gelir.\nZaman her 10 saniyede otomatik ilerler.", next: "İLERİ" }, { text: "Zamanı ilerletmek için SONRAKİ GÜN\nkullanın. Fiyatlar günlük değişir!\n\nKazanmak için $100 kâr yapın!", next: "OYUNU BAŞLAT" }] }; // Create shop background var shopBg = game.addChild(LK.getAsset('shop_bg', { anchorX: 0.5, anchorY: 0, x: 1024, y: 400 })); // Create products var productData = [{ type: 'apple', wholesalePrice: 1.5, marketPrice: 2.5, unlockCost: 0 }, { type: 'bread', wholesalePrice: 2.0, marketPrice: 3.0, unlockCost: 0 }, { type: 'milk', wholesalePrice: 1.8, marketPrice: 2.8, unlockCost: 0 }, { type: 'cheese', wholesalePrice: 3.0, marketPrice: 4.5, unlockCost: 25 }, { type: 'fish', wholesalePrice: 4.0, marketPrice: 6.0, unlockCost: 50 }, { type: 'cake', wholesalePrice: 5.0, marketPrice: 8.0, unlockCost: 100 }]; for (var i = 0; i < productData.length; i++) { var data = productData[i]; var product = new Product(data.type, data.wholesalePrice, data.marketPrice, data.unlockCost); // Position products in a grid layout var cols = 3; var col = i % cols; var row = Math.floor(i / cols); product.x = 500 + col * 400; product.y = 700 + row * 350; products.push(product); game.addChild(product); } // UI Elements var moneyText = new Text2('Money: $' + money.toFixed(2), { size: 32, fill: '#000000' }); moneyText.anchor.set(0, 0); moneyText.x = 150; moneyText.y = 50; game.addChild(moneyText); var dayText = new Text2('Day: ' + day, { size: 32, fill: '#000000' }); dayText.anchor.set(0, 0); dayText.x = 150; dayText.y = 100; game.addChild(dayText); var hourText = new Text2('Time: ' + currentHour + ':00', { size: 32, fill: '#000000' }); hourText.anchor.set(0, 0); hourText.x = 400; hourText.y = 100; game.addChild(hourText); var profitText = new Text2('Profit: $' + totalProfit.toFixed(2), { size: 32, fill: '#000000' }); profitText.anchor.set(0, 0); profitText.x = 150; profitText.y = 150; game.addChild(profitText); // Warehouse capacity display var warehouseText = new Text2('Warehouse: ' + totalStockStored + '/' + warehouseCapacity, { size: 32, fill: '#000000' }); warehouseText.anchor.set(0, 0); warehouseText.x = 150; warehouseText.y = 200; game.addChild(warehouseText); // Bills display var billsText = new Text2('No pending bills', { size: 28, fill: '#000000' }); billsText.anchor.set(0, 0); billsText.x = 150; billsText.y = 250; game.addChild(billsText); // Credit display var creditText = new Text2('Credit Debt: $' + creditDebt.toFixed(2), { size: 28, fill: '#000000' }); creditText.anchor.set(0, 0); creditText.x = 150; creditText.y = 300; game.addChild(creditText); // Warehouse upgrade button var upgradeButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 100, scaleX: 1.2, scaleY: 1.2, color: 0x9932cc })); var upgradeButtonText = new Text2('UPGRADE WAREHOUSE\nLevel ' + warehouseLevel + ' → ' + (warehouseLevel + 1) + '\n$' + warehouseUpgradeCost, { size: 18, fill: '#ffffff' }); upgradeButtonText.anchor.set(0.5, 0.5); upgradeButton.addChild(upgradeButtonText); upgradeButton.buttonText = upgradeButtonText; // Wholesale button var wholesaleButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 200, scaleX: 1.5, scaleY: 1.5 })); var wholesaleButtonText = new Text2('WHOLESALE', { size: 24, fill: '#ffffff' }); wholesaleButtonText.anchor.set(0.5, 0.5); wholesaleButton.addChild(wholesaleButtonText); wholesaleButton.buttonText = wholesaleButtonText; // Pay bills button var payBillsButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1650, y: 100, scaleX: 1.2, scaleY: 1.2, color: 0xaa4444 })); var payBillsButtonText = new Text2('PAY BILLS', { size: 24, fill: '#ffffff' }); payBillsButtonText.anchor.set(0.5, 0.5); payBillsButton.addChild(payBillsButtonText); payBillsButton.buttonText = payBillsButtonText; // Take credit button var takeCreditButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1650, y: 200, scaleX: 1.2, scaleY: 1.2, color: 0xcc6600 })); var takeCreditButtonText = new Text2('TAKE CREDIT', { size: 20, fill: '#ffffff' }); takeCreditButtonText.anchor.set(0.5, 0.5); takeCreditButton.addChild(takeCreditButtonText); takeCreditButton.buttonText = takeCreditButtonText; // Next day button var nextDayButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 300, scaleX: 1.5, scaleY: 1.5, color: 0x4444aa })); var nextDayButtonText = new Text2('NEXT DAY', { size: 24, fill: '#ffffff' }); nextDayButtonText.anchor.set(0.5, 0.5); nextDayButton.addChild(nextDayButtonText); nextDayButton.buttonText = nextDayButtonText; function updateMoneyDisplay() { moneyText.setText('Money: $' + money.toFixed(2)); profitText.setText('Profit: $' + totalProfit.toFixed(2)); } function calculateTotalStock() { totalStockStored = 0; for (var i = 0; i < products.length; i++) { totalStockStored += products[i].stock; } warehouseText.setText('Warehouse: ' + totalStockStored + '/' + warehouseCapacity); } function calculateElectricityBill() { // Base electricity cost + money-based component + stock-based component var baseCost = 20; var moneyComponent = money * 0.05; // 5% of current money var stockValue = 0; for (var i = 0; i < products.length; i++) { stockValue += products[i].stock * products[i].wholesalePrice; } var stockComponent = stockValue * 0.03; // 3% of stock value return Math.max(10, Math.floor(baseCost + moneyComponent + stockComponent)); } function calculateTaxBill() { // Base tax + money-based component + stock-based component var baseCost = 50; var moneyComponent = money * 0.08; // 8% of current money var stockValue = 0; for (var i = 0; i < products.length; i++) { stockValue += products[i].stock * products[i].wholesalePrice; } var stockComponent = stockValue * 0.05; // 5% of stock value return Math.max(25, Math.floor(baseCost + moneyComponent + stockComponent)); } function checkForNewBills() { // Check for electricity bill if (day - lastElectricityBillDay >= electricityBillInterval) { if (!hasPendingElectricityBill) { hasPendingElectricityBill = true; pendingElectricityAmount = calculateElectricityBill(); lastElectricityBillDay = day; storage.lastElectricityBillDay = lastElectricityBillDay; } } // Check for tax bill if (day - lastTaxBillDay >= taxBillInterval) { if (!hasPendingTaxBill) { hasPendingTaxBill = true; pendingTaxAmount = calculateTaxBill(); lastTaxBillDay = day; storage.lastTaxBillDay = lastTaxBillDay; } } } function updateBillsDisplay() { var billsMessage = ''; if (hasPendingElectricityBill && hasPendingTaxBill) { var elecOverdue = electricityBillDaysOverdue > 0 ? ' (' + electricityBillDaysOverdue + 'd overdue)' : ''; var taxOverdue = taxBillDaysOverdue > 0 ? ' (' + taxBillDaysOverdue + 'd overdue)' : ''; billsMessage = 'BILLS DUE: Electricity $' + pendingElectricityAmount + elecOverdue + ', Tax $' + pendingTaxAmount + taxOverdue; billsText.tint = 0xff0000; // Red color for urgent bills } else if (hasPendingElectricityBill) { var elecOverdue = electricityBillDaysOverdue > 0 ? ' (' + electricityBillDaysOverdue + ' days overdue)' : ''; billsMessage = 'ELECTRICITY BILL DUE: $' + pendingElectricityAmount + elecOverdue; billsText.tint = 0xff0000; // Red color for urgent bills } else if (hasPendingTaxBill) { var taxOverdue = taxBillDaysOverdue > 0 ? ' (' + taxBillDaysOverdue + ' days overdue)' : ''; billsMessage = 'TAX BILL DUE: $' + pendingTaxAmount + taxOverdue; billsText.tint = 0xff0000; // Red color for urgent bills } else { billsMessage = 'No pending bills'; billsText.tint = 0x000000; // Black color for no bills } billsText.setText(billsMessage); } function updateCreditDisplay() { var creditMessage = 'Credit Debt: $' + creditDebt.toFixed(2); if (creditDebt > 0 && creditDaysOverdue > 0) { creditMessage += ' (' + creditDaysOverdue + 'd overdue)'; creditText.tint = 0xff0000; // Red color for overdue debt } else if (creditDebt > 0) { creditText.tint = 0xff8800; // Orange color for active debt } else { creditText.tint = 0x000000; // Black color for no debt } creditText.setText(creditMessage); } function takeCredit() { var creditAmount = 100; // Fixed credit amount if (creditDebt === 0) { // Only allow taking credit if no existing debt money += creditAmount; creditDebt += creditAmount; storage.creditDebt = creditDebt; updateMoneyDisplay(); updateCreditDisplay(); LK.getSound('buy_sound').play(); } } function payCredit() { if (creditDebt > 0 && money >= creditDebt) { money -= creditDebt; creditDebt = 0; creditDaysOverdue = 0; storage.creditDebt = 0; storage.creditDaysOverdue = 0; updateMoneyDisplay(); updateCreditDisplay(); LK.getSound('buy_sound').play(); return true; } return false; } function handleCreditDebt() { if (creditDebt > 0) { // Apply daily interest creditDebt = Math.floor(creditDebt * (1 + dailyInterestRate)); creditDaysOverdue++; storage.creditDebt = creditDebt; storage.creditDaysOverdue = creditDaysOverdue; // Force collection after 4 days with 60% penalty if (creditDaysOverdue >= maxCreditDays) { var penaltyAmount = Math.floor(creditDebt * (1 + forcedCollectionPenalty)); forceCreditCollection(penaltyAmount); creditDebt = 0; creditDaysOverdue = 0; storage.creditDebt = 0; storage.creditDaysOverdue = 0; } } } function forceCreditCollection(amount) { // First take from money var remainingDebt = amount; if (money > 0) { var moneyTaken = Math.min(money, remainingDebt); money -= moneyTaken; remainingDebt -= moneyTaken; } // If debt remains, take from product stock value if (remainingDebt > 0) { for (var i = 0; i < products.length && remainingDebt > 0; i++) { var product = products[i]; while (product.stock > 0 && remainingDebt > 0) { var stockValue = product.wholesalePrice; if (remainingDebt >= stockValue) { product.stock--; remainingDebt -= stockValue; } else { break; } } product.updateDisplay(); } } totalProfit -= amount; // Reduce profit by total amount LK.setScore(Math.max(0, Math.floor(totalProfit))); updateMoneyDisplay(); calculateTotalStock(); } function handleBillDebt() { // Handle electricity bill debt if (hasPendingElectricityBill) { electricityBillDaysOverdue++; storage.electricityBillDaysOverdue = electricityBillDaysOverdue; // Add 10% interest each day pendingElectricityAmount = Math.floor(pendingElectricityAmount * 1.1); // Force collection after 4 days with 50% penalty if (electricityBillDaysOverdue >= 4) { var penaltyAmount = Math.floor(pendingElectricityAmount * 1.5); forceDebtCollection(penaltyAmount); hasPendingElectricityBill = false; pendingElectricityAmount = 0; electricityBillDaysOverdue = 0; storage.electricityBillDaysOverdue = 0; } } // Handle tax bill debt if (hasPendingTaxBill) { taxBillDaysOverdue++; storage.taxBillDaysOverdue = taxBillDaysOverdue; // Add 10% interest each day pendingTaxAmount = Math.floor(pendingTaxAmount * 1.1); // Force collection after 4 days with 50% penalty if (taxBillDaysOverdue >= 4) { var penaltyAmount = Math.floor(pendingTaxAmount * 1.5); forceDebtCollection(penaltyAmount); hasPendingTaxBill = false; pendingTaxAmount = 0; taxBillDaysOverdue = 0; storage.taxBillDaysOverdue = 0; } } } function forceDebtCollection(amount) { // First take from money var remainingDebt = amount; if (money > 0) { var moneyTaken = Math.min(money, remainingDebt); money -= moneyTaken; remainingDebt -= moneyTaken; } // If debt remains, take from product stock value if (remainingDebt > 0) { for (var i = 0; i < products.length && remainingDebt > 0; i++) { var product = products[i]; while (product.stock > 0 && remainingDebt > 0) { var stockValue = product.wholesalePrice; if (remainingDebt >= stockValue) { product.stock--; remainingDebt -= stockValue; } else { break; } } product.updateDisplay(); } } totalProfit -= amount; // Reduce profit by total amount LK.setScore(Math.max(0, Math.floor(totalProfit))); updateMoneyDisplay(); calculateTotalStock(); } function payBills() { var totalBillAmount = 0; if (hasPendingElectricityBill) { totalBillAmount += pendingElectricityAmount; } if (hasPendingTaxBill) { totalBillAmount += pendingTaxAmount; } if (totalBillAmount > 0 && money >= totalBillAmount) { money -= totalBillAmount; totalProfit -= totalBillAmount; // Bills reduce profit LK.setScore(Math.max(0, Math.floor(totalProfit))); hasPendingElectricityBill = false; hasPendingTaxBill = false; pendingElectricityAmount = 0; pendingTaxAmount = 0; electricityBillDaysOverdue = 0; taxBillDaysOverdue = 0; storage.electricityBillDaysOverdue = 0; storage.taxBillDaysOverdue = 0; updateMoneyDisplay(); updateBillsDisplay(); LK.getSound('buy_sound').play(); return true; } return false; } function upgradeWarehouse() { if (money >= warehouseUpgradeCost) { money -= warehouseUpgradeCost; warehouseLevel++; warehouseCapacity += 25; // Increase capacity by 25 each level warehouseUpgradeCost = Math.floor(warehouseUpgradeCost * 1.5); // Increase cost by 50% // Save to storage storage.warehouseCapacity = warehouseCapacity; storage.warehouseLevel = warehouseLevel; storage.warehouseUpgradeCost = warehouseUpgradeCost; // Update button text upgradeButton.removeChild(upgradeButton.buttonText); upgradeButton.buttonText = new Text2('UPGRADE WAREHOUSE\nLevel ' + warehouseLevel + ' → ' + (warehouseLevel + 1) + '\n$' + warehouseUpgradeCost, { size: 18, fill: '#ffffff' }); upgradeButton.buttonText.anchor.set(0.5, 0.5); upgradeButton.addChild(upgradeButton.buttonText); updateMoneyDisplay(); calculateTotalStock(); LK.getSound('buy_sound').play(); } } function refreshButtonTexts() { // Ensure wholesale button text is visible if (wholesaleButton) { // Remove old text if it exists if (wholesaleButton.buttonText) { wholesaleButton.removeChild(wholesaleButton.buttonText); } // Create new text wholesaleButton.buttonText = new Text2('WHOLESALE', { size: 24, fill: '#ffffff' }); wholesaleButton.buttonText.anchor.set(0.5, 0.5); wholesaleButton.addChild(wholesaleButton.buttonText); } // Ensure pay bills button text is visible if (payBillsButton) { // Remove old text if it exists if (payBillsButton.buttonText) { payBillsButton.removeChild(payBillsButton.buttonText); } // Create new text payBillsButton.buttonText = new Text2('PAY BILLS', { size: 24, fill: '#ffffff' }); payBillsButton.buttonText.anchor.set(0.5, 0.5); payBillsButton.addChild(payBillsButton.buttonText); } // Ensure next day button text is visible if (nextDayButton) { // Remove old text if it exists if (nextDayButton.buttonText) { nextDayButton.removeChild(nextDayButton.buttonText); } // Create new text nextDayButton.buttonText = new Text2('NEXT DAY', { size: 24, fill: '#ffffff' }); nextDayButton.buttonText.anchor.set(0.5, 0.5); nextDayButton.addChild(nextDayButton.buttonText); } } function spawnCustomer() { // Only spawn customers if store is open (before closing hour) if (currentHour < maxHour) { var customer = new Customer(); customer.x = -100; customer.y = 1200; customers.push(customer); game.addChild(customer); } } function updateMarketPrices() { var priceChanges = []; for (var i = 0; i < products.length; i++) { var product = products[i]; var oldWholesalePrice = product.wholesalePrice; var oldMarketPrice = product.marketPrice; // Fluctuate wholesale prices by ±20% var fluctuation = (Math.random() - 0.5) * 0.4; product.wholesalePrice = Math.max(0.5, product.wholesalePrice * (1 + fluctuation)); // Fluctuate market prices by ±15% var marketFluctuation = (Math.random() - 0.5) * 0.3; product.marketPrice = Math.max(1.0, product.marketPrice * (1 + marketFluctuation)); // Track price changes for wholesale prices var priceChange = product.wholesalePrice - oldWholesalePrice; if (Math.abs(priceChange) > 0.01) { // Only show significant changes priceChanges.push({ productName: product.type.toUpperCase(), oldPrice: oldWholesalePrice, newPrice: product.wholesalePrice, change: priceChange, type: priceChange > 0 ? 'increase' : 'decrease' }); } product.updateDisplay(); } // Show price changes panel if there are changes if (priceChanges.length > 0) { showPriceChanges(priceChanges); } } function showPriceChanges(priceChanges) { if (!showingPriceChanges) { priceChangesPanel = new PriceChangesPanel(priceChanges); priceChangesPanel.x = 1024; priceChangesPanel.y = 1366; game.addChild(priceChangesPanel); showingPriceChanges = true; } } function hidePriceChanges() { if (priceChangesPanel) { priceChangesPanel.destroy(); priceChangesPanel = null; showingPriceChanges = false; } } function advanceHour() { currentHour++; hourText.setText('Time: ' + currentHour + ':00'); // If store closes, show notification instead of forcing next day if (currentHour >= maxHour) { showStoreClosedNotification(); } } var storeClosedNotification = null; var showingStoreClosedNotification = false; function showStoreClosedNotification() { if (!showingStoreClosedNotification) { storeClosedNotification = game.addChild(LK.getAsset('wholesale_panel', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 0.8, scaleY: 0.6 })); storeClosedNotification.tint = 0x333333; var notificationText = new Text2('STORE CLOSED!\n\nIt\'s 18:00 and your store is now closed.\nCustomers will no longer come today.\n\nUse NEXT DAY button to continue.', { size: 32, fill: '#ffffff' }); notificationText.anchor.set(0.5, 0.5); storeClosedNotification.addChild(notificationText); var okButton = storeClosedNotification.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, y: 150, scaleX: 1.2, scaleY: 1.2, color: 0x44aa44 })); var okButtonText = new Text2('OK', { size: 24, fill: '#ffffff' }); okButtonText.anchor.set(0.5, 0.5); okButton.addChild(okButtonText); showingStoreClosedNotification = true; } } function hideStoreClosedNotification() { if (storeClosedNotification) { storeClosedNotification.destroy(); storeClosedNotification = null; showingStoreClosedNotification = false; } } function nextDay() { day++; currentHour = 8; // Reset to opening time dayText.setText('Day: ' + day); hourText.setText('Time: ' + currentHour + ':00'); updateMarketPrices(); if (wholesalePanel) { wholesalePanel.updatePrices(); } // Handle bill interest and forced collection handleBillDebt(); // Handle credit debt interest and forced collection handleCreditDebt(); // Check for new bills checkForNewBills(); updateBillsDisplay(); updateCreditDisplay(); // Hide store closed notification if showing hideStoreClosedNotification(); } function initTutorial() { tutorialOverlay = new TutorialOverlay(); tutorialOverlay.x = 1024; tutorialOverlay.y = 1366; game.addChild(tutorialOverlay); updateTutorialText(); } function updateTutorialText() { var content = tutorialContent[currentLanguage][tutorialStep]; var langText = currentLanguage === 'en' ? 'TR' : 'EN'; tutorialOverlay.updateText(content.text, content.next, langText); } function nextTutorialStep() { tutorialStep++; if (tutorialStep >= tutorialContent[currentLanguage].length) { // End tutorial tutorialOverlay.destroy(); tutorialOverlay = null; tutorialActive = false; tutorialStep = 0; return; } updateTutorialText(); } function toggleLanguage() { currentLanguage = currentLanguage === 'en' ? 'tr' : 'en'; updateTutorialText(); } function skipTutorial() { // End tutorial immediately tutorialOverlay.destroy(); tutorialOverlay = null; tutorialActive = false; tutorialStep = 0; } function showSettings() { if (!showingSettings) { settingsPanel = new SettingsPanel(); settingsPanel.x = 1024; settingsPanel.y = 1366; game.addChild(settingsPanel); showingSettings = true; } } function hideSettings() { if (settingsPanel) { settingsPanel.destroy(); settingsPanel = null; showingSettings = false; } } function showResetConfirmation() { if (!showingResetConfirmation) { resetConfirmation = new ResetConfirmation(); resetConfirmation.x = 1024; resetConfirmation.y = 1366; game.addChild(resetConfirmation); showingResetConfirmation = true; } } function hideResetConfirmation() { if (resetConfirmation) { resetConfirmation.destroy(); resetConfirmation = null; showingResetConfirmation = false; } } function resetGame() { // Clear all storage storage.warehouseCapacity = undefined; storage.warehouseLevel = undefined; storage.warehouseUpgradeCost = undefined; storage.lastElectricityBillDay = undefined; storage.lastTaxBillDay = undefined; storage.electricityBillDaysOverdue = undefined; storage.taxBillDaysOverdue = undefined; storage.creditDebt = undefined; storage.creditDaysOverdue = undefined; // Reset score LK.setScore(0); // Show game over to restart LK.showGameOver(); } function handleProductClick(product, x, y) { // Check if clicked on unlock button first (before checking if product is locked) if (!product.isUnlocked && product.unlockButton && y > 70) { product.unlock(); return; } // Only allow price adjustment for unlocked products if (!product.isUnlocked) { return; } // Price adjustment based on click position if (y < 0) { // Clicked upper half - increase price product.adjustPrice(0.1); } else { // Clicked lower half - decrease price product.adjustPrice(-0.1); } } function handleWholesalePurchase(productIndex) { var product = products[productIndex]; if (!product.isUnlocked) { return; // Can't buy locked products } var cost = product.wholesalePrice * 10; // Buy 10 units at a time if (money >= cost) { var actualAmount = product.addStock(10); if (actualAmount > 0) { var actualCost = product.wholesalePrice * actualAmount; money -= actualCost; updateMoneyDisplay(); calculateTotalStock(); LK.getSound('buy_sound').play(); if (actualAmount < 10) { // Show message that warehouse is full console.log('Warehouse full! Only bought ' + actualAmount + ' units.'); } } else { console.log('Warehouse is full!'); } } } // Event handlers game.down = function (x, y, obj) { // Handle tutorial interactions first if (tutorialActive && tutorialOverlay) { // Check tutorial next button var nextButtonX = tutorialOverlay.x + tutorialOverlay.nextButton.x; var nextButtonY = tutorialOverlay.y + tutorialOverlay.nextButton.y; if (Math.abs(x - nextButtonX) < 150 && Math.abs(y - nextButtonY) < 45) { nextTutorialStep(); return; } // Check language toggle button var langButtonX = tutorialOverlay.x + tutorialOverlay.langButton.x; var langButtonY = tutorialOverlay.y + tutorialOverlay.langButton.y; if (Math.abs(x - langButtonX) < 120 && Math.abs(y - langButtonY) < 36) { toggleLanguage(); return; } // Check skip button var skipButtonX = tutorialOverlay.x + tutorialOverlay.skipButton.x; var skipButtonY = tutorialOverlay.y + tutorialOverlay.skipButton.y; if (Math.abs(x - skipButtonX) < 120 && Math.abs(y - skipButtonY) < 36) { skipTutorial(); return; } // Block other interactions during tutorial return; } if (showingWholesale && wholesalePanel) { // Check wholesale panel buttons for (var i = 0; i < wholesalePanel.buttons.length; i++) { var button = wholesalePanel.buttons[i]; var buttonX = wholesalePanel.x + button.x; var buttonY = wholesalePanel.y + button.y; if (Math.abs(x - buttonX) < 100 && Math.abs(y - buttonY) < 30) { if (button.isCloseButton) { // Close wholesale panel wholesalePanel.destroy(); wholesalePanel = null; showingWholesale = false; } else { // Buy wholesale handleWholesalePurchase(button.productIndex); } return; } } } // Check if clicked on wholesale button if (Math.abs(x - wholesaleButton.x) < 150 && Math.abs(y - wholesaleButton.y) < 45) { if (!showingWholesale) { wholesalePanel = new WholesalePanel(); wholesalePanel.x = 1024; wholesalePanel.y = 1366; game.addChild(wholesalePanel); showingWholesale = true; } return; } // Check if clicked on next day button if (Math.abs(x - nextDayButton.x) < 150 && Math.abs(y - nextDayButton.y) < 45) { nextDay(); return; } // Check if clicked on warehouse upgrade button if (Math.abs(x - upgradeButton.x) < 120 && Math.abs(y - upgradeButton.y) < 36) { upgradeWarehouse(); return; } // Check if clicked on pay bills button if (Math.abs(x - payBillsButton.x) < 150 && Math.abs(y - payBillsButton.y) < 45) { payBills(); return; } // Check if clicked on take credit button if (Math.abs(x - takeCreditButton.x) < 150 && Math.abs(y - takeCreditButton.y) < 45) { takeCredit(); return; } // Check if clicked on credit display to pay debt if (Math.abs(x - 300) < 150 && Math.abs(y - 300) < 30 && creditDebt > 0) { payCredit(); return; } // Check if clicked on store closed notification OK button if (showingStoreClosedNotification && storeClosedNotification) { var okButtonX = storeClosedNotification.x; var okButtonY = storeClosedNotification.y + 150; if (Math.abs(x - okButtonX) < 120 && Math.abs(y - okButtonY) < 36) { hideStoreClosedNotification(); return; } } // Check if clicked on settings button if (Math.abs(x - settingsButton.x) < 120 && Math.abs(y - settingsButton.y) < 36) { showSettings(); return; } // Check if clicked on settings panel if (showingSettings && settingsPanel) { var resetButtonX = settingsPanel.x + settingsPanel.resetButton.x; var resetButtonY = settingsPanel.y + settingsPanel.resetButton.y; if (Math.abs(x - resetButtonX) < 150 && Math.abs(y - resetButtonY) < 45) { showResetConfirmation(); return; } var closeButtonX = settingsPanel.x + settingsPanel.closeButton.x; var closeButtonY = settingsPanel.y + settingsPanel.closeButton.y; if (Math.abs(x - closeButtonX) < 120 && Math.abs(y - closeButtonY) < 36) { hideSettings(); return; } } // Check if clicked on price changes panel if (showingPriceChanges && priceChangesPanel) { var okButtonX = priceChangesPanel.x + priceChangesPanel.okButton.x; var okButtonY = priceChangesPanel.y + priceChangesPanel.okButton.y; if (Math.abs(x - okButtonX) < 150 && Math.abs(y - okButtonY) < 45) { hidePriceChanges(); return; } } // Check if clicked on reset confirmation if (showingResetConfirmation && resetConfirmation) { var confirmButtonX = resetConfirmation.x + resetConfirmation.confirmButton.x; var confirmButtonY = resetConfirmation.y + resetConfirmation.confirmButton.y; if (Math.abs(x - confirmButtonX) < 120 && Math.abs(y - confirmButtonY) < 36) { resetGame(); return; } var cancelButtonX = resetConfirmation.x + resetConfirmation.cancelButton.x; var cancelButtonY = resetConfirmation.y + resetConfirmation.cancelButton.y; if (Math.abs(x - cancelButtonX) < 120 && Math.abs(y - cancelButtonY) < 36) { hideResetConfirmation(); return; } } // Check if clicked on products for (var i = 0; i < products.length; i++) { var product = products[i]; if (Math.abs(x - product.x) < 150 && Math.abs(y - product.y) < 100) { handleProductClick(product, x - product.x, y - product.y); return; } } }; var customerSpawnTimer = 0; var hourTimer = 0; game.update = function () { // Update customers for (var i = customers.length - 1; i >= 0; i--) { var customer = customers[i]; if (customer.update) { customer.update(); } } // Advance time every 10 seconds (600 ticks at 60fps) only if store is open hourTimer++; if (hourTimer >= 600 && currentHour < maxHour) { advanceHour(); hourTimer = 0; } // Spawn customers randomly only if store is open customerSpawnTimer++; if (customerSpawnTimer > 180 && Math.random() < 0.02 && currentHour < maxHour) { // Random spawn every 3+ seconds, but only during open hours spawnCustomer(); customerSpawnTimer = 0; } // Refresh button texts to ensure they stay visible refreshButtonTexts(); // Update warehouse display calculateTotalStock(); // Update bills display updateBillsDisplay(); // Update credit display updateCreditDisplay(); // Check win condition if (totalProfit >= 100) { LK.showYouWin(); } }; // Initialize with some starting stock for unlocked products only for (var i = 0; i < products.length; i++) { if (products[i].isUnlocked) { products[i].addStock(5); } } // Settings button var settingsButton = game.addChild(LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 1850, y: 2600, scaleX: 1.2, scaleY: 1.2, color: 0x666666 })); var settingsButtonText = new Text2('SETTINGS', { size: 20, fill: '#ffffff' }); settingsButtonText.anchor.set(0.5, 0.5); settingsButton.addChild(settingsButtonText); settingsButton.buttonText = settingsButtonText; // Settings panel variables var settingsPanel = null; var showingSettings = false; var showingResetConfirmation = false; var resetConfirmation = null; // Price changes panel variables var priceChangesPanel = null; var showingPriceChanges = false; var lastPrices = []; // Start tutorial initTutorial(); ;
===================================================================
--- original.js
+++ change.js
@@ -691,8 +691,14 @@
var tutorialOverlay = null;
var tutorialText = null;
var tutorialButton = null;
var currentLanguage = 'en'; // 'en' for English, 'tr' for Turkish
+// Credit system variables
+var creditDebt = storage.creditDebt || 0; // Current debt amount
+var creditDaysOverdue = storage.creditDaysOverdue || 0; // Days debt has been overdue
+var maxCreditDays = 4; // Maximum days before forced collection
+var dailyInterestRate = 0.15; // 15% daily interest
+var forcedCollectionPenalty = 0.60; // 60% penalty for forced collection
// Warehouse storage system
var warehouseCapacity = storage.warehouseCapacity || 50; // Default capacity
var warehouseLevel = storage.warehouseLevel || 1; // Storage level
var warehouseUpgradeCost = storage.warehouseUpgradeCost || 100; // Cost to upgrade
@@ -1724,14 +1730,8 @@
if (products[i].isUnlocked) {
products[i].addStock(5);
}
}
-// Credit system variables
-var creditDebt = storage.creditDebt || 0; // Current debt amount
-var creditDaysOverdue = storage.creditDaysOverdue || 0; // Days debt has been overdue
-var maxCreditDays = 4; // Maximum days before forced collection
-var dailyInterestRate = 0.15; // 15% daily interest
-var forcedCollectionPenalty = 0.60; // 60% penalty for forced collection
// Settings button
var settingsButton = game.addChild(LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
kırmızı elma logosu. In-Game asset. 2d. High contrast. No shadows
ekmek resmi. In-Game asset. 2d. High contrast. No shadows
süt kutusu resmi. In-Game asset. 2d. High contrast. No shadows
peynir resmi. In-Game asset. 2d. High contrast. No shadows
balık resmi. In-Game asset. 2d. High contrast. No shadows
pembe-beyaz renkli çilekli pasta. In-Game asset. 2d. High contrast. No shadows
erkek insan. In-Game asset. 2d. High contrast. No shadows
kadın insan. In-Game asset. 2d. High contrast. No shadows
erkek müşteri. In-Game asset. 2d. High contrast. No shadows
sarı saçlı kadın insan. In-Game asset. 2d. High contrast. No shadows
çocuk insan. In-Game asset. 2d. High contrast. No shadows
kız çocuğu. In-Game asset. 2d. High contrast. No shadows