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: Ghost/Ghost.h
- Revision:
- 2:eaf245af2aae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Ghost/Ghost.h Fri Mar 06 19:27:12 2020 +0000
@@ -0,0 +1,101 @@
+/** Ghosts Class
+ * @brief Library for generating and saving .ghost files for the game
+ * @author George Sykes [el18gs]
+ */
+
+/* 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
+*/
+
+
+#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 num, 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;
+};
+
+#endif
\ No newline at end of file