Documentation ¶
Index ¶
- Constants
- func Parse(r io.Reader) (string, error)
- func ParseString(rollStr string) (string, error)
- type ComparisonOp
- type ComparisonType
- type DiceRoll
- type Die
- type DieRoll
- type ErrAmbiguousModifier
- type ErrEndOfRoll
- type ErrUnexpectedToken
- type ErrUnknownDie
- type ExplodingOp
- type ExplodingType
- type FateDie
- type GroupedRoll
- type LimitOp
- type LimitType
- type NormalDie
- type Parser
- type RerollOp
- type Result
- type Roll
- type Scanner
- type SortType
- type Token
Constants ¶
const ( // FateBlank is the symbol for a blank Fate die face FateBlank = "☐" // FateMinus is the symbol for a minus Fate die face FateMinus = "⊟" // FatePlus is the symbol for a plus Fate die face FatePlus = "⊞" )
Variables ¶
This section is empty.
Functions ¶
func ParseString ¶
ParseString takes a string and does a dice roll
Types ¶
type ComparisonOp ¶
type ComparisonOp struct { Type ComparisonType Value int }
ComparisonOp is the operation that defines how you compare against a roll to determine whether the result counts
func (*ComparisonOp) Match ¶
func (op *ComparisonOp) Match(val int) bool
Match returns true if the given value compares positively against the op val
func (*ComparisonOp) String ¶
func (op *ComparisonOp) String() string
String returns the string representation of the comparison operator
type ComparisonType ¶
type ComparisonType int
ComparisonType is the type of comparison
const ( // Equals matches only values that are equal to the comparison value Equals ComparisonType = iota // GreaterThan matches only values greater than the comparison value GreaterThan // LessThan matches only values less than the comparison value LessThan )
type DiceRoll ¶
type DiceRoll struct { Multiplier int Die Die Modifier int Exploding *ExplodingOp Limit *LimitOp Success *ComparisonOp Failure *ComparisonOp Rerolls []RerollOp Sort SortType }
DiceRoll is an individual Dice Roll
type ErrAmbiguousModifier ¶
type ErrAmbiguousModifier int
ErrAmbiguousModifier is raised when a multiplier was misread as a modifier
func (ErrAmbiguousModifier) Error ¶
func (e ErrAmbiguousModifier) Error() string
type ErrEndOfRoll ¶
type ErrEndOfRoll string
ErrEndOfRoll is raised when parsing a roll has reached a terminating token
func (ErrEndOfRoll) Error ¶
func (e ErrEndOfRoll) Error() string
type ErrUnexpectedToken ¶
type ErrUnexpectedToken string
ErrUnexpectedToken is raised on unexpected tokens
func (ErrUnexpectedToken) Error ¶
func (e ErrUnexpectedToken) Error() string
type ErrUnknownDie ¶
type ErrUnknownDie string
ErrUnknownDie is raised on unrecognised die types
func (ErrUnknownDie) Error ¶
func (e ErrUnknownDie) Error() string
type ExplodingOp ¶
type ExplodingOp struct { *ComparisonOp Type ExplodingType }
ExplodingOp is the operation that defines how a dice roll explodes
func (ExplodingOp) String ¶
func (e ExplodingOp) String() (output string)
String returns the string representation of the exploding dice operation
type ExplodingType ¶
type ExplodingType int
ExplodingType is the type of exploding die
const ( // Exploding adds new dice for each roll satisfying the exploding condition Exploding ExplodingType = iota // Compounded adds to a single new result for each roll Compounded // Penetrating is like Exploding, except each die result has a -1 modifier Penetrating )
type FateDie ¶
type FateDie int
FateDie is a die representing the typical Fate/Fudge die
type GroupedRoll ¶
type GroupedRoll struct { Rolls []Roll Modifier int Limit *LimitOp Success *ComparisonOp Failure *ComparisonOp Combined bool Negative bool }
GroupedRoll is a group of other rolls. You can have nested groups.
func (*GroupedRoll) Roll ¶
func (gr *GroupedRoll) Roll() (result Result)
Roll gets the results of rolling the dice that make up a dice roll
func (*GroupedRoll) String ¶
func (gr *GroupedRoll) String() (output string)
String represents the grouped roll as a string
type LimitType ¶
type LimitType int
LimitType is the type of roll limitation
const ( // KeepHighest indicated we should keep the highest results KeepHighest LimitType = iota // KeepLowest indicated we should keep the lowest results KeepLowest // DropHighest indicated we should drop the highest results DropHighest // DropLowest indicated we should drop the lowest results DropLowest )
type NormalDie ¶
type NormalDie int
NormalDie is a die representing an N-sided die
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is our dice rolling parser
type RerollOp ¶
type RerollOp struct { *ComparisonOp Once bool }
RerollOp is the operation that defines how dice are rerolled
type Result ¶
Result is a collection of die rolls and a count of successes
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is our lexical scanner for dice roll strings
func NewScanner ¶
NewScanner returns a new instance of scanner