Test Failed
Pull Request — master (#239)
by Vincent
14:03
created

fr.quatrevieux.araknemu.network.game.out.game.FightStartPositions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toString() 0 12 1
A FightStartPositions(MapCell[[]],int) 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-2020 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.network.game.out.game;
21
22
import fr.arakne.utils.encoding.Base64;
23
import fr.arakne.utils.maps.MapCell;
24
25
import java.util.Arrays;
26
import java.util.stream.Collectors;
27
28
/**
29
 * Send the start positions on fight
30
 *
31
 * https://github.com/Emudofus/Dofus/blob/1.29/dofus/aks/Game.as#L145
32
 */
33
public final class FightStartPositions {
34
    private final MapCell[][] places;
35
    private final int team;
36
37 1
    public FightStartPositions(MapCell[][] places, int team) {
38 1
        this.places = places;
39 1
        this.team = team;
40 1
    }
41
42
    @Override
43
    public String toString() {
44 1
        return "GP" +
45 1
            Arrays.stream(places)
46 1
                .map(
47
                    list -> Arrays.stream(list)
48 1
                        .mapToInt(MapCell::id)
49 1
                        .mapToObj(i -> Base64.encode(i, 2))
50 1
                        .collect(Collectors.joining())
51
                )
52 1
                .collect(Collectors.joining("|")) +
53
            "|" + team
54
        ;
55
    }
56
}
57