diff options
author | Your Name <you@example.com> | 2021-12-25 16:52:34 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2021-12-25 16:52:34 -0500 |
commit | 52b91a1aca6640b1797a63afc8a9e9a778b0964a (patch) | |
tree | 0cfb8ebe6a0a511607b3acc6c67228b796cd9c90 /src/cmd_query.cc | |
parent | d8d1056af0383f0ef67c6d70d1594bcb430d7281 (diff) | |
download | dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.tar.gz dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.tar.bz2 dmtool-52b91a1aca6640b1797a63afc8a9e9a778b0964a.zip |
Added capability to cause two npcs to attack each other
Diffstat (limited to 'src/cmd_query.cc')
-rw-r--r-- | src/cmd_query.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/cmd_query.cc b/src/cmd_query.cc index 5172cda..e13876f 100644 --- a/src/cmd_query.cc +++ b/src/cmd_query.cc @@ -22,25 +22,22 @@ namespace cmd { std::string rollName = utils::join(args, " "); utils::lower(rollName); int rolled = dice::roll(20); - auto printResults = [&text](std::string name, std::string type, int rolled, int bonus) { - text << name << " " << type << ": " << rolled << " (d20) + " << bonus << " (" << name << " " << type << " bonus) = " << rolled + bonus << std::endl; - }; // Search through skills, saves, and attacks to roll if(rollName == "init" or rollName == "initiative") { - printResults("Initiative", "check", rolled, c->getInitiative()); + 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) { - printResults(skill.getName(), "check", rolled, c->getSkillBonus(skill)); + text << formatRoll(skill.getName(), "check", rolled, c->getSkillBonus(skill)); } else if(ability) { - printResults(ability.getFull(), "save", rolled, c->getAbilitySaveBonus(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); - printResults(w->getName(), "attack", rolled, bonus); + text << formatRoll(w->getName(), "attack", rolled, bonus); text << " on hit: " << entry::formatDmg(*w, *c) << std::endl; break; } |