aboutsummaryrefslogtreecommitdiff
path: root/src/cmd_query.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_query.cc
parent3f78a7e1647ba94129236bd2bf4fc855c109628a (diff)
downloaddmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.gz
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.tar.bz2
dmtool-d0e356d09e30a11c1e072415a5088f829d5c0a04.zip
Worked on features
Diffstat (limited to 'src/cmd_query.cc')
-rw-r--r--src/cmd_query.cc48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/cmd_query.cc b/src/cmd_query.cc
deleted file mode 100644
index e13876f..0000000
--- a/src/cmd_query.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "cmd.h"
-#include "utils.h"
-#include "creature.h"
-#include "dice.h"
-#include "weapon.h"
-#include <sstream>
-
-namespace cmd {
- std::string attacks(std::vector<std::string> args) {
- std::stringstream text;
- auto c = utils::instantiate<creature::Creature>(getTruePath(args[0]));
- for(auto w : creature::getAttacks(*c)) {
- text << w->getName() << std::endl;
- }
- return text.str();
- }
-
- std::string roll(std::vector<std::string> args) {
- std::stringstream text;
- auto c = utils::instantiate<creature::Creature>(getTruePath(args[0]));
- args.erase(args.begin());
- std::string rollName = utils::join(args, " ");
- utils::lower(rollName);
- int rolled = dice::roll(20);
- // Search through skills, saves, and attacks to roll
- if(rollName == "init" or rollName == "initiative") {
- text << formatRoll("Initiative", "check", rolled, c->getInitiative());
- }
- rules::Skill skill = rules::tryGetAbilityOrSkill<rules::Skill>(rollName);
- rules::Ability ability = rules::tryGetAbilityOrSkill<rules::Ability>(rollName);
- if(skill) {
- text << formatRoll(skill.getName(), "check", rolled, c->getSkillBonus(skill));
- } else if(ability) {
- text << formatRoll(ability.getFull(), "save", rolled, c->getAbilitySaveBonus(ability));
- } else {
- for(auto w : creature::getAttacks(*c)) {
- if(w->getName() == rollName) {
- text << w->getText(*c) << std::endl;
- int bonus = w->getToHitBonus(*c);
- text << formatRoll(w->getName(), "attack", rolled, bonus);
- text << " on hit: " << entry::formatDmg(*w, *c) << std::endl;
- break;
- }
- }
- }
- return text.str();
- }
-}