Rewrite the !dice command from scratch
This commit is contained in:
parent
d7e313c9fa
commit
6d44960867
13 changed files with 376 additions and 126 deletions
30
Geekbot.net/Lib/DiceParser/DieResult.cs
Normal file
30
Geekbot.net/Lib/DiceParser/DieResult.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
|
||||
namespace Geekbot.net.Lib.DiceParser
|
||||
{
|
||||
public class DieResult
|
||||
{
|
||||
// public int Result { get; set; }
|
||||
public int Roll1 { get; set; }
|
||||
public int Roll2 { get; set; }
|
||||
public DieAdvantageType AdvantageType { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return AdvantageType switch
|
||||
{
|
||||
DieAdvantageType.Advantage => Roll1 > Roll2 ? $"(**{Roll1}**, {Roll2})" : $"({Roll1}, **{Roll2}**)",
|
||||
DieAdvantageType.Disadvantage => Roll1 < Roll2 ? $"(**{Roll1}**, {Roll2})" : $"({Roll1}, **{Roll2}**)",
|
||||
_ => Result.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public int Result => AdvantageType switch
|
||||
{
|
||||
DieAdvantageType.None => Roll1,
|
||||
DieAdvantageType.Advantage => Math.Max(Roll1, Roll2),
|
||||
DieAdvantageType.Disadvantage => Math.Min(Roll1, Roll2),
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue