diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameInstance.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameInstance.java index 5c06777..02b1736 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameInstance.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameInstance.java @@ -101,6 +101,7 @@ public class GameInstance { * @param events The events to emit */ private void emit(Event... events) { + manager.applyEvents(events); emitter.update(events); } } diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java index e8aee84..b1f8404 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogic.java @@ -288,6 +288,10 @@ class GameLogic { requireAP(origin, 1); requireInfinityStone(origin, data.stoneType); + if(state.stoneCooldown.onCooldown(data.stoneType)) { + throw new InvalidRequestException(); + } + switch(((CharacterRequest) request).stoneType) { case SpaceStone -> { verifyCoordinates(state, data.targetField); @@ -507,6 +511,9 @@ class GameLogic { case MoveEvent -> { (state.entities.findEntity(((CharacterEvent)event).originEntity)).setPosition(((CharacterEvent)event).targetField); } + case UseInfinityStoneEvent -> { + state.stoneCooldown.setCooldown(((CharacterEvent)event).stoneType, 10); //TODO: use stone cooldown from config + } case ExchangeInfinityStoneEvent -> { ((Character)state.entities.findEntity(((CharacterEvent)event).originEntity)).inventory.removeStone(((CharacterEvent)event).stoneType); ((Character)state.entities.findEntity(((CharacterEvent)event).targetEntity)).inventory.addStone(((CharacterEvent)event).stoneType); @@ -598,6 +605,8 @@ class GameLogic { } } + state.stoneCooldown.update(); + result.add(new EventBuilder(EventType.RoundSetupEvent) .withRoundCount(state.roundNumber) .withCharacterOrder(state.turnOrder.toArray(new EntityID[0]))