feat: better code formatting
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { checkPositionWalkable } from "utils/funcs/checkPosition";
|
||||
import { checkPositionWalkable } from 'utils/funcs/checkPosition';
|
||||
import {
|
||||
createSourcePositionMatrix,
|
||||
forEachMatrixSpot,
|
||||
getPositionWithDelta,
|
||||
PositionSpotStatus,
|
||||
setSpotStatus
|
||||
} from "utils/positions";
|
||||
setSpotStatus,
|
||||
} from 'utils/positions';
|
||||
|
||||
class RoomInspector {
|
||||
public static inspectState(room: Room, state: GameState): GameState {
|
||||
@@ -30,29 +30,43 @@ class RoomInspector {
|
||||
return state;
|
||||
}
|
||||
|
||||
private static configureSourceState(source: Source, state: GameState): void {
|
||||
private static configureSourceState(
|
||||
source: Source,
|
||||
state: GameState
|
||||
): void {
|
||||
const sourceId = source.id.toString();
|
||||
|
||||
if (!state.sourcesStates[sourceId]) {
|
||||
state.sourcesStates[sourceId] = {
|
||||
id: sourceId,
|
||||
pos: source.pos,
|
||||
spots: createSourcePositionMatrix()
|
||||
spots: createSourcePositionMatrix(),
|
||||
};
|
||||
}
|
||||
|
||||
forEachMatrixSpot(state.sourcesStates[sourceId].spots, (delta, status) => {
|
||||
if (status !== PositionSpotStatus.UNKNOWN) {
|
||||
return; // Skip known spots
|
||||
forEachMatrixSpot(
|
||||
state.sourcesStates[sourceId].spots,
|
||||
(delta, status) => {
|
||||
if (status !== PositionSpotStatus.UNKNOWN) {
|
||||
return; // Skip known spots
|
||||
}
|
||||
const pos = getPositionWithDelta(source.pos, delta);
|
||||
if (checkPositionWalkable(pos)) {
|
||||
setSpotStatus(
|
||||
state.sourcesStates[sourceId].spots,
|
||||
delta,
|
||||
PositionSpotStatus.EMPTY
|
||||
);
|
||||
state.maxHarvesters += 1;
|
||||
} else {
|
||||
setSpotStatus(
|
||||
state.sourcesStates[sourceId].spots,
|
||||
delta,
|
||||
PositionSpotStatus.INVALID
|
||||
);
|
||||
}
|
||||
}
|
||||
const pos = getPositionWithDelta(source.pos, delta);
|
||||
if (checkPositionWalkable(pos)) {
|
||||
setSpotStatus(state.sourcesStates[sourceId].spots, delta, PositionSpotStatus.EMPTY);
|
||||
state.maxHarvesters += 1;
|
||||
} else {
|
||||
setSpotStatus(state.sourcesStates[sourceId].spots, delta, PositionSpotStatus.INVALID);
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user