Skip to content

Commit

Permalink
Fix pr #338: Fix issue #337: Displacement
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Jan 28, 2025
1 parent 1218d56 commit 863f7ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/src/libs/combat/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,10 @@ export const displacement = (
const dx = [0, 1, 0, -1] as const; // right, down, left, up
const dy = [1, 0, -1, 0] as const;
const getDirectionOffset = (dir: number): { x: number; y: number } => {
const index = dir % 4;
const x = dx[index];
const y = dy[index];
const index = ((dir % 4) + 4) % 4; // Ensure positive index between 0-3
// We know index is between 0-3, so these accesses are safe
const x = dx[index] as number;
const y = dy[index] as number;
return { x, y };
};
let x = target.longitude;
Expand Down

0 comments on commit 863f7ed

Please sign in to comment.