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.monster; |
21
|
|
|
|
22
|
|
|
import fr.quatrevieux.araknemu.game.fight.castable.weapon.CastableWeapon; |
23
|
|
|
import fr.quatrevieux.araknemu.game.fight.exception.FightException; |
24
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.AbstractFighter; |
25
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.BaseFighterLife; |
26
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.BaseFighterSpellList; |
27
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterCharacteristics; |
28
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterLife; |
29
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterSpellList; |
30
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.FighterData; |
31
|
|
|
import fr.quatrevieux.araknemu.game.fight.fighter.operation.FighterOperation; |
32
|
|
|
import fr.quatrevieux.araknemu.game.fight.team.FightTeam; |
33
|
|
|
import fr.quatrevieux.araknemu.game.monster.Monster; |
34
|
|
|
import fr.quatrevieux.araknemu.game.monster.reward.MonsterReward; |
35
|
|
|
import fr.quatrevieux.araknemu.game.world.creature.Sprite; |
36
|
|
|
import org.checkerframework.checker.index.qual.Positive; |
37
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Fighter for a monster |
41
|
|
|
*/ |
42
|
|
View Code Duplication |
public final class MonsterFighter extends AbstractFighter { |
|
|
|
|
43
|
|
|
private final int id; |
44
|
|
|
private final Monster monster; |
45
|
|
|
private final FightTeam team; |
46
|
|
|
|
47
|
|
|
private final BaseFighterLife life; |
48
|
|
|
private final MonsterFighterCharacteristics characteristics; |
49
|
|
|
private final MonsterFighterSprite sprite; |
50
|
|
|
private final FighterSpellList spells; |
51
|
|
|
|
52
|
|
|
@SuppressWarnings({"assignment", "argument"}) |
53
|
1 |
|
public MonsterFighter(int id, Monster monster, FightTeam team) { |
54
|
1 |
|
this.id = id; |
55
|
1 |
|
this.monster = monster; |
56
|
1 |
|
this.team = team; |
57
|
|
|
|
58
|
1 |
|
this.life = new BaseFighterLife(this, monster.life()); |
59
|
1 |
|
this.characteristics = new MonsterFighterCharacteristics(monster, this); |
60
|
1 |
|
this.sprite = new MonsterFighterSprite(this, monster); |
61
|
1 |
|
this.spells = new BaseFighterSpellList(monster.spells()); |
62
|
1 |
|
} |
63
|
|
|
|
64
|
|
|
@Override |
65
|
|
|
public int id() { |
66
|
1 |
|
return id; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
@Override |
70
|
|
|
public Sprite sprite() { |
71
|
1 |
|
return sprite; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
@Override |
75
|
|
|
public FighterLife life() { |
76
|
1 |
|
return life; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
@Override |
80
|
|
|
public FighterCharacteristics characteristics() { |
81
|
1 |
|
return characteristics; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
@Override |
85
|
|
|
public FighterSpellList spells() { |
86
|
1 |
|
return spells; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
@Override |
90
|
|
|
public CastableWeapon weapon() { |
91
|
1 |
|
throw new FightException("The fighter do not have any weapon"); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
@Override |
95
|
|
|
public @Positive int level() { |
96
|
1 |
|
return monster.level(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
@Override |
100
|
|
|
public FightTeam team() { |
101
|
1 |
|
return team; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
@Override |
105
|
|
|
public boolean ready() { |
106
|
1 |
|
return true; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
@Override |
110
|
|
|
public <O extends FighterOperation> O apply(O operation) { |
111
|
1 |
|
operation.onMonster(this); |
112
|
|
|
|
113
|
1 |
|
return operation; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get the end fight rewards |
118
|
|
|
* |
119
|
|
|
* @see Monster#reward() |
120
|
|
|
*/ |
121
|
|
|
public MonsterReward reward() { |
122
|
1 |
|
return monster.reward(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get the monster data for the fighter |
127
|
|
|
*/ |
128
|
|
|
public Monster monster() { |
129
|
1 |
|
return monster; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
@Override |
133
|
|
|
public @Nullable FighterData invoker() { |
134
|
1 |
|
return null; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|