Fixes Spot Holding Bug

This commit is contained in:
2025-07-12 11:23:26 -03:00
parent 293aaef0d4
commit 2ce86cd784
2 changed files with 10 additions and 10 deletions

View File

@@ -24,11 +24,7 @@ class HarvesterHandler extends RoleHandler {
} }
private static validateCreepMemory(creep: Creep, state: GameState) { private static validateCreepMemory(creep: Creep, state: GameState) {
if (!creep.memory.destination) { if (!!creep.memory.previousDestination && creep.memory.previousDestination.type === "source") {
return; // No destination set, nothing to validate
}
if (creep.memory.destination.type === "source" && !!creep.memory.previousDestination && creep.memory.previousDestination.type === "source") {
setSpotStatus( setSpotStatus(
state.sourcesStates[creep.memory.previousDestination.id].spots, state.sourcesStates[creep.memory.previousDestination.id].spots,
creep.memory.previousDestination.sourceSpot, creep.memory.previousDestination.sourceSpot,
@@ -37,6 +33,10 @@ class HarvesterHandler extends RoleHandler {
delete creep.memory.previousDestination; delete creep.memory.previousDestination;
} }
if (!creep.memory.destination) {
return; // No destination set, nothing to validate
}
if (creep.memory.destination.type === "source" && !creep.store.getFreeCapacity(RESOURCE_ENERGY)) { if (creep.memory.destination.type === "source" && !creep.store.getFreeCapacity(RESOURCE_ENERGY)) {
creep.memory.previousDestination = creep.memory.destination; creep.memory.previousDestination = creep.memory.destination;
creep.memory.destination = { creep.memory.destination = {

View File

@@ -24,11 +24,7 @@ class UpgraderHandler extends RoleHandler {
} }
private static validateCreepMemory(creep: Creep, state: GameState) { private static validateCreepMemory(creep: Creep, state: GameState) {
if (!creep.memory.destination) { if (!!creep.memory.previousDestination && creep.memory.previousDestination.type === "source") {
return; // No destination set, nothing to validate
}
if (creep.memory.destination.type === "source" && !!creep.memory.previousDestination && creep.memory.previousDestination.type === "source") {
setSpotStatus( setSpotStatus(
state.sourcesStates[creep.memory.previousDestination.id].spots, state.sourcesStates[creep.memory.previousDestination.id].spots,
creep.memory.previousDestination.sourceSpot, creep.memory.previousDestination.sourceSpot,
@@ -37,6 +33,10 @@ class UpgraderHandler extends RoleHandler {
delete creep.memory.previousDestination; delete creep.memory.previousDestination;
} }
if (!creep.memory.destination) {
return; // No destination set, nothing to validate
}
if (creep.memory.destination.type === "source" && !creep.store.getFreeCapacity(RESOURCE_ENERGY)) { if (creep.memory.destination.type === "source" && !creep.store.getFreeCapacity(RESOURCE_ENERGY)) {
creep.memory.previousDestination = creep.memory.destination; creep.memory.previousDestination = creep.memory.destination;