fr.quatrevieux.araknemu.game.fight.ai.action.MoveToBoost   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generate(AI,AiActionFactory) 0 3 1
A MoveToBoost(Simulator) 0 3 1
A initialize(AI) 0 4 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.game.fight.ai.action;
21
22
import fr.quatrevieux.araknemu.game.fight.ai.AI;
23
import fr.quatrevieux.araknemu.game.fight.ai.simulation.Simulator;
24
import fr.quatrevieux.araknemu.game.fight.fighter.ActiveFighter;
25
import fr.quatrevieux.araknemu.game.fight.turn.action.Action;
26
27
import java.util.Optional;
28
29
/**
30
 * Try to move for perform the optimal boost
31
 *
32
 * The best cell for cast the boost is selected.
33
 * If the current cell permit boost and the fighter is surrounded by enemies, the fighter will not perform any move.
34
 *
35
 * For select the cell, the generator will iterate over all reachable cells
36
 * with the current amount of MPs,
37
 * and check all spells on all available cells.
38
 * The best effective cell and cast is selected.
39
 */
40
public final class MoveToBoost<F extends ActiveFighter> implements ActionGenerator<F> {
41
    private final MoveToCast<F> generator;
42
    private final Boost<F> action;
43
44 1
    public MoveToBoost(Simulator simulator) {
45 1
        action = Boost.allies(simulator);
46 1
        generator = new MoveToCast<>(simulator, action, new MoveToCast.BestTargetStrategy<>());
47 1
    }
48
49
    @Override
50
    public void initialize(AI<F> ai) {
51 1
        action.initialize(ai);
52 1
        generator.initialize(ai);
53 1
    }
54
55
    @Override
56
    public Optional<Action> generate(AI<F> ai, AiActionFactory actions) {
57 1
        return generator.generate(ai, actions);
58
    }
59
}
60