ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18gs

Dependencies:   mbed

Revision:
4:2e8d7c6d2953
Parent:
3:9d811414d35e
Child:
5:27aa2d0891b7
--- a/Inventory/Ghost/Ghost.h	Mon May 11 11:58:31 2020 +0000
+++ b/Inventory/Ghost/Ghost.h	Mon May 11 17:17:20 2020 +0000
@@ -1,13 +1,27 @@
-/**
- * @file Ghost.h
+// Ensure that the library is not importated twice
+#ifndef GHOST_H
+#define GHOST_H
+
+// Import necessay libraries
+#include "SDFileSystem.h"
+#include <string>
+#include <vector>
+#include <iostream>
+
+// Define a stringvec as a vector of strings
+typedef std::vector<std::string> stringvec;
+
+enum Type {BASIC, ECTO, POLTER, ORB, FUNNEL};
+
+/** Ghost Class
  * @brief revision 0.9
- * @brief Library for generating and saving .ghost files for the game. Some of 
- * the files need to be imported from the SD others are generated. 
+ * @brief Library for generating and saving .ghost files for the game. Some of
+ * @brief the files need to be imported from the SD others are generated.
  * @author George Sykes [el18gs]
  * @date 11 May 2020
 
 @code
-* sample.ghost file
+sample.ghost file
 1.ghost:
 /Type
 Basic
@@ -31,56 +45,119 @@
 1
 @endcode
 */
-
-#ifndef GHOST_H
-#define GHOST_H
-
-#include "SDFileSystem.h"
-#include <string>
-#include <vector>
-#include <iostream>
-
-//const string Ghost::suffix = ".ghost";
-
-typedef std::vector<std::string> stringvec;
-
-// Connections to SD card holder on K64F (SPI interface)
-//SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
-
-enum Type {
-    BASIC,
-    ECTO,
-    POLTER,
-    ORB,
-    FUNNEL
-};
-
 class Ghost
 {
 public:
-
+    // Constructors
+    /** Create a Ghost object by importing a .ghost file
+    * @param path The name of the .ghost file to import
+    * @param root The directory to look for the file in
+    */
     Ghost(const std::string path, const std::string root);
+    
+    /** Create a Ghost object using two numbers to define its type and name
+    * @param type an interger number between 0 and 100 to define the type of ghost
+    * @param nameNumber an integer number between 0 and 20 to define the name of the ghost
+    * @param root the directory to save the Ghost object in
+    * @note this constructor will save the object as a .ghost file using the @ref save(void)
+    * @note the UID (Unique ID) of this object will be generated by @ref gen_uid(void)
+    */
     Ghost(int type, int nameNumber, const std::string root);
-
+    
+    /** List all files in the directory path passed
+    * @param Path directory to list
+    */
     void listdir(std::string path);
+    
+    /** Save the current ghost
+    * @note save the current ghost as a .ghost file, the name of the file is the UID
+    */
     void save(void);
+    
+    /** 'Sell' the ghost, in reality this means deleting its file and returning the value of the ghost
+    * @return an integer
+    */
     int sell(void);
+    
+    /** 'feed' the ghost, this means give it XP equal to the ammount passed
+    * @param ammount of food to feed, this is equal to the xp increase
+    * @note after this function the ghost will be saved using @ref save()
+    */
     void feed(int ammount);
-
+    
+    /** Print all the member variables over serial
+    * @note primarily used in debugging & development, can be removed if more space needed in final version
+    */
     void print_all(void);
+    
+    /** Get the type of ghost as an enum
+    * @notes uses the type stored in _type
+    * @return an enumerated class value
+    */
     Type get_type_enum(void);
+    
+    /** Get a string version of the type of ghost
+    * @notes uses the type stored in _type
+    * @return an c++ string
+    */
     std::string get_type_string(void);
+    
+    /** Get the name of the ghost
+    * @notes uses the name stored in _name
+    * @return an c++ string
+    */
     std::string get_name(void);
+    
+    /** Get the attack value of the ghost
+    * @notes uses the attack value stored in _attack
+    * @return an interger
+    */
     int get_attack(void);
+    
+    /** Get the defense value of the ghost
+    * @notes uses the defense value stored in _defense
+    * @return an integer
+    */
     int get_defense(void);
+    
+    /** Get the level of the ghost
+    * @notes uses the level stored in _level
+    * @return an integer
+    */
     int get_level(void);
+    
+    /** Get the ammount of XP the ghost has
+    * @notes uses the XP ammount stored in _xp
+    * @return an integer
+    */
     int get_xp(void);
+    
+    /** Get the value of the ghost
+    * @notes uses the value stored in _value
+    * @return an integer
+    */
     int get_value(void);
+    
+    /** Get the maximum HP of the ghost
+    * @notes uses the maximum HP stored in _hp_max
+    * @return an integer
+    */
     int get_hp_max(void);
+    
+    /** Get the current hp value of the ghost
+    * @notes uses the hp value stored in _hp
+    * @return an integer
+    */
     int get_hp(void);
+    
+    /** Get the UID of the ghost
+    * @notes uses the UID (Unique ID) stored in _uid
+    * @return an integer
+    */
     int get_uid(void);
 
 private:
+    // Methods
     int gen_uid(void);
     bool hasEnding (std::string const &fullString, std::string const &ending);