Passed
Pull Request — master (#23)
by
unknown
09:10 queued 04:58
created

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

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 105
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 71
dl 0
loc 105
rs 10
c 0
b 0
f 0
wmc 3
mnd 1
bc 1
fnc 2
bpm 0.5
cpm 1.5
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A CardSpriteComponent.ngOnInit 0 5 1
A CardSpriteComponent.setScreen 0 3 2
1
import { Sprite } from './../../../assets/data/sprites.d';
2
import { GameDataService } from './../../data/gameData.service';
3
import { SpriteData } from './../../data/savefile-expanded/fragments/SpriteData';
4
import { OnInit, EventEmitter, Output } from '@angular/core';
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
23
@Component({
24
    selector: 'card-sprite',
25
    templateUrl: './card-sprite.component.pug',
26
    styleUrls: ['./card-sprite.component.scss'],
27
})
28
export class CardSpriteComponent implements OnInit {
29
30
    constructor(
31
        public gd: GameDataService
32
    ) { }
33
34
    ngOnInit() {
35
        const sprites: Sprite[] = this.gd.file("sprites").data;
36
        sprites.forEach((el: Sprite) => {
37
            this.sprites[el.ind] = el;
38
        });
39
    }
40
41
    @Input()
42
    public entry: any = new SpriteData(true);
43
44
    @Input()
45
    public disabled: boolean = false;
46
47
    @Output()
48
    public rem: EventEmitter<boolean> = new EventEmitter();
49
50
    public get spriteName() {
51
        const data = this.sprites[this.entry.pictureID];
52
        if (data === null || data === undefined || !(this.entry.pictureID > 0))
53
            return "";
54
        else
55
            return data.name;
56
    }
57
58
    public get isNonTrainer() {
59
        return this.entry.trainerClassOrItemID == 0;
60
    }
61
62
    public get isItem() {
63
        return this.entry.trainerClassOrItemID > 0 &&
64
            this.entry.trainerSetID == 0;
65
    }
66
67
    public get isTrainer() {
68
        return this.entry.trainerClassOrItemID > 0 &&
69
            this.entry.trainerSetID > 0;
70
    }
71
72
    public get isMovementStay() {
73
        return this.entry.movementByte == 0xFF;
74
    }
75
76
    public get isMovementWander() {
77
        return this.entry.movementByte == 0xFE;
78
    }
79
80
    public get isMovementInvalid() {
81
        return !this.isMovementStay && !this.isMovementWander;
82
    }
83
84
    public get isPlayerSprite() {
85
        return this.entry.rangeDirByte == null;
86
    }
87
88
    public get isNormalSprite() {
89
        return !this.isPlayerSprite;
90
    }
91
92
    public get isMissable() {
93
        return this.entry.missableIndex > -1;
94
    }
95
96
    public setScreen(name: string) {
97
        this.screen = name;
98
    }
99
100
    // Current screen to display
101
    public screen: string = "basics/sprite";
102
103
    public sprites: any[] = [];
104
}
105