Class Map

java.lang.Object
me.simulation.game.Map

public class Map extends Object
Represents a game map with champions and objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Map(int width, int height)
    Constructs a new Map with the specified width and height.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clears the console screen.
    void
    Simulates a day cycle by moving objects on the map.
    Get the map of champions.
    boolean
    Checks if the game has reached its end condition.
    boolean
    Checks if there are any announcements.
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public ArrayList<ArrayList<Champion>> 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.