Package me.simulation.game
Class Map
java.lang.Object
me.simulation.game.Map
Represents a game map with champions and objects.
-
Constructor Summary
ConstructorsConstructorDescriptionMap
(int width, int height) Constructs a new Map with the specified width and height. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Clears the console screen.void
dayCycle()
Simulates a day cycle by moving objects on the map.getMap()
Get the map of champions.boolean
ifend()
Checks if the game has reached its end condition.boolean
ifstop()
Checks if there are any announcements.void
mapDraw()
Draws the game map with champions and objects.void
placeObjectRandomly
(int howMuchOrk, int howMuchHuman, int howMuchElf, int howMuchChest, int howMuchItem, int howMuchPotion) Randomly places objects on the map, such as champions, chests, items, and potions.void
Prints the current statistics of the map, including colors.
-
Constructor Details
-
Map
public Map(int width, int height) Constructs a new Map with the specified width and height.- Parameters:
width
- The width of the map.height
- The height of the map.
-
-
Method Details
-
getMap
Get the map of champions.- Returns:
- The map of champions.
-
placeObjectRandomly
public void placeObjectRandomly(int howMuchOrk, int howMuchHuman, int howMuchElf, int howMuchChest, int howMuchItem, int howMuchPotion) Randomly places objects on the map, such as champions, chests, items, and potions.- Parameters:
howMuchOrk
- The number of Ork objects to place on the map.howMuchHuman
- The number of Human objects to place on the map.howMuchElf
- The number of Elf objects to place on the map.howMuchChest
- The number of Chest objects to place on the map.howMuchItem
- The number of Item objects to place on the map.howMuchPotion
- The number of Potion objects to place on the map.
-
mapDraw
public void mapDraw()Draws the game map with champions and objects. -
dayCycle
public void dayCycle()Simulates a day cycle by moving objects on the map. The method handles the movement and behavior of champions. It also manages the regeneration of champions' health points. -
printStats
public void printStats()Prints the current statistics of the map, including colors. The statistics include the number of all objects on the map, the number of orks and their kills, the number of elves and their kills, the number of humans and their kills, the number of chests, potions, and items. It also prints any announcements stored in the announcements list. After printing the statistics and announcements, the announcements list is cleared. -
clear
public static void clear()Clears the console screen. This method attempts to clear the console screen by executing platform-specific commands. On Windows, it uses the "cls" command to clear the screen. On other platforms, it executes the "clear" command and also sends control characters to reset the cursor position. If any exception occurs during the process, it will be printed to the standard error output. -
ifend
public boolean ifend()Checks if the game has reached its end condition. The end conditions are: - If there are no more elves and humans remaining, the orcs have conquered the battlefield. - If there are no more elves and orcs remaining, the humans have conquered the battlefield. - If there are no more orcs and humans remaining, the elves have conquered the battlefield.- Returns:
true
if the game has not reached its end condition yet,false
otherwise.
-
ifstop
public boolean ifstop()Checks if there are any announcements.- Returns:
true
if there are no announcements,false
otherwise.
-