Test Failed
Branch master (cd3a65)
by Vincent
11:52
created

level()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
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.quatrevieux.araknemu.game.fight.ai.AI;
23
import fr.quatrevieux.araknemu.game.fight.castable.effect.buff.Buffs;
24
import fr.quatrevieux.araknemu.game.fight.fighter.FighterCharacteristics;
25
import fr.quatrevieux.araknemu.game.fight.fighter.FighterLife;
26
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter;
27
import fr.quatrevieux.araknemu.game.fight.fighter.States;
28
import fr.quatrevieux.araknemu.game.fight.map.FightCell;
29
import fr.quatrevieux.araknemu.game.fight.team.Team;
30
31
/**
32
 * Proxy class for override properties of other fighters
33
 *
34
 * Note: this object is immutable
35
 */
36
public final class ProxyPassiveFighter implements PassiveFighter {
37
    private final PassiveFighter fighter;
38
    private final AI ai;
39
40
    /**
41
     * @param fighter The fighter to wrap
42
     * @param ai The AI instance use to resolve the cell instance
43
     */
44 1
    public ProxyPassiveFighter(PassiveFighter fighter, AI ai) {
45 1
        this.fighter = fighter;
46 1
        this.ai = ai;
47 1
    }
48
49
    @Override
50
    public int id() {
51 1
        return fighter.id();
52
    }
53
54
    @Override
55
    public FightCell cell() {
56 1
        return ai.map().get(fighter.cell().id());
57
    }
58
59
    @Override
60
    public void move(FightCell cell) {
61 1
        throw new UnsupportedOperationException("This is a proxy fighter");
62
    }
63
64
    @Override
65
    public FighterLife life() {
66 1
        return fighter.life();
67
    }
68
69
    @Override
70
    public Buffs buffs() {
71 1
        return fighter.buffs();
72
    }
73
74
    @Override
75
    public States states() {
76 1
        return fighter.states();
77
    }
78
79
    @Override
80
    public int level() {
81
        return fighter.level();
82
    }
83
84
    @Override
85
    public FighterCharacteristics characteristics() {
86 1
        return fighter.characteristics();
87
    }
88
89
    @Override
90
    public Team<? extends PassiveFighter> team() {
91 1
        return fighter.team();
92
    }
93
94
    @Override
95
    public boolean dead() {
96 1
        return fighter.dead();
97
    }
98
99 View Code Duplication
    @Override
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
100
    public boolean equals(Object o) {
101 1
        if (this == o) {
102 1
            return true;
103
        }
104
105 1
        if (!(o instanceof PassiveFighter)) {
106 1
            return false;
107
        }
108
109 1
        final PassiveFighter that = (PassiveFighter) o;
110
111 1
        return id() == that.id();
112
    }
113
114
    @Override
115
    public int hashCode() {
116 1
        return fighter.hashCode();
117
    }
118
}
119