Class BasePlayer

java.lang.Object
org.bitsquad.warzone.player.BasePlayer
All Implemented Interfaces:
PlayerStrategy
Direct Known Subclasses:
AggressivePlayer, BenevolentPlayer, CheaterPlayer, Player, RandomPlayer

public abstract class BasePlayer extends Object implements PlayerStrategy
Represents a player in the game

The class defines a player with the aid of an ID, player name, number of army units available for the user in the following turn, list of orders which it places and the list of countries it owns.

  • Field Details

    • d_availableArmyUnits

      protected int d_availableArmyUnits
    • d_countriesOwned

      protected ArrayList<Country> d_countriesOwned
    • d_orderList

      protected ArrayList<Order> d_orderList
    • d_currentOrder

      protected Order d_currentOrder
  • Constructor Details

    • BasePlayer

      public BasePlayer(String p_name)
      Constructor
      Parameters:
      p_name - player name
  • Method Details

    • getId

      public int getId()
      Getter method for player id
      Returns:
      the player id
    • getName

      public String getName()
      Getter method for player name
      Returns:
      the player name
    • getAvailableArmyUnits

      public int getAvailableArmyUnits()
      Getter method for player available army units
      Returns:
      the player available army units
    • setAvailableArmyUnits

      public void setAvailableArmyUnits(int p_availableArmyUnits)
      Setter method for player available army units
      Parameters:
      p_availableArmyUnits - army units
    • getCountriesOwned

      public ArrayList<Country> getCountriesOwned()
      Getter method for player countries owned
      Returns:
      the player countries owned
    • getCountryByID

      public Country getCountryByID(int p_countryID)
      Used to fetch a player owned country using Country ID
      Parameters:
      p_countryID -
      Returns:
      Country
    • hasCountryWithID

      public boolean hasCountryWithID(int p_countryID)
      Used to check if player has a particular country
      Parameters:
      p_countryID -
      Returns:
      boolean
    • setCountriesOwned

      public void setCountriesOwned(ArrayList<Country> p_countriesOwned)
      Setter method for player countries owned
      Parameters:
      p_countriesOwned - countries owned
    • getOrderList

      public ArrayList<Order> getOrderList()
      Getter method for player order list
      Returns:
      the order list
    • getCurrentOrder

      public Order getCurrentOrder()
      Getter method for player current order
      Returns:
      player current order
    • setCurrentOrder

      public void setCurrentOrder(Order p_currentOrder)
      Setter method for player current order
      Parameters:
      p_currentOrder - current order
    • getCurrentCards

      public HashMap<Card,Integer> getCurrentCards()
      Getter for the cards which a player holds
      Returns:
      HashMap
    • hasCard

      public boolean hasCard(Card p_card)
      Checks if a player has a card
      Parameters:
      p_card -
      Returns:
      boolean
    • hasNewTerritory

      public boolean hasNewTerritory()
      Tells if a player has a new territory
      Returns:
      boolean
    • setHasNewTerritory

      public void setHasNewTerritory(boolean p_hasNewTerritory)
      Sets if the player has gained a new territory
      Parameters:
      p_hasNewTerritory -
    • nextOrder

      public Order nextOrder()
      Get the next order in the order list
      Returns:
      the next order
    • addCountryOwned

      public void addCountryOwned(Country p_country)
      Adds a country to the countries owned
      Parameters:
      p_country - Country object
    • removeCountryOwned

      public void removeCountryOwned(Country p_country)
      Removes a country from countries owned
      Parameters:
      p_country - Country object
    • isNextDeploy

      public Boolean isNextDeploy()
      Helper method to check if the next order to be executed is a Deploy order
      Returns:
    • clearState

      public void clearState()
      Clears the state of the player for executing the next turn of the game