Adding a new Game
There are a few things you need to do when adding a new game.
- Create a new enum for the game in
GameType.java(all upper-case, underscores; in this example, it'sGameType.NEW_GAME) - Create a new enum value
NEW_GAME- Give it a
titleand anid(for this example, it will beNEW_GAME("New Game", "new-game")) titleis the display nameidmust be lowercase with no spaces (only dashes) and only alphanumeric characters (it must match thevalidIdRegexin theGameTypeconstructor, or anIllegalArgumentExceptionwill be thrown)
- Give it a
- The Enum for the game is used in various places to identify which game is being played/selected. For example:
- This allows the
/mct game start new-gamecommand to start your new game - This allows the vote sub command to include this game in its list of votable games
- This allows the
- Add the
GameType.NEW_GAMEto theGameManager.java - add the game to the voting pool in
startVote()votingPool.add(GameType.NEW_GAME);
- Create a case in the
startGame()method switch statement for the game- You will implement this after you create the game class in the next few steps, leave it empty for now
- Use the other cases for the other games as an indicator
- Add
GameType.NEW_GAMEto theVoteManager.java - You need to specify an item to represent your new game in the voting pool. In
showVoteGui(), add anItemStackfor your game. Use the others as an example. In this example, we'll useMaterial.STONEfor the material, and call theItemStackvariablenewGameItem.- Make sure you add your
newGameItemto thevotingItemsMap, like so:votingItems.put(GameType.NEW_GAME, newGame);.
- Make sure you add your
- Add a case to the switch statement in
clickVoteInventory()forMaterial.STONE(or whatever material you used). This is why your material must be unique from the other game materials. Use the other cases as an example. - If you haven't already, create a folder under
braekpo1nt/mctmanager/games/game/<newgame> - Create your game class, which must implement
org.braekpo1nt.mctmanager.games.game.interfaces.MCTGame. For this example, we'll call itNewGame.java - Make
getType()returnGameType.NEW_GAME - For more details on implementing the
MCTGameclass and writing the functionality for your game, see the other games as examples. There should also be a general guide written soon. - Add your game to the
GameManager.java - Create a field for your game
private final NewGame newGame; - Initialize
newGameinGameManager's constructor. Use the other games as an example. - Now is when you implement the case in the switch statement you made for
GameType.NEW_GAMEinstartGame().- Use the others as an example.
- Note: Colossal Combat is a special case, don't use that as an example.
- Now test and make sure you can
- run your game with
/mct game start new-game(which is made possible with the addition to theVoteSubCommand.javaabove) - vote for your game with the vote system using
/mct game vote new-game <...any other games you want in the voting pool...>(made possible by adding it to theVoteManager.java) - use your game in an Event (
/mct event start <number of games>)