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
|
|
|
import fr.quatrevieux.araknemu.game.fight.turn.FightTurn; |
29
|
|
|
|
30
|
|
|
import java.util.Collections; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The fighter has been tackle during its move action |
34
|
|
|
* He'll lose all its MP, and some AP |
35
|
|
|
*/ |
36
|
|
|
public final class MoveFailed implements MoveResult { |
37
|
|
|
private final Fighter performer; |
38
|
|
|
private final int lostActionPoints; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param performer The current fighter |
42
|
|
|
* @param lostActionPoints Number of lost action points |
43
|
|
|
*/ |
44
|
1 |
|
public MoveFailed(Fighter performer, int lostActionPoints) { |
45
|
1 |
|
this.performer = performer; |
46
|
1 |
|
this.lostActionPoints = lostActionPoints; |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
@Override |
50
|
|
|
public int action() { |
51
|
1 |
|
return 104; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
@Override |
55
|
|
|
public boolean success() { |
56
|
1 |
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
@Override |
60
|
|
|
public boolean secret() { |
61
|
1 |
|
return performer.hidden(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
@Override |
65
|
|
|
public int lostActionPoints() { |
66
|
1 |
|
return lostActionPoints; |
67
|
1 |
|
} |
68
|
1 |
|
|
69
|
|
|
@Override |
70
|
|
|
public Path<FightCell> path() { |
71
|
|
|
return new Path<>( |
72
|
|
|
new Decoder<>(performer.cell().map()), |
73
|
|
|
Collections.singletonList(new PathStep<>(performer.cell(), Direction.EAST)) |
74
|
1 |
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
@Override |
78
|
|
|
public Fighter performer() { |
79
|
|
|
return performer; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
@Override |
83
|
|
|
public Direction orientation() { |
84
|
1 |
|
return performer.orientation(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
@Override |
88
|
|
|
public int lostMovementPoints() { |
89
|
1 |
|
return performer.turn().points().movementPoints(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
@Override |
93
|
|
|
public FightCell target() { |
94
|
1 |
|
return performer.cell(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
@Override |
98
|
|
|
public Object[] arguments() { |
99
|
1 |
|
return new Object[0]; |
100
|
1 |
|
} |
101
|
|
|
|
102
|
|
|
@Override |
103
|
1 |
|
public void apply(FightTurn turn) { |
104
|
1 |
|
if (lostActionPoints > 0) { |
105
|
|
|
turn.points().useActionPoints(lostActionPoints); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
turn.points().useMovementPoints(turn.points().movementPoints()); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|