| 1234567891011121314151617181920212223242526272829303132333435363738 |
- //
- // die.cxx
- // dice-roll
- //
- // Created by Sam Jaffe on 12/1/18.
- // Copyright © 2018 Sam Jaffe. All rights reserved.
- //
- #include "dice-roll/die.h"
- #include "dice-roll/exception.h"
- namespace dice {
- int sgn(sign s) { return s == sign::MINUS ? -1 : 1; }
- std::string str(sign s) {
- switch (s) {
- case sign::PLUS:
- return "+";
- case sign::MINUS:
- return "-";
- default:
- return "";
- }
- }
- mod::operator int() const { return sgn(sign) * value; }
- bool difficulty_class::operator()(int value) const {
- switch (comp) {
- case test::None: return true;
- case test::Less: return value < against;
- case test::LessOrEqual: return value <= against;
- case test::Greater: return value > against;
- case test::GreaterOrEqual: return value >= against;
- }
- }
- }
|