// // roll.hpp // dice-roll // // Created by Sam Jaffe on 12/1/18. // Copyright © 2018 Sam Jaffe. All rights reserved. // #pragma once #include #include "die.h" #include "random.h" namespace dice { // Describe the actual result of rolling (+/-)NdM struct die_roll { // Collapse this roll into its actual value operator int() const; // Is this being added, or subtracted from the total sign sign; // Since this roll was composed on NdM, rolled.size() == N. Each element // of rolled is within the integer range [1, M]. std::vector rolled; }; // Describe the actual result of rolling an arbitrary set of dice with mods struct dice_roll { // Collapse this roll into its actual value operator int() const; // A vector of component roll results, each on representing a single NdM // expression. std::vector sub_rolls; // A vector of every modifier attached to the system. std::vector modifiers; difficulty_class dc; }; class roller { public: roller(); roller(engine::random && g); /** * @param d Some dice roll structure, containing any number of dice sets 'NdM' * as well as any number of roll modifiers (fixed numbers). Additionally, * can contain a repetition parameter. * @return A vector of actualized rolls, where `vector.size() == d.num`. */ std::vector operator()(dice const & d); private: engine::random gen; }; /** * Print out the component elements of an actualized dice roll. * Use instead `out << int(r)` to print the final summation. */ std::ostream & operator<<(std::ostream & out, dice_roll const & r); }