Elin Decompiled Documentation EA 23.229 Stable 1st Anniversary Patch 2
Loading...
Searching...
No Matches
Dice Class Reference

Public Member Functions

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

Static Public Member Functions

static int Roll_Normal (long num, long sides, int bonus=0)
 
static int Roll_Precise (int num, int sides, int bonus=0)
 
static int Roll (int num, int sides, int bonus=0, Card card=null)
 
static int 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 80 of file Dice.cs.

81 {
82 num = _num;
83 sides = _sides;
84 bonus = _bonus;
85 card = _card;
86 }
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 120 of file Dice.cs.

121 {
122 string key = ele.source.alias;
123 if (!EClass.sources.calc.map.ContainsKey(key) && !ele.source.aliasRef.IsEmpty())
124 {
125 key = ele.source.alias.Split('_')[0] + "_";
126 }
127 if (!EClass.sources.calc.map.ContainsKey(key))
128 {
129 return null;
130 }
131 SourceCalc.Row row = EClass.sources.calc.map[key];
132 int power = ele.GetPower(c);
133 int ele2 = ((!ele.source.aliasParent.IsEmpty()) ? c.Evalue(ele.source.aliasParent) : 0);
134 try
135 {
136 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);
137 }
138 catch
139 {
140 Debug.Log(ele.id);
141 return new Dice();
142 }
143 }
int Evalue(int ele)
Definition: Card.cs:2559
Definition: Dice.cs:5
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
int id
Definition: ELEMENT.cs:250
SourceElement.Row source
Definition: ELEMENT.cs:273
virtual int GetPower(Card c)
Definition: ELEMENT.cs:1071
string bonus
Definition: SourceCalc.cs:14
string sides
Definition: SourceCalc.cs:12
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(), 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 145 of file Dice.cs.

146 {
147 if (!EClass.sources.calc.map.ContainsKey(id))
148 {
149 Debug.Log(id);
150 return null;
151 }
152 SourceCalc.Row row = EClass.sources.calc.map[id];
153 int power2 = power;
154 int ele = power / 10;
155 if (act != null)
156 {
157 Element orCreateElement = c.elements.GetOrCreateElement(act.source.id);
158 power2 = orCreateElement.GetPower(c);
159 ele = ((!orCreateElement.source.aliasParent.IsEmpty()) ? c.Evalue(orCreateElement.source.aliasParent) : 0);
160 }
161 try
162 {
163 return new Dice(Mathf.Max(1, row.num.Calc(power2, ele)), Mathf.Max(1, row.sides.Calc(power2, ele)), row.bonus.Calc(power2, ele), c);
164 }
165 catch
166 {
167 return new Dice();
168 }
169 }
ElementContainerCard elements
Definition: Card.cs:41
Element GetOrCreateElement(Element ele)

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

◆ Parse()

static Dice Dice.Parse ( string  raw)
inlinestatic

Definition at line 88 of file Dice.cs.

89 {
90 Dice dice = new Dice();
91 string[] array = raw.Split(',');
92 if (array.Length != 0)
93 {
94 string[] array2 = array[0].Split('d');
95 dice.num = int.Parse(array2[0]);
96 dice.sides = int.Parse(array2[1]);
97 }
98 if (array.Length > 1)
99 {
100 dice.bonus = int.Parse(array[1]);
101 }
102 return dice;
103 }

◆ rnd()

static int Dice.rnd ( int  a)
inlinestatic

Definition at line 75 of file Dice.cs.

76 {
77 return Rand.Range(0, a);
78 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:42

References Rand.Range().

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

◆ Roll() [1/2]

int Dice.Roll ( )
inline

Definition at line 105 of file Dice.cs.

106 {
107 return Roll(num, sides, bonus, card);
108 }
int Roll()
Definition: Dice.cs:105

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

Referenced by Roll().

◆ Roll() [2/2]

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

Definition at line 48 of file Dice.cs.

49 {
50 int a = 1;
51 bool flag = true;
52 int num2 = 0;
53 if (card != null)
54 {
55 int num3 = card.Evalue(78);
56 flag = num3 >= 0;
57 a = 1 + Mathf.Abs(num3 / 100) + ((Mathf.Abs(num3 % 100) > rnd(100)) ? 1 : 0);
58 }
59 for (int i = 0; i < Mathf.Min(a, 20); i++)
60 {
61 int num4 = ((num >= 10) ? Roll_Normal(num, sides, bonus) : Roll_Precise(num, sides, bonus));
62 if (i == 0 || (flag && num4 > num2) || (!flag && num4 < num2))
63 {
64 num2 = num4;
65 }
66 }
67 return num2;
68 }
static int Roll_Normal(long num, long sides, int bonus=0)
Definition: Dice.cs:18
static int Roll_Precise(int num, int sides, int bonus=0)
Definition: Dice.cs:38
static int rnd(int a)
Definition: Dice.cs:75

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

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

◆ Roll_Normal()

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

Definition at line 18 of file Dice.cs.

19 {
20 double num2 = (double)(num * (sides + 1)) / 2.0;
21 double num3 = Math.Sqrt((double)(num * (sides * sides - 1)) / 12.0);
22 double d = (double)(rnd(1000000) + 1) / 1000001.0;
23 double num4 = (double)(rnd(1000000) + 1) / 1000001.0;
24 double num5 = Math.Sqrt(-2.0 * Math.Log(d)) * Math.Cos(Math.PI * 2.0 * num4);
25 long num6 = (long)Math.Floor(num2 + num3 * num5 + 0.5);
26 long num7 = num * sides;
27 if (num6 < num)
28 {
29 num6 = num;
30 }
31 if (num6 > num7)
32 {
33 num6 = num7;
34 }
35 return (int)Mathf.Clamp(num6 + bonus, -MaxValue, MaxValue);
36 }
static int MaxValue
Definition: Dice.cs:16

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

Referenced by Roll().

◆ Roll_Precise()

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

Definition at line 38 of file Dice.cs.

39 {
40 long num2 = 0L;
41 for (int i = 0; i < num; i++)
42 {
43 num2 += rnd(sides) + 1;
44 }
45 return (int)Mathf.Clamp(num2 + bonus, -MaxValue, MaxValue);
46 }

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

Referenced by Roll().

◆ RollMax() [1/2]

int Dice.RollMax ( )
inline

Definition at line 110 of file Dice.cs.

111 {
112 return RollMax(num, sides, bonus);
113 }
int RollMax()
Definition: Dice.cs:110

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

Referenced by RollMax().

◆ RollMax() [2/2]

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

Definition at line 70 of file Dice.cs.

71 {
72 return (int)Mathf.Clamp((long)num * (long)sides + bonus, -MaxValue, MaxValue);
73 }

References bonus, MaxValue, num, and sides.

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

◆ ToString()

override string Dice.ToString ( )
inline

Definition at line 115 of file Dice.cs.

116 {
117 return num + "d" + sides + ((bonus > 0) ? ("+" + bonus) : ((bonus < 0) ? (bonus.ToString() ?? "") : ""));
118 }
override string ToString()
Definition: Dice.cs:115

References bonus, num, and sides.

Referenced by Element._WriteNote(), 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(), Roll_Precise(), and RollMax().


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