Passed
Push — master ( 668211...ef514d )
by Vincent
08:40 queued 13s
created

hidden()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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