User prompt
sıradaki güne geçildiğinde ekrana hangi ürünlerin fiyatının ne kadar düştüğü ya da yükseldiğini gösteren bir bilgilendirme ekranı açılsın.
User prompt
oyuna ayarlar sekmesi eklensin, ayarlar sekmesinin butonu sağ alt köşede olsun ve bu sekmede oyunu sıfırlama butonu olsun. oyunu sıfırlama butonuna basıldığında bilgilendirici bir uyarı mesajı çıksın. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
toptancı bölümündeki butonlar ve yazıları büyüt
User prompt
faturlaların ödenmediği her gün borç %10 artsın, faturalar 4 gün içinde ödenmezse borç +%50 olarak sahip olunan ürünlerden ve sahip olunan paradan alınsın. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
"PAY BILLS" butonunu sağ üst kısımlarda bir yerde konumlandır
User prompt
oyun otomatik olarak gün atlamasın, saat 18:00 olduğunda bir uyarı gelsin ve günü manuel olarak oynayan kişi atlasın
User prompt
"NEXT DAY" butonunu eski yerine al, "PAY BILLS" butonunu farklı bir yerde konumlandır.
User prompt
oyunda belirli günlerde gelicek olan elektrik ve vergi borcu sistemi eklensin. bu borçların fiyatları oyunda sahip olunan paraya ve stokta olan eşyaların fiyatlarına göre belirlensin. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
gün içi saat olsun müşteriler belirli bir saatten sonra dükkana gelmesinki gün atlamak zorunda kalalım
User prompt
belirli bir ürün stocklama sayısı olsun, depomda en fazla o sayı kadar ürün tutabileyim. depolamayı yükseltebilmek için ödeme yapmam gereksin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
toptan ve sıradaki gün butonlarının yazıları kayboldu düzelt
User prompt
öğreticideki bilgileri güncelle ve öğretici atlama butonu ekle
User prompt
müşteriler görünümü farklı 6 tip müşteri olsun
User prompt
toptan ve sıradaki gün butonlarının yazıları kayboldu düzelt
User prompt
müşterilerin aldığı ürünlerin resmi müşterinin üzerine gelsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
oyuna daha fazla ürün ekleyelim fakat bu fazla ürünlerin kilidini açabilmek için ürüne göre giderek artan bir fiyatla bu ürünlerin kilidini açmamız gereksin
User prompt
Oyunun başlangıcına oyunu öğreten ve nasıl oynanacağını anlatan bir öğretici ekle. Bu öğretici hem ingilizce hemde türkçe olsun
User prompt
ürünlerle alakalı görsel kısımları büyült
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var wholesalePos = game.toLocal(obj.parent.toGlobal(wholesaleButton.position));' Line Number: 411
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'fill')' in or related to this line: 'self.priceText.style.fill = '#000000'; // Black for normal' Line Number: 150
Code edit (1 edits merged)
Please save this source code
User prompt
Market Tycoon
Initial prompt
2D bir marketçilik simulatörü yapmanı istiyorum. Bu oyun tıpkı diğer marketçilik oyunları gibi olucak. Toptancıdan ürünleri alıp kendi dükkanımda dükkanıma gelen müşterilere daha yüksek fiyata satacağım. Satacağım ürünlerin piyasa fiyatı hergün değişecek. Bir ürünün ortalama satış fiyatı olacak. Ürünü ortalama satış fiyatından daha yükseğe satmaya çalışırsam müşteriler pahalı olduğu için almayacak. Fakat ortalama satış fiyatında yada daha ucuza satarsam daha çok müşteri bu ürünleri satın alıcak
/****
* 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 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: 18,
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 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: 48,
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
}));
var buttonText;
if (product.isUnlocked) {
buttonText = new Text2('BUY ' + product.type.toUpperCase() + '\n$' + product.wholesalePrice.toFixed(2), {
size: 20,
fill: '#ffffff'
});
} else {
buttonText = new Text2(product.type.toUpperCase() + '\nLOCKED', {
size: 20,
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
}));
var closeText = new Text2('CLOSE', {
size: 24,
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.buttonText.setText('BUY ' + product.type.toUpperCase() + '\n$' + product.wholesalePrice.toFixed(2));
button.tint = 0xffffff;
} else {
button.buttonText.setText(product.type.toUpperCase() + '\nLOCKED');
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 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
// 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
// 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: "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: "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 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);
// 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;
// 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 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 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() {
var customer = new Customer();
customer.x = -100;
customer.y = 1200;
customers.push(customer);
game.addChild(customer);
}
function updateMarketPrices() {
for (var i = 0; i < products.length; i++) {
var product = products[i];
// 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));
product.updateDisplay();
}
}
function nextDay() {
day++;
dayText.setText('Day: ' + day);
updateMarketPrices();
if (wholesalePanel) {
wholesalePanel.updatePrices();
}
}
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 handleProductClick(product, x, y) {
// Check if clicked on unlock button
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 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;
game.update = function () {
// Update customers
for (var i = customers.length - 1; i >= 0; i--) {
var customer = customers[i];
if (customer.update) {
customer.update();
}
}
// Spawn customers randomly
customerSpawnTimer++;
if (customerSpawnTimer > 180 && Math.random() < 0.02) {
// Random spawn every 3+ seconds
spawnCustomer();
customerSpawnTimer = 0;
}
// Refresh button texts to ensure they stay visible
refreshButtonTexts();
// Update warehouse display
calculateTotalStock();
// 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);
}
}
// Start tutorial
initTutorial(); ===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
@@ -307,10 +308,20 @@
self.retailPrice = Math.max(0.5, self.retailPrice + amount);
self.updateDisplay();
};
self.addStock = function (amount) {
- self.stock += amount;
- self.updateDisplay();
+ // 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--;
@@ -497,8 +508,13 @@
var tutorialOverlay = null;
var tutorialText = null;
var tutorialButton = null;
var currentLanguage = 'en'; // 'en' for English, 'tr' for Turkish
+// 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
// 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.",
@@ -632,8 +648,34 @@
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);
+// 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,
@@ -669,8 +711,38 @@
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 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
@@ -787,12 +859,22 @@
return; // Can't buy locked products
}
var cost = product.wholesalePrice * 10; // Buy 10 units at a time
if (money >= cost) {
- money -= cost;
- product.addStock(10);
- updateMoneyDisplay();
- LK.getSound('buy_sound').play();
+ 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) {
@@ -857,8 +939,13 @@
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 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) {
@@ -884,8 +971,10 @@
customerSpawnTimer = 0;
}
// Refresh button texts to ensure they stay visible
refreshButtonTexts();
+ // Update warehouse display
+ calculateTotalStock();
// Check win condition
if (totalProfit >= 100) {
LK.showYouWin();
}
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