|
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.admin.debug; |
|
21
|
|
|
|
|
22
|
|
|
import fr.arakne.utils.maps.MapCell; |
|
23
|
|
|
import fr.quatrevieux.araknemu.common.account.Permission; |
|
24
|
|
|
import fr.quatrevieux.araknemu.data.value.EffectArea; |
|
25
|
|
|
import fr.quatrevieux.araknemu.data.world.transformer.EffectAreaTransformer; |
|
26
|
|
|
import fr.quatrevieux.araknemu.game.admin.AbstractCommand; |
|
27
|
|
|
import fr.quatrevieux.araknemu.game.admin.AdminPerformer; |
|
28
|
|
|
import fr.quatrevieux.araknemu.game.admin.AdminUser; |
|
29
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.ExplorationMap; |
|
30
|
|
|
import fr.quatrevieux.araknemu.game.spell.effect.SpellEffectService; |
|
31
|
|
|
import fr.quatrevieux.araknemu.network.game.out.game.FightStartPositions; |
|
32
|
|
|
|
|
33
|
|
|
import java.util.ArrayList; |
|
34
|
|
|
import java.util.Arrays; |
|
35
|
|
|
import java.util.List; |
|
36
|
|
|
import java.util.stream.Collectors; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Display effect area |
|
40
|
|
|
*/ |
|
41
|
|
|
public final class Area extends AbstractCommand<String> { |
|
42
|
|
|
private final SpellEffectService service; |
|
43
|
|
|
private final EffectAreaTransformer areaTransformer; |
|
44
|
|
|
|
|
45
|
1 |
|
public Area(SpellEffectService service) { |
|
46
|
1 |
|
this.service = service; |
|
47
|
1 |
|
this.areaTransformer = new EffectAreaTransformer(); |
|
48
|
1 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
@Override |
|
51
|
|
|
protected void build(Builder builder) { |
|
52
|
|
|
builder |
|
53
|
|
|
.requires(Permission.DEBUG) |
|
54
|
|
|
.description("Display spell effect area") |
|
55
|
|
|
.help( |
|
56
|
|
|
formatter -> formatter |
|
57
|
|
|
.synopsis("area [area string]") |
|
58
|
|
|
.options( |
|
59
|
|
|
"area string", |
|
60
|
|
|
"Contains two chars, the first one is the area type, the second if the size in pseudo base 64\n" + |
|
61
|
|
|
"Types :\n" + |
|
62
|
|
|
Arrays.stream(EffectArea.Type.values()) |
|
63
|
|
|
.map(type -> "\t" + type.name() + " : " + type.c()) |
|
64
|
|
|
.collect(Collectors.joining("\n")) |
|
65
|
|
|
) |
|
66
|
|
|
.example("area Cb", "Circle of size 1") |
|
67
|
|
|
.example("area Tc", "Perpendicular line of size 2") |
|
68
|
|
|
) |
|
69
|
|
|
; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
@Override |
|
73
|
|
|
public String name() { |
|
74
|
1 |
|
return "area"; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
@Override |
|
78
|
|
|
public void execute(AdminPerformer performer, String arguments) { |
|
79
|
1 |
|
final AdminUser user = AdminUser.class.cast(performer); |
|
80
|
1 |
|
final EffectArea area = areaTransformer.unserialize(arguments); |
|
81
|
1 |
|
final ExplorationMap map = user.player().exploration().map(); |
|
82
|
|
|
|
|
83
|
1 |
|
final List<Integer> cells = service.area(area) |
|
84
|
1 |
|
.resolve( |
|
85
|
1 |
|
map.get(user.player().position().cell()), |
|
86
|
1 |
|
map.get(user.player().position().cell()) |
|
87
|
|
|
) |
|
88
|
1 |
|
.stream() |
|
89
|
1 |
|
.map(MapCell::id) |
|
90
|
1 |
|
.collect(Collectors.toList()) |
|
91
|
|
|
; |
|
92
|
|
|
|
|
93
|
1 |
|
user.send( |
|
94
|
|
|
new FightStartPositions( |
|
95
|
|
|
new List[] { |
|
96
|
|
|
cells, |
|
97
|
|
|
new ArrayList(), |
|
98
|
|
|
}, |
|
99
|
|
|
0 |
|
100
|
|
|
) |
|
101
|
|
|
); |
|
102
|
1 |
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|