diff --git a/src/main/java/project/app/warzone/Commands/MapEditorCommands.java b/src/main/java/project/app/warzone/Commands/MapEditorCommands.java index fa68b18..110aefb 100644 --- a/src/main/java/project/app/warzone/Commands/MapEditorCommands.java +++ b/src/main/java/project/app/warzone/Commands/MapEditorCommands.java @@ -29,6 +29,14 @@ public class MapEditorCommands { public PlayerFeatures playerFeatures; private final MapResouces mapResources; + /** + * Constructor for MapEditorCommands + * + * @param mapFeatures + * @param gameEngine + * @param playerFeatures + * @param mapResources + */ public MapEditorCommands(MapFeatures mapFeatures, GameEngine gameEngine, PlayerFeatures playerFeatures, MapResouces mapResources){ this.mapFeatures = mapFeatures; this.gameEngine = gameEngine; @@ -39,8 +47,10 @@ public MapEditorCommands(MapFeatures mapFeatures, GameEngine gameEngine, PlayerF /** - * @param p_filename - * @return String + * command for loading map for gameplay + * + * @param p_filename filename of the mao + * @return String returns message if the map is loaded */ @ShellMethod(key= "loadmap", value="Player can create or open an existing map") public String loadMap(@ShellOption String p_filename){ @@ -58,7 +68,9 @@ public String loadMap(@ShellOption String p_filename){ /** - * @return String + * Display the game map + * + * @return String returns message about the map validation */ @ShellMethod(key= "showmap", value="Used to display map continents with terriotories and boundaries") public String showmap(){ @@ -76,11 +88,13 @@ public String showmap(){ } - /** - * @param p_editcmd - * @param p_editremovecmd - * @return - */ + /** + * command for editing continent + * + * @param p_editremovecmd for remove command + * @param p_editcmd for edit command + * @return returns the message about status of command + */ @ShellMethod(key= "editcontinent", prefix = "-", value="This is used to add or update continents") public String editcontinent(@ShellOption(value="a",defaultValue=ShellOption.NULL)String p_editcmd, @ShellOption(value="r",defaultValue=ShellOption.NULL) String p_editremovecmd){ if(gameEngine.prevUserCommand==Commands.EDITMAP){ @@ -155,6 +169,13 @@ public String editcontinent(@ShellOption(value="a",defaultValue=ShellOption.NULL } + /** + * command for editing country + * + * @param p_editcmd for edit country command + * @param p_editremovecmd for remove country command + * @return returns the message about status of command + */ @ShellMethod(key= "editcountry", prefix = "-", value="This is used to add continents") public String editcountry(@ShellOption(value="a",defaultValue=ShellOption.NULL)String p_editcmd, @ShellOption(value="r",defaultValue=ShellOption.NULL) String p_editremovecmd){ if(gameEngine.prevUserCommand==Commands.EDITMAP){ diff --git a/src/main/java/project/app/warzone/Commands/OrderCommands.java b/src/main/java/project/app/warzone/Commands/OrderCommands.java index 2b6a828..1065e40 100644 --- a/src/main/java/project/app/warzone/Commands/OrderCommands.java +++ b/src/main/java/project/app/warzone/Commands/OrderCommands.java @@ -10,6 +10,13 @@ @ShellComponent public class OrderCommands { + /** + * command for deploy army + * + * @param p_countryID storing country id + * @param p_armies storing numberofArmies + * @return returns the status + */ @ShellMethod(key = "deploy", value = "This is used to deploy armies") public String deployArmies(@ShellOption int p_countryID, @ShellOption int p_armies) { return "You can deploy armies here"; diff --git a/src/main/java/project/app/warzone/Commands/PlayerCommands.java b/src/main/java/project/app/warzone/Commands/PlayerCommands.java index 5be8900..ae8e7a8 100644 --- a/src/main/java/project/app/warzone/Commands/PlayerCommands.java +++ b/src/main/java/project/app/warzone/Commands/PlayerCommands.java @@ -14,10 +14,16 @@ @ShellComponent public class PlayerCommands { - public GameEngine gameEngine; - public PlayerFeatures playerFeatures; - public String prevUserCommand; - + public GameEngine gameEngine; //used for gameEngine + public PlayerFeatures playerFeatures; //used for playerFeatures + public String prevUserCommand; //storing user previous command + + /** + * Constructor for Playercommands + * + * @param gameEngine storing gameEngine + * @param playerFeatures storing playerFeatures + */ public PlayerCommands(GameEngine gameEngine,PlayerFeatures playerFeatures){ this.gameEngine = gameEngine; this.playerFeatures= playerFeatures; @@ -25,14 +31,13 @@ public PlayerCommands(GameEngine gameEngine,PlayerFeatures playerFeatures){ - /** - * @param @ShellOption - * @param defaultValue=ShellOption.NULL - * @param p_playerNameOne - * @param @ShellOption(value="r" - * @param defaultValue=ShellOption.NULL - * @param p_playerNameTwo - * @return String + + /** + * command for add player + * + * @param p_playerNameOne storing player 1 name + * @param p_playerNameTwo storing player 2 name + * @return */ @ShellMethod(key= "gameplayer", prefix = "-", value="Player can create or remove a player") public String gamePlayerAdd(@ShellOption(value="a",defaultValue=ShellOption.NULL, arity = 10 ) String p_playerNameOne,@ShellOption(value="r", defaultValue=ShellOption.NULL, arity=10) String p_playerNameTwo){ diff --git a/src/main/java/project/app/warzone/Features/MapFeatures.java b/src/main/java/project/app/warzone/Features/MapFeatures.java index fc36adf..1500bd5 100644 --- a/src/main/java/project/app/warzone/Features/MapFeatures.java +++ b/src/main/java/project/app/warzone/Features/MapFeatures.java @@ -14,13 +14,18 @@ import project.app.warzone.Model.Map; import project.app.warzone.Model.Node;; +/** + * This class stores all the map-related functions in gameplay + */ @Component public class MapFeatures { /** - * @param filename - * @return Map + * used for reading map + * + * @param filename used for storing file name + * @return Map returns gamemap */ public Map readMap(String filename){ @@ -113,7 +118,9 @@ public Map readMap(String filename){ /** - * @param gameMap + *used for displaying map + * + * @param gameMap used for storing game map */ public void printMap(Map gameMap){ @@ -150,10 +157,12 @@ public void printMap(Map gameMap){ - /** - * @param p_allNodes - * @param l_visitedList - * @return Map + /** + * used for validation + * + * @param p_allNodes storing list of all nodes + * @param l_visitedList storing list of visited nodes + * @return Map storing map */ public java.util.Map validateByNodes(List p_allNodes, java.util.Map l_visitedList){ @@ -174,9 +183,11 @@ public java.util.Map validateByNodes(List p_allNodes, java.u - /** - * @param gameEngine - * @return Boolean + /** + * used for validating entire graph + * + * @param gameEngine storing gameEngine + * @return Boolean returns the status of validating */ public Boolean validateEntireGraph(GameEngine gameEngine){ @@ -217,10 +228,12 @@ public Boolean validateEntireGraph(GameEngine gameEngine){ /** - * @param con - * @param l_listOfNodes - * @param l_visitedList - * @return boolean + * used for validating sub-graph + * + * @param con storing continent + * @param l_listOfNodes storing list of nodes + * @param l_visitedList storing list of visited nodes + * @return boolean returns the status of validating */ public boolean validateSubGraph(Continent con, List l_listOfNodes,java.util.Map l_visitedList){ @@ -245,9 +258,11 @@ public boolean validateSubGraph(Continent con, List l_listOfNodes,java.uti /** - * @param currentCountry - * @param l_visitedList - * @return Map + * used for implementing DFS + * + * @param currentCountry storing current country + * @param l_visitedList storing list of visited list + * @return Map returns status */ private java.util.Map depthFirstSearch(Node currentCountry, java.util.Map l_visitedList){ diff --git a/src/main/java/project/app/warzone/Features/PlayerFeatures.java b/src/main/java/project/app/warzone/Features/PlayerFeatures.java index 69a2839..f0c48a0 100644 --- a/src/main/java/project/app/warzone/Features/PlayerFeatures.java +++ b/src/main/java/project/app/warzone/Features/PlayerFeatures.java @@ -10,13 +10,16 @@ import project.app.warzone.Model.Player; import project.app.warzone.Model.Country; +/** + * This class stores all the player-related functions in gameplay + */ @Component public class PlayerFeatures { /** - * @param allPlayers + * @param allPlayers list of all players */ public void showAllAssignments(List allPlayers){ @@ -38,7 +41,7 @@ public void showAllAssignments(List allPlayers){ /** - * @param p_gameEngine + * @param p_gameEngine storing gameEngine */ public void assignCountries(GameEngine p_gameEngine){ @@ -65,8 +68,8 @@ public void assignCountries(GameEngine p_gameEngine){ /** - * @param p_playerName - * @param gameEngine + * @param p_playerName storing playername + * @param gameEngine storing gameEngine */ public void addPlayers(String p_playerName, GameEngine gameEngine){ @@ -76,6 +79,9 @@ public void addPlayers(String p_playerName, GameEngine gameEngine){ } + /** + * @param gameEngine storing gameEngine + */ public void setPlayerIds(GameEngine gameEngine){ int i=1; @@ -89,8 +95,8 @@ public void setPlayerIds(GameEngine gameEngine){ /** - * @param p_playerName - * @param gameEngine + * @param p_playerName storing playername + * @param gameEngine storing gameEngine */ public void removePlayers(String p_playerName, GameEngine gameEngine){ @@ -105,7 +111,7 @@ public void removePlayers(String p_playerName, GameEngine gameEngine){ /** - * @param gameEngine + * @param gameEngine storing gameEngine */ public void printAllPlayers(GameEngine gameEngine){ System.out.println("Final players of the game are:"); @@ -118,7 +124,7 @@ public void printAllPlayers(GameEngine gameEngine){ /** - * @param gameengine + * @param gameengine storing gameEngine */ public void showStats(GameEngine gameengine){ List listOfPlayers = gameengine.getPlayers(); diff --git a/src/main/java/project/app/warzone/Model/Continent.java b/src/main/java/project/app/warzone/Model/Continent.java index f7418b1..8575d88 100644 --- a/src/main/java/project/app/warzone/Model/Continent.java +++ b/src/main/java/project/app/warzone/Model/Continent.java @@ -7,10 +7,12 @@ public class Continent { private String continentName; private Integer bonus; + //Intializing continentName public Continent(String continentName) { this.continentName = continentName; } + //Intializing continentName and bonus public Continent(String continentName, Integer bonus) { this.continentName = continentName; this.bonus = bonus; @@ -21,7 +23,7 @@ public Continent(String continentName, Integer bonus) { * @return String */ public String getContinentName() { - return continentName; + return continentName; //returns Continent name } @@ -30,14 +32,14 @@ public String getContinentName() { * @return int */ public int getBonus() { - return bonus; + return bonus; //returns Bonus value } /** * @param newBonus */ public void setBonus(int newBonus) { - bonus = newBonus; + bonus = newBonus; //used for setting new Bonus value } @@ -45,7 +47,7 @@ public void setBonus(int newBonus) { * @param newContinentName */ public void setContinentName(String newContinentName) { - continentName = newContinentName; + continentName = newContinentName; //used for setting new Continent name } diff --git a/src/main/java/project/app/warzone/Model/Country.java b/src/main/java/project/app/warzone/Model/Country.java index 0ea0507..2341cd5 100644 --- a/src/main/java/project/app/warzone/Model/Country.java +++ b/src/main/java/project/app/warzone/Model/Country.java @@ -11,8 +11,16 @@ public class Country { private Continent continent; - public Country() {} + public Country() {} //default constructor + /** + * Constructor for initializing countryname, continent, ownerid, numberofarmies + * + * @param CountryName + * @param continent + * @param ownerId + * @param numberOfArmies + */ public Country(String CountryName, Continent continent, int ownerId, int numberOfArmies) { this.CountryName = CountryName; this.ownerId = ownerId; @@ -20,41 +28,47 @@ public Country(String CountryName, Continent continent, int ownerId, int numberO this.continent = continent; } + /** + * Constructor for initializing countryname + * + * @param CountryName + * @param continent + */ public Country(String CountryName, Continent continent) { this.CountryName = CountryName; this.continent = continent; } public String getCountryName() { - return CountryName; + return CountryName; //returns Countryname } public int getOwnerId() { - return ownerId; + return ownerId; //returns ownerId } public int getNumberOfArmies() { - return numberOfArmies; + return numberOfArmies; //returns numberofArmies } public Continent getContinent() { - return continent; + return continent; //returns continent } public void setCountryName(String newCountryName) { - CountryName = newCountryName; + CountryName = newCountryName; //used for setting newCountryname } public void setOwnerId(int newOwnerId) { - ownerId = newOwnerId; + ownerId = newOwnerId; //used for setting newOwnerId } public void setNumberOfArmies(int newNumberOfArmies) { - numberOfArmies = newNumberOfArmies; + numberOfArmies = newNumberOfArmies; //used for setting newNumberofArmies } public void setContinent(Continent newContinent) { - continent = newContinent; + continent = newContinent; //used for setting newContinent } } diff --git a/src/main/java/project/app/warzone/Model/GameEngine.java b/src/main/java/project/app/warzone/Model/GameEngine.java index 118e086..fc86f44 100644 --- a/src/main/java/project/app/warzone/Model/GameEngine.java +++ b/src/main/java/project/app/warzone/Model/GameEngine.java @@ -14,21 +14,37 @@ public class GameEngine { - public List d_playersList; - public Map gameMap; - public Commands prevUserCommand; + public List d_playersList; //storing player list + public Map gameMap; //storing gameMap + public Commands prevUserCommand; //storing user's previous command + /** + * Initializing gameMap and d_playersList + * + * @param gameMap + */ public GameEngine(Map gameMap ){ this.gameMap = new Map(); // this is required this.d_playersList = new ArrayList<>(); } + + /** + * used for returning player list + * + * @return + */ public List getPlayers() { - return d_playersList; // returns all territories in the map + return d_playersList; // returns player list } + /** + * used for returning game map + * + * @return + */ public Map getGameMap() { - return gameMap; // returns all territories in the map + return gameMap; // returns game map } diff --git a/src/main/java/project/app/warzone/Model/Map.java b/src/main/java/project/app/warzone/Model/Map.java index 925c9d9..5ca30b4 100644 --- a/src/main/java/project/app/warzone/Model/Map.java +++ b/src/main/java/project/app/warzone/Model/Map.java @@ -18,9 +18,12 @@ public class Map { private List nodes; private List listOfContinents; - public String USER_SELECTED_FILE="europe"; + public String USER_SELECTED_FILE="europe"; //used for storing userselected file + /** + * Constructor for Map + */ public Map() { nodes = new ArrayList<>(); listOfContinents = new ArrayList<>(); @@ -28,7 +31,9 @@ public Map() { - /** + /** + * method used for returning all territories + * * @return List */ public List getNodes() { @@ -37,7 +42,9 @@ public List getNodes() { - /** + /** + * method used for creating continent + * * @param continentName * @param continentBonus */ @@ -50,6 +57,8 @@ public void createContinent(String continentName, Integer continentBonus){ /** + * method used for creating and inserting country + * * @param countryName * @param continent */ @@ -59,7 +68,9 @@ public void createAndInsertCountry(String countryName, Continent continent){ } - /** + /** + * method used for returning list of continents + * * @return List */ public List getListOfContinents() { @@ -68,7 +79,9 @@ public List getListOfContinents() { - /** + /** + * method used for adding borders + * * @param mainCountry * @param addBorders */ @@ -80,6 +93,8 @@ public void addEdgesOfCountry(Node mainCountry , List addBorders) /** + * method used for returning mapFile location + * * @return String */ public String getMapDirectory(){ @@ -89,6 +104,8 @@ public String getMapDirectory(){ /** + * returns user selected file + * * @return String */ public String get_USER_SELECTED_FILE() { @@ -97,7 +114,9 @@ public String get_USER_SELECTED_FILE() { - /** + /** + * used for setting user selected file + * * @param newFile */ public void set_USER_SELECTED_FILE(String newFile) { @@ -107,6 +126,8 @@ public void set_USER_SELECTED_FILE(String newFile) { /** + * method used to check if file exists + * * @param p_filename * @return boolean */ diff --git a/src/main/java/project/app/warzone/Model/Node.java b/src/main/java/project/app/warzone/Model/Node.java index b33c712..4765c86 100644 --- a/src/main/java/project/app/warzone/Model/Node.java +++ b/src/main/java/project/app/warzone/Model/Node.java @@ -11,6 +11,11 @@ public class Node { private List borderNodes; + /** + * counstructor for Node + * + * @param data storing country data + */ public Node(Country data) { this.data = data; } @@ -36,7 +41,7 @@ public Country getDataPtr() { /** - * @return List + * @return List returns bordernodes */ public List getBorders() { return borderNodes; @@ -45,7 +50,7 @@ public List getBorders() { /** - * @param data + * @param data set country data */ public void setData(Country data) { this.data = data; @@ -54,7 +59,7 @@ public void setData(Country data) { /** - * @param borderCountries + * @param borderCountries list of border countries */ public void addBorderTerritories(List borderCountries){ borderNodes=borderCountries; diff --git a/src/main/java/project/app/warzone/Model/Order.java b/src/main/java/project/app/warzone/Model/Order.java index 9fe7b56..d45a7b2 100644 --- a/src/main/java/project/app/warzone/Model/Order.java +++ b/src/main/java/project/app/warzone/Model/Order.java @@ -16,7 +16,7 @@ public class Order { /** * This method is used to set armies for the particular order - * @param p_numArmies + * @param p_numArmies storing numberofArmies to set */ public void setL_numberOfArmies(int p_numArmies) { this.d_numberOfArmies = p_numArmies; @@ -26,7 +26,7 @@ public void setL_numberOfArmies(int p_numArmies) { /** * This method is user to set Country for the particular order - * @param p_territory + * @param p_territory storing territory to set */ public void setL_territory(Country p_territory) { this.d_Country = p_territory; diff --git a/src/main/java/project/app/warzone/Model/Player.java b/src/main/java/project/app/warzone/Model/Player.java index 33dafbe..823a5d7 100644 --- a/src/main/java/project/app/warzone/Model/Player.java +++ b/src/main/java/project/app/warzone/Model/Player.java @@ -13,12 +13,17 @@ public class Player public int d_playerid; //Player id of the player to decide the round robin order to deploy public String d_playername; //Name of the player assigned by the user public int d_reinforcementPool; //Total number of players available to deploy in each round - - public List d_listOfCountriesOwned; //List of countries owned by the player + public List d_listOfCountriesOwned; //List of countries owned by the player public Stack d_listOfOrders; //stores orders issued by the player + /** + * Constructor for Player + * + * @param p_playerid storing playerId + * @param p_playername storing playername + */ public Player(int p_playerid ,String p_playername) { this.d_playerid = p_playerid; this.d_playername = p_playername; @@ -38,7 +43,7 @@ public int getL_playerid() { /** - * @param p_playerid + * @param p_playerid storing playerid to set */ public void setL_playerid(int p_playerid) { d_playerid = p_playerid; @@ -54,7 +59,7 @@ public String getL_playername() { /** - * @param noOfArmies + * @param noOfArmies storing numberofArmies to set reinforcement */ public void initReinforcementArmies(int noOfArmies){ d_reinforcementPool= noOfArmies; @@ -63,7 +68,7 @@ public void initReinforcementArmies(int noOfArmies){ /** - * @param noOfArmies + * @param noOfArmies storing numberofArmies to add reinforcement */ public void addReinforcementArmies(int noOfArmies){ d_reinforcementPool+= noOfArmies; @@ -81,7 +86,7 @@ public int getReinforcementArmies(){ /** - * @param l_playername + * @param l_playername storing playername to set */ public void setL_playername(String l_playername) { d_playername = l_playername; @@ -90,7 +95,7 @@ public void setL_playername(String l_playername) { /** - * @param country + * @param country storing country to add into player territories */ public void setTerritories(Country country){ d_listOfCountriesOwned.add(country); @@ -99,7 +104,7 @@ public void setTerritories(Country country){ /** - * @return List + * @return List returns players' list of territory */ public List getListOfTerritories(){ return d_listOfCountriesOwned; @@ -109,13 +114,16 @@ public List getListOfTerritories(){ /** - * @param order + * @param order storing order to add */ public void issue_order(Order order) { d_listOfOrders.push(order); } + /** + * method used to clear order list + */ public void clear_orderList(){ d_listOfOrders.clear(); } diff --git a/src/main/java/project/app/warzone/Utilities/Commands.java b/src/main/java/project/app/warzone/Utilities/Commands.java index 5c04caf..be44c24 100644 --- a/src/main/java/project/app/warzone/Utilities/Commands.java +++ b/src/main/java/project/app/warzone/Utilities/Commands.java @@ -4,11 +4,11 @@ * This enum class is used to store the available gameplay commands */ public enum Commands { - LOADMAP, - SHOWMAP, - ADDPLAYER, - REMOVEPLAYER, - EDITMAP + LOADMAP, //command to load map + SHOWMAP, //command to show map + ADDPLAYER, //command to add player + REMOVEPLAYER, //command to remove player + EDITMAP //command to edit map } \ No newline at end of file diff --git a/src/main/java/project/app/warzone/Utilities/MapResouces.java b/src/main/java/project/app/warzone/Utilities/MapResouces.java index 1fedad7..cdcec8c 100644 --- a/src/main/java/project/app/warzone/Utilities/MapResouces.java +++ b/src/main/java/project/app/warzone/Utilities/MapResouces.java @@ -14,6 +14,9 @@ public class MapResouces { Map listofContinents= new HashMap(); Map listofCountries= new HashMap(); + /** + * Constructor for MapResources + */ public MapResouces(){ setAllContinents(); @@ -23,6 +26,9 @@ public MapResouces(){ } + /** + * method to set all continents + */ public void setAllContinents(){ listofContinents.put(1, "North_Europe"); @@ -34,6 +40,9 @@ public void setAllContinents(){ + /** + * method to set all countries + */ public void setAllCountries(){ listofCountries.put(1, "England"); @@ -62,19 +71,25 @@ public void setAllCountries(){ listofCountries.put(24, "Luxembourg"); } + /** + * @return returns list of continents + */ public MapgetAllContinents(){ return listofContinents; } + /** + * @return returns list of country + */ public MapgetAllCountries(){ return listofCountries; } /** - * @param p_detailsOfMap + * @param p_detailsOfMap storing details of map */ public void printMapDetails(Map p_detailsOfMap){ diff --git a/src/main/java/project/app/warzone/Utilities/MyFilenameFilter.java b/src/main/java/project/app/warzone/Utilities/MyFilenameFilter.java index 83211b6..e74a5fd 100644 --- a/src/main/java/project/app/warzone/Utilities/MyFilenameFilter.java +++ b/src/main/java/project/app/warzone/Utilities/MyFilenameFilter.java @@ -10,7 +10,11 @@ public class MyFilenameFilter implements FilenameFilter { String d_initials; - // constructor to initialize object + /** + * constructor to initialize object + * + * @param p_initials storing filename + */ public MyFilenameFilter(String p_initials) { System.out.println("current"+System.getProperty("user.dir")); diff --git a/src/main/java/project/app/warzone/WarzoneApplication.java b/src/main/java/project/app/warzone/WarzoneApplication.java index 52f66d8..de83d38 100644 --- a/src/main/java/project/app/warzone/WarzoneApplication.java +++ b/src/main/java/project/app/warzone/WarzoneApplication.java @@ -3,9 +3,17 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * main class for the warzone application + */ @SpringBootApplication public class WarzoneApplication { + /** + * main method for warzone + * + * @param args string + */ public static void main(String[] args) { SpringApplication.run(WarzoneApplication.class, args); //System.out.println("test");