User prompt
before the game starts display a popup
Code edit (6 edits merged)
Please save this source code
User prompt
how would you handle energy so that low energy level slow down constructions
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'type')' in or related to this line: 'player1.spice += buildableRepository.getBuildableInfo(currentBuildingForPlacement.type).cost;' Line Number: 462
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: unit is not defined' in or related to this line: 'switch (unit.type) {' Line Number: 2176
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rockIlot2Center is not defined' in or related to this line: 'baseBuilding = {' Line Number: 1740
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getTime is not a function' in or related to this line: 'self.lastHitTime = LK.getTime();' Line Number: 1099
Code edit (2 edits merged)
Please save this source code
User prompt
could you implement findFactoryForUnit
Code edit (1 edits merged)
Please save this source code
User prompt
add a new function findEmplacementForBuilding(building, cellX, cellY) that scans the map around the given cellX,cellY to find a free area of rocks that fits the given building size
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: buildable.placeBuilding is not a function' in or related to this line: 'buildable.placeBuilding(placeX, placeY);' Line Number: 2117
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
in handleDragEnd, don't select buildings if they are under fog
User prompt
don't select ennemy units and building if they are under fog
===================================================================
--- original.js
+++ change.js
@@ -79,8 +79,9 @@
});
var BuildableItemIcon = Container.expand(function (type, x, y, sourceFactory) {
var self = Container.call(this);
self.type = type;
+ self.progressDisplay = null;
self.sourceFactory = sourceFactory;
self.asset = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5,
@@ -90,19 +91,30 @@
height: 200
});
self.asset.on('down', function () {
if (!self.asset.interactive) {
+ console.log("BuildableItemIcon : Not interactive. ignore");
return;
+ } else {
+ console.log("BuildableItemIcon : Is interactive. continue");
}
if (currentBuildingForPlacement) {
currentUserActionState = UserActionState.PLACING_BUILDINGS;
- console.log("User is placing ", currentBuildingForPlacement);
+ console.log("BuildableItemIcon : User is placing ", currentBuildingForPlacement);
game.addChild(currentBuildingForPlacement);
return;
+ } else {
+ console.log("BuildableItemIcon : No current building for placement. ignore");
}
- var progressDisplay = new BuildingProgressDisplay(self);
- game.addChild(progressDisplay);
- enqueueBuildable(self.type, self.sourceFactory, player1, progressDisplay);
+ if (!self.progressDisplay) {
+ console.log("BuildableItemIcon : No progress display => create one");
+ self.progressDisplay = new BuildingProgressDisplay(self);
+ } else {
+ console.log("BuildableItemIcon : Progress display already exists");
+ }
+ self.progressDisplay.show();
+ game.addChild(self.progressDisplay);
+ enqueueBuildable(self.type, self.sourceFactory, player1, self.progressDisplay);
game.children.forEach(function (child) {
if (child instanceof BuildableItemIcon) {
child.alpha = 0.75;
}
@@ -126,8 +138,9 @@
self.restoreLabel = function () {
self.label.setText(buildableInfo.name);
self.label.x = self.asset.x - buildableInfo.name.length / 2 * 13; // Recalculate x position for new text
};
+ // Restore progress display from global queue
return self;
});
// BuildableRepository class to store reference information about all buildables
var BuildableRepository = Container.expand(function () {
@@ -1216,10 +1229,10 @@
var deltaX = 0;
var deltaY = 0;
if (alternate) {
//console.log("search alternate spot...");
- deltaX = -2 + Math.random() * 4;
- deltaY = -2 + Math.random() * 4;
+ deltaX = -1 + Math.floor(Math.random() * 3);
+ deltaY = -1 + Math.floor(Math.random() * 3);
}
var closestSpiceSpot = findClosestSpiceSpot(self.cellX + deltaX, self.cellY + deltaY);
if (closestSpiceSpot) {
//console.log("closestSpiceSpot :", closestSpiceSpot);
@@ -1652,19 +1665,19 @@
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
-function moveActionLogic(targetUnit, destinationX, destinationY) {
- console.log("MoveActionLogic...", destinationX, ',', destinationY);
+function moveActionLogic(targetUnit, destinationX, destinationY, isAttack) {
+ console.log("MoveActionLogic...", destinationX, ',', destinationY, ", isAttack=", isAttack);
if (targetUnit && targetUnit.isUnit) {
targetUnit.stopOtherActions();
var path = gameMap.findPath({
x: targetUnit.cellX,
y: targetUnit.cellY
}, {
x: destinationX,
y: destinationY
- }, targetUnit.attackRange);
+ }, isAttack ? targetUnit.attackRange : 0);
targetUnit.moveAlongPath(path);
}
}
function attackActionLogic(theUnit, targetCellX, targetCellY) {
@@ -1853,8 +1866,10 @@
progressDisplay.parentIcon.setLabelToPlace(); // Change label text to 'Place'
}
currentBuildingForPlacement = buildable;
}
+ console.log("REMOVING PROGRESS DISPLAY ON ", buildable.progressDisplay.parent);
+ buildable.progressDisplay.parent.progressDisplay = null;
} else {
if (buildable.isBuilding) {
currentPlayer.isCurrentlyBuilding = false;
aiPlaceBuilding(buildable);
@@ -2012,10 +2027,11 @@
/* ********************************************* AI FUNCTIONS ****************************************** */
/* ***************************************************************************************************** */
var AI_LEVEL = {
EASY: {
- actingDelay: 500,
- thinkingDelay: 500
+ actingDelay: 50000,
+ //500, /// TEMP DEBUG !!!
+ thinkingDelay: 50000 //500, /// TEMP DEBUG !!!
},
NORMAL: {
actingDelay: 300,
thinkingDelay: 600
@@ -2286,11 +2302,11 @@
}
// 6) Launch attack wave
if (aiArmyIsReady && Date.now() - aiLastAttackWaveTime > aiNextAttackWaveDelayMs) {
aiLastAttackWaveTime = Date.now();
+ console.warn("6 - ATTACK !!! Wave " + aiCurrentAttackWave + " at ", new Date().toLocaleTimeString());
aiCurrentAttackWave++;
- aiNextAttackWaveDelayMs = Math.min(5 * 20 * 1000, aiCurrentAttackWave * 20 * 1000); //Math.min(5*60*1000, aiCurrentAttackWave * 60 * 1000); TEMP DEBUG !!!
- console.warn("6 - ATTACK !!! ATTACK !!! ATTACK !!! ATTACK !!! ATTACK !!!");
+ aiNextAttackWaveDelayMs = Math.min(5 * 60 * 1000, aiCurrentAttackWave * 60 * 1000);
// Find a building to attack
var firstAttaker = null;
for (var i = 0; i < aiCurrentArmyUnits.length; i++) {
if (!aiCurrentArmyUnits[i] || aiCurrentArmyUnits[i].health <= 0) {
@@ -2417,9 +2433,9 @@
for (var i = 0; i < nbUnits; i++) {
// Find a place for each unit by adding a delta depending on index
var deltaX = -1 + i % 3;
var deltaY = Math.floor(i / 3);
- moveActionLogic(aiCurrentArmyUnits[i], target.cellX + deltaX, target.cellY + deltaY);
+ moveActionLogic(aiCurrentArmyUnits[i], target.cellX + deltaX, target.cellY + deltaY, true);
}
}
/* ***************************************************************************************************** */
/* ********************************************* INIT FUNCTIONS ****************************************** */
@@ -2786,9 +2802,9 @@
currentBuildingForPlacement = null;
if (cancelActionBtn) {
cancelActionBtn.visible = false;
}
- updateActionBoard();
+ updateActionBoard(true);
updateFogOfWar();
}
};
// Screen <-> World Coordinates
@@ -2904,16 +2920,16 @@
});
return closestSpot;
};
// Global function to handle action board updates
-var updateActionBoard = function updateActionBoard() {
+var updateActionBoard = function updateActionBoard(resetProgress) {
console.log('updateActionBoard...' + (currentSelection ? currentSelection.name : 'No selection'));
if (!currentSelection || currentSelection.health <= 0) {
currentSelection = null;
}
currentSelectionText.setText(currentSelection ? currentSelection.name : '');
clearIconBorders();
- displayBuildableItems(); // Call displayBuildableItems to show items that can be built
+ displayBuildableItems(resetProgress); // Call displayBuildableItems to show items that can be built
displayActionItems(); // Call displayActionItems to show action items
};
function clearIconBorders() {
var iconBorders = game.children.filter(function (child) {
@@ -2922,20 +2938,25 @@
iconBorders.forEach(function (border) {
border.destroy();
});
}
-function displayBuildableItems() {
- console.log('updateActionBoard...', currentSelection);
+function displayBuildableItems(resetProgress) {
+ console.log('displayBuildableItems...', currentSelection);
var buildableItemIcons = game.children.filter(function (child) {
return child instanceof BuildableItemIcon;
});
buildableItemIcons.forEach(function (icon) {
- icon.destroy();
+ //icon.destroy(); // TEMP DEBUG !!!
+ if (icon.progressDisplay) {
+ icon.progressDisplay.visible = !resetProgress && !!currentSelection;
+ }
+ icon.visible = false;
});
if (currentSelection && currentSelection.playerId === player1.playerId && currentSelection.buildable && currentSelection.buildable.length) {
var iconX = commandPanel.x + 200; // Starting X position for the first icon
var iconY = commandPanel.y + 220; // Y position for all icons
currentSelection.buildable.forEach(function (itemType) {
+ console.log("Prepare icon for ", itemType);
var buildableInfo = buildableRepository.getBuildableInfo(itemType);
if (buildableInfo.requires) {
var requiredBuildingExists = player1.buildings.some(function (building) {
return building.type === buildableInfo.requires;
@@ -2945,10 +2966,30 @@
}
}
var border = new IconBorder(iconX, iconY);
game.addChild(border);
- var icon = new BuildableItemIcon(itemType, iconX, iconY, currentSelection);
+ var icon = null;
+ // Search if icon already exists
+ var existingIcons = game.children.filter(function (child) {
+ return child instanceof BuildableItemIcon && child.type === itemType;
+ });
+ console.log("Found existing icons", existingIcons);
+ if (existingIcons.length > 0) {
+ icon = existingIcons[0];
+ if (resetProgress) {
+ icon.restoreLabel();
+ }
+ icon.visible = true;
+ } else {
+ icon = new BuildableItemIcon(itemType, iconX, iconY, currentSelection);
+ }
game.addChild(icon);
+ if (icon.progressDisplay) {
+ icon.progressDisplay.visible = true;
+ game.addChild(icon.progressDisplay);
+ }
+ //icon = new BuildableItemIcon(itemType, iconX, iconY, currentSelection); // TEMP DEBUG !!!
+ //game.addChild(icon);
iconX += 300; // Increment X position for the next icon
});
}
}
a tileable sand terrain tile.
A square tileable rock terrain tile WITHOUT BBORDER. Single Game Texture. In-Game asset. 2d. No shadows. No Border
Zenith view of Dune's Wind Trap power facility square fence. Ressembles a bit to Sydney's Opera. Zenith view Directly from above.
grey cancel icon. UI
thin white circle empty.
0x5e86ff
Zenith view of a white rectangular Harvester shape of a garbage truck with a triangular head. Harvesting on sand, with flowing spice in the back. inside a square fence. Zenith view. Directly overhead. Plumb view.
Minimal Ui icon of an right sign aside with an icon of a target. sand background
Minimal icon of a home with direction icon pointing to the home. sand background
3 white flat isometric concentric circles like a target.
Remove background
Gray background
Minimal Ui icon of target sign on a fire icon.. sand background
top view of an explosion effect.
Simple heavy army tank factory buiding a tank with a crane. Square fence... Zenith view Directly overhead. Plumb view.
an empty black popup UI. UI