Elin Decompiled Documentation EA 23.350.1 Nightly
Loading...
Searching...
No Matches
Dice Class Reference

Public Member Functions

 Dice (int _num=0, int _sides=0, int _bonus=0, Card _card=null)
 
long Roll ()
 
long RollMax ()
 
override string ToString ()
 

Static Public Member Functions

static long Roll_Normal (long num, long sides, int bonus=0)
 
static long Roll_Precise (int num, int sides, int bonus=0)
 
static long Roll (int num, int sides, int bonus=0, Card card=null)
 
static long RollMax (int num, int sides, int bonus=0)
 
static int rnd (int a)
 
static Dice Parse (string raw)
 
static Dice Create (Element ele, Card c)
 
static Dice Create (string id, int power, Card c=null, Act act=null)
 

Public Attributes

int num
 
int sides
 
int bonus
 
Card card
 

Static Public Attributes

static Dice Null = new Dice()
 

Properties

static int MaxValue [get]
 

Detailed Description

Definition at line 4 of file Dice.cs.

Constructor & Destructor Documentation

◆ Dice()

Dice.Dice ( int  _num = 0,
int  _sides = 0,
int  _bonus = 0,
Card  _card = null 
)
inline

Definition at line 91 of file Dice.cs.

92 {
93 num = _num;
94 sides = _sides;
95 bonus = _bonus;
96 card = _card;
97 }
int bonus
Definition: Dice.cs:12
Card card
Definition: Dice.cs:14
int num
Definition: Dice.cs:8
int sides
Definition: Dice.cs:10

References bonus, card, num, and sides.

Member Function Documentation

◆ Create() [1/2]

static Dice Dice.Create ( Element  ele,
Card  c 
)
inlinestatic

Definition at line 131 of file Dice.cs.

132 {
133 string key = ele.source.alias;
134 if (!EClass.sources.calc.map.ContainsKey(key) && !ele.source.aliasRef.IsEmpty())
135 {
136 key = ele.source.alias.Split('_')[0] + "_";
137 }
138 if (!EClass.sources.calc.map.ContainsKey(key))
139 {
140 return null;
141 }
142 SourceCalc.Row row = EClass.sources.calc.map[key];
143 int power = ele.GetPower(c);
144 int ele2 = ((!ele.source.aliasParent.IsEmpty()) ? c.Evalue(ele.source.aliasParent) : 0);
145 try
146 {
147 return new Dice(Mathf.Max(1, row.num.Calc(power, ele2)), Mathf.Max(1, row.sides.Calc(power, ele2)), row.bonus.Calc(power, ele2), c);
148 }
149 catch
150 {
151 Debug.Log(ele.id);
152 return new Dice();
153 }
154 }
int Evalue(int ele)
Definition: Card.cs:2704
Definition: Dice.cs:5
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
int id
Definition: ELEMENT.cs:259
SourceElement.Row source
Definition: ELEMENT.cs:282
virtual int GetPower(Card c)
Definition: ELEMENT.cs:1134
string bonus
Definition: SourceCalc.cs:15
string sides
Definition: SourceCalc.cs:13
SourceCalc calc

References SourceCalc.Row.bonus, SourceManager.calc, Debug, Card.Evalue(), Element.GetPower(), Element.id, SourceCalc.Row.num, SourceCalc.Row.sides, Element.source, and EClass.sources.

Referenced by Element._WriteNote(), ActEffect.DamageEle(), ActTelekinesis.DoDamage(), ConHOT.OnWriteNote(), ConMiasma.OnWriteNote(), ActEffect.Proc(), ConHOT.Tick(), and ConMiasma.Tick().

◆ Create() [2/2]

static Dice Dice.Create ( string  id,
int  power,
Card  c = null,
Act  act = null 
)
inlinestatic

Definition at line 156 of file Dice.cs.

