Skip to content

Commit

Permalink
fix(Replay): flower and apple at same time counts as NoTouch (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
metsavir authored Feb 6, 2024
1 parent 30d7239 commit b8042a5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
ecmaVersion: 2020,
sourceType: 'module',
},
extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
rules: {},
ignorePatterns: ['webpack.config.js', '**/*.d.ts'],
};
Binary file added __tests__/assets/replays/lc408finish.rec
Binary file not shown.
Binary file added __tests__/assets/replays/lc408one.rec
Binary file not shown.
4 changes: 4 additions & 0 deletions __tests__/rec.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ describe('Replay', () => {
['rec_valid_2.rec', 4],
['rec_valid_3.rec', 4],
['appbug.rec', 19],
['lc408one.rec', 1],
['lc408finish.rec', 5],
])('.apples counts correct number of apples: %s', async (fileName, apples) => {
const filePath = `__tests__/assets/replays/${fileName}`;
const file = await readFile(filePath);
Expand All @@ -228,6 +230,8 @@ describe('Replay', () => {
['rec_valid_2.rec', 4],
['rec_valid_3.rec', 4],
['appbug.rec', 36],
['lc408one.rec', 1],
['lc408finish.rec', 5],
])('.totalApples counts correct number of apples: %s', async (fileName, apples) => {
const filePath = `__tests__/assets/replays/${fileName}`;
const file = await readFile(filePath);
Expand Down
2 changes: 1 addition & 1 deletion src/rec/Replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export default class Replay {
let apples = 0;

for (const ride of this.rides) {
const touchEvents = ride.events.filter((event) => event.type === 0);
const touchEvents = ride.events.filter((event) => event.type === 0).sort((a, b) => b.time - a.time);
const appleEvents = ride.events.filter((event) => event.type === 4);
const unique = [...new Set(touchEvents.map((event) => event.touchInfo))].map((event, idx) => touchEvents[idx]);

Expand Down

0 comments on commit b8042a5

Please sign in to comment.