Skip to content

Commit

Permalink
fix: Additional fight positions. Fixes #1039
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenoo committed Nov 16, 2024
1 parent 1580e64 commit 88da327
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion client/src/utils/fight/utils/fightPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const leftPositions = [
{ x: 60, y: 272 },
];

const extraLeftPositions = [
{ x: 100, y: 200 },
{ x: 80, y: 212 },
{ x: 100, y: 224 },
{ x: 80, y: 236 },
{ x: 100, y: 248 },
{ x: 80, y: 260 },
{ x: 100, y: 272 },
];

const rightPositions = [
{ x: 440, y: 200 },
{ x: 460, y: 212 },
Expand All @@ -21,12 +31,31 @@ const rightPositions = [
{ x: 440, y: 272 },
];

const extraRightPositions = [
{ x: 400, y: 200 },
{ x: 420, y: 212 },
{ x: 400, y: 224 },
{ x: 420, y: 236 },
{ x: 400, y: 248 },
{ x: 420, y: 260 },
{ x: 400, y: 272 },
];

const getAvailablePositions = (fighters: AnimationFighter[], team: 'L' | 'R') => {
const teamFighters = fighters.filter((fighter) => fighter.team === team);
const positions = (team === 'L' ? leftPositions : rightPositions)
.filter((p) => !teamFighters.find((f) => f.animation.container.x === p.x
&& f.animation.container.y === p.y));

if (positions.length > 0) {
return positions;
}

return (team === 'L' ? leftPositions : rightPositions)
const extraPositions = (team === 'L' ? extraLeftPositions : extraRightPositions)
.filter((p) => !teamFighters.find((f) => f.animation.container.x === p.x
&& f.animation.container.y === p.y));

return extraPositions;
};

const getRandomPosition = (fighters: AnimationFighter[], team: 'L' | 'R') => {
Expand Down

0 comments on commit 88da327

Please sign in to comment.