157 {
158 if (!EClass.sources.calc.map.TryGetValue(id, out var value) && (string.IsNullOrEmpty(act?.ID) || !EClass.sources.calc.map.TryGetValue(act.ID, out value)))
159 {
160 Debug.Log(id);
161 return null;
162 }
163 int power2 = power;
164 int ele = power / 10;
165 if (act != null)
166 {
167 Element orCreateElement = c.elements.GetOrCreateElement(act.source.id);
168 power2 = orCreateElement.GetPower(c);
169 ele = ((!orCreateElement.source.aliasParent.IsEmpty()) ? c.Evalue(orCreateElement.source.aliasParent) : 0);
170 }
171 try
172 {
173 return new Dice(Mathf.Max(1, value.num.Calc(power2, ele)), Mathf.Max(1, value.sides.Calc(power2, ele)), value.bonus.Calc(power2, ele), c);
174 }
175 catch
176 {
177 return new Dice();
178 }
179 }
virtual string ID
Definition: ACT.cs:99
ElementContainerCard elements
Definition: Card.cs:42
Element GetOrCreateElement(Element ele)

References SourceManager.calc, Debug, Element.GetPower(), Element.source, and EClass.sources.

◆ Parse()

static Dice Dice.Parse ( string  raw)
inlinestatic

Definition at line 99 of file Dice.cs.

100 {
101 Dice dice = new Dice();
102 string[] array = raw.Split(',');
103 if (array.Length != 0)
104 {
105 string[] array2 = array[0].Split('d');
106 dice.num = int.Parse(array2[0]);
107 dice.sides = int.Parse(array2[1]);
108 }
109 if (array.Length > 1)
110 {
111 dice.bonus = int.Parse(array[1]);
112 }
113 return dice;
114 }

◆ rnd()

static int Dice.rnd ( int  a)
inlinestatic

Definition at line 86 of file Dice.cs.

