junebug12851/pokered-save-editor

View on GitHub
src/app/data/savefile-expanded/fragments/WarpData.ts

Summary

Maintainability
A
45 mins
Test Coverage
import { SaveFileService } from './../../savefile.service';
 
export class WarpData {
Similar blocks of code found in 4 locations. Consider refactoring.
constructor(savefile?: SaveFileService, index?: number) {
if statements must be braced
if (savefile !== undefined)
this.load(savefile as SaveFileService, index as number);
}
 
public load(savefile: SaveFileService, index: number) {
const it = savefile.iterator.offsetTo((0x4 * index) + 0x265B);
 
this.y = it.getByte();
this.x = it.getByte();
this.destWarp = it.getByte();
this.destMap = it.getByte();
}
 
public save(savefile: SaveFileService, index: number) {
const it = savefile.iterator.offsetTo((0x4 * index) + 0x265B);
 
it.setByte(this.y);
it.setByte(this.x);
it.setByte(this.destWarp);
it.setByte(this.destMap);
}
 
Type number trivially inferred from a number literal, remove type annotation
public y: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public x: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public destWarp: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public destMap: number = 0;
}