Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
FortuneRollData.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using Newtonsoft.Json;
4using UnityEngine;
5
6public class FortuneRollData : EClass
7{
8 public class Prize : EClass
9 {
10 [JsonProperty]
11 public int grade;
12
13 [JsonProperty]
14 public string id;
15
16 [JsonProperty]
17 public string idRef;
18
19 [JsonProperty]
20 public bool claimed;
21
22 public Card model => EClass.sources.cards.map[id].model;
23
24 public int GetNum()
25 {
26 if (id == "ration")
27 {
28 return 10;
29 }
30 if (id == "medal")
31 {
32 if (grade != 2)
33 {
34 if (grade != 3)
35 {
36 return 1;
37 }
38 return 10;
39 }
40 return 3;
41 }
42 if (id == "plat")
43 {
44 if (grade != 1)
45 {
46 if (grade != 2)
47 {
48 if (grade != 3)
49 {
50 return 1;
51 }
52 return 50;
53 }
54 return 20;
55 }
56 return 10;
57 }
58 if (id == "1165" && grade == 3)
59 {
60 return 3;
61 }
62 return 1;
63 }
64
65 public void AddNote(UINote n)
66 {
67 string text = "_circle".lang().TagColor(EClass.sources.materials.alias[mats[grade]].GetColor()) + " " + Lang.GetList("fortuneroll")[grade];
68 string text2 = (model.IsUnique ? "★" : "") + EClass.sources.cards.map[id].GetName();
69 string text3 = id;
70 if (!(text3 == "panty"))
71 {
72 if (text3 == "mathammer")
73 {
74 if (idRef.IsEmpty())
75 {
76 idRef = "iron";
77 }
78 text2 = "_of".lang(EClass.sources.materials.alias[idRef].GetName(), text2);
79 }
80 }
81 else
82 {
83 string name = EClass.sources.cards.map[idRef].GetName();
84 text2 = "_of".lang(name, text2);
85 }
86 int num = GetNum();
87 if (num > 1)
88 {
89 text2 = text2 + " x " + num;
90 }
91 if (claimed)
92 {
93 text2 = "fortuneroll_claimed".lang();
94 }
95 n.AddTopic("TopicDomain", text, text2.ToTitleCase().TagColor(model.IsUnique ? FontColor.Great : FontColor.Good));
96 }
97 }
98
99 public static string[] mats = new string[4] { "plastic", "water", "hide_dragon", "gold" };
100
101 public static int[] chances = new int[4] { 1, 8, 25, 60 };
102
103 [JsonProperty]
104 public List<Prize> prizes = new List<Prize>();
105
106 [JsonProperty]
107 public int count;
108
109 [JsonProperty]
110 public int seed;
111
112 [JsonProperty]
113 public int dateNextRefresh;
114
115 public void Refresh()
116 {
118 {
119 Date date = EClass.world.date.Copy();
120 date.day = 1;
121 date.hour = 0;
122 date.min = 0;
123 date.AddMonth(1);
124 dateNextRefresh = date.GetRaw();
125 count++;
126 RefreshPrize();
127 }
128 }
129
130 public void RefreshPrize()
131 {
132 prizes.Clear();
134 List<List<string>> list = GetPrizeList();
135 if (EClass._zone.IsTown && EClass._zone.lv == 0)
136 {
137 Add(3);
138 Add(2);
139 Add(2);
140 Add(1);
141 Add(1);
142 Add(1);
143 }
144 Rand.SetSeed();
145 void Add(int grade)
146 {
147 List<string> list2 = list[grade];
148 int index = EClass.rnd(list2.Count);
149 Prize prize = new Prize
150 {
151 id = list2[index],
152 grade = grade
153 };
154 string id = prize.id;
155 if (!(id == "panty"))
156 {
157 if (id == "mathammer")
158 {
159 SourceMaterial.Row randomMaterial = MATERIAL.GetRandomMaterial(20);
160 prize.idRef = randomMaterial.alias;
161 }
162 }
163 else
164 {
165 IEnumerable<SourceChara.Row> ie = EClass.sources.charas.map.Values.Where((SourceChara.Row r) => (r.model.trait as TraitChara).IsWearingPanty && !r.HasTag(CTAG.noRandomProduct));
166 prize.idRef = ie.RandomItem().id;
167 }
168 prizes.Add(prize);
169 list2.RemoveAt(index);
170 }
171 }
172
173 public List<List<string>> GetPrizeList()
174 {
175 List<List<string>> list = new List<List<string>>
176 {
177 new List<string> { "scrubber", "tissue", "plat" },
178 new List<string>
179 {
180 "microchip", "1089", "150", "855", "medal", "water", "goods_charm", "electronicsS", "electronics", "plat",
181 "plat", "ration", "backpack2", "sister", "rp_food", "rp_block", "157", "sleepingbag"
182 },
183 new List<string>
184 {
185 "computer", "834", "1090", "goods_figure", "goods_canvas", "mb_1", "mb_2", "mb_3", "mb_4", "mb_5",
186 "1174", "1085", "toilet", "714", "nobility", "plat", "1165", "mathammer", "medal", "bbq",
187 "panty", "beehive", "ticket_resident", "lovepotion", "crystal_sun"
188 },
189 new List<string>
190 {
191 (EClass.player.luckycoin < 10) ? "goods_coin" : "plat",
192 "plat",
193 "1165",
194 "boat3",
195 "medal"
196 }
197 };
199 {
200 for (int i = 0; i < (EClass.debug.enable ? 50 : 5); i++)
201 {
202 list[2].Add("panty");
203 }
204 }
205 return list;
206 }
207
208 public void GetPrize(int grade, int seed)
209 {
211 Prize prize = null;
212 List<Prize> list = prizes.Where((Prize p) => p.grade == grade && !p.claimed).ToList();
213 if (list.Count > 0)
214 {
215 prize = list.RandomItem();
216 }
217 Card card = null;
218 if (prize != null)
219 {
220 if (prize.id == "sister")
221 {
222 card = CharaGen.Create("sister");
223 }
224 else
225 {
226 card = ThingGen.Create(prize.id).SetNum(prize.GetNum());
227 switch (card.id)
228 {
229 case "rp_food":
230 case "rp_block":
231 card.SetLv(10);
232 break;
233 case "goods_coin":
235 if (EClass.player.luckycoin >= 10)
236 {
237 prize.claimed = true;
238 }
239 break;
240 case "mathammer":
241 card.ChangeMaterial(prize.idRef);
242 card.noSell = true;
243 break;
244 case "panty":
245 card.c_idRefCard = prize.idRef;
246 card.rarity = Rarity.Legendary;
247 break;
248 }
249 }
250 if (grade != 3)
251 {
252 prize.claimed = true;
253 }
254 }
255 else
256 {
257 card = ThingGen.Create(GetPrizeList()[0].RandomItem());
258 }
259 if (card.isChara)
260 {
261 EClass._zone.AddCard(card, EClass.pc.pos.GetNearestPoint(allowBlock: false, allowChara: false) ?? EClass.pc.pos);
262 card.Chara.MakeMinion(EClass.pc);
263 }
264 else
265 {
266 EClass.pc.Pick(card.Thing);
267 }
268 Rand.SetSeed();
269 }
270
271 public void WriteNote(UINote n)
272 {
273 n.Clear();
274 n.AddHeader("fortuneroll_prize");
275 n.Space(4);
276 foreach (Prize prize in prizes)
277 {
278 prize.AddNote(n);
279 }
280 string text = "_circle".lang().TagColor(Color.white) + " " + Lang.GetList("fortuneroll")[0];
281 n.AddTopic("TopicDomain", text, "fortuneroll_lose".lang());
282 n.Build();
283 }
284}
CTAG
Definition: CTAG.cs:2
FontColor
Definition: FontColor.cs:2
Rarity
Definition: Rarity.cs:2
list. Add(item3)
Definition: Card.cs:11
bool IsUnique
Definition: Card.cs:1967
Thing SetNum(int a)
Definition: Card.cs:3242
Point pos
Definition: Card.cs:55
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Faction faction
Definition: Chara.cs:412
Thing Pick(Thing t, bool msg=true, bool tryStack=true)
Definition: Chara.cs:3920
Definition: Date.cs:4
Date Copy()
Definition: Date.cs:197
void AddMonth(int a)
Definition: Date.cs:235
int GetRaw(int offsetHours=0)
Definition: Date.cs:322
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static int rnd(int a)
Definition: EClass.cs:50
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static SourceManager sources
Definition: EClass.cs:42
static Player player
Definition: EClass.cs:12
static Chara pc
Definition: EClass.cs:14
bool IsGlobalPolicyActive(int id)
Definition: FACTION.cs:436
void AddNote(UINote n)
void WriteNote(UINote n)
List< Prize > prizes
void GetPrize(int grade, int seed)
static string[] mats
static int[] chances
List< List< string > > GetPrizeList()
int seed
Definition: Game.cs:197
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
static SourceMaterial.Row GetRandomMaterial(int lv, string group=null, bool tryLevelMatTier=false)
Definition: MATERIAL.cs:43
int luckycoin
Definition: Player.cs:763
Point GetNearestPoint(bool allowBlock=false, bool allowChara=true, bool allowInstalled=true, bool ignoreCenter=false)
Definition: Point.cs:595
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceMaterial materials
SourceCard cards
SourceChara charas
int lv
Definition: Spatial.cs:142
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
GameDate date
Definition: World.cs:6
virtual bool IsTown
Definition: Zone.cs:220
Card AddCard(Card t, Point point)
Definition: Zone.cs:1893