Passed
Pull Request — master (#281)
by Vincent
13:47
created

ProxyPassiveFighter(FighterData,AI)   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
c 0
b 0
f 0
cc 1
crap 1
rs 10
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.proxy;
21
22
import fr.arakne.utils.maps.constant.Direction;
23
import fr.quatrevieux.araknemu.game.fight.Fight;
24
import fr.quatrevieux.araknemu.game.fight.ai.AI;
25
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buffs;
26
import fr.quatrevieux.araknemu.game.fight.fighter.FighterCharacteristics;
27
import fr.quatrevieux.araknemu.game.fight.fighter.FighterLife;
28
import fr.quatrevieux.araknemu.game.fight.fighter.FighterData;
29
import fr.quatrevieux.araknemu.game.fight.fighter.States;
30
import fr.quatrevieux.araknemu.game.fight.map.FightCell;
31
import fr.quatrevieux.araknemu.game.fight.team.Team;
32
import fr.quatrevieux.araknemu.game.world.creature.Sprite;
33
import org.checkerframework.checker.index.qual.Positive;
34
import org.checkerframework.checker.nullness.qual.Nullable;
35
36
/**
37
 * Proxy class for override properties of other fighters
38
 *
39
 * Note: this object is immutable
40
 */
41
public final class ProxyPassiveFighter implements FighterData {
42
    private final FighterData fighter;
43
    private final AI ai;
44
45
    /**
46
     * @param fighter The fighter to wrap
47
     * @param ai The AI instance use to resolve the cell instance
48
     */
49 1
    public ProxyPassiveFighter(FighterData fighter, AI ai) {
50 1
        this.fighter = fighter;
51 1
        this.ai = ai;
52 1
    }
53
54
    @Override
55
    public int id() {
56 1
        return fighter.id();
57
    }
58
59
    @Override
60
    @SuppressWarnings("argument") // cell id always valid
61
    public FightCell cell() {
62 1
        return ai.map().get(fighter.cell().id());
63
    }
64
65
    @Override
66
    public Sprite sprite() {
67 1
        return fighter.sprite();
68
    }
69
70
    @Override
71
    public Direction orientation() {
72 1
        return fighter.orientation();
73
    }
74
75
    @Override
76
    public FighterLife life() {
77 1
        return fighter.life();
78
    }
79
80
    @Override
81
    public Buffs buffs() {
82 1
        return fighter.buffs();
83
    }
84
85
    @Override
86
    public States states() {
87 1
        return fighter.states();
88
    }
89
90
    @Override
91
    public @Positive int level() {
92
        return fighter.level();
93
    }
94
95
    @Override
96
    public FighterCharacteristics characteristics() {
97 1
        return fighter.characteristics();
98
    }
99
100
    @Override
101
    public Team<? extends FighterData> team() {
102 1
        return fighter.team();
103
    }
104
105
    @Override
106
    public Fight fight() {
107 1
        return fighter.fight();
108
    }
109
110
    @Override
111
    public boolean dead() {
112 1
        return fighter.dead();
113
    }
114
115
    @Override
116
    public boolean hidden() {
117 1
        return fighter.hidden();
118
    }
119
120
    @Override
121
    public boolean equals(@Nullable Object o) {
122 1
        if (this == o) {
123 1
            return true;
124
        }
125
126 1
        if (!(o instanceof FighterData)) {
127 1
            return false;
128
        }
129
130 1
        final FighterData that = (FighterData) o;
131
132 1
        return id() == that.id();
133
    }
134
135
    @Override
136
    public int hashCode() {
137 1
        return fighter.hashCode();
138
    }
139
140
    @Override
141
    public @Nullable FighterData invoker() {
142 1
        return fighter.invoker();
143
    }
144
}
145