forked from Arakne/Araknemu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Arakne#206 from vincent4vx/spell-effect-exchange
[fight] Arakne#27 Add switch position effects
- Loading branch information
Showing
22 changed files
with
1,256 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...atrevieux/araknemu/game/fight/castable/effect/handler/shifting/SwitchPositionApplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* This file is part of Araknemu. | ||
* | ||
* Araknemu is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Araknemu is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Araknemu. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Copyright (c) 2017-2021 Vincent Quatrevieux | ||
*/ | ||
|
||
package fr.quatrevieux.araknemu.game.fight.castable.effect.handler.shifting; | ||
|
||
import fr.quatrevieux.araknemu.game.fight.Fight; | ||
import fr.quatrevieux.araknemu.game.fight.fighter.ActiveFighter; | ||
import fr.quatrevieux.araknemu.game.fight.fighter.PassiveFighter; | ||
import fr.quatrevieux.araknemu.game.fight.map.FightCell; | ||
import fr.quatrevieux.araknemu.network.game.out.fight.action.ActionEffect; | ||
|
||
/** | ||
* Perform the switch position of two fighters | ||
*/ | ||
public final class SwitchPositionApplier { | ||
private final Fight fight; | ||
|
||
public SwitchPositionApplier(Fight fight) { | ||
this.fight = fight; | ||
} | ||
|
||
/** | ||
* Apply the switch effect | ||
* | ||
* @param caster The switch spell caster | ||
* @param target The other fighter to switch with | ||
*/ | ||
public void apply(ActiveFighter caster, PassiveFighter target) { | ||
final FightCell casterCell = caster.cell(); | ||
final FightCell targetCell = target.cell(); | ||
|
||
// Unset cells | ||
caster.move(null); | ||
target.move(null); | ||
|
||
// Switch cells | ||
caster.move(targetCell); | ||
target.move(casterCell); | ||
|
||
// Synchronize positions with client | ||
fight.send(ActionEffect.teleport(caster, caster, targetCell)); | ||
fight.send(ActionEffect.teleport(caster, target, casterCell)); | ||
} | ||
} |
Oops, something went wrong.