Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Inventory/Ghost/Ghost.h
- Revision:
- 3:9d811414d35e
- Child:
- 4:2e8d7c6d2953
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Inventory/Ghost/Ghost.h Mon May 11 11:58:31 2020 +0000
@@ -0,0 +1,107 @@
+/**
+ * @file Ghost.h
+ * @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.
+ * @author George Sykes [el18gs]
+ * @date 11 May 2020
+
+@code
+* sample.ghost file
+1.ghost:
+/Type
+Basic
+/Name
+Casper
+/Attack
+10
+/Defense
+10
+/Level
+1
+/XP
+0
+/Value
+10
+/HP_max
+10
+/HP
+10
+/UID
+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:
+
+ Ghost(const std::string path, const std::string root);
+ Ghost(int type, int nameNumber, const std::string root);
+
+ void listdir(std::string path);
+ void save(void);
+ int sell(void);
+ void feed(int ammount);
+
+ void print_all(void);
+ Type get_type_enum(void);
+ std::string get_type_string(void);
+ std::string get_name(void);
+ int get_attack(void);
+ int get_defense(void);
+ int get_level(void);
+ int get_xp(void);
+ int get_value(void);
+ int get_hp_max(void);
+ int get_hp(void);
+ int get_uid(void);
+
+private:
+ int gen_uid(void);
+ bool hasEnding (std::string const &fullString, std::string const &ending);
+
+ std::string type_to_string(Type type);
+ Type string_to_type(std::string type);
+ void delete_file(const char filename[]);
+
+ Type _type;
+ std::string _name;
+ int _attack;
+ int _defense;
+ int _level;
+ int _xp;
+ int _value;
+ int _hp_max;
+ int _hp;
+ int _uid;
+ static const string _suffix;
+ std::string _root;
+
+ stringvec _names;
+};
+
+#endif
\ No newline at end of file