aboutsummaryrefslogtreecommitdiff
path: root/src/cmd.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-01-16 21:32:01 -0500
committerYour Name <you@example.com>2022-01-16 21:32:01 -0500
commitd0e356d09e30a11c1e072415a5088f829d5c0a04 (patch)
tree1e64d37b9b424cd74c30ad4c8225828c7a76874e /src/cmd.cc
parent3f78a7e1647ba94129236bd2bf4fc855c109628a (diff)
downloaddmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.gz
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.bz2
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.zip
Worked on features
Diffstat (limited to 'src/cmd.cc')
-rw-r--r--src/cmd.cc54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/cmd.cc b/src/cmd.cc
deleted file mode 100644
index d84c55b..0000000
--- a/src/cmd.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "cmd.h"
-#include "settings.h"
-#include <vector>
-#include <string>
-#include <filesystem>
-#include <algorithm>
-
-namespace cmd {
- std::vector<std::string> getVirtDirs() {
- return {"weapons", "armor", "spells", "creatures"};
- }
-
- // Not idempotent: only do once!
- std::filesystem::path getTruePath(std::filesystem::path virtPath) {
- std::filesystem::path p;
- auto virtPaths = getVirtDirs();
- if(std::find(virtPaths.begin(), virtPaths.end(), *virtPath.begin()) != virtPaths.end()) {
- p = settings::getString(*virtPath.begin());
- // Erase root (part to be replaced by virtPaths)
- std::filesystem::path tmp;
- auto it = virtPath.begin();
- while(++it != virtPath.end()) {
- tmp /= *it;
- }
- virtPath = tmp;
- } else {
- p = settings::getString("savedir");
- }
- p /= virtPath;
- if(std::filesystem::directory_entry(p.string() + ".json").is_regular_file()) return p.string() + ".json";
- return p;
- }
-
- std::string formatRoll(std::string name, std::string type, int rolled, int bonus) {
- std::stringstream text;
- text << name << " " << type << ": " << rolled << " (d20) + " << bonus << " (" << name << " " << type << " bonus) = " << rolled + bonus << std::endl;
- return text.str();
- }
-
- std::vector<rules::Qualifier> parseQualifiers(std::map<std::string, std::string> flags) {
- std::vector<rules::Qualifier> qualifiers;
- for(auto flagPair : flags) {
- auto flag = flagPair.first;
- if(flag == "m" || flag == "magical") {
- qualifiers.push_back(rules::Qualifier::Magical());
- } else if(flag == "s" || flag == "silvered") {
- qualifiers.push_back(rules::Qualifier::Silvered());
- } else if(flag == "a" || flag == "adamantine") {
- qualifiers.push_back(rules::Qualifier::Adamantine());
- }
- }
- return qualifiers;
- }
-}