Difference between revisions of "Dice/PbP/RollPost/AddRoll (String, RollerConfig)"
(Created page with "{{APIdoc|RollPost.AddRoll Method (String, RollerConfig)}} Adds a new roll to the post using the given config if the roll needs to be evaluated. {{ns}} == Syntax == <syntaxhi...") |
|||
Line 44: | Line 44: | ||
| Evaluate ''diceExpr'' | | Evaluate ''diceExpr'' | ||
|} | |} | ||
+ | |||
+ | If Pristine or Stored are saving invalid rolls (such as the dice expression {{c|1d20+}}), replacing them with a valid roll does not change the state, but will replace the invalid roll with the new (valid) one for all future iterations. |
Latest revision as of 18:30, 16 June 2017
Adds a new roll to the post using the given config if the roll needs to be evaluated.
- Namespace: Dice.PbP
- Assembly: DiceRoller (in DiceRoller.dll)
Syntax
public void AddRoll(
string diceExpr,
RollerConfig config
)
Parameters
- diceExpr
- Type: System.String
- The dice expression to add, will be evaluated then added to the end of Current.
- config
- Type: Dice.RollerConfig
- The configuration used for the roll. If
null
, Roller.DefaultConfig is used.
Remarks
This will first attempt to use a previously evaluated version of this roll, if possible. If the roll does not matched the current position of Pristine or Stored, it will be evaluated anew via Roller.Roll using the given config.
When a new RollPost is made, it starts in the "pristine" state. When a roll is added via AddRoll(), the following chart indicates how it matches against saved roll results. Once all rolls have been added via AddRoll() and Validate() has been called, the state the RollPost is currently in determines how valid the current version of the post is. In the chart below, Pristine[i] and Stored[i] refer to the ith element of Pristine or Stored, where i is how many rolls have been added via AddRoll (so the first time AddRoll() is called, i = 0, then the next time it is called i = 1, and so on).
Current state | diceExpr == Pristine[i] | diceExpr == Stored[i] | Otherwise |
---|---|---|---|
Pristine | Use stored Pristine[i] roll | Use stored Stored[i] roll, move to state stored | Evaluate diceExpr, move to state divergent |
Stored | N/A (condition not checked) | Use stored Stored[i] roll | Evaluate diceExpr, move to state divergent |
Divergent | N/A (condition not checked) | N/A (condition not checked) | Evaluate diceExpr |
If Pristine or Stored are saving invalid rolls (such as the dice expression 1d20+
), replacing them with a valid roll does not change the state, but will replace the invalid roll with the new (valid) one for all future iterations.