Passed
Pull Request — master (#229)
by Vincent
12:16
created

fr.quatrevieux.araknemu.game.fight.ai.factory.AbstractAiBuilderFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 9
dl 0
loc 22
ccs 4
cts 7
cp 0.5714
rs 10
c 1
b 1
f 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure(GeneratorBuilder) 0 1 1
A create(Fighter) 0 7 1
A configure(GeneratorBuilder,Fighter) 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-2021 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.game.fight.ai.factory;
21
22
import fr.quatrevieux.araknemu.game.fight.ai.AI;
23
import fr.quatrevieux.araknemu.game.fight.ai.FighterAI;
24
import fr.quatrevieux.araknemu.game.fight.ai.action.builder.GeneratorBuilder;
25
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter;
26
27
import java.util.Optional;
28
29
/**
30
 * AiFactory implementation using a generator builder for configure the AI
31
 */
32 1
public abstract class AbstractAiBuilderFactory implements AiFactory {
33
    /**
34
     * Configure the AI generator
35
     */
36
    public void configure(GeneratorBuilder builder) {
37
        // To implements if configure(GeneratorBuilder, Fighter) is not implemented
38
    }
39
40
    /**
41
     * Configure the AI generator
42
     */
43
    public void configure(GeneratorBuilder builder, Fighter fighter) {
0 ignored issues
show
Unused Code introduced by
Remove this unused method parameter "fighter".
Loading history...
44
        configure(builder);
45
    }
46
47
    @Override
48
    public final Optional<AI> create(Fighter fighter) {
49 1
        final GeneratorBuilder builder = new GeneratorBuilder();
50
51 1
        configure(builder, fighter);
52
53 1
        return Optional.of(new FighterAI(fighter, fighter.fight(), builder.build()));
54
    }
55
}
56