Passed
Push — master ( 39f6d6...d30cfc )
by Vincent
05:49 queued 10s
created

fr.quatrevieux.araknemu.game.fight.turn.action.move.MoveFailed   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
eloc 35
dl 0
loc 59
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A success() 0 3 1
A arguments() 0 3 1
A lostMovementPoints() 0 3 1
A performer() 0 3 1
A MoveFailed(Fighter,int) 0 3 1
A target() 0 3 1
A orientation() 0 3 1
A path() 0 5 1
A lostActionPoints() 0 3 1
A action() 0 3 1
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-2021 Vincent Quatrevieux, Jean-Alexandre Valentin
18
 */
19
20
package fr.quatrevieux.araknemu.game.fight.turn.action.move;
21
22
import fr.arakne.utils.maps.constant.Direction;
23
import fr.arakne.utils.maps.path.Decoder;
24
import fr.arakne.utils.maps.path.Path;
25
import fr.arakne.utils.maps.path.PathStep;
26
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter;
27
import fr.quatrevieux.araknemu.game.fight.map.FightCell;
28
29
import java.util.Collections;
30
31
/**
32
 * The fighter has been tackle during its move action
33
 * He'll lose all its MP, and some AP
34
 */
35
public final class MoveFailed implements MoveResult {
36
    private final Fighter performer;
37
    private final int lostActionPoints;
38
39
    /**
40
     * @param performer The current fighter
41
     * @param lostActionPoints Number of lost action points
42
     */
43 1
    public MoveFailed(Fighter performer, int lostActionPoints) {
44 1
        this.performer = performer;
45 1
        this.lostActionPoints = lostActionPoints;
46 1
    }
47
48
    @Override
49
    public int action() {
50 1
        return 104;
51
    }
52
53
    @Override
54
    public boolean success() {
55 1
        return false;
56
    }
57
58
    @Override
59
    public int lostActionPoints() {
60 1
        return lostActionPoints;
61
    }
62
63
    @Override
64
    public Path<FightCell> path() {
65 1
        return new Path<>(
66 1
            new Decoder<>(performer.cell().map()),
67 1
            Collections.singletonList(new PathStep<>(performer.cell(), Direction.EAST))
68
        );
69
    }
70
71
    @Override
72
    public Fighter performer() {
73 1
        return performer;
74
    }
75
76
    @Override
77
    public Direction orientation() {
78
        return performer.orientation();
79
    }
80
81
    @Override
82
    public int lostMovementPoints() {
83 1
        return performer.turn().points().movementPoints();
84
    }
85
86
    @Override
87
    public FightCell target() {
88 1
        return performer.cell();
89
    }
90
91
    @Override
92
    public Object[] arguments() {
93 1
        return new Object[0];
94
    }
95
}
96