Implement DeathMatch class

This commit is contained in:
bilou
2020-10-30 21:37:07 +01:00
parent 26e6dacc89
commit 3d66ba2c39
3 changed files with 56 additions and 8 deletions

View File

@@ -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<MiniGame>();
_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;
}

View File

@@ -1,5 +1,5 @@
package moe.sdg.PluginSDG;
public enum GameType {
MINIGAME
DeathMatch
}

View File

@@ -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() {
}
}