| 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * Proxy class for override properties of other fighters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * Note: this object is immutable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | public final class ProxyPassiveFighter implements PassiveFighter { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     private final PassiveFighter fighter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     private final AI ai; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @param fighter The fighter to wrap | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @param ai The AI instance use to resolve the cell instance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 1 |  |     public ProxyPassiveFighter(PassiveFighter fighter, AI ai) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |         this.fighter = fighter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  |         this.ai = ai; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public int id() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |         return fighter.id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public FightCell cell() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  |         return ai.map().get(fighter.cell().id()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public Sprite sprite() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 1 |  |         return fighter.sprite(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     @Override | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     public Direction orientation() { | 
            
                                                                        
                            
            
                                    
            
            
                | 68 | 1 |  |         return fighter.orientation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public void move(FightCell cell) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  |         throw new UnsupportedOperationException("This is a proxy fighter"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public FighterLife life() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |         return fighter.life(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     public Buffs buffs() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 1 |  |         return fighter.buffs(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     public States states() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  |         return fighter.states(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     public int level() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         return fighter.level(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     public FighterCharacteristics characteristics() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  |         return fighter.characteristics(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public Team<? extends PassiveFighter> team() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  |         return fighter.team(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     public boolean dead() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 1 |  |         return fighter.dead(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 111 |  | View Code Duplication |     @Override | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public boolean equals(Object o) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 1 |  |         if (this == o) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 1 |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 1 |  |         if (!(o instanceof PassiveFighter)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 1 |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 1 |  |         final PassiveFighter that = (PassiveFighter) o; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 1 |  |         return id() == that.id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     @Override | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     public int hashCode() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  |         return fighter.hashCode(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 130 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 131 |  |  |  |