Skip to content

Commit

Permalink
Refactor: breaking: remove prefer NTSC & PAL options (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Aug 26, 2024
1 parent 7aa70d6 commit 6f80e28
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 156 deletions.
12 changes: 0 additions & 12 deletions docs/roms/filtering-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,6 @@ Prefer games that are considered "retail" releases over those that aren't.

See the [only retail](#only-retail) section for more information on what games are considered "retail."

### Prefer NTSC, PAL

```text
--prefer-ntsc, --prefer-pal
```

Prefer games that are explicitly labeled as NTSC or PAL, over those that aren't.

!!! note

Most DAT groups do not label games with this information, generally games are labeled by region instead.

### Prefer parent

```text
Expand Down
14 changes: 0 additions & 14 deletions src/modules/argumentsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,20 +750,6 @@ export default class ArgumentsParser {
type: 'boolean',
implies: 'single',
})
.option('prefer-ntsc', {
group: groupRomPriority,
description: 'Prefer NTSC ROMs over others',
type: 'boolean',
conflicts: 'prefer-pal',
implies: 'single',
})
.option('prefer-pal', {
group: groupRomPriority,
description: 'Prefer PAL ROMs over others',
type: 'boolean',
conflicts: 'prefer-ntsc',
implies: 'single',
})
.option('prefer-parent', {
group: groupRomPriority,
description: 'Prefer parent ROMs over clones',
Expand Down
16 changes: 0 additions & 16 deletions src/modules/candidatePreferer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ export default class CandidatePreferer extends Module {
|| this.preferRegionsSort(a, b)
|| this.preferRevisionSort(a, b)
|| this.preferRetailSort(a, b)
|| this.preferNTSCSort(a, b)
|| this.preferPALSort(a, b)
|| this.preferParentSort(a, b);
}

Expand Down Expand Up @@ -205,20 +203,6 @@ export default class CandidatePreferer extends Module {
return (a.getGame().isRetail() ? 0 : 1) - (b.getGame().isRetail() ? 0 : 1);
}

private preferNTSCSort(a: ReleaseCandidate, b: ReleaseCandidate): number {
if (!this.options.getPreferNTSC()) {
return 0;
}
return (a.getGame().isNTSC() ? 0 : 1) - (b.getGame().isNTSC() ? 0 : 1);
}

private preferPALSort(a: ReleaseCandidate, b: ReleaseCandidate): number {
if (!this.options.getPreferPAL()) {
return 0;
}
return (a.getGame().isPAL() ? 0 : 1) - (b.getGame().isPAL() ? 0 : 1);
}

private preferParentSort(a: ReleaseCandidate, b: ReleaseCandidate): number {
if (!this.options.getPreferParent()) {
return 0;
Expand Down
24 changes: 1 addition & 23 deletions src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import os from 'node:os';
import path from 'node:path';

import async, { AsyncResultCallback } from 'async';
import {
Expose, instanceToPlain, plainToInstance, Transform,
} from 'class-transformer';
import { Expose, instanceToPlain, plainToInstance } from 'class-transformer';
import fg from 'fast-glob';
import { isNotJunk } from 'junk';
import micromatch from 'micromatch';
Expand Down Expand Up @@ -154,8 +152,6 @@ export interface OptionsProps {
readonly preferRevisionNewer?: boolean,
readonly preferRevisionOlder?: boolean,
readonly preferRetail?: boolean,
readonly preferNTSC?: boolean,
readonly preferPAL?: boolean,
readonly preferParent?: boolean,

readonly reportOutput?: string,
Expand Down Expand Up @@ -342,14 +338,6 @@ export default class Options implements OptionsProps {

readonly preferRetail: boolean;

@Expose({ name: 'preferNtsc' })
@Transform(({ value }) => !!value)
readonly preferNTSC: boolean;

@Expose({ name: 'preferPal' })
@Transform(({ value }) => !!value)
readonly preferPAL: boolean;

readonly preferParent: boolean;

readonly reportOutput: string;
Expand Down Expand Up @@ -468,8 +456,6 @@ export default class Options implements OptionsProps {
this.preferRevisionNewer = options?.preferRevisionNewer ?? false;
this.preferRevisionOlder = options?.preferRevisionOlder ?? false;
this.preferRetail = options?.preferRetail ?? false;
this.preferNTSC = options?.preferNTSC ?? false;
this.preferPAL = options?.preferPAL ?? false;
this.preferParent = options?.preferParent ?? false;

this.reportOutput = options?.reportOutput ?? '';
Expand Down Expand Up @@ -1224,14 +1210,6 @@ export default class Options implements OptionsProps {
return this.preferRetail;
}

getPreferNTSC(): boolean {
return this.preferNTSC;
}

getPreferPAL(): boolean {
return this.preferPAL;
}

getPreferParent(): boolean {
return this.preferParent;
}
Expand Down
24 changes: 0 additions & 24 deletions test/modules/argumentsParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ describe('options', () => {
expect(options.getPreferRevisionNewer()).toEqual(false);
expect(options.getPreferRevisionOlder()).toEqual(false);
expect(options.getPreferRetail()).toEqual(false);
expect(options.getPreferNTSC()).toEqual(false);
expect(options.getPreferPAL()).toEqual(false);
expect(options.getPreferParent()).toEqual(false);

expect(options.getDatThreads()).toEqual(3);
Expand Down Expand Up @@ -787,28 +785,6 @@ describe('options', () => {
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--prefer-retail', 'true', '--prefer-retail', 'false', '--single']).getPreferRetail()).toEqual(false);
});

it('should parse "prefer-ntsc"', () => {
expect(() => argumentsParser.parse([...dummyCommandAndRequiredArgs, '--prefer-ntsc'])).toThrow(/dependent|implication/i);
expect(() => argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', '--prefer-pal', '--single']).getPreferNTSC()).toThrow(/mutually exclusive/i);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', '--single']).getPreferNTSC()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', 'true', '--single']).getPreferNTSC()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', 'false', '--single']).getPreferNTSC()).toEqual(false);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', '--prefer-ntsc', '--single']).getPreferNTSC()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', 'false', '--prefer-ntsc', 'true', '--single']).getPreferNTSC()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-ntsc', 'true', '--prefer-ntsc', 'false', '--single']).getPreferNTSC()).toEqual(false);
});

it('should parse "prefer-pal"', () => {
expect(() => argumentsParser.parse([...dummyCommandAndRequiredArgs, '--prefer-pal'])).toThrow(/dependent|implication/i);
expect(() => argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', '--prefer-ntsc', '--single']).getPreferPAL()).toThrow(/mutually exclusive/i);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', '--single']).getPreferPAL()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', 'true', '--single']).getPreferPAL()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', 'false', '--single']).getPreferPAL()).toEqual(false);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', '--prefer-pal', '--single']).getPreferPAL()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', 'false', '--prefer-pal', 'true', '--single']).getPreferPAL()).toEqual(true);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--dat', os.devNull, '--prefer-pal', 'true', '--prefer-pal', 'false', '--single']).getPreferPAL()).toEqual(false);
});

it('should parse "prefer-parent"', () => {
expect(() => argumentsParser.parse([...dummyCommandAndRequiredArgs, '--prefer-parent'])).toThrow(/dependent|implication/i);
expect(argumentsParser.parse([...dummyCommandAndRequiredArgs, '--prefer-parent', '--single']).getPreferParent()).toEqual(true);
Expand Down
67 changes: 0 additions & 67 deletions test/modules/candidatePreferer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,73 +591,6 @@ describe('sort', () => {
});
});

describe('prefer NTSC', () => {
it('should return the first candidate when option is false', async () => {
expectPreferredCandidates({ preferNTSC: false, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (NTSC)']),
await buildReleaseCandidatesWithRegionLanguage(['three (NTSC)', 'three']),
], ['one', 'two', 'three (NTSC)']);
});

it('should return the first candidate when none matching', async () => {
expectPreferredCandidates({ preferNTSC: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['four', 'four (Demo)']),
], ['one', 'four']);
});

it('should return the first matching candidate when some matching', async () => {
expectPreferredCandidates({ preferNTSC: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (NTSC)']),
await buildReleaseCandidatesWithRegionLanguage(['three (NTSC)', 'three']),
], ['one', 'two (NTSC)', 'three (NTSC)']);
});

it('should return the first candidate when all matching', async () => {
expectPreferredCandidates({ preferNTSC: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (NTSC)']),
await buildReleaseCandidatesWithRegionLanguage(['three (NTSC)', 'three']),
], ['two (NTSC)', 'three (NTSC)']);
});
});

describe('prefer PAL', () => {
it('should return the first candidate when option is false', async () => {
expectPreferredCandidates({ preferPAL: false, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (PAL)']),
await buildReleaseCandidatesWithRegionLanguage(['three', 'three (PAL 60Hz)']),
await buildReleaseCandidatesWithRegionLanguage(['four (PAL)', 'four']),
], ['one', 'two', 'three', 'four (PAL)']);
});

it('should return the first candidate when none matching', async () => {
expectPreferredCandidates({ preferPAL: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['five', 'five (Demo)']),
], ['one', 'five']);
});

it('should return the first matching candidate when some matching', async () => {
expectPreferredCandidates({ preferPAL: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['one']),
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (PAL)']),
await buildReleaseCandidatesWithRegionLanguage(['three', 'three (PAL 60Hz)']),
await buildReleaseCandidatesWithRegionLanguage(['four (PAL)', 'four']),
], ['one', 'two (PAL)', 'three (PAL 60Hz)', 'four (PAL)']);
});

it('should return the first candidate when all matching', async () => {
expectPreferredCandidates({ preferPAL: true, single: true }, [
await buildReleaseCandidatesWithRegionLanguage(['two', 'two (PAL)']),
await buildReleaseCandidatesWithRegionLanguage(['three', 'three (PAL 60Hz)']),
await buildReleaseCandidatesWithRegionLanguage(['four (PAL)', 'four']),
], ['two (PAL)', 'three (PAL 60Hz)', 'four (PAL)']);
});
});

describe('prefer parent', () => {
it('should return the first candidate when option is false', async () => {
expectPreferredCandidates({ preferParent: false, single: true }, [
Expand Down

0 comments on commit 6f80e28

Please sign in to comment.