User prompt
1- kolonize edilebilir bölgeler ekle fakat haritaya bağlı bir şekilde 2- gemiye tıklanınca çıkan colonize distant islands yazısını sil.
User prompt
gemilerin gidebileceği mümkün yerleri gemiye tıklanınca belirmesini sağla
User prompt
1-gemilerin gidebileceği sınırlı yerleri belirt 2- 2 deniz arasındaki bağlantıyı sağla
User prompt
gemilerin bir turda gidebileceği alanı kısıtla
User prompt
add more army types to the game
User prompt
Update army type icon when recruiting
User prompt
delete colonizable lands
User prompt
the colonizable states should be together with the land states
User prompt
Ensure that the ships are able to land on the mainland.
User prompt
Fix the ships being under the water estate asset.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'turnText.setText("Your Turn");' Line Number: 1022
User prompt
ensure that everyone starts the game on the ship
User prompt
Ensure that the water states do not overlap.
User prompt
make the surrounding of the colonizable states a sea state
User prompt
1- Make places without states into seas 2- fix colonization by ship
User prompt
use a different asset for colonizable lands
User prompt
make the color of the colonizable lands gray
User prompt
make the colonizable territories neutral
User prompt
Add colonizable territories far away from the main map. Colonization is only possible with ships.
User prompt
Let's be able to choose how much we can exert the soldier and ship power in one turn.
User prompt
make the feature of naval battles
User prompt
give the ai the ability to build ships and an army
User prompt
add sea territories and ships
User prompt
Let's be able to choose which border state we can attack through the state.
User prompt
If we declare war on ai, ensure that it can attack us.
/**** * Classes ****/ var ActionButton = Container.expand(function () { var self = Container.call(this); self.init = function (text, action, x, y) { self.action = action; // Button graphics self.buttonGraphics = self.attachAsset('actionButton', { anchorX: 0.5, anchorY: 0.5 }); // Button text self.buttonText = new Text2(text, { size: 28, fill: 0xFFFFFF }); self.buttonText.anchor.set(0.5, 0.5); self.addChild(self.buttonText); self.x = x; self.y = y; return self; }; self.down = function (x, y, obj) { if (self.action) { self.action(); } }; return self; }); var DiplomacyPanel = Container.expand(function () { var self = Container.call(this); self.init = function (targetCountry) { self.targetCountry = targetCountry; self.visible = false; // Panel background self.panelBg = LK.getAsset('actionButton', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 4 }); self.panelBg.tint = 0x2c3e50; self.addChild(self.panelBg); // Panel title self.titleText = new Text2("Diplomacy with Country " + targetCountry, { size: 32, fill: 0xFFFFFF }); self.titleText.anchor.set(0.5, 0.5); self.titleText.y = -80; self.addChild(self.titleText); // Declare war button self.warButton = new ActionButton(); self.warButton.init("Declare War", function () { declareWar(targetCountry); self.hide(); }, 0, 0); self.addChild(self.warButton); // Close button self.closeButton = new ActionButton(); self.closeButton.init("Close", function () { self.hide(); }, 0, 60); self.addChild(self.closeButton); // Position panel in center of screen self.x = 2048 / 2; self.y = 2732 / 2; return self; }; self.show = function () { self.visible = true; game.addChild(self); }; self.hide = function () { self.visible = false; if (self.parent) { self.parent.removeChild(self); } }; return self; }); var Ship = Container.expand(function () { var self = Container.call(this); self.init = function (owner, x, y) { self.owner = owner; self.hp = 3; // Ships have more health than armies self.selected = false; // Ship graphics self.shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); // Color based on owner if (owner === 1) { self.shipGraphics.tint = 0x27ae60; // Green for player } else if (owner === 2) { self.shipGraphics.tint = 0xe74c3c; // Red for enemy } // HP display self.hpText = new Text2(self.hp.toString(), { size: 20, fill: 0xFFFFFF }); self.hpText.anchor.set(0.5, 0.5); self.hpText.x = 0; self.hpText.y = -35; self.addChild(self.hpText); self.x = x; self.y = y; return self; }; self.takeDamage = function (damage) { self.hp -= damage; self.hpText.setText(self.hp.toString()); return self.hp <= 0; }; self.down = function (x, y, obj) { if (gameState === 'playing' && self.owner === 1) { selectShip(self); } else if (gameState === 'playing' && selectedShip && selectedShip.owner === 1 && self.owner === 2) { // Check if ships are close enough for naval combat var distance = Math.abs(selectedShip.x - self.x) + Math.abs(selectedShip.y - self.y); if (distance < 200) { // Initiate naval combat navalCombat(selectedShip, self); selectedShip.selected = false; selectedShip.shipGraphics.tint = 0x27ae60; // Reset color selectedShip = null; endPlayerTurn(); } } }; return self; }); // Game state variables var Territory = Container.expand(function () { var self = Container.call(this); self.init = function (id, x, y, owner, isSea) { self.id = id; self.owner = owner; // 0 = neutral, 1 = player, 2 = enemy self.isSea = isSea || false; self.armies = owner === 0 || self.isSea ? 0 : Math.floor(Math.random() * 3) + 1; self.selected = false; self.lastSelected = false; // Create territory graphics self.updateGraphics(); // Position self.x = x; self.y = y; // Army display (only for land territories) if (!self.isSea) { self.armyText = new Text2(self.armies.toString(), { size: 24, fill: 0x000000 }); self.armyText.anchor.set(0.5, 0.5); self.armyText.x = 0; self.armyText.y = 0; self.addChild(self.armyText); } return self; }; self.updateGraphics = function () { // Remove existing graphics if (self.graphics) { self.removeChild(self.graphics); } var assetName = 'country1Territory'; if (self.isSea) { assetName = 'seaTerritory'; } else if (self.selected) { assetName = 'selectedTerritory'; } else if (self.showAsTarget) { assetName = 'targetTerritory'; } else { // Assign different country colors based on owner if (self.owner === 1) { assetName = 'country1Territory'; // Green for player } else if (self.owner === 2) { assetName = 'country2Territory'; // Red for enemy } else if (self.owner === 3) { assetName = 'country3Territory'; // Blue } else if (self.owner === 4) { assetName = 'country4Territory'; // Purple } else if (self.owner === 5) { assetName = 'country5Territory'; // Orange } else if (self.owner === 6) { assetName = 'country6Territory'; // Cyan } else if (self.isColonizable) { assetName = 'selectedTerritory'; // Use gray for colonizable territories } else { assetName = 'country1Territory'; // Default fallback } } self.graphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); }; self.setOwner = function (newOwner, armies) { self.owner = newOwner; if (!self.isSea) { self.armies = armies || 1; self.armyText.setText(self.armies.toString()); } self.updateGraphics(); }; self.addArmies = function (count) { if (!self.isSea) { self.armies += count; self.armyText.setText(self.armies.toString()); } }; self.down = function (x, y, obj) { if (gameState === 'playing') { // Handle ship movement to sea territories if (selectedShip && self.isSea) { // Move ship to sea territory selectedShip.x = self.x; selectedShip.y = self.y; selectedShip.selected = false; selectedShip.shipGraphics.tint = 0x27ae60; // Reset color selectedShip = null; endPlayerTurn(); return; } // Handle ship colonization of distant territories if (selectedShip && self.isColonizable && self.owner === 0) { // Check if ship is close enough to colonize var distance = Math.abs(selectedShip.x - self.x) + Math.abs(selectedShip.y - self.y); if (distance < 200) { // Colonize the territory self.setOwner(selectedShip.owner, 2); // Give it 2 armies if (selectedShip.owner === 1) { // Player gets money reward for colonization playerMoney += self.colonizationReward; if (playerMoneyText) { playerMoneyText.setText("Money: " + playerMoney); } if (instructionText) { instructionText.setText("Island colonized! Gained $" + self.colonizationReward); } } LK.getSound('capture').play(); selectedShip.selected = false; selectedShip.shipGraphics.tint = 0x27ae60; // Reset color selectedShip = null; updateTerritoryCount(); endPlayerTurn(); return; } } selectTerritory(self); } else if (gameState === 'selectingTarget' && self.showAsTarget) { executeAttack(self); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 }); /**** * Game Code ****/ // Game state variables // Territory and game assets var gameState = 'playing'; // 'playing', 'gameOver', 'victory', 'selectingTarget' var attackTargets = []; // Available targets for attack var currentTurn = 1; // 1 = player, 2 = enemy var selectedTerritory = null; var territories = []; var playerTerritories = 0; var enemyTerritories = 0; var totalTerritories = 0; var playerMoney = 100; // Starting money var aiMoney = 100; // Starting AI money var incomePerTerritory = 10; // Money generated per territory per turn // Diplomacy variables var warDeclarations = {}; // Track which countries we're at war with var diplomacyPanel = null; // Ship variables var ships = []; var selectedShip = null; // Power selection variables var selectedAttackPower = 1; var maxAttackPower = 1; var powerSelectionMode = false; // UI elements var turnText, scoreText, instructionText, playerArmyText, playerMoneyText; var powerText, powerDownButton, powerUpButton; var actionButtons = []; // Game settings var mapWidth = 8; var mapHeight = 12; var territorySpacing = 140; var startX = 2048 / 2 - mapWidth * territorySpacing / 2 + territorySpacing / 2; var startY = 300; // Create the game map function createMap() { var id = 0; // Create contiguous regions for each country with sea territories // Divide the map into regions for 6 countries for (var row = 0; row < mapHeight; row++) { for (var col = 0; col < mapWidth; col++) { var x = startX + col * territorySpacing; var y = startY + row * territorySpacing; var isSea = false; var owner = 1; // default // Create sea lanes (vertical strips) if (col === 2 || col === 5) { isSea = true; owner = 0; // Neutral sea } else { // Determine owner based on map regions to create contiguous countries if (row < mapHeight / 3) { // Top third - countries 1 and 2 if (col < mapWidth / 2) { owner = 1; // Country 1 (Green) - top left } else { owner = 2; // Country 2 (Red) - top right } } else if (row < mapHeight * 2 / 3) { // Middle third - countries 3 and 4 if (col < mapWidth / 2) { owner = 3; // Country 3 (Blue) - middle left } else { owner = 4; // Country 4 (Purple) - middle right } } else { // Bottom third - countries 5 and 6 if (col < mapWidth / 2) { owner = 5; // Country 5 (Orange) - bottom left } else { owner = 6; // Country 6 (Cyan) - bottom right } } } var territory = new Territory(); territory.init(id, x, y, owner, isSea); territories.push(territory); game.addChild(territory); id++; } } // Create initial ships for player and enemy createShips(); // Create distant colonizable territories (islands) createColonizableTerritories(); updateTerritoryCount(); } // Create initial ships function createShips() { // Find sea territories for ship placement var seaTerritories = []; for (var i = 0; i < territories.length; i++) { if (territories[i].isSea) { seaTerritories.push(territories[i]); } } // Place initial ships if (seaTerritories.length > 0) { // Player ship var playerShip = new Ship(); var playerSeaPos = seaTerritories[Math.floor(Math.random() * seaTerritories.length)]; playerShip.init(1, playerSeaPos.x, playerSeaPos.y); ships.push(playerShip); game.addChild(playerShip); // Enemy ship var enemyShip = new Ship(); var enemySeaPos = seaTerritories[Math.floor(Math.random() * seaTerritories.length)]; enemyShip.init(2, enemySeaPos.x, enemySeaPos.y); ships.push(enemyShip); game.addChild(enemyShip); } } // Ship selection function selectShip(ship) { if (currentTurn !== 1) return; // Deselect previous selections if (selectedTerritory) { selectedTerritory.selected = false; selectedTerritory.updateGraphics(); selectedTerritory = null; } if (selectedShip) { selectedShip.selected = false; selectedShip.shipGraphics.tint = 0x27ae60; // Reset to green } // Select new ship selectedShip = ship; ship.selected = true; ship.shipGraphics.tint = 0xf1c40f; // Yellow when selected hidePowerSelection(); updateInstructions(); } // Generate income based on territories owned function generateIncome() { var income = playerTerritories * incomePerTerritory; playerMoney += income; if (playerMoneyText) { playerMoneyText.setText("Money: " + playerMoney + " (+$" + income + ")"); } } // Update territory ownership counts function updateTerritoryCount() { playerTerritories = 0; enemyTerritories = 0; var playerTotalArmies = 0; var country1Count = 0, country2Count = 0, country3Count = 0; var country4Count = 0, country5Count = 0, country6Count = 0; totalTerritories = territories.length; for (var i = 0; i < territories.length; i++) { if (territories[i].owner === 1) { playerTerritories++; country1Count++; playerTotalArmies += territories[i].armies; } else if (territories[i].owner === 2) { enemyTerritories++; country2Count++; } else if (territories[i].owner === 3) { country3Count++; } else if (territories[i].owner === 4) { country4Count++; } else if (territories[i].owner === 5) { country5Count++; } else if (territories[i].owner === 6) { country6Count++; } } // Update score display if (scoreText) { scoreText.setText("Countries - Green: " + country1Count + " | Red: " + country2Count + " | Blue: " + country3Count + " | Purple: " + country4Count + " | Orange: " + country5Count + " | Cyan: " + country6Count); } // Update player army display if (playerArmyText) { playerArmyText.setText("Total Armies: " + playerTotalArmies); } // Update money display if (playerMoneyText) { playerMoneyText.setText("Money: " + playerMoney); } // Check victory conditions if (playerTerritories >= Math.floor(totalTerritories * 0.75)) { gameState = 'victory'; LK.showYouWin(); } else if (enemyTerritories >= Math.floor(totalTerritories * 0.75)) { gameState = 'gameOver'; LK.showGameOver(); } } // Declare war function function declareWar(countryId) { warDeclarations[countryId] = true; if (instructionText) { instructionText.setText("War declared on Country " + countryId + "! You can now attack their territories."); } } // Territory selection function selectTerritory(territory) { if (currentTurn !== 1) return; // Only during player turn // If we're in target selection mode, cancel it if (gameState === 'selectingTarget') { // Clear target highlighting for (var i = 0; i < attackTargets.length; i++) { attackTargets[i].showAsTarget = false; attackTargets[i].updateGraphics(); } gameState = 'playing'; attackTargets = []; } // Deselect previous territory if (selectedTerritory) { selectedTerritory.selected = false; selectedTerritory.updateGraphics(); // Ensure previous territory's army text remains visible selectedTerritory.armyText.setText(selectedTerritory.armies.toString()); // Re-add army text to ensure it's visible selectedTerritory.removeChild(selectedTerritory.armyText); selectedTerritory.addChild(selectedTerritory.armyText); } // Handle enemy territory clicks - show diplomacy panel if (territory.owner !== 1 && territory.owner !== 0) { // Create diplomacy panel if it doesn't exist if (!diplomacyPanel) { diplomacyPanel = new DiplomacyPanel(); diplomacyPanel.init(territory.owner); } else { // Update existing panel for new country diplomacyPanel.targetCountry = territory.owner; diplomacyPanel.titleText.setText("Diplomacy with Country " + territory.owner); } diplomacyPanel.show(); return; } // Select new territory if (territory.owner === 1) { // Only select player territories selectedTerritory = territory; territory.selected = true; territory.updateGraphics(); // Ensure army text is visible and updated territory.armyText.setText(territory.armies.toString()); // Bring army text to front to ensure it's visible territory.removeChild(territory.armyText); territory.addChild(territory.armyText); // Show power selection for territories with armies > 1 if (!territory.isSea && territory.armies > 1) { showPowerSelection(territory.armies - 1); } else { hidePowerSelection(); } updateInstructions(); } else { hidePowerSelection(); } } // Get neighboring territories function getNeighbors(territory) { var neighbors = []; var index = territories.indexOf(territory); var row = Math.floor(index / mapWidth); var col = index % mapWidth; // Check all 4 directions var directions = [{ row: -1, col: 0 }, // up { row: 1, col: 0 }, // down { row: 0, col: -1 }, // left { row: 0, col: 1 } // right ]; for (var i = 0; i < directions.length; i++) { var newRow = row + directions[i].row; var newCol = col + directions[i].col; if (newRow >= 0 && newRow < mapHeight && newCol >= 0 && newCol < mapWidth) { var neighborIndex = newRow * mapWidth + newCol; neighbors.push(territories[neighborIndex]); } } return neighbors; } // Attack action function attackTerritory() { if (!selectedTerritory || selectedTerritory.armies <= 1) return; var neighbors = getNeighbors(selectedTerritory); var targets = []; for (var i = 0; i < neighbors.length; i++) { if (neighbors[i].owner !== 1) { // Check if we can attack this country (either neutral or at war) if (neighbors[i].owner === 0 || warDeclarations[neighbors[i].owner]) { targets.push(neighbors[i]); } } } if (targets.length > 0) { // Show target selection mode gameState = 'selectingTarget'; attackTargets = targets; // Highlight all possible targets for (var i = 0; i < targets.length; i++) { targets[i].showAsTarget = true; targets[i].updateGraphics(); } if (instructionText) { instructionText.setText("Select a territory to attack"); } } } // Execute attack on selected target function executeAttack(target) { if (!selectedTerritory || !target) return; // Clear target highlighting for (var i = 0; i < attackTargets.length; i++) { attackTargets[i].showAsTarget = false; attackTargets[i].updateGraphics(); } // Simple combat resolution using selected attack power var attackPower = selectedAttackPower; var defensePower = target.armies; if (attackPower > defensePower) { // Victory target.setOwner(1, attackPower - defensePower); selectedTerritory.armies = selectedTerritory.armies - attackPower; selectedTerritory.armyText.setText(selectedTerritory.armies.toString()); LK.getSound('capture').play(); } else { // Defeat - lose the armies used in attack selectedTerritory.armies = selectedTerritory.armies - attackPower; selectedTerritory.armyText.setText(selectedTerritory.armies.toString()); if (defensePower > attackPower) { target.armies = defensePower - attackPower; target.armyText.setText(target.armies.toString()); } } LK.getSound('attack').play(); updateTerritoryCount(); // Reset game state gameState = 'playing'; attackTargets = []; endPlayerTurn(); } // Recruit armies action function recruitArmies() { if (!selectedTerritory) return; var recruitCost = 50; // Cost to recruit armies if (playerMoney >= recruitCost) { playerMoney -= recruitCost; selectedTerritory.addArmies(2); if (playerMoneyText) { playerMoneyText.setText("Money: " + playerMoney); } endPlayerTurn(); } else { // Not enough money - show feedback but don't end turn if (instructionText) { instructionText.setText("Not enough money! Need $" + recruitCost + " to recruit"); } } } // Build ship action function buildShip() { if (!selectedTerritory || selectedTerritory.isSea) return; var shipCost = 100; if (playerMoney >= shipCost) { // Find adjacent sea territory var neighbors = getNeighbors(selectedTerritory); var seaNeighbors = []; for (var i = 0; i < neighbors.length; i++) { if (neighbors[i].isSea) { seaNeighbors.push(neighbors[i]); } } if (seaNeighbors.length > 0) { playerMoney -= shipCost; var seaPos = seaNeighbors[0]; var newShip = new Ship(); newShip.init(1, seaPos.x, seaPos.y); ships.push(newShip); game.addChild(newShip); if (playerMoneyText) { playerMoneyText.setText("Money: " + playerMoney); } endPlayerTurn(); } else { if (instructionText) { instructionText.setText("No adjacent sea territory to build ship!"); } } } else { if (instructionText) { instructionText.setText("Not enough money! Need $" + shipCost + " to build ship"); } } } // Naval combat function navalCombat(attackerShip, defenderShip) { var damage = 1; var defenderDestroyed = defenderShip.takeDamage(damage); if (defenderDestroyed) { // Remove destroyed ship var index = ships.indexOf(defenderShip); if (index > -1) { ships.splice(index, 1); } defenderShip.destroy(); LK.getSound('capture').play(); } else { LK.getSound('attack').play(); } } // End player turn function endPlayerTurn() { if (selectedTerritory) { selectedTerritory.selected = false; selectedTerritory.updateGraphics(); selectedTerritory = null; } hidePowerSelection(); // Generate income based on territories owned generateIncome(); currentTurn = 2; updateInstructions(); // AI turn after short delay LK.setTimeout(function () { aiTurn(); }, 1000); } // Simple AI turn function aiTurn() { // Generate AI income var aiIncome = enemyTerritories * incomePerTerritory; aiMoney += aiIncome; var enemyTerrs = []; for (var i = 0; i < territories.length; i++) { if (territories[i].owner === 2) { enemyTerrs.push(territories[i]); } } if (enemyTerrs.length > 0) { var aiTerritory = enemyTerrs[Math.floor(Math.random() * enemyTerrs.length)]; var neighbors = getNeighbors(aiTerritory); var playerTargets = []; for (var j = 0; j < neighbors.length; j++) { // AI can attack player territories if war is declared on AI (country 2) if (neighbors[j].owner === 1 && warDeclarations[2]) { playerTargets.push(neighbors[j]); } } if (playerTargets.length > 0 && aiTerritory.armies > 1) { // AI attacks var target = playerTargets[Math.floor(Math.random() * playerTargets.length)]; var attackPower = aiTerritory.armies - 1; var defensePower = target.armies; if (attackPower > defensePower) { target.setOwner(2, attackPower - defensePower); aiTerritory.armies = 1; aiTerritory.armyText.setText(aiTerritory.armies.toString()); } else { aiTerritory.armies = 1; aiTerritory.armyText.setText(aiTerritory.armies.toString()); if (defensePower > attackPower) { target.armies = defensePower - attackPower; target.armyText.setText(target.armies.toString()); } } } else { // AI decides what to do based on money and strategy var action = Math.random(); var recruitCost = 50; var shipCost = 100; if (action < 0.4 && aiMoney >= recruitCost) { // 40% chance to recruit armies if affordable aiMoney -= recruitCost; aiTerritory.addArmies(2); } else if (action < 0.7 && aiMoney >= shipCost) { // 30% chance to build ship if possible and affordable var seaNeighbors = []; for (var k = 0; k < neighbors.length; k++) { if (neighbors[k].isSea) { seaNeighbors.push(neighbors[k]); } } if (seaNeighbors.length > 0) { // Build ship in adjacent sea aiMoney -= shipCost; var seaPos = seaNeighbors[0]; var newShip = new Ship(); newShip.init(2, seaPos.x, seaPos.y); ships.push(newShip); game.addChild(newShip); } else { // No sea nearby, recruit if affordable or just add basic army if (aiMoney >= recruitCost) { aiMoney -= recruitCost; aiTerritory.addArmies(2); } else { aiTerritory.addArmies(1); } } } else { // Default action - add basic army (free) aiTerritory.addArmies(1); } } } // AI ship movement and naval combat var aiShips = []; for (var i = 0; i < ships.length; i++) { if (ships[i].owner === 2) { aiShips.push(ships[i]); } } if (aiShips.length > 0) { var aiShip = aiShips[Math.floor(Math.random() * aiShips.length)]; // Look for player ships to attack var playerShips = []; for (var i = 0; i < ships.length; i++) { if (ships[i].owner === 1) { var distance = Math.abs(ships[i].x - aiShip.x) + Math.abs(ships[i].y - aiShip.y); if (distance < 200) { // Close enough to attack playerShips.push(ships[i]); } } } if (playerShips.length > 0) { // Attack nearest player ship var target = playerShips[0]; navalCombat(aiShip, target); } else { // Look for colonizable territories var colonizableTargets = []; for (var i = 0; i < territories.length; i++) { if (territories[i].isColonizable && territories[i].owner === 0) { var distance = Math.abs(territories[i].x - aiShip.x) + Math.abs(territories[i].y - aiShip.y); if (distance < 200) { colonizableTargets.push(territories[i]); } } } if (colonizableTargets.length > 0) { // Colonize nearest available territory var target = colonizableTargets[0]; target.setOwner(2, 2); aiMoney += target.colonizationReward; } else { // Move to random sea territory or towards colonizable islands var moveTargets = []; // Add sea territories for (var i = 0; i < territories.length; i++) { if (territories[i].isSea) { moveTargets.push(territories[i]); } } // Add positions near colonizable islands for (var i = 0; i < territories.length; i++) { if (territories[i].isColonizable && territories[i].owner === 0) { moveTargets.push(territories[i]); } } if (moveTargets.length > 0) { var newPos = moveTargets[Math.floor(Math.random() * moveTargets.length)]; aiShip.x = newPos.x; aiShip.y = newPos.y; } } } } updateTerritoryCount(); currentTurn = 1; updateInstructions(); } // Create UI elements function createUI() { // Turn indicator turnText = new Text2("Your Turn", { size: 40, fill: 0xFFFFFF }); turnText.anchor.set(0.5, 0); LK.gui.top.addChild(turnText); turnText.y = 100; // Score display scoreText = new Text2("Player: 0 | Enemy: 0", { size: 32, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 150; // Player army count display playerArmyText = new Text2("Total Armies: 0", { size: 32, fill: 0x7ed321 }); playerArmyText.anchor.set(0.5, 0); LK.gui.top.addChild(playerArmyText); playerArmyText.y = 190; // Player money display playerMoneyText = new Text2("Money: " + playerMoney, { size: 32, fill: 0xf5a623 }); playerMoneyText.anchor.set(0.5, 0); LK.gui.top.addChild(playerMoneyText); playerMoneyText.y = 230; // Instructions instructionText = new Text2("Select your territory, then choose an action", { size: 28, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 1); LK.gui.bottom.addChild(instructionText); instructionText.y = -200; // Action buttons var attackBtn = new ActionButton(); attackBtn.init("Attack", attackTerritory, 2048 / 2 - 150, 2732 - 120); actionButtons.push(attackBtn); game.addChild(attackBtn); var recruitBtn = new ActionButton(); recruitBtn.init("Recruit", recruitArmies, 2048 / 2, 2732 - 120); actionButtons.push(recruitBtn); game.addChild(recruitBtn); var buildShipBtn = new ActionButton(); buildShipBtn.init("Build Ship", buildShip, 2048 / 2 + 150, 2732 - 120); actionButtons.push(buildShipBtn); game.addChild(buildShipBtn); // Power selection display powerText = new Text2("Attack Power: 1/1", { size: 28, fill: 0xffff00 }); powerText.anchor.set(0.5, 1); LK.gui.bottom.addChild(powerText); powerText.y = -240; powerText.visible = false; // Power adjustment buttons var powerDownBtn = new ActionButton(); powerDownBtn.init("-", decreasePower, 2048 / 2 - 100, 2732 - 180); actionButtons.push(powerDownBtn); game.addChild(powerDownBtn); powerDownBtn.visible = false; var powerUpBtn = new ActionButton(); powerUpBtn.init("+", increasePower, 2048 / 2 + 100, 2732 - 180); actionButtons.push(powerUpBtn); game.addChild(powerUpBtn); powerUpBtn.visible = false; // Store power buttons for visibility control powerDownButton = powerDownBtn; powerUpButton = powerUpBtn; } // Power selection functions function decreasePower() { if (selectedAttackPower > 1) { selectedAttackPower--; updatePowerDisplay(); } } function increasePower() { if (selectedAttackPower < maxAttackPower) { selectedAttackPower++; updatePowerDisplay(); } } function updatePowerDisplay() { if (powerText) { powerText.setText("Attack Power: " + selectedAttackPower + "/" + maxAttackPower); } } function showPowerSelection(maxPower) { maxAttackPower = maxPower; selectedAttackPower = Math.min(selectedAttackPower, maxAttackPower); powerSelectionMode = true; if (powerText) { powerText.visible = true; updatePowerDisplay(); } if (powerDownButton && powerUpButton) { powerDownButton.visible = true; powerUpButton.visible = true; } } function hidePowerSelection() { powerSelectionMode = false; if (powerText) { powerText.visible = false; } if (powerDownButton && powerUpButton) { powerDownButton.visible = false; powerUpButton.visible = false; } } // Update instruction text function updateInstructions() { if (currentTurn === 1) { turnText.setText("Your Turn"); if (selectedShip) { instructionText.setText("Ship selected - Move to sea, attack enemy ships, or colonize distant islands"); } else if (selectedTerritory) { if (selectedTerritory.isSea) { instructionText.setText("Sea territory selected - Ships can move here"); } else if (powerSelectionMode) { instructionText.setText("Use +/- to choose attack power, then Attack, Recruit ($50), or Build Ship ($100)"); } else { instructionText.setText("Territory selected - Attack, Recruit ($50), or Build Ship ($100)"); } } else { instructionText.setText("Select your territory/ship (green), then choose an action"); } } else { turnText.setText("Enemy Turn"); instructionText.setText("Enemy is thinking..."); } } // Game update loop for naval combat highlighting game.update = function () { // Highlight enemy ships in combat range when player ship is selected if (selectedShip && selectedShip.owner === 1) { for (var i = 0; i < ships.length; i++) { if (ships[i].owner === 2) { var distance = Math.abs(selectedShip.x - ships[i].x) + Math.abs(selectedShip.y - ships[i].y); if (distance < 200) { // Highlight enemy ship in range ships[i].shipGraphics.tint = 0xff6b6b; // Red tint for attackable } else { ships[i].shipGraphics.tint = 0xe74c3c; // Default red for enemy } } } } else { // Reset all ship colors when no ship selected for (var i = 0; i < ships.length; i++) { if (ships[i].owner === 2) { ships[i].shipGraphics.tint = 0xe74c3c; // Default red for enemy } else if (ships[i].owner === 1 && ships[i] !== selectedShip) { ships[i].shipGraphics.tint = 0x27ae60; // Default green for player } } } }; // Initialize the game createMap(); createUI(); updateInstructions(); // Create distant colonizable territories function createColonizableTerritories() { var islandPositions = [ // Far left islands { x: startX - 400, y: startY + 200 }, { x: startX - 500, y: startY + 600 }, { x: startX - 350, y: startY + 1000 }, // Far right islands { x: startX + mapWidth * territorySpacing + 300, y: startY + 300 }, { x: startX + mapWidth * territorySpacing + 450, y: startY + 700 }, { x: startX + mapWidth * territorySpacing + 250, y: startY + 1100 }, // Far top islands { x: startX + 300, y: startY - 300 }, { x: startX + 600, y: startY - 250 }, // Far bottom islands { x: startX + 200, y: startY + mapHeight * territorySpacing + 200 }, { x: startX + 500, y: startY + mapHeight * territorySpacing + 150 }]; for (var i = 0; i < islandPositions.length; i++) { var island = new Territory(); island.init(territories.length, islandPositions[i].x, islandPositions[i].y, 0, false); // Neutral land territory island.isColonizable = true; // Mark as colonizable island.colonizationReward = 20; // Money reward for colonization island.setOwner(0, 0); // Explicitly set as neutral with 0 armies territories.push(island); game.addChild(island); } }
===================================================================
--- original.js
+++ change.js
@@ -186,8 +186,10 @@
} else if (self.owner === 5) {
assetName = 'country5Territory'; // Orange
} else if (self.owner === 6) {
assetName = 'country6Territory'; // Cyan
+ } else if (self.isColonizable) {
+ assetName = 'selectedTerritory'; // Use gray for colonizable territories
} else {
assetName = 'country1Territory'; // Default fallback
}
}
green grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
cyan grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
gray grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
sea territory. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
soldier. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
blue grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
white grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
red grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
yellow grass. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
pixelart empty button. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
paper piece pixel. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
pixel ship. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
swords pixelart. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat