SlotMachine class

A class that creates the slot machine.

It currently only creates slot machines with 5 slot lines, 10 images each. The slot machine is visualized through 2 DOM elements. canvasEl shows the slot machine itself, with rotating slots. resultEl is a span element that automatically populates with the current outcome in real time.

The SlotMachine is single-serving, i.e. it cannot be rolled more than once.


SlotMachine(num probability, {Result predeterminedFirstResult, AnimationFrameFunction animationFrame, bool rerollable: false, String rerollEffectDescription})
Create a slot machine animation with given probability of success. [...]
SlotMachine.fromProbability(num probability, {Result predeterminedResult, AnimationFrameFunction animationFrame})
Create a slot machine animation with probability of success (of the whole machine) being probability.


allowCriticalFailure bool
Whether or not to allow this slot machine to return critical failures.
allowCriticalSuccess bool
Whether or not to allow this slot machine to return critical successes.
canvasEl CanvasElement
The canvas element that this library creates and that should be added to the DOM by the library's user.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
rerollable bool
Whether or not this SlotMachine allows rerolling. If so, rerollEffectDescription must not be null.
rerollEffectDescription String
What to show to user as the 'cost' of reroll. [...]
rerollEl DivElement
Element that the slot machine populates with buttons when reroll is in order.
read / write
resultEl SpanElement
The result element that this library updates with current result (i.e. what the slot machine would output if it was immediately halted, frozen in current state). [...]
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
width int
The width of each reel in pixels.


noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
play() Future<Result>
Start the slot machine session. This will roll the reels to completion once and will return the result of the first roll. [...]
rerollIfNeeded() Future<SessionResult>
This method returns the final SessionResult. It may allow the user to reroll if that is needed.
roll() Future<Result>
Start rolling the slot machine. Returns with the text of the result.
@Deprecated('Use play() instead')
toString() String
Returns a string representation of this object.


operator ==(Object other) bool
The equality operator. [...]


reelCount → const int
The number of reels (vertical lines) per each machine.
symbolCount → const int
Number of symbols in each reel.