-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7c32194
commit 77a3676
Showing
16 changed files
with
505 additions
and
8 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
src/main/java/fr/quatrevieux/araknemu/core/event/EventsSubscriber.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
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
49 changes: 49 additions & 0 deletions
49
...r/quatrevieux/araknemu/game/fight/castable/effect/handler/shifting/RaulebaqueHandler.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,49 @@ | ||
package fr.quatrevieux.araknemu.game.fight.castable.effect.handler.shifting; | ||
|
||
import fr.quatrevieux.araknemu.game.fight.Fight; | ||
import fr.quatrevieux.araknemu.game.fight.castable.CastScope; | ||
import fr.quatrevieux.araknemu.game.fight.castable.effect.handler.EffectHandler; | ||
import fr.quatrevieux.araknemu.game.fight.map.FightCell; | ||
import fr.quatrevieux.araknemu.game.fight.module.RaulebaqueModule; | ||
import fr.quatrevieux.araknemu.network.game.out.fight.FighterPositions; | ||
|
||
/** | ||
* Handle the Raulebaque effect | ||
*/ | ||
final public class RaulebaqueHandler implements EffectHandler { | ||
final private Fight fight; | ||
final private RaulebaqueModule module; | ||
|
||
public RaulebaqueHandler(Fight fight, RaulebaqueModule module) { | ||
this.fight = fight; | ||
this.module = module; | ||
} | ||
|
||
@Override | ||
public void handle(CastScope cast, CastScope.EffectScope effect) { | ||
module.startPositions().forEach((fighter, startCell) -> { | ||
if (fighter.dead()) { | ||
return; | ||
} | ||
|
||
FightCell lastCell = fighter.cell(); | ||
|
||
if (lastCell.equals(startCell)) { | ||
return; | ||
} | ||
|
||
fighter.move(null); | ||
|
||
// Cell is not free : exchange place | ||
startCell.fighter().ifPresent(other -> other.move(lastCell)); | ||
fighter.move(startCell); | ||
}); | ||
|
||
fight.send(new FighterPositions(fight.fighters())); | ||
} | ||
|
||
@Override | ||
public void buff(CastScope cast, CastScope.EffectScope effect) { | ||
throw new UnsupportedOperationException("Cannot use Raulebaque as buff effect"); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/fr/quatrevieux/araknemu/game/fight/module/FightModule.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,29 @@ | ||
package fr.quatrevieux.araknemu.game.fight.module; | ||
|
||
import fr.quatrevieux.araknemu.core.event.EventsSubscriber; | ||
import fr.quatrevieux.araknemu.game.fight.Fight; | ||
import fr.quatrevieux.araknemu.game.fight.castable.effect.EffectsHandler; | ||
import fr.quatrevieux.araknemu.game.fight.state.FightState; | ||
|
||
/** | ||
* The fight module is used to register new effects, or listeners on the fight for extends its capabilities | ||
* The module instance is dedicated to one fight instance, and can safely be used as state object | ||
*/ | ||
public interface FightModule extends EventsSubscriber { | ||
public interface Factory { | ||
/** | ||
* Create the module for the given fight | ||
*/ | ||
public FightModule create(Fight fight); | ||
} | ||
|
||
/** | ||
* Register fight effects into the effect handle | ||
*/ | ||
public void effects(EffectsHandler handler); | ||
|
||
/** | ||
* The fight has changed its current state | ||
*/ | ||
public void stateChanged(FightState newState); | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/fr/quatrevieux/araknemu/game/fight/module/RaulebaqueModule.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,70 @@ | ||
package fr.quatrevieux.araknemu.game.fight.module; | ||
|
||
import fr.quatrevieux.araknemu.core.event.Listener; | ||
import fr.quatrevieux.araknemu.game.fight.Fight; | ||
import fr.quatrevieux.araknemu.game.fight.castable.effect.EffectsHandler; | ||
import fr.quatrevieux.araknemu.game.fight.castable.effect.handler.shifting.RaulebaqueHandler; | ||
import fr.quatrevieux.araknemu.game.fight.event.FightStarted; | ||
import fr.quatrevieux.araknemu.game.fight.fighter.Fighter; | ||
import fr.quatrevieux.araknemu.game.fight.map.FightCell; | ||
import fr.quatrevieux.araknemu.game.fight.state.FightState; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Module for handle Raulebaque spell | ||
* | ||
* This spell will reset all fighters position to the initial one | ||
*/ | ||
final public class RaulebaqueModule implements FightModule { | ||
final private Fight fight; | ||
|
||
private Map<Fighter, FightCell> startPositions; | ||
|
||
public RaulebaqueModule(Fight fight) { | ||
this.fight = fight; | ||
} | ||
|
||
@Override | ||
public void effects(EffectsHandler handler) { | ||
handler.register(784, new RaulebaqueHandler(fight, this)); | ||
} | ||
|
||
@Override | ||
public void stateChanged(FightState newState) { | ||
|
||
} | ||
|
||
public Map<Fighter, FightCell> startPositions() { | ||
return startPositions; | ||
} | ||
|
||
@Override | ||
public Listener[] listeners() { | ||
return new Listener[] { | ||
new Listener<FightStarted>() { | ||
@Override | ||
public void on(FightStarted event) { | ||
loadStartPositions(); | ||
} | ||
|
||
@Override | ||
public Class<FightStarted> event() { | ||
return FightStarted.class; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Load the start positions | ||
*/ | ||
private void loadStartPositions() { | ||
startPositions = new HashMap<>(); | ||
|
||
for (Fighter fighter : fight.fighters()) { | ||
startPositions.put(fighter, fighter.cell()); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.