fr.arakne.utils.maps.BattlefieldCell   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
ccs 1
cts 1
cp 1
rs 10
wmc 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
sightBlocking() 0 2 ?
A sight() 0 2 1
1
/*
2
 * This file is part of ArakneUtils.
3
 *
4
 * ArakneUtils 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
 * ArakneUtils 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 ArakneUtils.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2021 Vincent Quatrevieux
18
 */
19
20
package fr.arakne.utils.maps;
21
22
import fr.arakne.utils.maps.sight.CellSight;
23
import org.checkerframework.checker.nullness.qual.NonNull;
24
import org.checkerframework.dataflow.qual.Pure;
25
26
/**
27
 * Base type for a battlefield cell
28
 */
29
public interface BattlefieldCell<C extends @NonNull BattlefieldCell> extends MapCell<C> {
30
    /**
31
     * Check if the cell block line of sight
32
     *
33
     * @return true if the cell block the line of sight (i.e. spell cannot be casted through this cell)
34
     *
35
     * @see CellSight
36
     * @see BattlefieldCell#sight()
37
     */
38
    @Pure
39
    public boolean sightBlocking();
40
41
    /**
42
     * Get the current cell sight
43
     * This method is equivalent to {@code new CellSight<>(cell)}
44
     *
45
     * Note: each call of this method will recreate a new {@link CellSight} instance
46
     *
47
     * <pre>{@code
48
     * // Check if the "target" cell is accessible from the current cell
49
     * if (!fighter.cell().sight().isFree(target)) {
50
     *     return false;
51
     * }
52
     * }</pre>
53
     *
54
     * @return The current cell sight
55
     */
56
    public default CellSight<C> sight() {
57 1
        return new CellSight<>(coordinate());
58
    }
59
}
60