Passed
Pull Request — master (#280)
by Vincent
13:25
created

fr.quatrevieux.araknemu.game.fight.fighter.operation.FighterOperation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
ccs 5
cts 7
cp 0.7143
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onMonster(MonsterFighter) 0 2 1
A onGenericFighter(Fighter) 0 1 1
A onPlayer(PlayerFighter) 0 2 1
A onInvocation(InvocationFighter) 0 2 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.game.fight.fighter.operation;
21
22
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter;
23
import fr.quatrevieux.araknemu.game.fight.fighter.invocation.InvocationFighter;
24
import fr.quatrevieux.araknemu.game.fight.fighter.monster.MonsterFighter;
25
import fr.quatrevieux.araknemu.game.fight.fighter.player.PlayerFighter;
26
27
/**
28
 * Operation to apply on a fighter creature
29
 * Implements the visitor pattern
30
 *
31
 * @see Fighter#apply(FighterOperation)
32
 */
33
public interface FighterOperation {
34
    /**
35
     * Apply the operation to a PlayerFighter
36
     */
37
    public default void onPlayer(PlayerFighter fighter) {
38 1
        onGenericFighter(fighter);
39 1
    }
40
41
    /**
42
     * Apply the operation to a MonsterFighter
43
     */
44
    public default void onMonster(MonsterFighter fighter) {
45 1
        onGenericFighter(fighter);
46 1
    }
47
48
    /**
49
     * Apply the operation to an InvocationFighter
50
     */
51
    public default void onInvocation(InvocationFighter fighter) {
52
        onGenericFighter(fighter);
53
    }
54
55
    /**
56
     * Apply the operation to a generic fighter type
57
     */
58 1
    public default void onGenericFighter(Fighter fighter) {}
59
}
60