Passed
Pull Request — master (#280)
by Vincent
13:25
created

MonsterFighterSprite(Fighter,Monster)   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
ccs 3
cts 3
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.fight.fighter.Fighter;
25
import fr.quatrevieux.araknemu.game.monster.Monster;
26
import fr.quatrevieux.araknemu.game.world.creature.Sprite;
27
28
/**
29
 * Sprite for monster
30
 *
31
 * The sprite type ID MUST be the class id
32
 *
33
 * https://github.com/Emudofus/Dofus/blob/1.29/dofus/aks/Game.as#L520
34
 */
35
public final class MonsterFighterSprite implements Sprite {
36
    private final Fighter fighter;
37
    private final Monster monster;
38
39 1
    public MonsterFighterSprite(Fighter fighter, Monster monster) {
40 1
        this.fighter = fighter;
41 1
        this.monster = monster;
42 1
    }
43
44
    @Override
45
    public int id() {
46 1
        return fighter.id();
47
    }
48
49
    @Override
50
    public int cell() {
51 1
        return fighter.dead() || fighter.hidden() ? -1 : fighter.cell().id();
52
    }
53
54
    @Override
55
    public Direction orientation() {
56 1
        return fighter.orientation();
57
    }
58
59
    @Override
60
    public Type type() {
61 1
        return Type.MONSTER;
62
    }
63
64
    @Override
65
    public int gfxId() {
66 1
        return monster.gfxId();
67
    }
68
69
    @Override
70
    public String name() {
71 1
        return Integer.toString(monster.id());
72
    }
73
74
    @Override
75
    public String toString() {
76 1
        return
77 1
            cell() + ";" +
78 1
            fighter.orientation().ordinal() + ";" +
79
            "0;" + // @todo Bonus value (get from group ?)
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
80 1
            id() + ";" +
81 1
            name() + ";" +
82 1
            type().id() + ";" +
83 1
            gfxId() + "^100;" + // @todo size
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
84 1
            monster.gradeNumber() + ";" +
85 1
            monster.colors().toHexString(";") + ";" +
86
            "0,0,0,0;" + // @todo accessories
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
87 1
            fighter.life().current() + ";" +
88 1
            fighter.characteristics().get(Characteristic.ACTION_POINT) + ";" +
89 1
            fighter.characteristics().get(Characteristic.MOVEMENT_POINT) + ";" +
90 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_NEUTRAL) + ";" +
91 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_EARTH) + ";" +
92 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_FIRE) + ";" +
93 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_WATER) + ";" +
94 1
            fighter.characteristics().get(Characteristic.RESISTANCE_PERCENT_AIR) + ";" +
95 1
            fighter.characteristics().get(Characteristic.RESISTANCE_ACTION_POINT) + ";" +
96 1
            fighter.characteristics().get(Characteristic.RESISTANCE_MOVEMENT_POINT) + ";" +
97 1
            fighter.team().number()
98
        ;
99
    }
100
}
101