From 3d66ba2c398ba4a581a2686f14e2e5e37c7cd7c7 Mon Sep 17 00:00:00 2001 From: bilou Date: Fri, 30 Oct 2020 21:37:07 +0100 Subject: [PATCH] Implement DeathMatch class --- .../java/moe/sdg/PluginSDG/GameManager.java | 21 ++++++---- src/main/java/moe/sdg/PluginSDG/GameType.java | 2 +- .../moe/sdg/PluginSDG/games/DeathMatch.java | 41 +++++++++++++++++++ 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/main/java/moe/sdg/PluginSDG/games/DeathMatch.java diff --git a/src/main/java/moe/sdg/PluginSDG/GameManager.java b/src/main/java/moe/sdg/PluginSDG/GameManager.java index 14112b8..158a715 100644 --- a/src/main/java/moe/sdg/PluginSDG/GameManager.java +++ b/src/main/java/moe/sdg/PluginSDG/GameManager.java @@ -1,5 +1,6 @@ package moe.sdg.PluginSDG; +import moe.sdg.PluginSDG.games.DeathMatch; import moe.sdg.PluginSDG.Commands.HubCommand; import moe.sdg.PluginSDG.Commands.SetHubCommand; import org.apache.commons.lang.NotImplementedException; @@ -26,21 +27,24 @@ public class GameManager extends JavaPlugin getCommand("hub").setExecutor(new HubCommand(config)); getCommand("sethub").setExecutor(new SetHubCommand(config)); - _games = new ArrayList(); + _games = new ArrayList<>(); getLogger().info("Game manager loaded."); } - public Location getHubLocation() - { - throw new NotImplementedException(); - } - @Override public void onDisable() { super.onDisable(); } + +//! @brief return hub location + //! @return return a Location containing the server hub + public Location getHubLocation() + { + throw new NotImplementedException(); + } + //! @brief factory for creating new game //! @param type The type of game to create //! @param map the name of the map to use @@ -48,7 +52,10 @@ public class GameManager extends JavaPlugin public MiniGame createGame(GameType type, String map) { switch (type) { - // TODO: create a new game and add it the array list + case DeathMatch: + DeathMatch match = new DeathMatch(this); + this._games.add(match); + return match; } return null; } diff --git a/src/main/java/moe/sdg/PluginSDG/GameType.java b/src/main/java/moe/sdg/PluginSDG/GameType.java index fc73088..15dc9db 100644 --- a/src/main/java/moe/sdg/PluginSDG/GameType.java +++ b/src/main/java/moe/sdg/PluginSDG/GameType.java @@ -1,5 +1,5 @@ package moe.sdg.PluginSDG; public enum GameType { - MINIGAME + DeathMatch } diff --git a/src/main/java/moe/sdg/PluginSDG/games/DeathMatch.java b/src/main/java/moe/sdg/PluginSDG/games/DeathMatch.java new file mode 100644 index 0000000..8403a52 --- /dev/null +++ b/src/main/java/moe/sdg/PluginSDG/games/DeathMatch.java @@ -0,0 +1,41 @@ +package moe.sdg.PluginSDG.games; + +import moe.sdg.PluginSDG.GameManager; +import moe.sdg.PluginSDG.GameType; +import moe.sdg.PluginSDG.MiniGame; + +public class DeathMatch extends MiniGame { + + private int _maxPlayer = 4; + private boolean enforceMaxPlayer = false; + + public DeathMatch(GameManager gameManager) + { + super(gameManager); + } + + @Override + public GameType getType() { + return GameType.DeathMatch; + } + + @Override + public int getMaxPlayers() { + if (enforceMaxPlayer) + return _maxPlayer; + return 0; + } + + //! @brief Start the game. + @Override + public void start() { + + } + + //! @brief End the game. + @Override + public void end() { + + } + +}