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

configure(GeneratorBuilder,Fighter)   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
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