junebug12851/pokered-save-editor

View on GitHub
src/app/data/savefile-expanded/sections/Area/AreaPlayer.ts

Summary

Maintainability
A
2 hrs
Test Coverage
import { SaveFileService } from './../../../savefile.service';
 
export class AreaPlayer {
constructor(saveFile?: SaveFileService) {
if statements must be braced
if (saveFile !== undefined)
this.load(saveFile as SaveFileService);
}
 
Function `load` has 28 lines of code (exceeds 25 allowed). Consider refactoring.
public load(saveFile: SaveFileService) {
this.yCoord = saveFile.getByte(0x260D);
this.xCoord = saveFile.getByte(0x260E);
this.yBlockCoord = saveFile.getByte(0x260F);
this.xBlockCoord = saveFile.getByte(0x2610);
this.yOffsetSinceLastSpecialWarp = saveFile.getByte(0x278E);
this.xOffsetSinceLastSpecialWarp = saveFile.getByte(0x278F);
this.playerMoveDir = saveFile.getByte(0x27D4);
this.playerLastStopDir = saveFile.getByte(0x27D5);
this.playerCurDir = saveFile.getByte(0x27D6);
this.walkBikeSurf = saveFile.getByte(0x29AC);
this.safariSteps = saveFile.getWord(0x29B9);
this.playerJumpingYScrnCoords = saveFile.getByte(0x29C0);
this.strengthOutsideBattle = saveFile.getBit(0x29D4, 1, 0);
this.surfingAllowed = saveFile.getBit(0x29D4, 1, 1);
this.usedCardKey = saveFile.getBit(0x29D4, 1, 7);
this.isBattle = saveFile.getBit(0x29D9, 1, 6);
this.isTrainerBattle = saveFile.getBit(0x29D9, 1, 7);
this.noBattles = saveFile.getBit(0x29DA, 1, 4);
this.battleEndedOrBlackout = saveFile.getBit(0x29DA, 1, 5);
this.usingLinkCable = saveFile.getBit(0x29DA, 1, 6);
this.flyOutofBattle = saveFile.getBit(0x29DF, 1, 7);
this.standingOnDoor = saveFile.getBit(0x29E2, 1, 0);
this.movingThroughDoor = saveFile.getBit(0x29E2, 1, 1);
this.standingOnWarp = saveFile.getBit(0x29E2, 1, 2);
this.finalLedgeJumping = saveFile.getBit(0x29E2, 1, 6);
this.spinPlayer = saveFile.getBit(0x29E2, 1, 7);
this.safariGameOver = saveFile.getByte(0x2CF2) == 1;
this.safariBallCount = saveFile.getByte(0x2CF3);
}
 
Function `save` has 28 lines of code (exceeds 25 allowed). Consider refactoring.
public save(saveFile: SaveFileService) {
saveFile.setByte(0x260D, this.yCoord);
saveFile.setByte(0x260E, this.xCoord);
saveFile.setByte(0x260F, this.yBlockCoord);
saveFile.setByte(0x2610, this.xBlockCoord);
saveFile.setByte(0x278E, this.yOffsetSinceLastSpecialWarp);
saveFile.setByte(0x278F, this.xOffsetSinceLastSpecialWarp);
saveFile.setByte(0x27D4, this.playerMoveDir);
saveFile.setByte(0x27D5, this.playerLastStopDir);
saveFile.setByte(0x27D6, this.playerCurDir);
saveFile.setByte(0x29AC, this.walkBikeSurf);
saveFile.setWord(0x29B9, this.safariSteps);
saveFile.setByte(0x29C0, this.playerJumpingYScrnCoords);
saveFile.setBit(0x29D4, 1, 0, this.strengthOutsideBattle);
saveFile.setBit(0x29D4, 1, 1, this.surfingAllowed);
saveFile.setBit(0x29D4, 1, 7, this.usedCardKey);
saveFile.setBit(0x29D9, 1, 6, this.isBattle);
saveFile.setBit(0x29D9, 1, 7, this.isTrainerBattle);
saveFile.setBit(0x29DA, 1, 4, this.noBattles);
saveFile.setBit(0x29DA, 1, 5, this.battleEndedOrBlackout);
saveFile.setBit(0x29DA, 1, 6, this.usingLinkCable);
saveFile.setBit(0x29DF, 1, 7, this.flyOutofBattle);
saveFile.setBit(0x29E2, 1, 0, this.standingOnDoor);
saveFile.setBit(0x29E2, 1, 1, this.movingThroughDoor);
saveFile.setBit(0x29E2, 1, 2, this.standingOnWarp);
saveFile.setBit(0x29E2, 1, 6, this.finalLedgeJumping);
saveFile.setBit(0x29E2, 1, 7, this.spinPlayer);
saveFile.setByte(0x2CF2, (this.safariGameOver) ? 1 : 0);
saveFile.setByte(0x2CF3, this.safariBallCount);
}
 
/**
* Player (Complete)
*/
 
// Direction
// if the player is moving, the current direction
// if the player is not moving, zero
// None 0
// Right 1
// Left 2
// Down 4
// Up 8
Type number trivially inferred from a number literal, remove type annotation
public playerMoveDir: number = 0;
 
// the direction in which the player was moving before the player last stopped
Type number trivially inferred from a number literal, remove type annotation
public playerLastStopDir: number = 0;
 
// if the player is moving, the current direction
// if the player is not moving, the last the direction in which the player moved
Type number trivially inferred from a number literal, remove type annotation
public playerCurDir: number = 0;
 
// Coords
Type number trivially inferred from a number literal, remove type annotation
public yCoord: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public xCoord: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public yBlockCoord: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public xBlockCoord: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public playerJumpingYScrnCoords: number = 0;
 
// Safari
Type boolean trivially inferred from a boolean literal, remove type annotation
public safariGameOver: boolean = false;
Type number trivially inferred from a number literal, remove type annotation
public safariBallCount: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public safariSteps: number = 0;
 
// HMs
Type boolean trivially inferred from a boolean literal, remove type annotation
public strengthOutsideBattle: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public surfingAllowed: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public flyOutofBattle: boolean = false;
 
// Battle
Type boolean trivially inferred from a boolean literal, remove type annotation
public isBattle: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public isTrainerBattle: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public noBattles: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public battleEndedOrBlackout: boolean = false;
 
// Warps
Type number trivially inferred from a number literal, remove type annotation
public yOffsetSinceLastSpecialWarp: number = 0;
Type number trivially inferred from a number literal, remove type annotation
public xOffsetSinceLastSpecialWarp: number = 0;
Type boolean trivially inferred from a boolean literal, remove type annotation
public standingOnDoor: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public movingThroughDoor: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public standingOnWarp: boolean = false;
 
// Misc
 
// 0x00 = walking
// 0x01 = biking
// 0x02 = surfing
Type number trivially inferred from a number literal, remove type annotation
public walkBikeSurf: number = 0;
Type boolean trivially inferred from a boolean literal, remove type annotation
public finalLedgeJumping: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public spinPlayer: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public usedCardKey: boolean = false;
Type boolean trivially inferred from a boolean literal, remove type annotation
public usingLinkCable: boolean = false;
}