| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // roll.hpp
- // dice-roll
- //
- // Created by Sam Jaffe on 12/1/18.
- // Copyright © 2018 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <vector>
- #include "die.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<int> 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<die_roll> sub_rolls;
- // A vector of every modifier attached to the system.
- std::vector<mod> modifiers;
- };
- /**
- * @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<dice_roll> roll(dice const & d);
- /**
- * 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);
- }
|