Code edit (1 edits merged)
Please save this source code
User prompt
Crypto & Stock Trading Empire
Initial prompt
crea un juego que seamos vendedores y compradores de cryptos y de acciones d eempresas quiero 5 filas de 5 columnas de las cryptos y una de 5 filas y 3 columnas de acciones de empresas podamos comprar minadores de cyptos que nos dan un 0.3838444 de una crypto podamos comprar mas pero aumentan mas de precio hayan mala barata buena carro gos cada una sea mejor que la otro y aya un portafolio que podamos venderlas.3
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var CryptoAsset = Container.expand(function (name, price, gridX, gridY) {
var self = Container.call(this);
self.assetName = name;
self.currentPrice = price;
self.basePrice = price;
self.gridX = gridX;
self.gridY = gridY;
self.owned = 0;
var background = self.attachAsset('cryptoGrid', {
anchorX: 0.5,
anchorY: 0.5
});
var nameText = new Text2(name, {
size: 24,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0);
nameText.x = 0;
nameText.y = -60;
self.addChild(nameText);
self.priceText = new Text2('$' + price.toFixed(2), {
size: 20,
fill: 0x00FF00
});
self.priceText.anchor.set(0.5, 0.5);
self.priceText.x = 0;
self.priceText.y = -20;
self.addChild(self.priceText);
self.ownedText = new Text2('Owned: 0', {
size: 16,
fill: 0xFFFFFF
});
self.ownedText.anchor.set(0.5, 0.5);
self.ownedText.x = 0;
self.ownedText.y = 10;
self.addChild(self.ownedText);
var buyBtn = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
}));
buyBtn.x = -40;
buyBtn.y = 40;
var buyText = new Text2('BUY', {
size: 12,
fill: 0xFFFFFF
});
buyText.anchor.set(0.5, 0.5);
buyBtn.addChild(buyText);
var sellBtn = self.addChild(LK.getAsset('sellButton', {
anchorX: 0.5,
anchorY: 0.5
}));
sellBtn.x = 40;
sellBtn.y = 40;
var sellText = new Text2('SELL', {
size: 12,
fill: 0xFFFFFF
});
sellText.anchor.set(0.5, 0.5);
sellBtn.addChild(sellText);
buyBtn.down = function () {
if (playerMoney >= self.currentPrice) {
playerMoney -= self.currentPrice;
self.owned += 1;
updateUI();
LK.getSound('buy').play();
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
sellBtn.down = function () {
if (self.owned > 0) {
playerMoney += self.currentPrice;
self.owned -= 1;
updateUI();
LK.getSound('sell').play();
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
self.updatePrice = function () {
var change = (Math.random() - 0.5) * 0.2;
self.currentPrice = Math.max(0.01, self.currentPrice * (1 + change));
self.priceText.setText('$' + self.currentPrice.toFixed(2));
if (change > 0) {
self.priceText.tint = 0x00ff00;
} else {
self.priceText.tint = 0xff0000;
}
self.ownedText.setText('Owned: ' + self.owned);
};
return self;
});
var MinerCard = Container.expand(function (tier, cost, efficiency) {
var self = Container.call(this);
self.tier = tier;
self.cost = cost;
self.efficiency = efficiency;
self.owned = 0;
var background = self.attachAsset('minerCard', {
anchorX: 0.5,
anchorY: 0.5
});
var tierText = new Text2(tier, {
size: 20,
fill: 0xFFFFFF
});
tierText.anchor.set(0.5, 0);
tierText.x = 0;
tierText.y = -45;
self.addChild(tierText);
self.costText = new Text2('Cost: $' + cost.toFixed(0), {
size: 16,
fill: 0xFFFF00
});
self.costText.anchor.set(0.5, 0.5);
self.costText.x = 0;
self.costText.y = -15;
self.addChild(self.costText);
self.ownedText = new Text2('Owned: 0', {
size: 14,
fill: 0xFFFFFF
});
self.ownedText.anchor.set(0.5, 0.5);
self.ownedText.x = 0;
self.ownedText.y = 5;
self.addChild(self.ownedText);
var buyBtn = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
}));
buyBtn.x = 0;
buyBtn.y = 35;
var buyText = new Text2('BUY', {
size: 12,
fill: 0xFFFFFF
});
buyText.anchor.set(0.5, 0.5);
buyBtn.addChild(buyText);
buyBtn.down = function () {
if (playerMoney >= self.cost) {
playerMoney -= self.cost;
self.owned += 1;
self.cost *= 1.5;
self.costText.setText('Cost: $' + self.cost.toFixed(0));
self.ownedText.setText('Owned: ' + self.owned);
updateUI();
LK.getSound('buy').play();
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
}
};
return self;
});
var StockAsset = Container.expand(function (name, price, gridX, gridY) {
var self = Container.call(this);
self.assetName = name;
self.currentPrice = price;
self.basePrice = price;
self.gridX = gridX;
self.gridY = gridY;
self.owned = 0;
var background = self.attachAsset('stockGrid', {
anchorX: 0.5,
anchorY: 0.5
});
var nameText = new Text2(name, {
size: 24,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0);
nameText.x = 0;
nameText.y = -60;
self.addChild(nameText);
self.priceText = new Text2('$' + price.toFixed(2), {
size: 20,
fill: 0x00AAFF
});
self.priceText.anchor.set(0.5, 0.5);
self.priceText.x = 0;
self.priceText.y = -20;
self.addChild(self.priceText);
self.ownedText = new Text2('Owned: 0', {
size: 16,
fill: 0xFFFFFF
});
self.ownedText.anchor.set(0.5, 0.5);
self.ownedText.x = 0;
self.ownedText.y = 10;
self.addChild(self.ownedText);
var buyBtn = self.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
}));
buyBtn.x = -40;
buyBtn.y = 40;
var buyText = new Text2('BUY', {
size: 12,
fill: 0xFFFFFF
});
buyText.anchor.set(0.5, 0.5);
buyBtn.addChild(buyText);
var sellBtn = self.addChild(LK.getAsset('sellButton', {
anchorX: 0.5,
anchorY: 0.5
}));
sellBtn.x = 40;
sellBtn.y = 40;
var sellText = new Text2('SELL', {
size: 12,
fill: 0xFFFFFF
});
sellText.anchor.set(0.5, 0.5);
sellBtn.addChild(sellText);
buyBtn.down = function () {
if (playerMoney >= self.currentPrice) {
playerMoney -= self.currentPrice;
self.owned += 1;
updateUI();
LK.getSound('buy').play();
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
sellBtn.down = function () {
if (self.owned > 0) {
playerMoney += self.currentPrice;
self.owned -= 1;
updateUI();
LK.getSound('sell').play();
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
}
};
self.updatePrice = function () {
var change = (Math.random() - 0.5) * 0.15;
self.currentPrice = Math.max(0.01, self.currentPrice * (1 + change));
self.priceText.setText('$' + self.currentPrice.toFixed(2));
if (change > 0) {
self.priceText.tint = 0x00aaff;
} else {
self.priceText.tint = 0xff4444;
}
self.ownedText.setText('Owned: ' + self.owned);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0a0a0a
});
/****
* Game Code
****/
var playerMoney = storage.playerMoney || 1000;
var cryptoAssets = [];
var stockAssets = [];
var miners = [];
var miningTimer = 0;
var cryptoNames = ['BTC', 'ETH', 'ADA', 'DOT', 'SOL', 'LINK', 'UNI', 'MATIC', 'AVAX', 'ATOM', 'ALGO', 'XTZ', 'FTM', 'NEAR', 'ICP', 'EGLD', 'HBAR', 'VET', 'THETA', 'FLOW', 'MANA', 'SAND', 'AXS', 'ENJ', 'CHZ'];
var stockNames = ['AAPL', 'GOOGL', 'MSFT', 'AMZN', 'TSLA', 'META', 'NVDA', 'NFLX', 'BABA', 'V', 'JPM', 'JNJ', 'WMT', 'PG', 'DIS'];
var moneyText = new Text2('Money: $' + playerMoney.toFixed(2), {
size: 32,
fill: 0x00FF00
});
moneyText.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyText);
var portfolioValue = 0;
var portfolioText = new Text2('Portfolio: $0.00', {
size: 28,
fill: 0xFFFF00
});
portfolioText.anchor.set(0.5, 0);
portfolioText.y = 40;
LK.gui.top.addChild(portfolioText);
var cryptoTitle = new Text2('CRYPTOCURRENCIES', {
size: 24,
fill: 0xFFFFFF
});
cryptoTitle.anchor.set(0.5, 0);
cryptoTitle.x = 1024;
cryptoTitle.y = 120;
game.addChild(cryptoTitle);
for (var i = 0; i < 25; i++) {
var row = Math.floor(i / 5);
var col = i % 5;
var crypto = new CryptoAsset(cryptoNames[i], Math.random() * 90 + 10, col, row);
crypto.x = 200 + col * 220;
crypto.y = 200 + row * 180;
game.addChild(crypto);
cryptoAssets.push(crypto);
}
var stockTitle = new Text2('STOCKS', {
size: 24,
fill: 0xFFFFFF
});
stockTitle.anchor.set(0.5, 0);
stockTitle.x = 1024;
stockTitle.y = 1200;
game.addChild(stockTitle);
for (var j = 0; j < 15; j++) {
var stockRow = Math.floor(j / 5);
var stockCol = j % 5;
var stock = new StockAsset(stockNames[j], Math.random() * 400 + 100, stockCol, stockRow);
stock.x = 200 + stockCol * 220;
stock.y = 1300 + stockRow * 180;
game.addChild(stock);
stockAssets.push(stock);
}
var minerTitle = new Text2('CRYPTO MINERS', {
size: 24,
fill: 0xFFFFFF
});
minerTitle.anchor.set(0.5, 0);
minerTitle.x = 1024;
minerTitle.y = 2000;
game.addChild(minerTitle);
var minerTiers = [{
name: 'Mala',
cost: 50,
efficiency: 1
}, {
name: 'Barata',
cost: 200,
efficiency: 2.5
}, {
name: 'Buena',
cost: 800,
efficiency: 5
}, {
name: 'Carro',
cost: 3000,
efficiency: 10
}];
for (var k = 0; k < 4; k++) {
var miner = new MinerCard(minerTiers[k].name, minerTiers[k].cost, minerTiers[k].efficiency);
miner.x = 300 + k * 200;
miner.y = 2150;
game.addChild(miner);
miners.push(miner);
}
function updateUI() {
moneyText.setText('Money: $' + playerMoney.toFixed(2));
portfolioValue = 0;
for (var i = 0; i < cryptoAssets.length; i++) {
portfolioValue += cryptoAssets[i].owned * cryptoAssets[i].currentPrice;
}
for (var j = 0; j < stockAssets.length; j++) {
portfolioValue += stockAssets[j].owned * stockAssets[j].currentPrice;
}
portfolioText.setText('Portfolio: $' + portfolioValue.toFixed(2));
storage.playerMoney = playerMoney;
}
game.update = function () {
if (LK.ticks % 120 == 0) {
for (var i = 0; i < cryptoAssets.length; i++) {
cryptoAssets[i].updatePrice();
}
for (var j = 0; j < stockAssets.length; j++) {
stockAssets[j].updatePrice();
}
updateUI();
}
miningTimer++;
if (miningTimer >= 300) {
miningTimer = 0;
var totalMining = 0;
for (var k = 0; k < miners.length; k++) {
totalMining += miners[k].owned * miners[k].efficiency;
}
if (totalMining > 0) {
var miningReward = totalMining * 0.3838444;
playerMoney += miningReward;
updateUI();
LK.getSound('mining').play();
tween(moneyText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
onFinish: function onFinish() {
tween(moneyText, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,465 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var CryptoAsset = Container.expand(function (name, price, gridX, gridY) {
+ var self = Container.call(this);
+ self.assetName = name;
+ self.currentPrice = price;
+ self.basePrice = price;
+ self.gridX = gridX;
+ self.gridY = gridY;
+ self.owned = 0;
+ var background = self.attachAsset('cryptoGrid', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var nameText = new Text2(name, {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ nameText.anchor.set(0.5, 0);
+ nameText.x = 0;
+ nameText.y = -60;
+ self.addChild(nameText);
+ self.priceText = new Text2('$' + price.toFixed(2), {
+ size: 20,
+ fill: 0x00FF00
+ });
+ self.priceText.anchor.set(0.5, 0.5);
+ self.priceText.x = 0;
+ self.priceText.y = -20;
+ self.addChild(self.priceText);
+ self.ownedText = new Text2('Owned: 0', {
+ size: 16,
+ fill: 0xFFFFFF
+ });
+ self.ownedText.anchor.set(0.5, 0.5);
+ self.ownedText.x = 0;
+ self.ownedText.y = 10;
+ self.addChild(self.ownedText);
+ var buyBtn = self.addChild(LK.getAsset('buyButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ buyBtn.x = -40;
+ buyBtn.y = 40;
+ var buyText = new Text2('BUY', {
+ size: 12,
+ fill: 0xFFFFFF
+ });
+ buyText.anchor.set(0.5, 0.5);
+ buyBtn.addChild(buyText);
+ var sellBtn = self.addChild(LK.getAsset('sellButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ sellBtn.x = 40;
+ sellBtn.y = 40;
+ var sellText = new Text2('SELL', {
+ size: 12,
+ fill: 0xFFFFFF
+ });
+ sellText.anchor.set(0.5, 0.5);
+ sellBtn.addChild(sellText);
+ buyBtn.down = function () {
+ if (playerMoney >= self.currentPrice) {
+ playerMoney -= self.currentPrice;
+ self.owned += 1;
+ updateUI();
+ LK.getSound('buy').play();
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ sellBtn.down = function () {
+ if (self.owned > 0) {
+ playerMoney += self.currentPrice;
+ self.owned -= 1;
+ updateUI();
+ LK.getSound('sell').play();
+ tween(self, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ self.updatePrice = function () {
+ var change = (Math.random() - 0.5) * 0.2;
+ self.currentPrice = Math.max(0.01, self.currentPrice * (1 + change));
+ self.priceText.setText('$' + self.currentPrice.toFixed(2));
+ if (change > 0) {
+ self.priceText.tint = 0x00ff00;
+ } else {
+ self.priceText.tint = 0xff0000;
+ }
+ self.ownedText.setText('Owned: ' + self.owned);
+ };
+ return self;
+});
+var MinerCard = Container.expand(function (tier, cost, efficiency) {
+ var self = Container.call(this);
+ self.tier = tier;
+ self.cost = cost;
+ self.efficiency = efficiency;
+ self.owned = 0;
+ var background = self.attachAsset('minerCard', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var tierText = new Text2(tier, {
+ size: 20,
+ fill: 0xFFFFFF
+ });
+ tierText.anchor.set(0.5, 0);
+ tierText.x = 0;
+ tierText.y = -45;
+ self.addChild(tierText);
+ self.costText = new Text2('Cost: $' + cost.toFixed(0), {
+ size: 16,
+ fill: 0xFFFF00
+ });
+ self.costText.anchor.set(0.5, 0.5);
+ self.costText.x = 0;
+ self.costText.y = -15;
+ self.addChild(self.costText);
+ self.ownedText = new Text2('Owned: 0', {
+ size: 14,
+ fill: 0xFFFFFF
+ });
+ self.ownedText.anchor.set(0.5, 0.5);
+ self.ownedText.x = 0;
+ self.ownedText.y = 5;
+ self.addChild(self.ownedText);
+ var buyBtn = self.addChild(LK.getAsset('buyButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ buyBtn.x = 0;
+ buyBtn.y = 35;
+ var buyText = new Text2('BUY', {
+ size: 12,
+ fill: 0xFFFFFF
+ });
+ buyText.anchor.set(0.5, 0.5);
+ buyBtn.addChild(buyText);
+ buyBtn.down = function () {
+ if (playerMoney >= self.cost) {
+ playerMoney -= self.cost;
+ self.owned += 1;
+ self.cost *= 1.5;
+ self.costText.setText('Cost: $' + self.cost.toFixed(0));
+ self.ownedText.setText('Owned: ' + self.owned);
+ updateUI();
+ LK.getSound('buy').play();
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 150,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 150
+ });
+ }
+ });
+ }
+ };
+ return self;
+});
+var StockAsset = Container.expand(function (name, price, gridX, gridY) {
+ var self = Container.call(this);
+ self.assetName = name;
+ self.currentPrice = price;
+ self.basePrice = price;
+ self.gridX = gridX;
+ self.gridY = gridY;
+ self.owned = 0;
+ var background = self.attachAsset('stockGrid', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var nameText = new Text2(name, {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ nameText.anchor.set(0.5, 0);
+ nameText.x = 0;
+ nameText.y = -60;
+ self.addChild(nameText);
+ self.priceText = new Text2('$' + price.toFixed(2), {
+ size: 20,
+ fill: 0x00AAFF
+ });
+ self.priceText.anchor.set(0.5, 0.5);
+ self.priceText.x = 0;
+ self.priceText.y = -20;
+ self.addChild(self.priceText);
+ self.ownedText = new Text2('Owned: 0', {
+ size: 16,
+ fill: 0xFFFFFF
+ });
+ self.ownedText.anchor.set(0.5, 0.5);
+ self.ownedText.x = 0;
+ self.ownedText.y = 10;
+ self.addChild(self.ownedText);
+ var buyBtn = self.addChild(LK.getAsset('buyButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ buyBtn.x = -40;
+ buyBtn.y = 40;
+ var buyText = new Text2('BUY', {
+ size: 12,
+ fill: 0xFFFFFF
+ });
+ buyText.anchor.set(0.5, 0.5);
+ buyBtn.addChild(buyText);
+ var sellBtn = self.addChild(LK.getAsset('sellButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ sellBtn.x = 40;
+ sellBtn.y = 40;
+ var sellText = new Text2('SELL', {
+ size: 12,
+ fill: 0xFFFFFF
+ });
+ sellText.anchor.set(0.5, 0.5);
+ sellBtn.addChild(sellText);
+ buyBtn.down = function () {
+ if (playerMoney >= self.currentPrice) {
+ playerMoney -= self.currentPrice;
+ self.owned += 1;
+ updateUI();
+ LK.getSound('buy').play();
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ sellBtn.down = function () {
+ if (self.owned > 0) {
+ playerMoney += self.currentPrice;
+ self.owned -= 1;
+ updateUI();
+ LK.getSound('sell').play();
+ tween(self, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ self.updatePrice = function () {
+ var change = (Math.random() - 0.5) * 0.15;
+ self.currentPrice = Math.max(0.01, self.currentPrice * (1 + change));
+ self.priceText.setText('$' + self.currentPrice.toFixed(2));
+ if (change > 0) {
+ self.priceText.tint = 0x00aaff;
+ } else {
+ self.priceText.tint = 0xff4444;
+ }
+ self.ownedText.setText('Owned: ' + self.owned);
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x0a0a0a
+});
+
+/****
+* Game Code
+****/
+var playerMoney = storage.playerMoney || 1000;
+var cryptoAssets = [];
+var stockAssets = [];
+var miners = [];
+var miningTimer = 0;
+var cryptoNames = ['BTC', 'ETH', 'ADA', 'DOT', 'SOL', 'LINK', 'UNI', 'MATIC', 'AVAX', 'ATOM', 'ALGO', 'XTZ', 'FTM', 'NEAR', 'ICP', 'EGLD', 'HBAR', 'VET', 'THETA', 'FLOW', 'MANA', 'SAND', 'AXS', 'ENJ', 'CHZ'];
+var stockNames = ['AAPL', 'GOOGL', 'MSFT', 'AMZN', 'TSLA', 'META', 'NVDA', 'NFLX', 'BABA', 'V', 'JPM', 'JNJ', 'WMT', 'PG', 'DIS'];
+var moneyText = new Text2('Money: $' + playerMoney.toFixed(2), {
+ size: 32,
+ fill: 0x00FF00
+});
+moneyText.anchor.set(0.5, 0);
+LK.gui.top.addChild(moneyText);
+var portfolioValue = 0;
+var portfolioText = new Text2('Portfolio: $0.00', {
+ size: 28,
+ fill: 0xFFFF00
+});
+portfolioText.anchor.set(0.5, 0);
+portfolioText.y = 40;
+LK.gui.top.addChild(portfolioText);
+var cryptoTitle = new Text2('CRYPTOCURRENCIES', {
+ size: 24,
+ fill: 0xFFFFFF
+});
+cryptoTitle.anchor.set(0.5, 0);
+cryptoTitle.x = 1024;
+cryptoTitle.y = 120;
+game.addChild(cryptoTitle);
+for (var i = 0; i < 25; i++) {
+ var row = Math.floor(i / 5);
+ var col = i % 5;
+ var crypto = new CryptoAsset(cryptoNames[i], Math.random() * 90 + 10, col, row);
+ crypto.x = 200 + col * 220;
+ crypto.y = 200 + row * 180;
+ game.addChild(crypto);
+ cryptoAssets.push(crypto);
+}
+var stockTitle = new Text2('STOCKS', {
+ size: 24,
+ fill: 0xFFFFFF
+});
+stockTitle.anchor.set(0.5, 0);
+stockTitle.x = 1024;
+stockTitle.y = 1200;
+game.addChild(stockTitle);
+for (var j = 0; j < 15; j++) {
+ var stockRow = Math.floor(j / 5);
+ var stockCol = j % 5;
+ var stock = new StockAsset(stockNames[j], Math.random() * 400 + 100, stockCol, stockRow);
+ stock.x = 200 + stockCol * 220;
+ stock.y = 1300 + stockRow * 180;
+ game.addChild(stock);
+ stockAssets.push(stock);
+}
+var minerTitle = new Text2('CRYPTO MINERS', {
+ size: 24,
+ fill: 0xFFFFFF
+});
+minerTitle.anchor.set(0.5, 0);
+minerTitle.x = 1024;
+minerTitle.y = 2000;
+game.addChild(minerTitle);
+var minerTiers = [{
+ name: 'Mala',
+ cost: 50,
+ efficiency: 1
+}, {
+ name: 'Barata',
+ cost: 200,
+ efficiency: 2.5
+}, {
+ name: 'Buena',
+ cost: 800,
+ efficiency: 5
+}, {
+ name: 'Carro',
+ cost: 3000,
+ efficiency: 10
+}];
+for (var k = 0; k < 4; k++) {
+ var miner = new MinerCard(minerTiers[k].name, minerTiers[k].cost, minerTiers[k].efficiency);
+ miner.x = 300 + k * 200;
+ miner.y = 2150;
+ game.addChild(miner);
+ miners.push(miner);
+}
+function updateUI() {
+ moneyText.setText('Money: $' + playerMoney.toFixed(2));
+ portfolioValue = 0;
+ for (var i = 0; i < cryptoAssets.length; i++) {
+ portfolioValue += cryptoAssets[i].owned * cryptoAssets[i].currentPrice;
+ }
+ for (var j = 0; j < stockAssets.length; j++) {
+ portfolioValue += stockAssets[j].owned * stockAssets[j].currentPrice;
+ }
+ portfolioText.setText('Portfolio: $' + portfolioValue.toFixed(2));
+ storage.playerMoney = playerMoney;
+}
+game.update = function () {
+ if (LK.ticks % 120 == 0) {
+ for (var i = 0; i < cryptoAssets.length; i++) {
+ cryptoAssets[i].updatePrice();
+ }
+ for (var j = 0; j < stockAssets.length; j++) {
+ stockAssets[j].updatePrice();
+ }
+ updateUI();
+ }
+ miningTimer++;
+ if (miningTimer >= 300) {
+ miningTimer = 0;
+ var totalMining = 0;
+ for (var k = 0; k < miners.length; k++) {
+ totalMining += miners[k].owned * miners[k].efficiency;
+ }
+ if (totalMining > 0) {
+ var miningReward = totalMining * 0.3838444;
+ playerMoney += miningReward;
+ updateUI();
+ LK.getSound('mining').play();
+ tween(moneyText, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ tween(moneyText, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200
+ });
+ }
+ });
+ }
+ }
+};
\ No newline at end of file