equals(Object)   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 8
dl 0
loc 13
ccs 0
cts 6
cp 0
crap 20
rs 10
c 0
b 0
f 0
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.realm.host;
21
22
import org.checkerframework.checker.nullness.qual.Nullable;
23
24
/**
25
 * Host for game server
26
 */
27
public final class GameHost {
28 1
    public enum State {
29 1
        OFFLINE,
30 1
        ONLINE,
31 1
        SAVING
32
    }
33
34
    private final GameConnector connector;
35
    private final int id;
36
    private final int port;
37
    private final String ip;
38
39
    // @todo Quelle valeur ?
0 ignored issues
show
introduced by
Comment matches to-do format '(TODO:)|(@todo )'.
Loading history...
40 1
    private int completion = 110;
41 1
    private boolean canLog = false;
42 1
    private State state    = State.OFFLINE;
43
44 1
    public GameHost(GameConnector connector, int id, int port, String ip) {
45 1
        this.connector = connector;
46 1
        this.id = id;
47 1
        this.port = port;
48 1
        this.ip = ip;
49 1
    }
50
51
    /**
52
     * Get the server ID
53
     * MUST be present is Dofus langs
54
     */
55
    public int id() {
56 1
        return id;
57
    }
58
59
    /**
60
     * Get the server port
61
     */
62
    public int port() {
63 1
        return port;
64
    }
65
66
    /**
67
     * Get the server IP address
68
     */
69
    public String ip() {
70 1
        return ip;
71
    }
72
73
    /**
74
     * Get the server completion
75
     */
76
    public int completion() {
77 1
        return completion;
78
    }
79
80
    /**
81
     * Check if can log into the server
82
     */
83
    public boolean canLog() {
84 1
        return canLog;
85
    }
86
87
    /**
88
     * Set if can log into the server
89
     */
90
    public void setCanLog(boolean b) {
91 1
        canLog = b;
92 1
    }
93
94
    /**
95
     * Get the current server state
96
     */
97
    public State state() {
98 1
        return state;
99
    }
100
101
    /**
102
     * Set the server state
103
     */
104
    public void setState(State state) {
105 1
        this.state = state;
106 1
    }
107
108
    /**
109
     * Get the connector for this host
110
     */
111
    public GameConnector connector() {
112 1
        return connector;
113
    }
114
115
    @Override
116
    public boolean equals(@Nullable Object o) {
117
        if (this == o) {
118
            return true;
119
        }
120
121
        if (o == null || getClass() != o.getClass()) {
122
            return false;
123
        }
124
125
        final GameHost host = (GameHost) o;
126
127
        return id == host.id;
128
    }
129
130
    @Override
131
    public int hashCode() {
132 1
        return id;
133
    }
134
}
135