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.network.game.out.info; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.data.constant.Characteristic; |
23
|
|
|
import fr.quatrevieux.araknemu.game.exploration.ExplorationPlayer; |
|
|
|
|
24
|
|
|
|
25
|
|
|
import java.time.Instant; |
26
|
|
|
import java.time.LocalDateTime; |
27
|
|
|
import java.time.ZoneId; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Information messages |
31
|
|
|
*/ |
32
|
|
|
public final class Information extends AbstractInformationMessage { |
33
|
|
|
public Information(Entry... entries) { |
34
|
1 |
|
super(Type.INFO, entries); |
35
|
1 |
|
} |
36
|
|
|
|
37
|
|
|
public Information(int id) { |
38
|
1 |
|
this(new Entry(id)); |
39
|
1 |
|
} |
40
|
|
|
|
41
|
|
|
public Information(int id, Object... arguments) { |
42
|
1 |
|
this(new Entry(id, arguments)); |
43
|
1 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Message for global channel flood |
47
|
|
|
* |
48
|
|
|
* @param remainingSeconds Remaining time in seconds before send another message |
49
|
|
|
*/ |
50
|
|
|
public static Information chatFlood(int remainingSeconds) { |
51
|
1 |
|
return new Information(115, remainingSeconds); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* An item cannot be posted to the channel |
56
|
|
|
*/ |
57
|
|
|
public static Information cannotPostItemOnChannel() { |
58
|
1 |
|
return new Information(114); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Add life points message |
63
|
|
|
* |
64
|
|
|
* @param value The recovered life points |
65
|
|
|
*/ |
66
|
|
|
public static Information heal(int value) { |
67
|
1 |
|
return new Information(1, value); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Message for spell learned |
72
|
|
|
* |
73
|
|
|
* @param spellId The learned spell id |
74
|
|
|
*/ |
75
|
|
|
public static Information spellLearn(int spellId) { |
76
|
1 |
|
return new Information(3, spellId); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Send message for characteristic boost |
81
|
|
|
* |
82
|
|
|
* @param characteristic The boosted characteristic |
83
|
|
|
* @param value The boost value |
84
|
|
|
*/ |
85
|
|
|
public static Information characteristicBoosted(Characteristic characteristic, int value) { |
86
|
1 |
|
switch (characteristic) { |
87
|
|
|
case WISDOM: |
88
|
1 |
|
return new Information(9, value); |
89
|
|
|
case STRENGTH: |
90
|
1 |
|
return new Information(10, value); |
91
|
|
|
case LUCK: |
92
|
1 |
|
return new Information(11, value); |
93
|
|
|
case AGILITY: |
94
|
1 |
|
return new Information(12, value); |
95
|
|
|
case VITALITY: |
96
|
1 |
|
return new Information(13, value); |
97
|
|
|
case INTELLIGENCE: |
98
|
1 |
|
return new Information(14, value); |
99
|
|
|
} |
100
|
|
|
|
101
|
1 |
|
return null; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* The position of the player is saved |
106
|
|
|
*/ |
107
|
|
|
public static Information positionSaved() { |
108
|
1 |
|
return new Information(6); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* The bank tax has been payed |
113
|
|
|
* |
114
|
|
|
* @param cost The kamas given by the player |
115
|
|
|
*/ |
116
|
|
|
public static Information bankTaxPayed(long cost) { |
117
|
1 |
|
return new Information(20, cost); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Show the last login date and IP address |
122
|
|
|
* |
123
|
|
|
* @param date Last login date |
124
|
|
|
* @param ipAddress Last login IP address |
125
|
|
|
*/ |
126
|
|
|
public static Information lastLogin(Instant date, String ipAddress) { |
127
|
1 |
|
final LocalDateTime localDateTime = LocalDateTime.ofInstant(date, ZoneId.systemDefault()); |
128
|
|
|
|
129
|
1 |
|
return new Information( |
130
|
|
|
152, |
131
|
1 |
|
localDateTime.getYear(), localDateTime.getMonthValue(), localDateTime.getDayOfMonth(), |
132
|
1 |
|
localDateTime.getHour(), localDateTime.getMinute(), |
133
|
|
|
ipAddress |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Show the current IP address |
139
|
|
|
* |
140
|
|
|
* @param ipAddress IP address to show |
141
|
|
|
*/ |
142
|
|
|
public static Information currentIpAddress(String ipAddress) { |
143
|
1 |
|
return new Information(153, ipAddress); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Inform fighter that a spectator has joined the fight |
148
|
|
|
* |
149
|
|
|
* @param spectatorName The spectator name |
150
|
|
|
*/ |
151
|
|
|
public static Information spectatorHasJoinFight(String spectatorName) { |
152
|
1 |
|
return new Information(36, spectatorName); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|