87 {
88 return Rand.Range(0, a);
89 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49

References Rand.Range().

Referenced by Roll(), Roll_Normal(), and Roll_Precise().

◆ Roll() [1/2]

long Dice.Roll ( )
inline

Definition at line 116 of file Dice.cs.

117 {
118 return Roll(num, sides, bonus, card);
119 }
long Roll()
Definition: Dice.cs:116

References bonus, card, num, Roll(), and sides.

Referenced by Roll().

◆ Roll() [2/2]

static long Dice.Roll ( int  num,
int  sides,
int  bonus = 0,
Card  card = null 
)
inlinestatic

Definition at line 59 of file Dice.cs.

60 {
61 int a = 1;
62 bool flag = true;
63 long num2 = 0L;
64 if (card != null)
65 {
66 int num3 = card.Evalue(78);
67 flag = num3 >= 0;
68 a = 1 + Mathf.Abs(num3 / 100) + ((Mathf.Abs(num3 % 100) > rnd(100)) ? 1 : 0);
69 }
70 for (int i = 0; i < Mathf.Min(a, 20); i++)
71 {
72 long num4 = ((num >= 10) ? Roll_Normal(num, sides, bonus) : Roll_Precise(num, sides, bonus));
73 if (i == 0 || (flag && num4 > num2) || (!flag && num4 < num2))
74 {
75 num2 = num4;
76 }
77 }
78 return num2;
79 }
static long Roll_Precise(int num, int sides, int bonus=0)
Definition: Dice.cs:49
static int rnd(int a)
Definition: Dice.cs:86
static long Roll_Normal(long num, long sides, int bonus=0)
Definition: Dice.cs:18

References bonus, card, Card.Evalue(), num, rnd(), Roll_Normal(), Roll_Precise(), and sides.

Referenced by Card.ApplyProtection(), ActEffect.DamageEle(), ActTelekinesis.DoDamage(), AttackProcess.GetRawDamage(), Check.Perform(), ActEffect.Proc(), ConHOT.Tick(), and ConMiasma.Tick().

◆ Roll_Normal()

static long Dice.Roll_Normal ( long  num,
long  sides,
int  bonus = 0 
)
inlinestatic

Definition at line 18 of file Dice.cs.

19 {
20 double num2 = num;
21 double num3 = sides;
22 double num4 = num2 * (num3 + 1.0) / 2.0;
23 double num5 = Math.Sqrt(num2 * (num3 * num3 - 1.0) / 12.0);
24 double d = (double)(rnd(1000000) + 1) / 1000001.0;
25 double num6 = (double)(rnd(1000000) + 1) / 1000001.0;
26 double num7 = Math.Sqrt(-2.0 * Math.Log(d)) * Math.Cos(Math.PI * 2.0 * num6);
27 double num8 = Math.Floor(num4 + num5 * num7 + 0.5);
28 long num9 = ((sides != 0L && num > long.MaxValue / sides) ? long.MaxValue : (num * sides));
29 if (num8 < (double)num)
30 {
31 num8 = num;
32 }
33 if (num8 > (double)num9)
34 {
35 num8 = num9;
36 }
37 long num10 = (long)num8;
38 if (bonus > 0 && num10 > long.MaxValue - bonus)
39 {
40 return long.MaxValue;
41 }
42 if (bonus < 0 && num10 < long.MinValue - bonus)
43 {
44 return long.MinValue;
45 }
46 return num10 + bonus;
47 }
static int MaxValue
Definition: Dice.cs:16

References bonus, MaxValue, num, rnd(), and sides.

Referenced by Roll().

◆ Roll_Precise()

static long Dice.Roll_Precise ( int  num,
int  sides,
int  bonus = 0 
)
inlinestatic

Definition at line 49 of file Dice.cs.

50 {
51 long num2 = 0L;
52 for (int i = 0; i < num; i++)
53 {
54 num2 += rnd(sides) + 1;
55 }
56 return num2 + bonus;
57 }

References bonus, num, rnd(), and sides.

Referenced by Roll().

◆ RollMax() [1/2]

long Dice.RollMax ( )
inline

Definition at line 121 of file Dice.cs.

122 {
123 return RollMax(num, sides, bonus);
124 }
long RollMax()
Definition: Dice.cs:121

References bonus, num, RollMax(), and sides.

Referenced by RollMax().

◆ RollMax() [2/2]

static long Dice.RollMax ( int  num,
int  sides,
int  bonus = 0 
)
inlinestatic

Definition at line 81 of file Dice.cs.

82 {
83 return (long)num * (long)sides + bonus;
84 }

References bonus, num, and sides.

Referenced by ActEffect.DamageEle(), and AttackProcess.GetRawDamage().

◆ ToString()

override string Dice.ToString ( )
inline

Definition at line 126 of file Dice.cs.

127 {
128 return num + "d" + sides + ((bonus > 0) ? ("+" + bonus) : ((bonus < 0) ? (bonus.ToString() ?? "") : ""));
129 }
override string ToString()
Definition: Dice.cs:126

References bonus, num, and sides.

Referenced by Element._WriteNote(), ActEffect.DamageEle(), ConHOT.OnWriteNote(), and ConMiasma.OnWriteNote().

Member Data Documentation

◆ bonus

int Dice.bonus

Definition at line 12 of file Dice.cs.

Referenced by Dice(), Roll(), Roll_Normal(), Roll_Precise(), RollMax(), and ToString().

◆ card

Card Dice.card

Definition at line 14 of file Dice.cs.

Referenced by Dice(), and Roll().

◆ Null

Dice Dice.Null = new Dice()
static

Definition at line 6 of file Dice.cs.

◆ num

int Dice.num

Definition at line 8 of file Dice.cs.

Referenced by Dice(), Roll(), Roll_Normal(), Roll_Precise(), RollMax(), and ToString().

◆ sides

int Dice.sides

Definition at line 10 of file Dice.cs.

Referenced by Dice(), Roll(), Roll_Normal(), Roll_Precise(), RollMax(), and ToString().

Property Documentation

◆ MaxValue

int Dice.MaxValue
staticget

Definition at line 16 of file Dice.cs.

Referenced by Roll_Normal().


The documentation for this class was generated from the following file: