Passed
Branch master (3db100)
by Vincent
12:21
created

joinTeamLocked()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
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
24
import java.time.Instant;
25
import java.time.LocalDateTime;
26
import java.time.ZoneId;
27
28
/**
29
 * Information messages
30
 */
31
public final class Information extends AbstractInformationMessage {
32
    public Information(Entry... entries) {
33 1
        super(Type.INFO, entries);
34 1
    }
35
36
    public Information(int id) {
37 1
        this(new Entry(id));
38 1
    }
39
40
    public Information(int id, Object... arguments) {
41 1
        this(new Entry(id, arguments));
42 1
    }
43
44
    /**
45
     * Message for global channel flood
46
     *
47
     * @param remainingSeconds Remaining time in seconds before send another message
48
     */
49
    public static Information chatFlood(int remainingSeconds) {
50 1
        return new Information(115, remainingSeconds);
51
    }
52
53
    /**
54
     * An item cannot be posted to the channel
55
     */
56
    public static Information cannotPostItemOnChannel() {
57 1
        return new Information(114);
58
    }
59
60
    /**
61
     * Add life points message
62
     *
63
     * @param value The recovered life points
64
     */
65
    public static Information heal(int value) {
66 1
        return new Information(1, value);
67
    }
68
69
    /**
70
     * Message for spell learned
71
     *
72
     * @param spellId The learned spell id
73
     */
74
    public static Information spellLearn(int spellId) {
75 1
        return new Information(3, spellId);
76
    }
77
78
    /**
79
     * Send message for characteristic boost
80
     *
81
     * @param characteristic The boosted characteristic
82
     * @param value The boost value
83
     */
84
    public static Information characteristicBoosted(Characteristic characteristic, int value) {
85 1
        switch (characteristic) {
86
            case WISDOM:
87 1
                return new Information(9, value);
88
            case STRENGTH:
89 1
                return new Information(10, value);
90
            case LUCK:
91 1
                return new Information(11, value);
92
            case AGILITY:
93 1
                return new Information(12, value);
94
            case VITALITY:
95 1
                return new Information(13, value);
96
            case INTELLIGENCE:
97 1
                return new Information(14, value);
98
        }
99
100 1
        return null;
101
    }
102
103
    /**
104
     * The position of the player is saved
105
     */
106
    public static Information positionSaved() {
107 1
        return new Information(6);
108
    }
109
110
    /**
111
     * The bank tax has been payed
112
     *
113
     * @param cost The kamas given by the player
114
     */
115
    public static Information bankTaxPayed(long cost) {
116 1
        return new Information(20, cost);
117
    }
118
119
    /**
120
     * Show the last login date and IP address
121
     *
122
     * @param date Last login date
123
     * @param ipAddress Last login IP address
124
     */
125
    public static Information lastLogin(Instant date, String ipAddress) {
126 1
        final LocalDateTime localDateTime = LocalDateTime.ofInstant(date, ZoneId.systemDefault());
127
128 1
        return new Information(
129
            152,
130 1
            localDateTime.getYear(), localDateTime.getMonthValue(), localDateTime.getDayOfMonth(),
131 1
            localDateTime.getHour(), localDateTime.getMinute(),
132
            ipAddress
133
        );
134
    }
135
136
    /**
137
     * Show the current IP address
138
     *
139
     * @param ipAddress IP address to show
140
     */
141
    public static Information currentIpAddress(String ipAddress) {
142 1
        return new Information(153, ipAddress);
143
    }
144
145
    /**
146
     * Inform fighter that a spectator has joined the fight
147
     *
148
     * @param spectatorName The spectator name
149
     */
150
    public static Information spectatorHasJoinFight(String spectatorName) {
151 1
        return new Information(36, spectatorName);
152
    }
153
154
    /**
155
     * The fight team request help
156
     */
157
    public static Information helpRequested() {
158 1
        return new Information(103);
159
    }
160
161
    /**
162
     * The help requested has been stopped
163
     */
164
    public static Information helpRequestStopped() {
165 1
        return new Information(104);
166
    }
167
168
    /**
169
     * The fight team has been locked
170
     */
171
    public static Information joinTeamLocked() {
172 1
        return new Information(95);
173
    }
174
175
    /**
176
     * The fight team has released join of new fighters
177
     */
178
    public static Information joinTeamReleased() {
179 1
        return new Information(96);
180
    }
181
182
    /**
183
     * Spectators has been blocked on the fight
184
     */
185
    public static Information spectatorsBlocked() {
186 1
        return new Information(40);
187
    }
188
189
    /**
190
     * Spectators has been allowed on the fight
191
     */
192
    public static Information spectatorsAllowed() {
193 1
        return new Information(39);
194
    }
195
}
196