|
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.builder; |
|
21
|
|
|
|
|
22
|
|
|
import fr.arakne.utils.value.helper.RandomUtil; |
|
23
|
|
|
import fr.quatrevieux.araknemu.game.exploration.map.ExplorationMap; |
|
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.Fight; |
|
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.FightService; |
|
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterFactory; |
|
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.team.SimpleTeam; |
|
28
|
|
|
import fr.quatrevieux.araknemu.game.fight.type.ChallengeType; |
|
29
|
|
|
import fr.quatrevieux.araknemu.game.player.GamePlayer; |
|
30
|
|
|
import org.apache.logging.log4j.Logger; |
|
31
|
|
|
|
|
32
|
|
|
import java.util.concurrent.ScheduledExecutorService; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Builder for challenge fight |
|
36
|
|
|
*/ |
|
37
|
|
|
public final class ChallengeBuilder implements FightBuilder { |
|
38
|
|
|
private final BaseBuilder builder; |
|
39
|
|
|
private final FighterFactory fighterFactory; |
|
40
|
|
|
|
|
41
|
1 |
|
public ChallengeBuilder(FightService service, FighterFactory fighterFactory, RandomUtil random, Logger logger, ScheduledExecutorService executor) { |
|
42
|
1 |
|
this.builder = new BaseBuilder(service, random, new ChallengeType(), logger, executor); |
|
43
|
1 |
|
this.fighterFactory = fighterFactory; |
|
44
|
1 |
|
} |
|
45
|
|
|
|
|
46
|
|
|
@Override |
|
47
|
|
|
public Fight build(int fightId) { |
|
48
|
1 |
|
return builder.build(fightId); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Set the fight map |
|
53
|
|
|
*/ |
|
54
|
|
|
public ChallengeBuilder map(ExplorationMap map) { |
|
55
|
1 |
|
builder.map(map); |
|
56
|
|
|
|
|
57
|
1 |
|
return this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Add new fighter |
|
62
|
|
|
*/ |
|
63
|
|
|
public ChallengeBuilder fighter(GamePlayer player) { |
|
64
|
1 |
|
builder.addTeam((number, startPlaces) -> new SimpleTeam( |
|
65
|
1 |
|
fighterFactory.create(player), |
|
66
|
|
|
startPlaces, |
|
67
|
|
|
number |
|
68
|
|
|
)); |
|
69
|
|
|
|
|
70
|
1 |
|
return this; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|