Difference between revisions of "Dice/DieResult"

From DiceRoller Documentation
(Created page with "{{APIdoc|DieResult Structure}} Contains the result of an individual die roll. {{ns}} == Syntax == <syntaxhighlight lang="C#"> public struct DieResult </syntaxhighlight> ==...")
 
 
(12 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
== Syntax ==
 
== Syntax ==
 
<syntaxhighlight lang="C#">
 
<syntaxhighlight lang="C#">
public struct DieResult
+
[Serializable]
 +
public struct DieResult : ISerializable, IEquatable<DieResult>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Fields ==
+
== Constructors ==
 
{| class="wikitable"
 
{| class="wikitable"
 
! style="width: 5em" |
 
! style="width: 5em" |
 
! Name !! Description
 
! Name !! Description
 
|-
 
|-
| {{public}} {{field}} || [[/DieType|DieType]] || What type of die was rolled.
+
| {{public}} {{method}} || [[/DieResult ()|DieResult()]] || Constructs a new default DieResult.
 
|-
 
|-
| {{public}} {{field}} || [[/Flags|Flags]] || Any special flags giving more information about the roll.
+
| {{public}} {{method}} || [[/DieResult (SpecialDie)|DieResult(SpecialDie)]] || Constructs a new DieResult corresponding to the given SpecialDie.
 
|-
 
|-
| {{public}} {{field}} || [[/NumSides|NumSides]] || How many sides the die had.
+
| {{public}} {{method}} || [[/DieResult (String)|DieResult(String)]] || Constructs a new DieResult with DieType SpecialDie.Text and the passed-in data.
 
|-
 
|-
| {{public}} {{field}} || [[/Value|Value]] || What the result of the roll was.
+
| {{private}} {{method}} || [[/DieResult (SerializationInfo, StreamingContext)|DieResult(SerializationInfo, StreamingContext)]] || Constructs a new DieResult with serialized data.
 +
|}
 +
 
 +
== Methods ==
 +
{| class="wikitable"
 +
! style="width: 5em" |
 +
! Name !! Description
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Deserialize|Deserialize(Stream)]] || Deserializes binary data from the given stream.
 +
|-
 +
| {{public}} {{method}} || [[/Drop|Drop()]] || Return a new DieResult based on the current one flagged as dropped.
 +
|-
 +
| {{public}} {{method}} || [[/Equals (DieResult)|Equals(DieResult)]] || Compare two DieResults and return whether or not they are equal.
 +
|-
 +
| {{public}} {{method}} || [[/Equals (Object)|Equals(Object)]] || Compare two DieResults and return whether or not they are equal. Overridden from Object.Equals(Object).
 +
|-
 +
| {{public}} {{method}} || [[/Failure|Failure()]] || Return a new DieResult based on the current one flagged as a failure.
 +
|-
 +
| {{public}} {{method}} || [[/GetHashCode|GetHashCode()]] || Gets a hash code for the DieResult. Overridden from Object.GetHashCode().
 +
|-
 +
| {{public}} {{method}} || [[/GetObjectData|GetObjectData(SerializationInfo, StreamingContext)]] || Serializes a DieResult.
 +
|-
 +
| {{public}} {{method}} || [[/IsLiveDie|IsLiveDie()]] || Checks if the die is not a special die and has not been dropped.
 +
|-
 +
| {{public}} {{method}} || [[/IsSpecialDie|IsSpecialDie(SpecialDie)]] || Checks if this die is a special die of the specified type.
 +
|-
 +
| {{public}} {{method}} || [[/Serialize|Serialize(Stream)]] || Serializes binary data to the given stream.
 +
|-
 +
| {{public}} {{method}} || [[/Success|Success()]] || Return a new DieResult based on the current one flagged as a success.
 +
|}
 +
 
 +
== Properties ==
 +
{| class="wikitable"
 +
! style="width: 5em" |
 +
! Name !! Description
 +
|-
 +
| {{public}} {{property}} || [[/Data|Data]] || Gets or sets string data associated with a roll.
 +
|-
 +
| {{public}} {{property}} || [[/DieType|DieType]] || Gets or sets what type of die was rolled.
 +
|-
 +
| {{public}} {{property}} || [[/Flags|Flags]] || Gets or sets any special flags giving more information about the roll.
 +
|-
 +
| {{public}} {{property}} || [[/NumSides|NumSides]] || Gets or sets how many sides the die had.
 +
|-
 +
| {{public}} {{property}} || [[/SpecialDie|SpecialDie]] || Gets or sets what type of special die this is. Calling this is an error if DieType != DieType.SpecialDie.
 +
|-
 +
| {{public}} {{property}} || [[/SuccessCount|SuccessCount]] || Gets 1 if the die is a success, -1 if the die is a failure, and 0 otherwise.
 +
|-
 +
| {{public}} {{property}} || [[/Value|Value]] || Gets or sets what the result of the roll was.
 +
|}
 +
 
 +
== Overloaded Operators ==
 +
{| class="wikitable"
 +
! style="width: 5em" |
 +
! Name !! Description
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/operator ==|operator ==(DieResult, DieResult)]] || Implements DieResult == DieResult.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/operator !=|operator !=(DieResult, DieResult)]] || Implements DieResult != DieResult.
 
