Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
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 (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()
 

Detailed Description

Definition at line 3 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 56 of file Dice.cs.

57 {
58 num = _num;
59 sides = _sides;
60 bonus = _bonus;
61 card = _card;
62 }
int bonus
Definition: Dice.cs:11
Card card
Definition: Dice.cs:13
int num
Definition: Dice.cs:7
int sides
Definition: Dice.cs:9

References bonus, card, num, and sides.

Member Function Documentation

◆ Create() [1/2]

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

Definition at line 96 of file Dice.cs.

97 {
98 string key = ele.source.alias;
99 if (!EClass.sources.calc.map.ContainsKey(key) && !ele.source.aliasRef.IsEmpty())
100 {
101 key = ele.source.alias.Split('_')[0] + "_";
102 }
103 if (!EClass.sources.calc.map.ContainsKey(key))
104 {
105 return null;
106 }
107 SourceCalc.Row row = EClass.sources.calc.map[key];
108 int power = ele.GetPower(c);
109 int ele2 = ((!ele.source.aliasParent.IsEmpty()) ? c.Evalue(ele.source.aliasParent) : 0);
110 try
111 {
112 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);
113 }
114 catch
115 {
116 Debug.Log(ele.id);
117 return new Dice();
118 }
119 }
int Evalue(int ele)
Definition: Card.cs:2431
Definition: Dice.cs:4
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
int id
Definition: ELEMENT.cs:240
SourceElement.Row source
Definition: ELEMENT.cs:263
virtual int GetPower(Card c)
Definition: ELEMENT.cs:884
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 121 of file Dice.cs.

122 {
123 if (!EClass.sources.calc.map.ContainsKey(id))
124 {
125 Debug.Log(id);
126 return null;
127 }
128 SourceCalc.Row row = EClass.sources.calc.map[id];
129 int power2 = power;
130 int ele = power / 10;
131 if (act != null)
132 {
133 Element orCreateElement = c.elements.GetOrCreateElement(act.source.id);
134 power2 = orCreateElement.GetPower(c);
135 ele = ((!orCreateElement.source.aliasParent.IsEmpty()) ? c.Evalue(orCreateElement.source.aliasParent) : 0);
136 }
137 try
138 {
139 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);
140 }
141 catch
142 {
143 return new Dice();
144 }
145 }
ElementContainerCard elements
Definition: Card.cs:37
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 64 of file Dice.cs.

65 {
66 Dice dice = new Dice();
67 string[] array = raw.Split(',');
68 if (array.Length != 0)
69 {
70 string[] array2 = array[0].Split('d');
71 dice.num = int.Parse(array2[0]);
72 dice.sides = int.Parse(array2[1]);
73 }
74 if (array.Length > 1)
75 {
76 dice.bonus = int.Parse(array[1]);
77 }
78 return dice;
79 }

◆ rnd()

static int Dice.rnd ( int  a)
inlinestatic

Definition at line 51 of file Dice.cs.

52 {
53 return Rand.Range(0, a);
54 }
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:42

References Rand.Range().

Referenced by Roll().

◆ Roll() [1/2]

int Dice.Roll ( )
inline

Definition at line 81 of file Dice.cs.

82 {
83 return Roll(num, sides, bonus, card);
84 }
int Roll()
Definition: Dice.cs:81

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 15 of file Dice.cs.

16 {
17 int a = 1;
18 bool flag = true;
19 int num2 = 0;
20 if (card != null)
21 {
22 int num3 = card.Evalue(78);
23 flag = num3 >= 0;
24 a = 1 + Mathf.Abs(num3 / 100) + ((Mathf.Abs(num3 % 100) > rnd(100)) ? 1 : 0);
25 }
26 for (int i = 0; i < Mathf.Min(a, 20); i++)
27 {
28 int num4 = Roll();
29 if (i == 0 || (flag && num4 > num2) || (!flag && num4 < num2))
30 {
31 num2 = num4;
32 }
33 }
34 return num2;
35 int Roll()
36 {
37 int num5 = 0;
38 for (int j = 0; j < num; j++)
39 {
40 num5 += rnd(sides) + 1;
41 }
42 return num5 + bonus;
43 }
44 }
static int rnd(int a)
Definition: Dice.cs:51

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

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

◆ RollMax() [1/2]

int Dice.RollMax ( )
inline

Definition at line 86 of file Dice.cs.

87 {
88 return RollMax(num, sides, bonus);
89 }
int RollMax()
Definition: Dice.cs:86

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 46 of file Dice.cs.

47 {
48 return num * sides + bonus;
49 }

References bonus, num, and sides.

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

◆ ToString()

override string Dice.ToString ( )
inline

Definition at line 91 of file Dice.cs.

92 {
93 return num + "d" + sides + ((bonus > 0) ? ("+" + bonus) : ((bonus < 0) ? (bonus.ToString() ?? "") : ""));
94 }
override string ToString()
Definition: Dice.cs:91

References bonus, num, and sides.

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

Member Data Documentation

◆ bonus

int Dice.bonus

Definition at line 11 of file Dice.cs.

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

◆ card

Card Dice.card

Definition at line 13 of file Dice.cs.

Referenced by Dice(), and Roll().

◆ Null

Dice Dice.Null = new Dice()
static

Definition at line 5 of file Dice.cs.

◆ num

int Dice.num

Definition at line 7 of file Dice.cs.

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

◆ sides

int Dice.sides

Definition at line 9 of file Dice.cs.

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


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