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-2019 Vincent Quatrevieux |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.network.game.out.fight.turn; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.data.constant.Characteristic; |
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter; |
24
|
|
|
|
25
|
|
|
import java.util.Collection; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Send fighters information between two turns |
29
|
|
|
* |
30
|
|
|
* https://github.com/Emudofus/Dofus/blob/1.29/dofus/aks/Game.as#L326 |
31
|
|
|
*/ |
32
|
|
|
public final class TurnMiddle { |
33
|
|
|
private final Collection<Fighter> fighters; |
34
|
|
|
|
35
|
1 |
|
public TurnMiddle(Collection<Fighter> fighters) { |
36
|
1 |
|
this.fighters = fighters; |
37
|
1 |
|
} |
38
|
|
|
|
39
|
|
|
@Override |
40
|
|
|
public String toString() { |
41
|
1 |
|
final StringBuilder sb = new StringBuilder("GTM"); |
42
|
|
|
|
43
|
1 |
|
for (Fighter fighter : fighters) { |
44
|
1 |
|
sb.append('|').append(fighter.id()).append(';'); |
45
|
|
|
|
46
|
1 |
|
if (fighter.dead()) { |
47
|
1 |
|
sb.append(1); |
48
|
1 |
|
continue; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
final int actionPoints; |
52
|
|
|
final int movementPoints; |
53
|
|
|
|
54
|
1 |
|
if (fighter.isPlaying()) { |
55
|
1 |
|
actionPoints = fighter.turn().points().actionPoints(); |
56
|
1 |
|
movementPoints = fighter.turn().points().movementPoints(); |
57
|
|
|
} else { |
58
|
1 |
|
actionPoints = fighter.characteristics().get(Characteristic.ACTION_POINT); |
59
|
1 |
|
movementPoints = fighter.characteristics().get(Characteristic.MOVEMENT_POINT); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
sb.append("0;").append(fighter.life().current()).append(';') |
63
|
1 |
|
.append(actionPoints).append(';') |
64
|
1 |
|
.append(movementPoints).append(';') |
65
|
1 |
|
.append(fighter.hidden() ? -1 : fighter.cell().id()).append(';') // @todo send real cell to hidden fighter ? |
|
|
|
|
66
|
1 |
|
.append(';') // Not used by client (line 348) |
67
|
1 |
|
.append(fighter.life().max()) |
68
|
|
|
; |
69
|
1 |
|
} |
70
|
|
|
|
71
|
1 |
|
return sb.toString(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|