Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Check.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3
4public class Check : EClass
5{
6 public enum Result
7 {
9 Pass,
10 Fail,
12 }
13
14 public enum Output
15 {
16 None,
18 }
19
21
22 public string id;
23
24 public float dcMod;
25
27
28 public string mainElementName => EClass.sources.elements.map[source.element].GetName();
29
30 public int baseDC => source.baseDC;
31
32 public static Check Get(string id, float dcMod = 1f)
33 {
34 return new Check
35 {
36 id = id,
37 dcMod = dcMod
38 };
39 }
40
41 public string GetText(Chara p, Card tg, bool inDialog = false)
42 {
43 string text = "";
44 int finalDC = GetFinalDC(p, tg);
45 string text2 = ((finalDC > 20) ? "絶望的" : ((finalDC > 17) ? "ほぼ絶望的" : ((finalDC > 14) ? "とても難しい" : ((finalDC > 11) ? "難しい" : ((finalDC > 8) ? "普通" : ((finalDC > 5) ? "簡単" : ((finalDC > 2) ? "とても簡単" : "とても余裕")))))));
46 if (finalDC <= 20 && finalDC <= 15 && finalDC <= 10)
47 {
48 _ = 5;
49 }
50 text = text + "DC " + GetDC(tg) + " " + mainElementName + " " + text2;
51 return text + " " + source.element + "/" + EClass.sources.elements.map[source.element].alias;
52 }
53
54 public int GetDC(Card tg = null)
55 {
56 float num = (float)baseDC * dcMod;
57 if (tg == null)
58 {
59 return (int)num;
60 }
61 num += source.lvMod * (float)tg.LV;
62 if (source.targetElement != 0)
63 {
64 Element element = tg.elements.GetElement(source.element);
65 if (element != null)
66 {
67 num += (float)element.Value;
68 if (source.targetSubFactor > 0f && !element.source.aliasParent.IsEmpty())
69 {
70 Element element2 = tg.elements.GetElement(element.source.aliasParent);
71 if (element2 != null)
72 {
73 num += source.targetSubFactor * (float)element2.Value;
74 }
75 }
76 }
77 }
78 return (int)num;
79 }
80
81 public int GetFinalDC(Chara p, Card tg = null)
82 {
83 int num = GetDC(tg);
84 if (source.element != 0)
85 {
86 Element element = p.elements.GetElement(source.element);
87 if (element != null)
88 {
89 num -= element.Value;
90 if (source.subFactor > 0f && !element.source.aliasParent.IsEmpty())
91 {
92 Element element2 = p.elements.GetElement(element.source.aliasParent);
93 if (element2 != null)
94 {
95 num -= (int)(source.subFactor * (float)element2.Value);
96 }
97 }
98 }
99 }
100 if (num > 14)
101 {
102 num = 14 + (int)Mathf.Sqrt(num - 14);
103 }
104 else if (num < 6)
105 {
106 num = 6 - (int)Mathf.Sqrt(6 - num);
107 }
108 return num;
109 }
110
111 public Result Perform(Chara p, Card tg = null)
112 {
113 int finalDC = GetFinalDC(p, tg);
114 int num = Dice.Roll(1, 20);
115 if (EClass.debug.logDice)
116 {
117 string text = "Check:" + source.id + " dc=" + finalDC + " roll=" + num + " ";
118 Debug.Log(num switch
119 {
120 20 => text + "CriticalPass",
121 1 => text + "CriticalFail",
122 _ => (num < finalDC) ? (text + "Fail") : (text + "Pass"),
123 });
124 }
125 switch (num)
126 {
127 case 20:
128 return Result.CriticalPass;
129 case 1:
130 return Result.CriticalFail;
131 default:
132 if (num >= finalDC)
133 {
134 return Result.Pass;
135 }
136 return Result.Fail;
137 }
138 }
139
140 public Result Perform(Chara p, Card tg, Action<Result> action)
141 {
142 Result result = Perform(p, tg);
143 action?.Invoke(result);
144 return result;
145 }
146}
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
Definition: Card.cs:11
ElementContainerCard elements
Definition: Card.cs:37
Definition: Chara.cs:10
Definition: Check.cs:5
Result Perform(Chara p, Card tg=null)
Definition: Check.cs:111
SourceCheck.Row _source
Definition: Check.cs:20
string mainElementName
Definition: Check.cs:28
int baseDC
Definition: Check.cs:30
Result Perform(Chara p, Card tg, Action< Result > action)
Definition: Check.cs:140
float dcMod
Definition: Check.cs:24
string id
Definition: Check.cs:22
string GetText(Chara p, Card tg, bool inDialog=false)
Definition: Check.cs:41
static Check Get(string id, float dcMod=1f)
Definition: Check.cs:32
Result
Definition: Check.cs:7
Output
Definition: Check.cs:15
SourceCheck.Row source
Definition: Check.cs:26
int GetFinalDC(Chara p, Card tg=null)
Definition: Check.cs:81
int GetDC(Card tg=null)
Definition: Check.cs:54
bool logDice
Definition: CoreDebug.cs:246
Definition: Dice.cs:4
static int Roll(int num, int sides, int bonus=0, Card card=null)
Definition: Dice.cs:15
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
static CoreDebug debug
Definition: EClass.cs:48
Element GetElement(string alias)
SourceElement.Row source
Definition: ELEMENT.cs:263
int Value
Definition: ELEMENT.cs:282
SourceCheck checks
SourceElement elements