Passed
Pull Request — master (#22)
by
unknown
08:10 queued 04:20
created

src/app/data/savefile-expanded/sections/HoF.ts   A

Complexity

Total Complexity 5
Complexity/F 2.5

Size

Lines of Code 27
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 5
mnd 3
bc 3
fnc 2
bpm 1.5
cpm 2.5
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A HoF.load 0 5 3
A HoF.save 0 5 2
1
import { HoFRecord } from './../fragments/HoFRecord';
2
import { SaveFileService } from './../../savefile.service';
3
4
export class HoF {
5
    constructor(saveFile?: SaveFileService) {
6
        if (saveFile !== undefined)
7
            this.load(saveFile as SaveFileService);
8
    }
9
10
    public load(saveFile: SaveFileService) {
11
        const hofRecordCount = saveFile.getByte(0x284E);
12
        for (let i = 0; i < hofRecordCount && i < 50; i++) {
13
            this.hallOfFame.push(new HoFRecord(saveFile, i));
14
        }
15
    }
16
17
    public save(saveFile: SaveFileService) {
18
        saveFile.setByte(0x284E, this.hallOfFame.length);
19
        for (let i = 0; i < this.hallOfFame.length && i < 50; i++) {
20
            this.hallOfFame[i].save(saveFile, i);
21
        }
22
    }
23
24
    // Related to the Hall of Fame
25
    public hallOfFame: HoFRecord[] = [];
26
}
27