igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
48 lines • 1.68 kB
JavaScript
/**
* A container holding a {@link Game}, optionally a {@link Release} for that {@link Game}, and a
* {@link ROMWithFiles} with input and output {@link File} information for every {@link ROM}.
* In other words, a {@link WriteCandidate} will only exist if every {@link ROM} of a {@link Game}
* has been found.
*/
export default class WriteCandidate {
constructor(game, romsWithFiles) {
this.game = game;
this.romsWithFiles = romsWithFiles;
}
// Property getters
getGame() {
return this.game;
}
getRomsWithFiles() {
return this.romsWithFiles;
}
// Computed getters
getName() {
return this.game.getName();
}
/**
* Returns true if any {@link ROMWithFiles} input {@link File} has a {@link Patch} attached to it.
*/
isPatched() {
return this.getRomsWithFiles().some((romWithFiles) => romWithFiles.getInputFile().getPatch() !== undefined);
}
// Immutable setters
withRomsWithFiles(romsWithFiles) {
if (romsWithFiles === this.romsWithFiles ||
(romsWithFiles.length === this.romsWithFiles.length &&
romsWithFiles.every((rwf, idx) => this.romsWithFiles[idx] === rwf))) {
return this;
}
return new WriteCandidate(this.game, romsWithFiles);
}
// Pseudo Built-Ins
/**
* A string hash code to uniquely identify this {@link WriteCandidate}.
*/
hashCode() {
let hashCode = this.game.hashCode();
hashCode += `|${this.romsWithFiles.map((romWithFiles) => romWithFiles.hashCode()).join(',')}`;
return hashCode;
}
}
//# sourceMappingURL=writeCandidate.js.map