|}
 
|}
  
 
== Remarks ==
 
== Remarks ==
The NumSides field is only non-zero if DieType is {{cs|DieType.Normal}} or {{cs|DieType.Fudge}}. If DieType is {{cs|DieType.Special}}, then Value can be cast into a [[Dice/SpecialDie|SpecialDie enum]] value.
+
The NumSides property is only non-zero if DieType is {{cs|DieType.Normal}} or {{cs|DieType.Fudge}}. If DieType is {{cs|DieType.Special}}, then Value can be cast into a [[Dice/SpecialDie|SpecialDie enum]] value, however it is usually better to access the SpecialDie property instead as typecasts are unnecessary with that property.
 +
 
 +
The property setters are provided for dice construction purposes. Since DieResult is a value type, attempting to call a setter on a DieResult instance will result in a new instance being constructed rather than the existing instance being mutated (unless the instance is a {{cs|ref}} or {{cs|out}} parameter).

Latest revision as of 16:47, 15 May 2017

Contains the result of an individual die roll.

  • Namespace: Dice
  • Assembly: DiceRoller (in DiceRoller.dll)

Syntax

[Serializable]
public struct DieResult : ISerializable, IEquatable<DieResult>

Constructors

Name Description
DieResult() Constructs a new default DieResult.
DieResult(SpecialDie) Constructs a new DieResult corresponding to the given SpecialDie.
DieResult(String) Constructs a new DieResult with DieType SpecialDie.Text and the passed-in data.
DieResult(SerializationInfo, StreamingContext) Constructs a new DieResult with serialized data.

Methods

Name Description
S Deserialize(Stream) Deserializes binary data from the given stream.
Drop() Return a new DieResult based on the current one flagged as dropped.
Equals(DieResult) Compare two DieResults and return whether or not they are equal.
Equals(Object) Compare two DieResults and return whether or not they are equal. Overridden from Object.Equals(Object).
Failure() Return a new DieResult based on the current one flagged as a failure.
GetHashCode() Gets a hash code for the DieResult. Overridden from Object.GetHashCode().
GetObjectData(SerializationInfo, StreamingContext) Serializes a DieResult.
IsLiveDie() Checks if the die is not a special die and has not been dropped.
IsSpecialDie(SpecialDie) Checks if this die is a special die of the specified type.
Serialize(Stream) Serializes binary data to the given stream.
Success() Return a new DieResult based on the current one flagged as a success.

Properties

Name Description
Data Gets or sets string data associated with a roll.
DieType Gets or sets what type of die was rolled.
Flags Gets or sets any special flags giving more information about the roll.
NumSides Gets or sets how many sides the die had.
SpecialDie Gets or sets what type of special die this is. Calling this is an error if DieType != DieType.SpecialDie.
SuccessCount Gets 1 if the die is a success, -1 if the die is a failure, and 0 otherwise.
Value Gets or sets what the result of the roll was.

Overloaded Operators

Name Description
S operator ==(DieResult, DieResult) Implements DieResult == DieResult.
S operator !=(DieResult, DieResult) Implements DieResult != DieResult.

Remarks

The NumSides property is only non-zero if DieType is DieType.Normal or DieType.Fudge. If DieType is DieType.Special, then Value can be cast into a SpecialDie enum value, however it is usually better to access the SpecialDie property instead as typecasts are unnecessary with that property.

The property setters are provided for dice construction purposes. Since DieResult is a value type, attempting to call a setter on a DieResult instance will result in a new instance being constructed rather than the existing instance being mutated (unless the instance is a ref or out parameter).