< Dice
Difference between revisions of "Dice/RollResult"
From DiceRoller Documentation
m (→Fields) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
== Syntax == | == Syntax == | ||
<syntaxhighlight lang="C#"> | <syntaxhighlight lang="C#"> | ||
− | public class RollResult | + | [Serializable] |
+ | public class RollResult : ISerializable, IEquatable<RollResult> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 18: | Line 19: | ||
! Name !! Description | ! Name !! Description | ||
|- | |- | ||
− | | {{internal}} {{method}} || [[/RollResult|RollResult(DiceAST, Int32)]] || Constructs a new instance of RollResult. | + | | {{private}} {{method}} || [[/RollResult ()|RollResult()]] || Constructs a new instance of RollResult. |
+ | |- | ||
+ | | {{internal}} {{method}} || [[/RollResult (RollerConfig, DiceAST, Int32)|RollResult(RollerConfig, DiceAST, Int32)]] || Constructs a new instance of RollResult. | ||
+ | |- | ||
+ | | {{protected}} {{method}} || [[/RollResult (SerializationInfo, StreamingContext)|RollResult(SerializationInfo, StreamingContext)]] || Constructs a new instance of RollResult using the serialized data. | ||
|} | |} | ||
Line 25: | Line 30: | ||
! style="width: 5em" | | ! style="width: 5em" | | ||
! Name !! Description | ! Name !! Description | ||
+ | |- | ||
+ | | {{public}} {{static}} {{method}} || [[/Deserialize|Deserialize(Stream)]] || Deserializes binary data from the given stream. | ||
+ | |- | ||
+ | | {{public}} {{method}} || [[/Equals (RollResult)|Equals(RollResult)]] || Compare two RollResults and return whether or not they are equal. | ||
+ | |- | ||
+ | | {{public}} {{method}} || [[/Equals (Object)|Equals(Object)]] || Compare two RollResults and return whether or not they are equal. Overridden from Object.Equals(Object). | ||
+ | |- | ||
+ | | {{public}} {{method}} || [[/GetHashCode|GetHashCode()]] || Gets a hash code for the RollResult. Overridden from Object.GetHashCode(). | ||
+ | |- | ||
+ | | {{public}} {{method}} || [[/GetObjectData|GetObjectData(SerializationInfo, StreamingContext)]] || Serializes the RollResult. | ||
+ | |- | ||
+ | | {{public}} {{method}} || [[/Serialize|Serialize(Stream)]] || Serializes binary data to the given stream. | ||
|- | |- | ||
| {{public}} {{method}} || [[/ToString|ToString()]] || Display a representation of the roll. Overrides Object.ToString(). | | {{public}} {{method}} || [[/ToString|ToString()]] || Display a representation of the roll. Overrides Object.ToString(). | ||
Line 34: | Line 51: | ||
! Name !! Description | ! Name !! Description | ||
|- | |- | ||
− | | {{public}} {{property}} || [[/NumRolls|NumRolls]] || | + | | {{public}} {{property}} || [[/Expression|Expression]] || Gets the normalized dice expression that was rolled. |
+ | |- | ||
+ | | {{public}} {{property}} || [[/NumRolls|NumRolls]] || Gets the number of dice rolls that were needed to fully evaluate this expression. | ||
|- | |- | ||
| {{public}} {{property}} || [[/ResultType|ResultType]] || Gets whether or not Value represents the die total or the number of successes. | | {{public}} {{property}} || [[/ResultType|ResultType]] || Gets whether or not Value represents the die total or the number of successes. | ||
Line 43: | Line 62: | ||
|- | |- | ||
| {{public}} {{property}} || [[/Values|Values]] || Gets the results of each individual die rolled. | | {{public}} {{property}} || [[/Values|Values]] || Gets the results of each individual die rolled. | ||
+ | |} | ||
+ | |||
+ | == Fields == | ||
+ | {| class="wikitable" | ||
+ | ! style="width: 5em" | | ||
+ | ! Name !! Description | ||
+ | |- | ||
+ | | {{private}} {{field}} || [[/AllRolls|AllRolls]] || The rolled value for every die, from left-to-right according to the normalized Expression. | ||
+ | |- | ||
+ | | {{private}} {{field}} || [[/AllMacros|AllMacros]] || The value for every macro, from left-to-right according to the normalized Expression. | ||
+ | |- | ||
+ | | {{public}} {{static}} {{field}} || [[/InvalidRoll|InvalidRoll]] || This RollResult is used as a placeholder whenever an invalid roll is added to a [[Dice/PbP/RollPost|RollPost]]. | ||
+ | |} | ||
+ | |||
+ | == Overloaded Operators == | ||
+ | {| class="wikitable" | ||
+ | ! style="width: 5em" | | ||
+ | ! Name !! Description | ||
+ | |- | ||
+ | | {{public}} {{static}} {{method}} || [[/operator ==|operator ==(RollResult, RollResult)]] || Implements RollResult == RollResult. | ||
+ | |- | ||
+ | | {{public}} {{static}} {{method}} || [[/operator !=|operator !=(RollResult, RollResult)]] || Implements RollResult != RollResult. | ||
|} | |} | ||
== Remarks == | == Remarks == | ||
RollResults are returned from the [[Dice/Roller/Roll|Roller.Roll]] method, and can be used to obtain the results of the roll. This class is read-only. Typically, Value and Values are the only properties that are needed in the course of normal operations, however the full AST is exposed for advanced insight into the roll, should such be necessary. | RollResults are returned from the [[Dice/Roller/Roll|Roller.Roll]] method, and can be used to obtain the results of the roll. This class is read-only. Typically, Value and Values are the only properties that are needed in the course of normal operations, however the full AST is exposed for advanced insight into the roll, should such be necessary. | ||
+ | |||
+ | If a RollResult is deserialized, its RollRoot will be {{cs|null}}. A method may be provided in the future to re-construct the AST from the serialized data, but such a method does not currently exist. If you need access to the AST after deserialization, open an issue on GitHub letting me know (search for an existing one first!). |
Latest revision as of 18:29, 16 June 2017
Contains the result of a roll expression.
- Namespace: Dice
- Assembly: DiceRoller (in DiceRoller.dll)
Inheritance Hierarchy
System.Object
- Dice.RollResult
Syntax
[Serializable]
public class RollResult : ISerializable, IEquatable<RollResult>
Constructors
Name | Description | |
---|---|---|
RollResult() | Constructs a new instance of RollResult. | |
RollResult(RollerConfig, DiceAST, Int32) | Constructs a new instance of RollResult. | |
RollResult(SerializationInfo, StreamingContext) | Constructs a new instance of RollResult using the serialized data. |
Methods
Name | Description | |
---|---|---|
S | Deserialize(Stream) | Deserializes binary data from the given stream. |
Equals(RollResult) | Compare two RollResults and return whether or not they are equal. | |
Equals(Object) | Compare two RollResults and return whether or not they are equal. Overridden from Object.Equals(Object). | |
GetHashCode() | Gets a hash code for the RollResult. Overridden from Object.GetHashCode(). | |
GetObjectData(SerializationInfo, StreamingContext) | Serializes the RollResult. | |
Serialize(Stream) | Serializes binary data to the given stream. | |
ToString() | Display a representation of the roll. Overrides Object.ToString(). |
Properties
Name | Description | |
---|---|---|
Expression | Gets the normalized dice expression that was rolled. | |
NumRolls | Gets the number of dice rolls that were needed to fully evaluate this expression. | |
ResultType | Gets whether or not Value represents the die total or the number of successes. | |
RollRoot | Gets the root of the dice expression's abstract syntax tree. | |
Value | Gets the result of the roll. | |
Values | Gets the results of each individual die rolled. |
Fields
Name | Description | |
---|---|---|
AllRolls | The rolled value for every die, from left-to-right according to the normalized Expression. | |
AllMacros | The value for every macro, from left-to-right according to the normalized Expression. | |
S | InvalidRoll | This RollResult is used as a placeholder whenever an invalid roll is added to a RollPost. |
Overloaded Operators
Name | Description | |
---|---|---|
S | operator ==(RollResult, RollResult) | Implements RollResult == RollResult. |
S | operator !=(RollResult, RollResult) | Implements RollResult != RollResult. |
Remarks
RollResults are returned from the Roller.Roll method, and can be used to obtain the results of the roll. This class is read-only. Typically, Value and Values are the only properties that are needed in the course of normal operations, however the full AST is exposed for advanced insight into the roll, should such be necessary.
If a RollResult is deserialized, its RollRoot will be null
. A method may be provided in the future to re-construct the AST from the serialized data, but such a method does not currently exist. If you need access to the AST after deserialization, open an issue on GitHub letting me know (search for an existing one first!).