fr.quatrevieux.araknemu.network.game.in.account.DeleteCharacterRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 2 1
A answer() 0 2 1
A Parser.parse(String) 0 7 1
A Parser.code() 0 3 1
A DeleteCharacterRequest(int,String) 0 3 1
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.network.game.in.account;
21
22
import fr.quatrevieux.araknemu.core.network.parser.Packet;
23
import fr.quatrevieux.araknemu.core.network.parser.PacketTokenizer;
24
import fr.quatrevieux.araknemu.core.network.parser.ParsePacketException;
25
import fr.quatrevieux.araknemu.core.network.parser.SinglePacketParser;
26
import org.checkerframework.common.value.qual.MinLen;
27
28
/**
29
 * Ask for character deletion
30
 *
31
 * https://github.com/Emudofus/Dofus/blob/1.29/dofus/aks/Account.as#L94
32
 */
33
public final class DeleteCharacterRequest implements Packet {
34
    private final int id;
35
    private final String answer;
36
37 1
    public DeleteCharacterRequest(int id, String answer) {
38 1
        this.id = id;
39 1
        this.answer = answer;
40 1
    }
41
42
    public int id() {
43 1
        return id;
44
    }
45
46
    public String answer() {
47 1
        return answer;
48
    }
49
50 1
    public static final class Parser implements SinglePacketParser<DeleteCharacterRequest> {
51
        @Override
52
        public DeleteCharacterRequest parse(String input) throws ParsePacketException {
53 1
            final PacketTokenizer tokenizer = tokenize(input, '|');
54
55 1
            return new DeleteCharacterRequest(
56 1
                tokenizer.nextInt(),
57 1
                tokenizer.nextPartOrDefault("")
58
            );
59
        }
60
61
        @Override
62
        public @MinLen(2) String code() {
63 1
            return "AD";
64
        }
65
    }
66
}
67