/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
coins: 100,
highestCar: 1
});
/****
* Classes
****/
var BuyButton = Container.expand(function (price) {
var self = Container.call(this);
self.price = price || 10;
var buttonGraphics = self.attachAsset('buy_button', {
anchorX: 0.5,
anchorY: 0.5
});
// Add coin icon
var coinIcon = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
x: -70,
y: 0,
scaleX: 0.8,
scaleY: 0.8
});
// Add price text
self.priceText = new Text2(self.price.toString(), {
size: 35,
fill: 0xFFFFFF
});
self.priceText.anchor.set(0, 0.5);
self.priceText.x = -40;
self.addChild(self.priceText);
// Add "Buy Car" text
var buyText = new Text2("Buy Car", {
size: 25,
fill: 0xFFFFFF
});
buyText.anchor.set(0.5, 0.5);
buyText.y = -35;
self.addChild(buyText);
self.down = function (x, y, obj) {
tween(self, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
};
self.up = function (x, y, obj) {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
if (game.coins >= self.price) {
game.coins -= self.price;
storage.coins = game.coins;
game.updateCoinsDisplay();
game.addNewCar(1);
LK.getSound('buy').play();
// Increase price for next car
self.price = Math.floor(self.price * 1.2);
self.priceText.setText(self.price.toString());
} else {
// Visual feedback for not enough coins
tween(self, {
rotation: 0.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
rotation: -0.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(self, {
rotation: 0
}, {
duration: 100
});
}
});
}
});
}
};
return self;
});
var Car = Container.expand(function (carLevel) {
var self = Container.call(this);
self.carLevel = carLevel || 1;
var colorMap = {
1: 0x336699,
// Blue
2: 0x66CC99,
// Teal
3: 0xCC6633,
// Orange
4: 0x9966CC,
// Purple
5: 0xFFCC33,
// Yellow
6: 0xFF3366 // Pink
};
var assetId = 'car' + (self.carLevel <= 6 ? self.carLevel : 1 + self.carLevel % 6);
var carGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Text to display car level
self.levelText = new Text2(self.carLevel.toString(), {
size: 40,
fill: 0xFFFFFF
});
self.levelText.anchor.set(0.5, 0.5);
self.addChild(self.levelText);
self.isDragging = false;
self.originalPosition = {
x: 0,
y: 0
};
self.originalSlot = null;
// Make cars draggable
self.down = function (x, y, obj) {
self.isDragging = true;
self.originalPosition.x = self.x;
self.originalPosition.y = self.y;
// Bring to front (since we can't use swapChildren, we'll handle in the game class)
game.bringCarToFront(self);
// Scale up to indicate being dragged
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200
});
};
self.up = function (x, y, obj) {
if (self.isDragging) {
self.isDragging = false;
// Scale back to normal
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
// Check for merge in game controller
game.checkForMerge(self);
}
};
self.getValue = function () {
// Base value is 5, doubles with each level
return 5 * Math.pow(2, self.carLevel - 1);
};
return self;
});
var GarageSlot = Container.expand(function (row, col) {
var self = Container.call(this);
self.row = row;
self.col = col;
self.isEmpty = true;
self.currentCar = null;
var slotGraphics = self.attachAsset('garage_slot', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
});
self.highlight = function () {
tween(slotGraphics, {
alpha: 0.6
}, {
duration: 200
});
};
self.unhighlight = function () {
tween(slotGraphics, {
alpha: 0.3
}, {
duration: 200
});
};
self.setCar = function (car) {
self.currentCar = car;
self.isEmpty = false;
};
self.removeCar = function () {
self.currentCar = null;
self.isEmpty = true;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222222
});
/****
* Game Code
****/
// Game variables
game.grid = {
rows: 5,
cols: 4
};
game.slotSize = 250;
game.slots = [];
game.cars = [];
game.draggedCar = null;
game.coins = storage.coins || 100;
game.highestCar = storage.highestCar || 1;
// Start background music
LK.playMusic('bgmusic');
// Calculate garage position
game.garageX = 2048 / 2 - game.grid.cols * game.slotSize / 2 + game.slotSize / 2;
game.garageY = 300;
// Initialize garage grid
game.initializeGarage = function () {
for (var row = 0; row < game.grid.rows; row++) {
game.slots[row] = [];
for (var col = 0; col < game.grid.cols; col++) {
var slot = new GarageSlot(row, col);
slot.x = game.garageX + col * game.slotSize;
slot.y = game.garageY + row * game.slotSize;
game.addChild(slot);
game.slots[row][col] = slot;
}
}
};
// Create UI elements
game.initializeUI = function () {
// Coins display
var coinIcon = LK.getAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
x: 50,
y: 50
});
game.addChild(coinIcon);
game.coinsText = new Text2(game.coins.toString(), {
size: 45,
fill: 0xFFD700
});
game.coinsText.anchor.set(0, 0.5);
game.coinsText.x = 80;
game.coinsText.y = 50;
game.addChild(game.coinsText);
// Game title
var titleText = new Text2("Car Merge: Garage Tycoon", {
size: 70,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 2048 / 2;
titleText.y = 50;
game.addChild(titleText);
// Highest car level display
game.highestCarText = new Text2("Highest Car: Level " + game.highestCar, {
size: 35,
fill: 0xFFFFFF
});
game.highestCarText.anchor.set(1, 0.5);
game.highestCarText.x = 2048 - 50;
game.highestCarText.y = 50;
game.addChild(game.highestCarText);
// Buy button
game.buyButton = new BuyButton(10);
game.buyButton.x = 2048 / 2;
game.buyButton.y = game.garageY + game.grid.rows * game.slotSize + 100;
game.addChild(game.buyButton);
// Instructions
var instructionsText = new Text2("Drag matching cars together to merge them into higher level cars!", {
size: 30,
fill: 0xAAAAAA
});
instructionsText.anchor.set(0.5, 0);
instructionsText.x = 2048 / 2;
instructionsText.y = game.garageY - 100;
game.addChild(instructionsText);
};
// Update coins display
game.updateCoinsDisplay = function () {
game.coinsText.setText(game.coins.toString());
};
// Update highest car display
game.updateHighestCarDisplay = function () {
game.highestCarText.setText("Highest Car: Level " + game.highestCar);
};
// Find an empty slot
game.findEmptySlot = function () {
for (var row = 0; row < game.grid.rows; row++) {
for (var col = 0; col < game.grid.cols; col++) {
if (game.slots[row][col].isEmpty) {
return game.slots[row][col];
}
}
}
return null;
};
// Add a new car of specified level
game.addNewCar = function (level) {
var emptySlot = game.findEmptySlot();
if (!emptySlot) {
// No empty slots, can't add a car
return false;
}
var car = new Car(level);
car.x = emptySlot.x;
car.y = emptySlot.y;
car.originalSlot = emptySlot;
emptySlot.setCar(car);
game.addChild(car);
game.cars.push(car);
return true;
};
// Move handler for drag operations
game.move = function (x, y, obj) {
game.cars.forEach(function (car) {
if (car.isDragging) {
car.x = x;
car.y = y;
}
});
};
// Check if a car can be merged with another
game.checkForMerge = function (draggedCar) {
var foundMerge = false;
// Find the closest slot to the car
var closestSlot = null;
var closestDistance = Number.MAX_VALUE;
for (var row = 0; row < game.grid.rows; row++) {
for (var col = 0; col < game.grid.cols; col++) {
var slot = game.slots[row][col];
var distance = Math.sqrt(Math.pow(draggedCar.x - slot.x, 2) + Math.pow(draggedCar.y - slot.y, 2));
if (distance < closestDistance) {
closestDistance = distance;
closestSlot = slot;
}
}
}
// If the closest slot has a car of the same level, merge them
if (closestSlot && !closestSlot.isEmpty && closestSlot.currentCar !== draggedCar && closestSlot.currentCar.carLevel === draggedCar.carLevel) {
// Perform the merge
var newLevel = draggedCar.carLevel + 1;
var mergeTargetCar = closestSlot.currentCar;
// Update the highest car level if needed
if (newLevel > game.highestCar) {
game.highestCar = newLevel;
storage.highestCar = game.highestCar;
game.updateHighestCarDisplay();
}
// Remove both cars
closestSlot.removeCar();
draggedCar.originalSlot.removeCar();
// Add coins based on the new car value
var reward = 5 * Math.pow(2, newLevel - 1);
game.coins += reward;
storage.coins = game.coins;
game.updateCoinsDisplay();
// Create the new car
var newCar = new Car(newLevel);
newCar.x = closestSlot.x;
newCar.y = closestSlot.y;
newCar.originalSlot = closestSlot;
closestSlot.setCar(newCar);
game.addChild(newCar);
// Remove old cars from the array
game.cars = game.cars.filter(function (car) {
return car !== draggedCar && car !== mergeTargetCar;
});
// Add new car to the array
game.cars.push(newCar);
// Visual and audio feedback
LK.effects.flashObject(newCar, 0xFFFFFF, 500);
LK.getSound('merge').play();
// Cleanup old car visuals
draggedCar.destroy();
mergeTargetCar.destroy();
foundMerge = true;
} else if (closestSlot && closestDistance < 100) {
// If we're close to a slot but not merging, move to that slot
if (closestSlot.isEmpty) {
// Move to the empty slot
if (draggedCar.originalSlot) {
draggedCar.originalSlot.removeCar();
}
draggedCar.originalSlot = closestSlot;
closestSlot.setCar(draggedCar);
tween(draggedCar, {
x: closestSlot.x,
y: closestSlot.y
}, {
duration: 200
});
} else {
// Slot occupied, return to original position
tween(draggedCar, {
x: draggedCar.originalPosition.x,
y: draggedCar.originalPosition.y
}, {
duration: 200
});
}
} else {
// If not close to any slot, return to original position
tween(draggedCar, {
x: draggedCar.originalPosition.x,
y: draggedCar.originalPosition.y
}, {
duration: 200
});
}
return foundMerge;
};
// Bring a car to the front of the display list
game.bringCarToFront = function (car) {
// Since we can't use swapChildren, we'll remove and re-add
game.removeChild(car);
game.addChild(car);
};
// Initialize the game
game.initializeGarage();
game.initializeUI();
// Add initial cars
for (var i = 0; i < 5; i++) {
game.addNewCar(1);
}
// Game update function
game.update = function () {
// Check if game is full
var hasEmptySlot = game.findEmptySlot() !== null;
game.buyButton.alpha = hasEmptySlot ? 1 : 0.5;
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,441 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1", {
+ coins: 100,
+ highestCar: 1
+});
+
+/****
+* Classes
+****/
+var BuyButton = Container.expand(function (price) {
+ var self = Container.call(this);
+ self.price = price || 10;
+ var buttonGraphics = self.attachAsset('buy_button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Add coin icon
+ var coinIcon = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -70,
+ y: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ });
+ // Add price text
+ self.priceText = new Text2(self.price.toString(), {
+ size: 35,
+ fill: 0xFFFFFF
+ });
+ self.priceText.anchor.set(0, 0.5);
+ self.priceText.x = -40;
+ self.addChild(self.priceText);
+ // Add "Buy Car" text
+ var buyText = new Text2("Buy Car", {
+ size: 25,
+ fill: 0xFFFFFF
+ });
+ buyText.anchor.set(0.5, 0.5);
+ buyText.y = -35;
+ self.addChild(buyText);
+ self.down = function (x, y, obj) {
+ tween(self, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100
+ });
+ };
+ self.up = function (x, y, obj) {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ if (game.coins >= self.price) {
+ game.coins -= self.price;
+ storage.coins = game.coins;
+ game.updateCoinsDisplay();
+ game.addNewCar(1);
+ LK.getSound('buy').play();
+ // Increase price for next car
+ self.price = Math.floor(self.price * 1.2);
+ self.priceText.setText(self.price.toString());
+ } else {
+ // Visual feedback for not enough coins
+ tween(self, {
+ rotation: 0.1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ rotation: -0.1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self, {
+ rotation: 0
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ });
+ }
+ };
+ return self;
+});
+var Car = Container.expand(function (carLevel) {
+ var self = Container.call(this);
+ self.carLevel = carLevel || 1;
+ var colorMap = {
+ 1: 0x336699,
+ // Blue
+ 2: 0x66CC99,
+ // Teal
+ 3: 0xCC6633,
+ // Orange
+ 4: 0x9966CC,
+ // Purple
+ 5: 0xFFCC33,
+ // Yellow
+ 6: 0xFF3366 // Pink
+ };
+ var assetId = 'car' + (self.carLevel <= 6 ? self.carLevel : 1 + self.carLevel % 6);
+ var carGraphics = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Text to display car level
+ self.levelText = new Text2(self.carLevel.toString(), {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ self.levelText.anchor.set(0.5, 0.5);
+ self.addChild(self.levelText);
+ self.isDragging = false;
+ self.originalPosition = {
+ x: 0,
+ y: 0
+ };
+ self.originalSlot = null;
+ // Make cars draggable
+ self.down = function (x, y, obj) {
+ self.isDragging = true;
+ self.originalPosition.x = self.x;
+ self.originalPosition.y = self.y;
+ // Bring to front (since we can't use swapChildren, we'll handle in the game class)
+ game.bringCarToFront(self);
+ // Scale up to indicate being dragged
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 200
+ });
+ };
+ self.up = function (x, y, obj) {
+ if (self.isDragging) {
+ self.isDragging = false;
+ // Scale back to normal
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200
+ });
+ // Check for merge in game controller
+ game.checkForMerge(self);
+ }
+ };
+ self.getValue = function () {
+ // Base value is 5, doubles with each level
+ return 5 * Math.pow(2, self.carLevel - 1);
+ };
+ return self;
+});
+var GarageSlot = Container.expand(function (row, col) {
+ var self = Container.call(this);
+ self.row = row;
+ self.col = col;
+ self.isEmpty = true;
+ self.currentCar = null;
+ var slotGraphics = self.attachAsset('garage_slot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.3
+ });
+ self.highlight = function () {
+ tween(slotGraphics, {
+ alpha: 0.6
+ }, {
+ duration: 200
+ });
+ };
+ self.unhighlight = function () {
+ tween(slotGraphics, {
+ alpha: 0.3
+ }, {
+ duration: 200
+ });
+ };
+ self.setCar = function (car) {
+ self.currentCar = car;
+ self.isEmpty = false;
+ };
+ self.removeCar = function () {
+ self.currentCar = null;
+ self.isEmpty = true;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x222222
+});
+
+/****
+* Game Code
+****/
+// Game variables
+game.grid = {
+ rows: 5,
+ cols: 4
+};
+game.slotSize = 250;
+game.slots = [];
+game.cars = [];
+game.draggedCar = null;
+game.coins = storage.coins || 100;
+game.highestCar = storage.highestCar || 1;
+// Start background music
+LK.playMusic('bgmusic');
+// Calculate garage position
+game.garageX = 2048 / 2 - game.grid.cols * game.slotSize / 2 + game.slotSize / 2;
+game.garageY = 300;
+// Initialize garage grid
+game.initializeGarage = function () {
+ for (var row = 0; row < game.grid.rows; row++) {
+ game.slots[row] = [];
+ for (var col = 0; col < game.grid.cols; col++) {
+ var slot = new GarageSlot(row, col);
+ slot.x = game.garageX + col * game.slotSize;
+ slot.y = game.garageY + row * game.slotSize;
+ game.addChild(slot);
+ game.slots[row][col] = slot;
+ }
+ }
+};
+// Create UI elements
+game.initializeUI = function () {
+ // Coins display
+ var coinIcon = LK.getAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 50,
+ y: 50
+ });
+ game.addChild(coinIcon);
+ game.coinsText = new Text2(game.coins.toString(), {
+ size: 45,
+ fill: 0xFFD700
+ });
+ game.coinsText.anchor.set(0, 0.5);
+ game.coinsText.x = 80;
+ game.coinsText.y = 50;
+ game.addChild(game.coinsText);
+ // Game title
+ var titleText = new Text2("Car Merge: Garage Tycoon", {
+ size: 70,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0);
+ titleText.x = 2048 / 2;
+ titleText.y = 50;
+ game.addChild(titleText);
+ // Highest car level display
+ game.highestCarText = new Text2("Highest Car: Level " + game.highestCar, {
+ size: 35,
+ fill: 0xFFFFFF
+ });
+ game.highestCarText.anchor.set(1, 0.5);
+ game.highestCarText.x = 2048 - 50;
+ game.highestCarText.y = 50;
+ game.addChild(game.highestCarText);
+ // Buy button
+ game.buyButton = new BuyButton(10);
+ game.buyButton.x = 2048 / 2;
+ game.buyButton.y = game.garageY + game.grid.rows * game.slotSize + 100;
+ game.addChild(game.buyButton);
+ // Instructions
+ var instructionsText = new Text2("Drag matching cars together to merge them into higher level cars!", {
+ size: 30,
+ fill: 0xAAAAAA
+ });
+ instructionsText.anchor.set(0.5, 0);
+ instructionsText.x = 2048 / 2;
+ instructionsText.y = game.garageY - 100;
+ game.addChild(instructionsText);
+};
+// Update coins display
+game.updateCoinsDisplay = function () {
+ game.coinsText.setText(game.coins.toString());
+};
+// Update highest car display
+game.updateHighestCarDisplay = function () {
+ game.highestCarText.setText("Highest Car: Level " + game.highestCar);
+};
+// Find an empty slot
+game.findEmptySlot = function () {
+ for (var row = 0; row < game.grid.rows; row++) {
+ for (var col = 0; col < game.grid.cols; col++) {
+ if (game.slots[row][col].isEmpty) {
+ return game.slots[row][col];
+ }
+ }
+ }
+ return null;
+};
+// Add a new car of specified level
+game.addNewCar = function (level) {
+ var emptySlot = game.findEmptySlot();
+ if (!emptySlot) {
+ // No empty slots, can't add a car
+ return false;
+ }
+ var car = new Car(level);
+ car.x = emptySlot.x;
+ car.y = emptySlot.y;
+ car.originalSlot = emptySlot;
+ emptySlot.setCar(car);
+ game.addChild(car);
+ game.cars.push(car);
+ return true;
+};
+// Move handler for drag operations
+game.move = function (x, y, obj) {
+ game.cars.forEach(function (car) {
+ if (car.isDragging) {
+ car.x = x;
+ car.y = y;
+ }
+ });
+};
+// Check if a car can be merged with another
+game.checkForMerge = function (draggedCar) {
+ var foundMerge = false;
+ // Find the closest slot to the car
+ var closestSlot = null;
+ var closestDistance = Number.MAX_VALUE;
+ for (var row = 0; row < game.grid.rows; row++) {
+ for (var col = 0; col < game.grid.cols; col++) {
+ var slot = game.slots[row][col];
+ var distance = Math.sqrt(Math.pow(draggedCar.x - slot.x, 2) + Math.pow(draggedCar.y - slot.y, 2));
+ if (distance < closestDistance) {
+ closestDistance = distance;
+ closestSlot = slot;
+ }
+ }
+ }
+ // If the closest slot has a car of the same level, merge them
+ if (closestSlot && !closestSlot.isEmpty && closestSlot.currentCar !== draggedCar && closestSlot.currentCar.carLevel === draggedCar.carLevel) {
+ // Perform the merge
+ var newLevel = draggedCar.carLevel + 1;
+ var mergeTargetCar = closestSlot.currentCar;
+ // Update the highest car level if needed
+ if (newLevel > game.highestCar) {
+ game.highestCar = newLevel;
+ storage.highestCar = game.highestCar;
+ game.updateHighestCarDisplay();
+ }
+ // Remove both cars
+ closestSlot.removeCar();
+ draggedCar.originalSlot.removeCar();
+ // Add coins based on the new car value
+ var reward = 5 * Math.pow(2, newLevel - 1);
+ game.coins += reward;
+ storage.coins = game.coins;
+ game.updateCoinsDisplay();
+ // Create the new car
+ var newCar = new Car(newLevel);
+ newCar.x = closestSlot.x;
+ newCar.y = closestSlot.y;
+ newCar.originalSlot = closestSlot;
+ closestSlot.setCar(newCar);
+ game.addChild(newCar);
+ // Remove old cars from the array
+ game.cars = game.cars.filter(function (car) {
+ return car !== draggedCar && car !== mergeTargetCar;
+ });
+ // Add new car to the array
+ game.cars.push(newCar);
+ // Visual and audio feedback
+ LK.effects.flashObject(newCar, 0xFFFFFF, 500);
+ LK.getSound('merge').play();
+ // Cleanup old car visuals
+ draggedCar.destroy();
+ mergeTargetCar.destroy();
+ foundMerge = true;
+ } else if (closestSlot && closestDistance < 100) {
+ // If we're close to a slot but not merging, move to that slot
+ if (closestSlot.isEmpty) {
+ // Move to the empty slot
+ if (draggedCar.originalSlot) {
+ draggedCar.originalSlot.removeCar();
+ }
+ draggedCar.originalSlot = closestSlot;
+ closestSlot.setCar(draggedCar);
+ tween(draggedCar, {
+ x: closestSlot.x,
+ y: closestSlot.y
+ }, {
+ duration: 200
+ });
+ } else {
+ // Slot occupied, return to original position
+ tween(draggedCar, {
+ x: draggedCar.originalPosition.x,
+ y: draggedCar.originalPosition.y
+ }, {
+ duration: 200
+ });
+ }
+ } else {
+ // If not close to any slot, return to original position
+ tween(draggedCar, {
+ x: draggedCar.originalPosition.x,
+ y: draggedCar.originalPosition.y
+ }, {
+ duration: 200
+ });
+ }
+ return foundMerge;
+};
+// Bring a car to the front of the display list
+game.bringCarToFront = function (car) {
+ // Since we can't use swapChildren, we'll remove and re-add
+ game.removeChild(car);
+ game.addChild(car);
+};
+// Initialize the game
+game.initializeGarage();
+game.initializeUI();
+// Add initial cars
+for (var i = 0; i < 5; i++) {
+ game.addNewCar(1);
+}
+// Game update function
+game.update = function () {
+ // Check if game is full
+ var hasEmptySlot = game.findEmptySlot() !== null;
+ game.buyButton.alpha = hasEmptySlot ? 1 : 0.5;
+};
\ No newline at end of file