Package edu.uw.calebcha.hvz
Class HvZGame
java.lang.Object
edu.uw.calebcha.hvz.HvZGame
- All Implemented Interfaces:
org.bukkit.event.Listener
public class HvZGame
extends java.lang.Object
implements org.bukkit.event.Listener
Represents a game of Humans vs Zombies.
- Author:
- Caleb Chan (cccfire)
-
Constructor Summary
Constructors Constructor Description HvZGame(java.lang.String name, HvZMap map)
Initializes the HvZGameHvZGame(java.lang.String name, HvZMap map, HvZPlayerRegistry playerRegistry, HvZGraveyard graveyard)
Initializes the HvZGame with existing players. -
Method Summary
Modifier and Type Method Description void
add(org.bukkit.entity.Player player)
Adds player to this HvZ gamevoid
countdown()
Starts countdown to start the game.void
endGame()
Ends the game.java.lang.String
getCreatorName()
Get the name of player who created this game.HvZGraveyard
getGraveyard()
Gets this game's graveyard.HvZPlayerRegistry
getPlayerRegistry()
Gets this game's player registry.int
getTimeLimit()
Gets the time limit for this gamevoid
onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent event)
void
remove(org.bukkit.entity.Player player)
Removes given player from this HvZ gamevoid
setTimeLimit(int timeLimit)
Sets the time limit for this gameint
size()
Returns number of playersvoid
start()
Starts this game.boolean
winnerIsHuman()
Returns whether the humans win.
-
Constructor Details
-
HvZGame
public HvZGame(java.lang.String name, HvZMap map, HvZPlayerRegistry playerRegistry, HvZGraveyard graveyard)Initializes the HvZGame with existing players.Mainly used for when humans win and decide to continue the game with the same remaining players as humans.
- Parameters:
name
- name of the player who created this gamemap
- the map used in this gameplayerRegistry
- existing player registry from previous gamegraveyard
- existing graveyard from previous game
-
HvZGame
Initializes the HvZGame- Parameters:
name
- name of the player who created this gamemap
- the map used in this game
-
-
Method Details
-
getCreatorName
public java.lang.String getCreatorName()Get the name of player who created this game. Mainly used for distinguishing games when listing them in a menu.- Returns:
- name of player who created this game
-
size
public int size()Returns number of players- Returns:
- number of players
-
add
public void add(org.bukkit.entity.Player player)Adds player to this HvZ game- Parameters:
player
- player to be added to game
-
remove
public void remove(org.bukkit.entity.Player player)Removes given player from this HvZ game- Parameters:
player
- player to be removed from game
-
countdown
public void countdown()Starts countdown to start the game. -
start
public void start()Starts this game. -
endGame
public void endGame()Ends the game. -
winnerIsHuman
public boolean winnerIsHuman()Returns whether the humans win. To be overridden for missions with different win conditions.- Returns:
- true if humans win, false otherwise
-
getPlayerRegistry
Gets this game's player registry.- Returns:
- this HvZ game's player registry
-
getGraveyard
Gets this game's graveyard.- Returns:
- this HvZ game's graveyard
-
setTimeLimit
public void setTimeLimit(int timeLimit)Sets the time limit for this game- Parameters:
timeLimit
- value of time limit
-
getTimeLimit
public int getTimeLimit()Gets the time limit for this game- Returns:
- time limit of this game
-
onPlayerQuit
public void onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent event)
-