diff --git a/.eslintrc.js b/.eslintrc.js index 4992883..5393e03 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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'], }; diff --git a/__tests__/assets/replays/lc408finish.rec b/__tests__/assets/replays/lc408finish.rec new file mode 100644 index 0000000..60aae6b Binary files /dev/null and b/__tests__/assets/replays/lc408finish.rec differ diff --git a/__tests__/assets/replays/lc408one.rec b/__tests__/assets/replays/lc408one.rec new file mode 100644 index 0000000..f5fc43a Binary files /dev/null and b/__tests__/assets/replays/lc408one.rec differ diff --git a/__tests__/rec.int.test.ts b/__tests__/rec.int.test.ts index fda20c0..d89318d 100644 --- a/__tests__/rec.int.test.ts +++ b/__tests__/rec.int.test.ts @@ -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); @@ -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); diff --git a/src/rec/Replay.ts b/src/rec/Replay.ts index 522e2fd..f412a88 100644 --- a/src/rec/Replay.ts +++ b/src/rec/Replay.ts @@ -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]);