Passed
Push — depfu/update/npm/lodash-4.17.1... ( c1263d )
by
unknown
04:21
created

src/app/fragments/card-sprite-header/card-sprite-header.component.ts   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 101
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 67
dl 0
loc 101
rs 10
c 0
b 0
f 0
wmc 2
mnd 1
bc 1
fnc 1
bpm 1
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A CardSpriteHeader.ngOnInit 0 5 1
1
import { Sprite } from '../../../assets/data/sprites.d';
2
import { GameDataService } from './../../data/gameData.service';
3
import { OnInit } from '@angular/core';
4
5
/**
6
   Copyright 2018 June Hanabi
7
8
   Licensed under the Apache License, Version 2.0 (the "License");
9
   you may not use this file except in compliance with the License.
10
   You may obtain a copy of the License at
11
12
       http://www.apache.org/licenses/LICENSE-2.0
13
14
   Unless required by applicable law or agreed to in writing, software
15
   distributed under the License is distributed on an "AS IS" BASIS,
16
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
   See the License for the specific language governing permissions and
18
   limitations under the License.
19
 */
20
21
import { Component, Input } from '@angular/core';
22
import { SpriteData } from './../../data/savefile-expanded/fragments/SpriteData';
23
24
@Component({
25
    selector: 'card-sprite-header',
26
    templateUrl: './card-sprite-header.component.pug',
27
    styleUrls: ['./card-sprite-header.component.scss'],
28
})
29
export class CardSpriteHeader implements OnInit {
30
31
    constructor(
32
        public gd: GameDataService
33
    ) { }
34
35
    ngOnInit() {
36
        const sprites: Sprite[] = this.gd.file("sprites").data;
37
        sprites.forEach((el: Sprite) => {
38
            this.sprites[el.ind] = el;
39
        });
40
    }
41
42
    @Input()
43
    public entry: any = new SpriteData(true);
44
45
    @Input()
46
    public disabled: boolean = false;
47
48
    public get coords() {
49
        const sprite: SpriteData = this.entry;
50
        return `(${sprite.mapX}, ${sprite.mapY})`;
51
    }
52
53
    public get spriteName() {
54
        const data = this.sprites[this.entry.pictureID];
55
        if (data === null || data === undefined || !(this.entry.pictureID > 0))
56
            return "";
57
        else
58
            return data.name;
59
    }
60
61
    public get isNonTrainer() {
62
        return this.entry.trainerClassOrItemID == 0;
63
    }
64
65
    public get isItem() {
66
        return this.entry.trainerClassOrItemID > 0 &&
67
            this.entry.trainerSetID == 0;
68
    }
69
70
    public get isTrainer() {
71
        return this.entry.trainerClassOrItemID > 0 &&
72
            this.entry.trainerSetID > 0;
73
    }
74
75
    public get isMovementStay() {
76
        return this.entry.movementByte == 0xFF;
77
    }
78
79
    public get isMovementWander() {
80
        return this.entry.movementByte == 0xFE;
81
    }
82
83
    public get isMovementInvalid() {
84
        return !this.isMovementStay && !this.isMovementWander;
85
    }
86
87
    public get isPlayerSprite() {
88
        return this.entry.rangeDirByte == null;
89
    }
90
91
    public get isNormalSprite() {
92
        return !this.isPlayerSprite;
93
    }
94
95
    public get isMissable() {
96
        return this.entry.missableIndex > -1;
97
    }
98
99
    public sprites: any[] = [];
100
}
101