Documentation ¶
Index ¶
Constants ¶
const ( Penalty = iota Bonus Multiplier )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Modifier ¶
type Modifier struct {
// contains filtered or unexported fields
}
Modifier represents a modifier, i.e. to a die.Roll.
func New ¶
New takes as input an operator and an operand. The operator can be one of modifier.Penalty, modifier.Bonus, or modifier.Multiplier. The operand can take any integer value. It returns a pointer to a modifier.Modifier or an error.
func Parse ¶
Parse takes as input a string representing a modifier, e.g., "+1", "-1" or "×3". The structure of the input must exactly match the regular expression, `^\s*([\+\-–\*×])?(\d+)\s*$. Assuming the input string can be successfully parsed, a pointer to a modifier.Modifier will be returned. Otherwise, an error will be returned.
func (*Modifier) Eval ¶
Eval evaluates the modifier against the caller-supplied score, returning the new score.