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 |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
package fr.quatrevieux.araknemu.game.listener.map.fight; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.core.event.EventsSubscriber; |
23
|
|
|
import fr.quatrevieux.araknemu.core.event.Listener; |
24
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.ExplorationMap; |
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.team.event.AllowJoinTeamChanged; |
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.team.event.AllowSpectatorChanged; |
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.team.event.NeedHelpChanged; |
28
|
|
|
import fr.quatrevieux.araknemu.network.game.out.fight.FightOption; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Send to the map the changed team fight option |
32
|
|
|
*/ |
33
|
|
|
public final class SendTeamOptionChanged implements EventsSubscriber { |
34
|
|
|
private final ExplorationMap map; |
35
|
|
|
|
36
|
1 |
|
public SendTeamOptionChanged(ExplorationMap map) { |
37
|
1 |
|
this.map = map; |
38
|
1 |
|
} |
39
|
|
|
|
40
|
|
|
@Override |
41
|
|
|
public Listener[] listeners() { |
42
|
1 |
|
return new Listener[] { |
43
|
1 |
|
new Listener<AllowSpectatorChanged>() { |
44
|
|
|
@Override |
45
|
|
|
public void on(AllowSpectatorChanged event) { |
46
|
1 |
|
map.send(FightOption.blockSpectators(event.options())); |
47
|
1 |
|
} |
48
|
|
|
|
49
|
|
|
@Override |
50
|
|
|
public Class<AllowSpectatorChanged> event() { |
51
|
1 |
|
return AllowSpectatorChanged.class; |
52
|
|
|
} |
53
|
|
|
}, |
54
|
1 |
|
new Listener<AllowJoinTeamChanged>() { |
55
|
|
|
@Override |
56
|
|
|
public void on(AllowJoinTeamChanged event) { |
57
|
1 |
|
map.send(FightOption.blockJoiner(event.options())); |
58
|
1 |
|
} |
59
|
|
|
|
60
|
|
|
@Override |
61
|
|
|
public Class<AllowJoinTeamChanged> event() { |
62
|
1 |
|
return AllowJoinTeamChanged.class; |
63
|
|
|
} |
64
|
|
|
}, |
65
|
1 |
|
new Listener<NeedHelpChanged>() { |
66
|
|
|
@Override |
67
|
|
|
public void on(NeedHelpChanged event) { |
68
|
1 |
|
map.send(FightOption.needHelp(event.options())); |
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
@Override |
72
|
|
|
public Class<NeedHelpChanged> event() { |
73
|
1 |
|
return NeedHelpChanged.class; |
74
|
|
|
} |
75
|
|
|
}, |
76
|
|
|
}; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|