Passed
Pull Request — master (#222)
by Vincent
11:14
created

gfxId()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
/*
2
 * This file is part of Araknemu.
3
 *
4
 * Araknemu is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * Araknemu is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with Araknemu.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.fight.fighter.monster;
21
22
import fr.arakne.utils.maps.constant.Direction;
23
import fr.quatrevieux.araknemu.data.constant.Characteristic;
24
import fr.quatrevieux.araknemu.game.monster.Monster;
25
import fr.quatrevieux.araknemu.game.world.creature.Sprite;
26
27
/**
28
 * Sprite for monster
29
 *
30
 * The sprite type ID MUST be the class id
31
 *
32
 * https://github.com/Emudofus/Dofus/blob/1.29/dofus/aks/Game.as#L520
33
 */
34
public final class MonsterFighterSprite implements Sprite {
35
    private final MonsterFighter fighter;
36
    private final Monster monster;
37
38 1
    public MonsterFighterSprite(MonsterFighter fighter, Monster monster) {
39 1
        this.fighter = fighter;
40 1
        this.monster = monster;
41 1
    }
42
43
    @Override
44
    public int id() {
45 1
        return fighter.id();
46
    }
47
48
    @Override
49
    public int cell() {
50 1
        return fighter.dead() ? -1 : fighter.cell().id();
51
    }
52
53
    @Override
54
    public Direction orientation() {
55 1
        return fighter.orientation();
56
    }
57
58
    @Override
59
    public Type type() {
60 1
        return Type.MONSTER;
61
    }
62
63
    @Override
64
    public int gfxId() {
65 1
        return monster.gfxId();
66
    }
67
68
    @Override
69
    public String name() {
70 1
        return Integer.toString(monster.id());
71
    }
72
73
    @Override
74
    public String toString() {
75 1
        return
76 1
            cell() + ";" +
77 1
            fighter.orientation().ordinal() + ";" +
78
            "0;" + // @todo Bonus value (get from group ?)
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
79 1
            id() + ";" +
80 1
            name() + ";" +
81 1
            type().id() + ";" +
82 1
            gfxId() + "^100;" + // @todo size
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
83 1
            monster.gradeNumber() + ";" +
84 1
            monster.colors().toHexString(";") + ";" +
85
            "0,0,0,0;" + // @todo accessories
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
86 1
            fighter.life().current() + ";" +
87 1
            fighter.characteristics().get(Characteristic.ACTION_POINT) + ";" +
88 1
            fighter.characteristics().get(Characteristic.MOVEMENT_POINT) + ";" +
89 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_NEUTRAL) + ";" +
90 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_EARTH) + ";" +
91 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_FIRE) + ";" +
92 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_WATER) + ";" +
93 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_AIR) + ";" +
94 1
            fighter.characteristics().get(Characteristic.RESISTANCE_ACTION_POINT) + ";" +
95 1
            fighter.characteristics().get(Characteristic.RESISTANCE_MOVEMENT_POINT) + ";" +
96 1
            fighter.team().number()
97
        ;
98
    }
99
}
100