Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ELEMENT.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class ELEMENT
7{
8 public const int rare = 751;
9
10 public const int cute = 752;
11
12 public const int antidote = 753;
13
14 public const int nerve = 754;
15
16 public const int blood = 755;
17
18 public const int hotspring = 756;
19
20 public const int purity = 759;
21
22 public const int comfort = 750;
23
24 public const int _void = 0;
25
26 public const int quality = 2;
27
28 public const int lv = 1;
29
30 public const int d = 3;
31
32 public const int socket = 5;
33
34 public const int nutrition = 10;
35
36 public const int weight = 11;
37
38 public const int size = 12;
39
40 public const int hardness = 13;
41
42 public const int growth = 14;
43
44 public const int heat = 16;
45
46 public const int decay = 17;
47
48 public const int taste = 18;
49
50 public const int water = 15;
51
52 public const int fire = 21;
53
54 public const int cut = 22;
55
56 public const int old_detox = 23;
57
58 public const int old_heal = 24;
59
60 public const int old_antidote = 25;
61
62 public const int cure = 26;
63
64 public const int race = 29;
65
66 public const int piety = 85;
67
68 public const int poison = 20;
69
70 public static readonly int[] IDS = new int[31]
71 {
72 751, 752, 753, 754, 755, 756, 759, 750, 0, 2,
73 1, 3, 5, 10, 11, 12, 13, 14, 16, 17,
74 18, 15, 21, 22, 23, 24, 25, 26, 29, 85,
75 20
76 };
77}
78public class Element : EClass
79{
80 public class BonusInfo
81 {
82 public Element ele;
83
84 public UINote n;
85
86 public Chara c;
87
88 public bool first = true;
89
90 public int total;
91
92 public void CheckFirst()
93 {
94 if (first)
95 {
96 first = false;
97 n.Space(8);
98 }
99 }
100
101 public void AddText(string text, FontColor col = FontColor.Warning)
102 {
103 CheckFirst();
104 n.AddText("_bullet".lang() + text, col);
105 }
106
107 public void AddText(int v, string text, string textBad = null)
108 {
109 if (v != 0)
110 {
111 string text2 = text;
112 if (!textBad.IsEmpty() && v < 0)
113 {
114 text2 = textBad;
115 }
116 CheckFirst();
117 total += v;
118 n.AddText("_bullet".lang() + text2 + " " + ((v > 0) ? "+" : "") + v, (v > 0) ? FontColor.Good : FontColor.Bad);
119 }
120 }
121
122 public void AddFix(int v, string text)
123 {
124 if (v != 0)
125 {
126 CheckFirst();
127 n.AddText("_bullet".lang() + text + " " + ((v > 0) ? "+" : "") + v + "%", (v > 0) ? FontColor.Good : FontColor.Bad);
128 }
129 }
130
131 public void WriteNote()
132 {
133 int id = ele.id;
134 int num = 0;
135 foreach (BodySlot slot in c.body.slots)
136 {
137 if (slot.elementId != 44 && slot.thing != null && ((id != 67 && id != 66) || slot.elementId != 35))
138 {
139 Element orCreateElement = slot.thing.elements.GetOrCreateElement(id);
140 if (orCreateElement != null && !orCreateElement.IsGlobalElement)
141 {
142 num += orCreateElement.Value;
143 }
144 }
145 }
146 AddText(num, "equipment".lang());
147 if (c.IsPCFaction)
148 {
150 if (element != null)
151 {
152 AddText(element.Value, "sub_faction".lang());
153 }
154 }
155 foreach (Condition condition in c.conditions)
156 {
157 if (condition.elements != null)
158 {
159 AddText(condition.elements.Value(id), condition.Name);
160 }
161 }
162 if (c.tempElements != null)
163 {
164 AddText(c.tempElements.Value(id), "tempStrengthen".lang(), "tempWeaken".lang());
165 }
166 try
167 {
168 if (c.faithElements != null)
169 {
170 Element element2 = c.elements.GetElement("featGod_" + c.faith.id + "1");
171 if (element2 != null)
172 {
173 AddText(c.faithElements.Value(id), element2.Name);
174 }
175 }
176 }
177 catch
178 {
179 }
180 _ = ele.Value;
181 _ = ele.ValueWithoutLink + total;
182 foreach (Element value in c.elements.dict.Values)
183 {
184 if (value.HasTag("multiplier") && value.source.aliasRef == ele.source.alias)
185 {
186 AddFix(value.Value, value.Name);
187 }
188 }
189 if (id == 79)
190 {
191 c.RefreshSpeed(this);
192 }
193 if (id == 78 && c.IsPCFactionOrMinion)
194 {
195 int num2 = EClass.player.CountKeyItem("lucky_coin");
196 if (num2 > 0)
197 {
198 AddText(EClass.sources.keyItems.alias["lucky_coin"].GetName() + " (+" + num2 * 2 + ")", FontColor.Great);
199 }
201 {
202 AddFix(100, EClass.sources.elements.map[663].GetName());
203 }
204 }
205 if (!c.race.IsMachine && !(c.id == "android"))
206 {
207 return;
208 }
209 int num3 = c.Evalue(664);
210 if (num3 > 0)
211 {
212 switch (id)
213 {
214 case 64:
215 case 65:
216 AddFix(num3 / 2, EClass.sources.elements.map[664].GetName());
217 break;
218 case 79:
219 AddFix(num3, EClass.sources.elements.map[664].GetName());
220 break;
221 }
222 }
223 }
224 }
225
226 public const int Div = 5;
227
228 public static Element Void = new Element();
229
230 public static int[] List_MainAttributes = new int[9] { 70, 72, 71, 77, 74, 75, 76, 73, 79 };
231
232 public static int[] List_MainAttributesMajor = new int[8] { 70, 72, 71, 77, 74, 75, 76, 73 };
233
234 public static int[] List_Body = new int[4] { 70, 72, 71, 77 };
235
236 public static int[] List_Mind = new int[4] { 74, 75, 76, 73 };
237
239
240 public int id;
241
242 public int vBase;
243
244 public int vExp;
245
246 public int vPotential;
247
248 public int vTempPotential;
249
250 public int vLink;
251
252 public int vSource;
253
255
257
258 public static List<SourceElement.Row> ListElements = new List<SourceElement.Row>();
259
260 public static List<SourceElement.Row> ListAttackElements = new List<SourceElement.Row>();
261
263 {
264 get
265 {
267 if (row == null)
268 {
269 SourceElement.Row obj = ((id == 0) ? GetSource() : Get(id)) ?? EClass.sources.elements.rows[0];
270 SourceElement.Row row2 = obj;
271 _source = obj;
272 row = row2;
273 }
274 return row;
275 }
276 }
277
278 public virtual int DisplayValue => Value;
279
280 public virtual int MinValue => -100;
281
282 public int Value => ValueWithoutLink + vLink + ((owner != null) ? owner.ValueBonus(this) : 0);
283
285
286 public virtual int MinPotential => 100;
287
289
290 public virtual bool CanGainExp => ValueWithoutLink > 0;
291
292 public bool IsFlag => source.tag.Contains("flag");
293
294 public virtual string Name => source.GetName();
295
296 public virtual string FullName => Name;
297
298 public virtual int ExpToNext => 1000;
299
300 public virtual bool UseExpMod => true;
301
302 public virtual int CostTrain => Mathf.Max((ValueWithoutLink / 10 + 5) * (100 + vTempPotential) / 500, 1);
303
304 public virtual int CostLearn => 5;
305
306 public virtual bool ShowXP
307 {
308 get
309 {
311 {
312 return source.category != "attribute";
313 }
314 return true;
315 }
316 }
317
318 public virtual bool ShowMsgOnValueChanged => true;
319
320 public virtual bool ShowValue => true;
321
322 public virtual bool ShowPotential => true;
323
324 public virtual bool UsePotential => true;
325
326 public virtual bool PotentialAsStock => false;
327
328 public virtual bool ShowRelativeAttribute => false;
329
330 public virtual bool ShowBonuses => true;
331
332 public virtual string ShortName => Name;
333
334 public bool IsGlobalElement
335 {
336 get
337 {
338 if (vExp != -1)
339 {
340 return vExp == -2;
341 }
342 return true;
343 }
344 }
345
346 public bool IsFactionWideElement => vExp == -1;
347
348 public bool IsPartyWideElement => vExp == -2;
349
350 public virtual bool ShowEncNumber => true;
351
352 public bool IsTrait => source.tag.Contains("trait");
353
354 public bool IsFoodTrait => !source.foodEffect.IsEmpty();
355
356 public bool IsFoodTraitMain
357 {
358 get
359 {
360 if (IsFoodTrait)
361 {
362 if (!source.tag.Contains("primary"))
363 {
364 return source.tag.Contains("foodpot");
365 }
366 return true;
367 }
368 return false;
369 }
370 }
371
372 public bool IsMainAttribute
373 {
374 get
375 {
376 if (source.category == "attribute")
377 {
378 return source.tag.Contains("primary");
379 }
380 return false;
381 }
382 }
383
384 public Act act => (this as Act) ?? ACT.Create(id);
385
386 public static string GetName(string alias)
387 {
388 return EClass.sources.elements.alias[alias].GetName();
389 }
390
391 public static SourceElement.Row Get(int id)
392 {
393 return EClass.sources.elements.map[id];
394 }
395
397 {
398 return EClass.sources.elements.alias.TryGetValue(GetType().ToString());
399 }
400
401 public virtual int GetSourcePotential(int v)
402 {
403 return 0;
404 }
405
406 public virtual Sprite GetSprite()
407 {
408 return null;
409 }
410
411 public int GetMaterialSourceValue(Thing t, int v)
412 {
413 if (id == 2 || v < 0)
414 {
415 return v;
416 }
417 if (IsTrait)
418 {
419 if (t.IsFurniture)
420 {
421 return v;
422 }
423 return Mathf.Min(v + t.encLV * 10, 60);
424 }
425 return v * (100 + t.encLV * 10) / 100;
426 }
427
428 public virtual int GetSourceValue(int v, int lv, SourceValueType type)
429 {
430 return type switch
431 {
432 SourceValueType.Chara => v * (100 + (lv - 1 + EClass.rnd(lv / 2 + 1)) * source.lvFactor / 10) / 100 + EClass.rnd(lv / 3) * source.lvFactor / 100,
433 SourceValueType.Fixed => v,
434 _ => v * ((source.encFactor == 0) ? 100 : (50 + EClass.rnd(100) + EClass.rnd((int)Mathf.Sqrt(lv * 100)) * source.encFactor / 100)) / 100,
435 };
436 }
437
438 public virtual Sprite GetIcon(string suffix = "")
439 {
440 return SpriteSheet.Get("Media/Graphics/Icon/Element/icon_elements", "ele_" + source.alias + suffix) ?? SpriteSheet.Get("Media/Graphics/Icon/Element/icon_elements", "ele_" + source.aliasParent + suffix) ?? SpriteSheet.Get("Media/Graphics/Icon/Element/icon_elements", "cat_" + source.category);
441 }
442
443 public bool IsActive(Card c)
444 {
445 if (IsGlobalElement && c != null && !c.c_idDeity.IsEmpty() && c.c_idDeity != EClass.pc.idFaith)
446 {
447 return false;
448 }
449 return Value != 0;
450 }
451
452 public int SortVal(bool charaSheet = false)
453 {
454 int num = ((source.sort != 0) ? source.sort : id);
455 return (IsFlag ? 100000 : 0) + ((!charaSheet && IsGlobalElement) ? (-1000000) : 0) + num;
456 }
457
458 public virtual bool CanLink(ElementContainer owner)
459 {
460 return false;
461 }
462
463 public bool HasTag(string tag)
464 {
465 return source.tag.Contains(tag);
466 }
467
468 public void SetImage(Image i)
469 {
470 Sprite icon = GetIcon();
471 if ((bool)icon)
472 {
473 i.sprite = icon;
474 i.SetNativeSize();
475 }
476 }
477
478 public virtual string GetDetail()
479 {
480 return source.GetDetail();
481 }
482
483 public bool IsFactionElement(Chara c)
484 {
485 if (c == null)
486 {
487 return false;
488 }
489 if (c.IsPCFaction)
490 {
491 foreach (Element value in EClass.pc.faction.charaElements.dict.Values)
492 {
493 if (value.id == id && value.Value > 0)
494 {
495 return true;
496 }
497 }
498 }
499 if (c.faithElements != null)
500 {
501 foreach (Element value2 in c.faithElements.dict.Values)
502 {
503 if (value2.id == id && value2.Value > 0)
504 {
505 return true;
506 }
507 }
508 }
509 return false;
510 }
511
513 {
514 if (!source.aliasParent.IsEmpty())
515 {
516 return c.elements.GetOrCreateElement(source.aliasParent);
517 }
518 return null;
519 }
520
521 public static Dictionary<int, int> GetElementMap(int[] list)
522 {
523 Dictionary<int, int> dictionary = new Dictionary<int, int>();
524 if (list != null)
525 {
526 for (int i = 0; i < list.Length / 2; i++)
527 {
528 dictionary[list[i * 2]] = list[i * 2 + 1];
529 }
530 }
531 return dictionary;
532 }
533
534 public static Dictionary<int, int> GetElementMap(int[] list, Dictionary<int, int> map)
535 {
536 if (list != null)
537 {
538 for (int i = 0; i < list.Length / 2; i++)
539 {
540 map[list[i * 2]] = list[i * 2 + 1];
541 }
542 }
543 return map;
544 }
545
546 public static SourceElement.Row GetRandomElement(int lv = 1)
547 {
548 if (lv > 100)
549 {
550 lv = 100;
551 }
552 if (ListElements.Count == 0)
553 {
554 foreach (SourceElement.Row row in EClass.sources.elements.rows)
555 {
556 if (row.categorySub == "eleAttack" && row.chance > 0)
557 {
558 ListElements.Add(row);
559 }
560 }
561 }
562 List<Tuple<SourceElement.Row, int>> list = new List<Tuple<SourceElement.Row, int>>();
563 foreach (SourceElement.Row listElement in ListElements)
564 {
565 int num = 40 * (listElement.eleP - 100) / 100;
566 if (list.Count == 0 || num < lv)
567 {
568 list.Add(new Tuple<SourceElement.Row, int>(listElement, num));
569 }
570 }
571 return list.RandomItemWeighted((Tuple<SourceElement.Row, int> a) => 10000 / (100 + (lv - a.Item2) * 25)).Item1;
572 }
573
574 public void WriteNote(UINote n, ElementContainer owner = null, Action<UINote> onWriteNote = null)
575 {
576 n.Clear();
577 _WriteNote(n, owner, onWriteNote, isRef: false);
578 n.Build();
579 }
580
581 public void WriteNoteWithRef(UINote n, ElementContainer owner, Action<UINote> onWriteNote, Element refEle)
582 {
583 n.Clear();
584 _WriteNote(n, owner, onWriteNote, isRef: false);
585 if (refEle.Value > 0)
586 {
587 refEle._WriteNote(n, owner, onWriteNote, isRef: true);
588 }
590 {
592 }
593 n.Build();
594 }
595
596 public void _WriteNote(UINote n, Chara c, Act act)
597 {
599 Act.Cost cost = e.GetCost(c);
600 int p = e.GetPower(c);
601 n.Space(6);
602 string text = source.GetText("textExtra");
603 if (!text.IsEmpty())
604 {
605 string[] array = text.Split(',');
606 foreach (string text2 in array)
607 {
608 if (text2.StartsWith("@"))
609 {
610 Condition condition = Condition.Create(text2.Replace("@", ""), p);
611 condition.owner = c;
612 if (!source.aliasRef.IsEmpty())
613 {
614 condition.SetElement(EClass.sources.elements.alias[source.aliasRef].id);
615 }
616 switch (act.id)
617 {
618 case 6902:
619 condition.SetRefVal(79, 267);
620 break;
621 case 8510:
622 case 8710:
623 condition.SetRefVal(79, (act.id == 8710) ? 222 : 221);
624 break;
625 }
626 n.AddText("_bullet".lang() + "hintCon".lang(condition.Name, condition.EvaluateTurn(p).ToString() ?? ""));
627 condition._WriteNote(n, asChild: true);
628 }
629 else
630 {
631 string text3 = text2.Replace("#calc", Calc());
632 if (!source.aliasRef.IsEmpty())
633 {
634 text3 = text3.Replace("#ele", EClass.sources.elements.alias[source.aliasRef].GetName().ToLower());
635 }
636 n.AddText("_bullet".lang() + text3);
637 }
638 }
639 }
640 if (source.tag.Contains("syncRide"))
641 {
642 n.AddText("_bullet".lang() + "hintSyncRide".lang());
643 }
645 {
646 int i = id;
647 if (i != 8230 && i != 8232)
648 {
649 n.AddText("_bullet".lang() + "hintPartyAbility".lang());
650 }
651 }
652 if (!act.LocalAct)
653 {
654 n.Space();
655 n.AddText("isGlobalAct".lang());
656 }
657 if (cost.type != 0 && cost.cost != 0)
658 {
659 n.Space(4);
660 UIItem uIItem = n.AddExtra<UIItem>("costPrice");
661 int num = cost.cost;
662 if (cost.type == Act.CostType.MP && c.Evalue(483) > 0)
663 {
664 num = cost.cost * 100 / (100 + (int)Mathf.Sqrt(c.Evalue(483) * 10) * 3);
665 }
666 string text4 = cost.cost.ToString() ?? "";
667 if (num != cost.cost)
668 {
669 text4 = num + " (" + text4 + ")";
670 }
671 uIItem.text1.SetText(text4, (((cost.type == Act.CostType.MP) ? c.mana.value : c.stamina.value) >= num) ? FontColor.Good : FontColor.Bad);
672 uIItem.image1.sprite = ((cost.type == Act.CostType.MP) ? EClass.core.refs.icons.mana : EClass.core.refs.icons.stamina);
673 uIItem.image1.SetNativeSize();
674 }
675 string Calc()
676 {
677 Dice dice = Dice.Create(e, c);
678 if (dice == null)
679 {
680 return p.ToString() ?? "";
681 }
682 return dice.ToString();
683 }
684 }
685
687 {
688 UIItem uIItem = n.AddHeader("HeaderAbility", FullName.ToTitleCase(wholeText: true), GetSprite());
689 uIItem.text2.text = ((this is Spell) ? (vPotential.ToString() ?? "") : "-");
690 (this as Act)?.SetImage(uIItem.image1);
691 }
692
693 public void _WriteNote(UINote n, ElementContainer owner, Action<UINote> onWriteNote, bool isRef, bool addHeader = true)
694 {
695 if (addHeader)
696 {
697 if (isRef)
698 {
699 UIText.globalSizeMod = -2;
700 n.AddHeader("prevElement".lang(FullName));
701 }
702 else if (this is Act)
703 {
705 n.Space(8);
706 }
707 else
708 {
709 n.AddHeader(FullName.ToTitleCase(wholeText: true));
710 }
711 }
712 string detail = GetDetail();
713 if (!detail.IsEmpty())
714 {
715 n.AddText("NoteText_flavor_element", detail);
716 n.Space(6);
717 }
718 int num = vLink;
719 if (owner.Chara != null && owner.Chara.IsPCFaction)
720 {
722 }
723 bool flag = ShowValue;
724 bool flag2 = ShowRelativeAttribute;
725 if (source.category == "landfeat")
726 {
727 flag = false;
728 flag2 = false;
729 }
730 if (this is Act)
731 {
732 Act act = ACT.Create(source.id);
733 UIItem uIItem = n.AddItem("ItemAbility");
734 uIItem.text1.text = "vValue".lang(DisplayValue.ToString() ?? "", ValueWithoutLink + ((num == 0) ? "" : ((num > 0) ? (" + " + num) : (" - " + -num))));
735 uIItem.text2.text = act.TargetType.ToString().lang();
736 uIItem.text3.text = ((this is Spell) ? (owner.Chara.CalcCastingChance(owner.GetOrCreateElement(act.source.id)) + "%") : "-") ?? "";
737 }
738 else if (flag)
739 {
740 n.AddTopic("TopicLeft", "vCurrent".lang(), "vValue".lang(DisplayValue.ToString() ?? "", ValueWithoutLink + ((num == 0) ? "" : ((num > 0) ? (" + " + num) : (" - " + -num)))));
741 if (ShowPotential)
742 {
743 num = vTempPotential;
744 n.AddTopic("TopicLeft", "vPotential".lang(), "vValue".lang(Potential.ToString() ?? "", vPotential + vSourcePotential + MinPotential + ((num == 0) ? "" : ((num > 0) ? (" + " + num) : (" - " + -num)))));
745 }
747 }
748 if (flag2 && !source.aliasParent.IsEmpty())
749 {
750 Element element = Create(source.aliasParent);
751 UIItem uIItem2 = n.AddItem("ItemRelativeAttribute");
752 uIItem2.text1.SetText(element.Name);
753 element.SetImage(uIItem2.image1);
754 bool flag3 = source.lvFactor > 0 && this is Act;
755 uIItem2.text2.SetActive(flag3);
756 uIItem2.text3.SetActive(flag3);
757 if (flag3)
758 {
759 uIItem2.text2.SetText(GetPower(EClass.pc).ToString() ?? "");
760 }
761 }
762 OnWriteNote(n, owner);
764 {
765 n.AddTopic("TopicLeft", "Class:", GetType()?.ToString() ?? "");
766 n.AddTopic("TopicLeft", "vExp".lang(), vExp.ToString() ?? "");
767 n.AddTopic("TopicLeft", "vSource", vSource.ToString() ?? "");
768 n.AddTopic("TopicLeft", "vSourcePotential", vSourcePotential.ToString() ?? "");
769 n.AddTopic("TopicLeft", "vPotential", vPotential.ToString() ?? "");
770 n.AddTopic("TopicLeft", "Potential", Potential.ToString() ?? "");
771 }
773 onWriteNote?.Invoke(n);
774 if (ShowBonuses && owner.Chara != null)
775 {
776 BonusInfo bonusInfo = new BonusInfo();
777 bonusInfo.ele = this;
778 bonusInfo.n = n;
779 bonusInfo.c = owner.Chara;
780 bonusInfo.WriteNote();
781 }
782 UIText.globalSizeMod = 0;
783 }
784
785 public virtual void OnWriteNote(UINote n, ElementContainer owner)
786 {
787 }
788
789 public virtual void OnChangeValue()
790 {
791 }
792
794 {
795 if (owner == null || source.levelBonus.IsEmpty())
796 {
797 return;
798 }
799 bool flag = n == null;
800 string[] array = (source.GetText("levelBonus", returnNull: true) ?? source.levelBonus).Split(Environment.NewLine.ToCharArray());
801 if (!flag)
802 {
803 n.Space(10);
804 }
805 string[] array2 = array;
806 foreach (string obj in array2)
807 {
808 string[] array3 = obj.Split(',');
809 int lv = array3[0].ToInt();
810 SourceElement.Row row = (EClass.sources.elements.alias.ContainsKey(array3[1]) ? EClass.sources.elements.alias[array3[1]] : null);
811 if (flag)
812 {
813 if (lv > ValueWithoutLink)
814 {
815 break;
816 }
817 if (row != null && !owner.Has(row.id) && owner is ElementContainerZone)
818 {
819 owner.Learn(row.id);
820 }
821 }
822 else
823 {
824 string s = ((row != null) ? row.GetName() : array3[1]);
825 n.AddText((" Lv " + lv).TagColor(FontColor.Topic) + " " + s.TagColorGoodBad(() => (row != null) ? owner.Has(row.id) : (lv <= ValueWithoutLink), () => false));
826 }
827 }
828 if (!flag)
829 {
830 n.Space(4);
831 }
832 }
833
835 {
836 switch (m)
837 {
838 case UIList.SortMode.ByCategory:
839 return source.id + ((!source.aliasParent.IsEmpty()) ? (EClass.sources.elements.alias[source.aliasParent].id * 10000) : 0);
840 case UIList.SortMode.ByNumber:
841 return -vPotential * 10000 + source.id;
842 case UIList.SortMode.ByElementParent:
843 if (!source.aliasParent.IsEmpty())
844 {
845 return EClass.sources.elements.alias[source.aliasParent].sort;
846 }
847 return id;
848 default:
849 return source.id;
850 }
851 }
852
853 public virtual Act.Cost GetCost(Chara c)
854 {
855 if (source.cost[0] == 0)
856 {
857 Act.Cost result = default(Act.Cost);
858 result.type = Act.CostType.None;
859 return result;
860 }
861 Act.Cost result2 = default(Act.Cost);
862 if (this is Spell)
863 {
864 result2.type = Act.CostType.MP;
865 int num = EClass.curve(Value, 50, 10);
866 result2.cost = source.cost[0] * (100 + ((!source.tag.Contains("noCostInc")) ? (num * 3) : 0)) / 100;
867 }
868 else
869 {
870 result2.type = Act.CostType.SP;
871 result2.cost = source.cost[0];
872 if (source.id == 6020)
873 {
874 result2.cost = c.stamina.max / 3 + 10;
875 }
876 }
877 if (!c.IsPC && result2.cost > 2)
878 {
879 result2.cost /= 2;
880 }
881 return result2;
882 }
883
884 public virtual int GetPower(Card c)
885 {
886 return 100;
887 }
888
889 public virtual void SetTextValue(UIText text)
890 {
891 string text2 = DisplayValue.ToString() ?? "";
892 if (ShowXP)
893 {
894 text2 += ".".TagSize((vExp / 10).ToString("D2") ?? "", 11);
895 }
896 if (vLink != 0)
897 {
898 string text3 = ((vLink > 0) ? "+" : "") + vLink;
899 text2 = "<color=" + ((DisplayValue > ValueWithoutLink) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad).ToHex() + ">" + text2 + (" (" + text3 + ")").TagSize(13) + "</color>";
900 }
901 text.text = text2;
902 }
903
904 public virtual bool IsPurchaseFeatReqMet(ElementContainer owner, int lv = -1)
905 {
906 return false;
907 }
908
909 public virtual void WritePurchaseReq(UINote n, int lv = 1)
910 {
911 }
912
913 public static Element Create(int id, int v = 0)
914 {
915 SourceElement.Row row = EClass.sources.elements.map.TryGetValue(id);
916 if (row == null)
917 {
918 return null;
919 }
920 Element element = ClassCache.Create<Element>(row.type.IsEmpty("Element"), "Elin");
921 element.id = id;
922 element.vBase = v;
923 element._source = row;
924 return element;
925 }
926
927 public static Element Create(string id, int v = 1)
928 {
929 return Create(EClass.sources.elements.alias[id].id, v);
930 }
931
932 public static int GetId(string alias)
933 {
934 return EClass.sources.elements.alias[alias].id;
935 }
936
937 public static int GetResistLv(int v)
938 {
939 int num = v / 5;
940 if (num < -2)
941 {
942 num = -2;
943 }
944 if (num > 4)
945 {
946 num = 4;
947 }
948 return num;
949 }
950
951 public static int GetResistDamage(int dmg, int v, int power = 0)
952 {
953 int resistLv = GetResistLv(v);
954 resistLv -= power;
955 if (resistLv >= 4)
956 {
957 return 0;
958 }
959 return resistLv switch
960 {
961 3 => dmg / 4,
962 2 => dmg / 3,
963 1 => dmg / 2,
964 0 => dmg,
965 -1 => dmg * 3 / 2,
966 -2 => dmg * 2,
967 _ => dmg * 2,
968 };
969 }
970}
FontColor
Definition: FontColor.cs:2
SourceValueType
Definition: ACT.cs:6
static Act Create(int id)
Definition: ACT.cs:36
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
virtual bool LocalAct
Definition: ACT.cs:169
virtual TargetType TargetType
Definition: ACT.cs:140
virtual bool HaveLongPressAction
Definition: ACT.cs:131
void SetElement(int id)
virtual string Name
override void _WriteNote(UINote n, bool asChild=false)
virtual int EvaluateTurn(int p)
ElementContainer elements
void SetRefVal(int a, int b)
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2132
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
string c_idDeity
Definition: Card.cs:1481
bool IsFurniture
Definition: Card.cs:2111
int encLV
Definition: Card.cs:310
int Evalue(int ele)
Definition: Card.cs:2431
List< BodySlot > slots
Definition: CharaBody.cs:8
Definition: Chara.cs:10
CharaBody body
Definition: Chara.cs:91
string idFaith
Definition: Chara.cs:216
Faction faction
Definition: Chara.cs:412
override bool IsPC
Definition: Chara.cs:597
ElementContainer tempElements
Definition: Chara.cs:36
List< Condition > conditions
Definition: Chara.cs:196
int CalcCastingChance(Element e, int num=1)
Definition: Chara.cs:5535
override bool IsPCFaction
Definition: Chara.cs:656
Stats stamina
Definition: Chara.cs:955
ElementContainer faithElements
Definition: Chara.cs:38
void RefreshSpeed(Element.BonusInfo info=null)
Definition: Chara.cs:1614
Religion faith
Definition: Chara.cs:424
SourceRace.Row race
Definition: Chara.cs:449
static Condition Create(string alias, int power=100, Action< Condition > onCreate=null)
Definition: Condition.cs:46
bool showExtra
Definition: CoreDebug.cs:167
Sprite mana
Definition: CoreRef.cs:120
Sprite stamina
Definition: CoreRef.cs:122
Icons icons
Definition: CoreRef.cs:339
CoreRef refs
Definition: Core.cs:51
Definition: Dice.cs:4
override string ToString()
Definition: Dice.cs:91
static Dice Create(Element ele, Card c)
Definition: Dice.cs:96
Definition: EClass.cs:5
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:55
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:42
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
const int antidote
Definition: ELEMENT.cs:12
const int weight
Definition: ELEMENT.cs:36
const int growth
Definition: ELEMENT.cs:42
const int old_heal
Definition: ELEMENT.cs:58
const int race
Definition: ELEMENT.cs:64
const int comfort
Definition: ELEMENT.cs:22
const int cute
Definition: ELEMENT.cs:10
const int decay
Definition: ELEMENT.cs:46
const int purity
Definition: ELEMENT.cs:20
const int nutrition
Definition: ELEMENT.cs:34
const int _void
Definition: ELEMENT.cs:24
const int heat
Definition: ELEMENT.cs:44
const int rare
Definition: ELEMENT.cs:8
const int taste
Definition: ELEMENT.cs:48
const int size
Definition: ELEMENT.cs:38
const int quality
Definition: ELEMENT.cs:26
const int piety
Definition: ELEMENT.cs:66
const int nerve
Definition: ELEMENT.cs:14
const int poison
Definition: ELEMENT.cs:68
static readonly int[] IDS
Definition: ELEMENT.cs:70
const int hotspring
Definition: ELEMENT.cs:18
const int cure
Definition: ELEMENT.cs:62
const int water
Definition: ELEMENT.cs:50
const int fire
Definition: ELEMENT.cs:52
const int lv
Definition: ELEMENT.cs:28
const int old_detox
Definition: ELEMENT.cs:56
const int socket
Definition: ELEMENT.cs:32
const int old_antidote
Definition: ELEMENT.cs:60
const int blood
Definition: ELEMENT.cs:16
const int d
Definition: ELEMENT.cs:30
const int hardness
Definition: ELEMENT.cs:40
const int cut
Definition: ELEMENT.cs:54
Dictionary< int, Element > dict
void Learn(int ele, int v=1)
bool Has(int ele)
int Value(int ele)
virtual int ValueBonus(Element e)
Element GetOrCreateElement(Element ele)
virtual Chara Chara
Element GetElement(string alias)
void AddText(string text, FontColor col=FontColor.Warning)
Definition: ELEMENT.cs:101
void WriteNote()
Definition: ELEMENT.cs:131
void AddFix(int v, string text)
Definition: ELEMENT.cs:122
Element ele
Definition: ELEMENT.cs:82
void CheckFirst()
Definition: ELEMENT.cs:92
void AddText(int v, string text, string textBad=null)
Definition: ELEMENT.cs:107
bool IsFactionElement(Chara c)
Definition: ELEMENT.cs:483
virtual bool ShowPotential
Definition: ELEMENT.cs:322
virtual bool ShowMsgOnValueChanged
Definition: ELEMENT.cs:318
virtual bool CanGainExp
Definition: ELEMENT.cs:290
virtual Sprite GetSprite()
Definition: ELEMENT.cs:406
virtual int DisplayValue
Definition: ELEMENT.cs:278
virtual void OnChangeValue()
Definition: ELEMENT.cs:789
static Element Create(string id, int v=1)
Definition: ELEMENT.cs:927
int ValueWithoutLink
Definition: ELEMENT.cs:284
static int[] List_Body
Definition: ELEMENT.cs:234
virtual bool ShowXP
Definition: ELEMENT.cs:307
virtual bool UseExpMod
Definition: ELEMENT.cs:300
static int GetResistDamage(int dmg, int v, int power=0)
Definition: ELEMENT.cs:951
int Potential
Definition: ELEMENT.cs:288
int GetMaterialSourceValue(Thing t, int v)
Definition: ELEMENT.cs:411
virtual SourceElement.Row GetSource()
Definition: ELEMENT.cs:396
int id
Definition: ELEMENT.cs:240
int vBase
Definition: ELEMENT.cs:242
virtual void WritePurchaseReq(UINote n, int lv=1)
Definition: ELEMENT.cs:909
SourceElement.Row source
Definition: ELEMENT.cs:263
int vExp
Definition: ELEMENT.cs:244
virtual int GetSourceValue(int v, int lv, SourceValueType type)
Definition: ELEMENT.cs:428
virtual bool IsPurchaseFeatReqMet(ElementContainer owner, int lv=-1)
Definition: ELEMENT.cs:904
void _WriteNote(UINote n, Chara c, Act act)
Definition: ELEMENT.cs:596
int vPotential
Definition: ELEMENT.cs:246
static SourceElement.Row Get(int id)
Definition: ELEMENT.cs:391
virtual int GetSourcePotential(int v)
Definition: ELEMENT.cs:401
ElementContainer owner
Definition: ELEMENT.cs:256
virtual Sprite GetIcon(string suffix="")
Definition: ELEMENT.cs:438
static int GetResistLv(int v)
Definition: ELEMENT.cs:937
virtual int MinValue
Definition: ELEMENT.cs:280
bool HasTag(string tag)
Definition: ELEMENT.cs:463
virtual int CostTrain
Definition: ELEMENT.cs:302
int vTempPotential
Definition: ELEMENT.cs:248
static List< SourceElement.Row > ListAttackElements
Definition: ELEMENT.cs:260
static int[] List_MainAttributes
Definition: ELEMENT.cs:230
static int GetId(string alias)
Definition: ELEMENT.cs:932
virtual string FullName
Definition: ELEMENT.cs:296
void AddHeaderAbility(UINote n)
Definition: ELEMENT.cs:686
static Dictionary< int, int > GetElementMap(int[] list, Dictionary< int, int > map)
Definition: ELEMENT.cs:534
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:834
virtual int GetPower(Card c)
Definition: ELEMENT.cs:884
void SetImage(Image i)
Definition: ELEMENT.cs:468
int Value
Definition: ELEMENT.cs:282
void CheckLevelBonus(ElementContainer owner, UINote n=null)
Definition: ELEMENT.cs:793
virtual bool ShowRelativeAttribute
Definition: ELEMENT.cs:328
void WriteNoteWithRef(UINote n, ElementContainer owner, Action< UINote > onWriteNote, Element refEle)
Definition: ELEMENT.cs:581
bool IsFoodTrait
Definition: ELEMENT.cs:354
virtual void SetTextValue(UIText text)
Definition: ELEMENT.cs:889
virtual string Name
Definition: ELEMENT.cs:294
static Dictionary< int, int > GetElementMap(int[] list)
Definition: ELEMENT.cs:521
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:913
virtual bool CanLink(ElementContainer owner)
Definition: ELEMENT.cs:458
int vLink
Definition: ELEMENT.cs:250
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:853
virtual bool ShowEncNumber
Definition: ELEMENT.cs:350
static string GetName(string alias)
Definition: ELEMENT.cs:386
static SourceElement.Row GetRandomElement(int lv=1)
Definition: ELEMENT.cs:546
static List< SourceElement.Row > ListElements
Definition: ELEMENT.cs:258
virtual bool ShowBonuses
Definition: ELEMENT.cs:330
virtual bool PotentialAsStock
Definition: ELEMENT.cs:326
int vSource
Definition: ELEMENT.cs:252
void WriteNote(UINote n, ElementContainer owner=null, Action< UINote > onWriteNote=null)
Definition: ELEMENT.cs:574
static Element Void
Definition: ELEMENT.cs:228
virtual bool UsePotential
Definition: ELEMENT.cs:324
int vSourcePotential
Definition: ELEMENT.cs:254
void _WriteNote(UINote n, ElementContainer owner, Action< UINote > onWriteNote, bool isRef, bool addHeader=true)
Definition: ELEMENT.cs:693
bool IsGlobalElement
Definition: ELEMENT.cs:335
bool IsPartyWideElement
Definition: ELEMENT.cs:348
bool IsTrait
Definition: ELEMENT.cs:352
bool IsFactionWideElement
Definition: ELEMENT.cs:346
static int[] List_Mind
Definition: ELEMENT.cs:236
virtual void OnWriteNote(UINote n, ElementContainer owner)
Definition: ELEMENT.cs:785
virtual string GetDetail()
Definition: ELEMENT.cs:478
Element GetParent(Card c)
Definition: ELEMENT.cs:512
virtual int MinPotential
Definition: ELEMENT.cs:286
virtual int CostLearn
Definition: ELEMENT.cs:304
SourceElement.Row _source
Definition: ELEMENT.cs:238
static int[] List_MainAttributesMajor
Definition: ELEMENT.cs:232
const int Div
Definition: ELEMENT.cs:226
Act act
Definition: ELEMENT.cs:384
bool IsFoodTraitMain
Definition: ELEMENT.cs:357
bool IsFlag
Definition: ELEMENT.cs:292
virtual bool ShowValue
Definition: ELEMENT.cs:320
bool IsMainAttribute
Definition: ELEMENT.cs:373
virtual int ExpToNext
Definition: ELEMENT.cs:298
bool IsActive(Card c)
Definition: ELEMENT.cs:443
virtual string ShortName
Definition: ELEMENT.cs:332
int SortVal(bool charaSheet=false)
Definition: ELEMENT.cs:452
ElementContainerFaction charaElements
Definition: FACTION.cs:144
int CountKeyItem(string alias)
Definition: Player.cs:1946
virtual string id
Definition: Religion.cs:26
static SkinColorProfile CurrentColors
Definition: SkinManager.cs:84
override string GetName()
SourceKeyItem keyItems
SourceElement elements
Definition: SPELL.cs:468
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
virtual int value
Definition: Stats.cs:56
Definition: Thing.cs:8
Definition: UIItem.cs:5
UIText text3
Definition: UIItem.cs:10
Image image1
Definition: UIItem.cs:14
UIText text2
Definition: UIItem.cs:8
UIText text1
Definition: UIItem.cs:6
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
UIItem AddItem(string id)
Definition: UINote.cs:139
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159
Definition: ACT.cs:71
CostType type
Definition: ACT.cs:74
int cost
Definition: ACT.cs:72