DataBase.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. using System.Linq;
  6. using System.IO;
  7. public class DataBase : MonoBehaviour
  8. {
  9. public static DataBase instance = null;
  10. private void Awake()
  11. {
  12. instance = this;
  13. }
  14. public static Dictionary<CardKind, string> CardKindJPNameDictionary = new Dictionary<CardKind, string>()
  15. {
  16. {CardKind.Digimon,"デジモン" },
  17. {CardKind.Tamer,"テイマー" },
  18. {CardKind.Option,"オプション" },
  19. {CardKind.DigiEgg,"デジタマ" },
  20. };
  21. public static Dictionary<CardKind, string> CardKindENNameDictionary = new Dictionary<CardKind, string>()
  22. {
  23. {CardKind.Digimon,"Digimon" },
  24. {CardKind.Tamer,"Tamer" },
  25. {CardKind.Option,"Option" },
  26. {CardKind.DigiEgg,"DigiEgg" },
  27. };
  28. public static Dictionary<CardColor, string> CardColorNameDictionary = new Dictionary<CardColor, string>()
  29. {
  30. { CardColor.Green,"green"},
  31. { CardColor.Red,"red"},
  32. { CardColor.Blue,"blue"},
  33. { CardColor.Yellow,"yellow"},
  34. { CardColor.Purple,"purple"},
  35. { CardColor.Black,"black"},
  36. { CardColor.White,"white"},
  37. { CardColor.None,"-"},
  38. };
  39. public static Dictionary<CardColor, Color> CardColor_ColorLightDictionary = new Dictionary<CardColor, Color>()
  40. {
  41. { CardColor.Green,new Color32(55,255,49,255)},
  42. { CardColor.Red,new Color32(253,63,49,255)},
  43. { CardColor.Blue, new Color32(49,118,253,255) },
  44. { CardColor.Yellow, new Color32(255,231,64,255)},
  45. { CardColor.Purple,new Color32(234,64,176,255)},
  46. { CardColor.Black,new Color32(61,61,61,255)},
  47. { CardColor.White,new Color32(224,224,224,255)},
  48. { CardColor.None,new Color32(222,222,222,255)},
  49. };
  50. public static Dictionary<CardColor, Color> CardColor_ColorDarkDictionary = new Dictionary<CardColor, Color>()
  51. {
  52. { CardColor.Red,new Color32(171,12,0,255)},
  53. { CardColor.Blue, new Color32(0,103,171,255) },
  54. { CardColor.Green,new Color32(1,171,0,255)},
  55. { CardColor.Yellow, new Color32(255,242,64,255)},
  56. { CardColor.Purple,new Color32(155,0,171,255)},
  57. { CardColor.Black,new Color32(61,61,61,255)},
  58. { CardColor.White,new Color32(224,224,224,255)},
  59. { CardColor.None,new Color32(222,222,222,255)},
  60. };
  61. public static Dictionary<CardColor, String> CardColorInitialDictionary = new Dictionary<CardColor, String>()
  62. {
  63. { CardColor.Red,"R"},
  64. { CardColor.Blue, "U" },
  65. { CardColor.Green,"G"},
  66. { CardColor.Yellow, "Y"},
  67. { CardColor.Purple,"P"},
  68. { CardColor.Black,"B"},
  69. { CardColor.White,"W"},
  70. { CardColor.None,"N"},
  71. };
  72. public static List<string> CardListIDs(string SetID, bool isEnglish)
  73. {
  74. List<string> cardListID = new List<string>();
  75. if (isEnglish)
  76. {
  77. switch (SetID)
  78. {
  79. case "ST1":
  80. cardListID.Add("522101");
  81. break;
  82. case "ST2":
  83. cardListID.Add("522102");
  84. break;
  85. case "ST3":
  86. cardListID.Add("522103");
  87. break;
  88. case "ST4":
  89. cardListID.Add("522104");
  90. break;
  91. case "ST5":
  92. cardListID.Add("522105");
  93. break;
  94. case "ST6":
  95. cardListID.Add("522106");
  96. break;
  97. case "ST7":
  98. cardListID.Add("522107");
  99. break;
  100. case "ST8":
  101. cardListID.Add("522108");
  102. break;
  103. case "ST9":
  104. cardListID.Add("522109");
  105. break;
  106. case "ST10":
  107. cardListID.Add("522110");
  108. break;
  109. case "ST12":
  110. cardListID.Add("522112");
  111. break;
  112. case "ST13":
  113. cardListID.Add("522113");
  114. break;
  115. case "ST14":
  116. cardListID.Add("522114");
  117. break;
  118. case "ST15":
  119. cardListID.Add("522115");
  120. break;
  121. case "ST16":
  122. cardListID.Add("522116");
  123. break;
  124. case "ST17":
  125. cardListID.Add("522117");
  126. break;
  127. case "BT1":
  128. cardListID.Add("522001");
  129. cardListID.Add("522002");
  130. break;
  131. case "BT2":
  132. cardListID.Add("522001");
  133. cardListID.Add("522002");
  134. break;
  135. case "BT3":
  136. cardListID.Add("522001");
  137. cardListID.Add("522002");
  138. break;
  139. case "BT4":
  140. cardListID.Add("522003");
  141. break;
  142. case "BT5":
  143. cardListID.Add("522004");
  144. break;
  145. case "BT6":
  146. cardListID.Add("522005");
  147. break;
  148. case "EX1":
  149. cardListID.Add("522006");
  150. break;
  151. case "BT7":
  152. cardListID.Add("522007");
  153. break;
  154. case "BT8":
  155. cardListID.Add("522008");
  156. break;
  157. case "EX2":
  158. cardListID.Add("522009");
  159. break;
  160. case "BT9":
  161. cardListID.Add("522010");
  162. break;
  163. case "BT10":
  164. cardListID.Add("522011");
  165. break;
  166. case "EX3":
  167. cardListID.Add("522012");
  168. break;
  169. case "BT11":
  170. cardListID.Add("522013");
  171. break;
  172. case "BT12":
  173. cardListID.Add("522014");
  174. break;
  175. case "EX4":
  176. cardListID.Add("522015");
  177. break;
  178. case "BT13":
  179. cardListID.Add("522016");
  180. break;
  181. case "RB1":
  182. cardListID.Add("522017");
  183. break;
  184. case "BT14":
  185. cardListID.Add("522018");
  186. break;
  187. case "EX5":
  188. cardListID.Add("522019");
  189. break;
  190. case "BT15":
  191. cardListID.Add("522020");
  192. break;
  193. case "LM":
  194. cardListID.Add("522020");
  195. break;
  196. case "P":
  197. cardListID.Add("522007");
  198. cardListID.Add("522901");
  199. break;
  200. }
  201. }
  202. else
  203. {
  204. switch (SetID)
  205. {
  206. case "ST1":
  207. cardListID.Add("503101");
  208. break;
  209. case "ST2":
  210. cardListID.Add("503102");
  211. break;
  212. case "ST3":
  213. cardListID.Add("503103");
  214. break;
  215. case "ST4":
  216. cardListID.Add("503104");
  217. break;
  218. case "ST5":
  219. cardListID.Add("503105");
  220. break;
  221. case "ST6":
  222. cardListID.Add("503106");
  223. break;
  224. case "ST7":
  225. cardListID.Add("503107");
  226. break;
  227. case "ST8":
  228. cardListID.Add("503108");
  229. break;
  230. case "ST9":
  231. cardListID.Add("503109");
  232. break;
  233. case "ST10":
  234. cardListID.Add("503110");
  235. break;
  236. case "ST11":
  237. cardListID.Add("503111");
  238. break;
  239. case "ST12":
  240. cardListID.Add("503112");
  241. break;
  242. case "ST13":
  243. cardListID.Add("503113");
  244. break;
  245. case "ST14":
  246. cardListID.Add("503114");
  247. break;
  248. case "ST15":
  249. cardListID.Add("503115");
  250. break;
  251. case "ST16":
  252. cardListID.Add("503116");
  253. break;
  254. case "ST17":
  255. cardListID.Add("503117");
  256. break;
  257. case "BT1":
  258. cardListID.Add("503001");
  259. break;
  260. case "BT2":
  261. cardListID.Add("503002");
  262. break;
  263. case "BT3":
  264. cardListID.Add("503003");
  265. break;
  266. case "BT4":
  267. cardListID.Add("503004");
  268. break;
  269. case "BT5":
  270. cardListID.Add("503005");
  271. break;
  272. case "BT6":
  273. cardListID.Add("503006");
  274. break;
  275. case "EX1":
  276. cardListID.Add("503007");
  277. break;
  278. case "BT7":
  279. cardListID.Add("503008");
  280. break;
  281. case "BT8":
  282. cardListID.Add("503009");
  283. break;
  284. case "EX2":
  285. cardListID.Add("503010");
  286. break;
  287. case "BT9":
  288. cardListID.Add("503011");
  289. break;
  290. case "BT10":
  291. cardListID.Add("503012");
  292. break;
  293. case "EX3":
  294. cardListID.Add("503013");
  295. break;
  296. case "BT11":
  297. cardListID.Add("503014");
  298. break;
  299. case "BT12":
  300. cardListID.Add("503015");
  301. break;
  302. case "EX4":
  303. cardListID.Add("503016");
  304. break;
  305. case "RB1":
  306. cardListID.Add("503017");
  307. break;
  308. case "BT13":
  309. cardListID.Add("503018");
  310. break;
  311. case "BT14":
  312. cardListID.Add("503019");
  313. break;
  314. case "EX5":
  315. cardListID.Add("503020");
  316. break;
  317. case "BT15":
  318. cardListID.Add("503021");
  319. break;
  320. case "LM":
  321. cardListID.Add("503201");
  322. break;
  323. case "P":
  324. cardListID.Add("503008");
  325. cardListID.Add("503901");
  326. break;
  327. }
  328. }
  329. return cardListID;
  330. }
  331. public List<Sprite> ColorIcons_circle = new List<Sprite>();
  332. public List<Sprite> ColorIcons_bar = new List<Sprite>();
  333. public static Color SelectColor_Orange => new Color32(255, 98, 31, 255);
  334. public static Color SelectColor_Blue => new Color32(30, 246, 255, 255);
  335. public static Color SelectColor_Green => new Color32(57, 255, 30, 255);
  336. public static Color CommandColor_Attack => new Color32(255, 54, 54, 255);
  337. public static Color CommandColor_Move => new Color32(54, 111, 255, 255);
  338. public static Color CommandColor_Skill => new Color32(86, 255, 102, 255);
  339. public static bool IsXAntibodyString(string text) =>
  340. !string.IsNullOrEmpty(text) && text.Replace(" ", "").Replace("-", "").ToLower() == "xantibody";
  341. public static bool IsContainingXAntibodyString(string text) =>
  342. !string.IsNullOrEmpty(text) && text.Replace(" ", "").Replace("-", "").ToLower().Contains("xantibody");
  343. public static string BlockerEffectDiscription()
  344. {
  345. return "<Blocker> (When an opponent's Digimon attacks, you may suspend this Digimon to force the opponent to attack it instead.)";
  346. }
  347. public static string RebootEffectDiscription()
  348. {
  349. return "<Reboot> (Unsuspend this Digimon during your opponent's unsuspend phase.)";
  350. }
  351. public static string PierceEffectDiscription()
  352. {
  353. return "<Piercing> (When this Digimon attacks and deletes an opponent's Digimon and survives the battle, it performs any security checks it normally would.)";
  354. }
  355. public static string RetaliationEffectDiscription()
  356. {
  357. return "<Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling)";
  358. }
  359. public static string BilitzEffectDiscription()
  360. {
  361. return "<Blitz> (This Digimon can attack when your opponent has 1 or more memory.)";
  362. }
  363. public static string ArmorPurgeEffectDiscription()
  364. {
  365. return "<Armor Purge> (When this Digimon would be deleted, you may trash the top card of this Digimon to prevent that deletion.)";
  366. }
  367. public static string SaveEffectDiscription()
  368. {
  369. return "[On Deletion] <Save> (You may place this card under one of your Tamers.)";
  370. }
  371. public static string EvadeEffectDiscription()
  372. {
  373. return "<Evade> (When this Digimon would be deleted, you may suspend it to prevent that deletion.)";
  374. }
  375. public static string RaidEffectDiscription()
  376. {
  377. return "<Raid> (When this Digimon attacks, you may switch the target of attack to 1 of your opponent's unsuspended Digimon with the highest DP.)";
  378. }
  379. public static string BarrierEffectDiscription()
  380. {
  381. return "<Barrier? (When this Digimon would be deleted in battle, by trashing the top card of your security stack, prevent that deletion.)";
  382. }
  383. public static string BlastDigivolveEffectDiscription()
  384. {
  385. return "[Hand] [Counter] <Blast Digivolve> (Your Digimon may digivolve into this card without paying the cost).";
  386. }
  387. public static string FortitudeEffectDiscription()
  388. {
  389. return "<Fortitude> (When this Digimon with digivolution cards is deleted, play this card without paying the cost).";
  390. }
  391. public static string AllianceEffectDiscription()
  392. {
  393. return "<Alliance> (When this Digimon attacks, by suspending 1 of your other Digimon, this Digimon adds the suspended Digimon's DP and gains <Security Attack +1> for the attack.)";
  394. }
  395. public static string ReplaceToASCII(string text)
  396. {
  397. if (string.IsNullOrEmpty(text))
  398. {
  399. return "";
  400. }
  401. return text
  402. .Replace("<", "<")
  403. .Replace(">", ">")
  404. .Replace("、", ",")
  405. .Replace(",", ",")
  406. .Replace("“", "\"")
  407. .Replace("・", "")
  408. .Replace(" ", "")
  409. .Replace("!", "!");
  410. }
  411. public static string DigiburstRegex = "デジバースト[0-9]";
  412. public static string FirstPlayerKey = "FirstPlayerId";
  413. public static string FirstPlayerIndexIdKey = "FirstPlayerIndexId";
  414. #region use for sort
  415. public static CardKind[] cardKinds = new[] { CardKind.Digimon, CardKind.Tamer, CardKind.Option };
  416. public static CardColor[] cardColors = new[] { CardColor.Red, CardColor.Blue, CardColor.Yellow, CardColor.Green, CardColor.Black, CardColor.Purple, CardColor.White, CardColor.None };
  417. public static string[] SetIDs = new string[]
  418. {
  419. "BT28",
  420. "BT27",
  421. "BT26",
  422. "BT25",
  423. "BT24",
  424. "BT23",
  425. "BT22",
  426. "BT21",
  427. "BT20",
  428. "BT19",
  429. "BT18",
  430. "BT17",
  431. "BT16",
  432. "BT15",
  433. "BT14",
  434. "BT13",
  435. "BT12",
  436. "BT11",
  437. "BT10",
  438. "BT9",
  439. "BT8",
  440. "BT7",
  441. "BT6",
  442. "BT5",
  443. "BT4",
  444. "BT3",
  445. "BT2",
  446. "BT1",
  447. "EX28",
  448. "EX27",
  449. "EX26",
  450. "EX25",
  451. "EX24",
  452. "EX23",
  453. "EX22",
  454. "EX21",
  455. "EX20",
  456. "EX19",
  457. "EX18",
  458. "EX17",
  459. "EX16",
  460. "EX15",
  461. "EX14",
  462. "EX13",
  463. "EX12",
  464. "EX11",
  465. "EX10",
  466. "EX9",
  467. "EX8",
  468. "EX7",
  469. "EX6",
  470. "EX5",
  471. "EX4",
  472. "EX3",
  473. "EX2",
  474. "EX1",
  475. "RB11",
  476. "RB10",
  477. "RB9",
  478. "RB8",
  479. "RB7",
  480. "RB6",
  481. "RB5",
  482. "RB4",
  483. "RB3",
  484. "RB2",
  485. "RB1",
  486. "LM11",
  487. "LM10",
  488. "LM9",
  489. "LM8",
  490. "LM7",
  491. "LM6",
  492. "LM5",
  493. "LM4",
  494. "LM3",
  495. "LM2",
  496. "LM1",
  497. "ST28",
  498. "ST27",
  499. "ST26",
  500. "ST25",
  501. "ST24",
  502. "ST23",
  503. "ST22",
  504. "ST21",
  505. "ST20",
  506. "ST19",
  507. "ST18",
  508. "ST17",
  509. "ST16",
  510. "ST15",
  511. "ST14",
  512. "ST13",
  513. "ST12",
  514. "ST11",
  515. "ST10",
  516. "ST9",
  517. "ST8",
  518. "ST7",
  519. "ST6",
  520. "ST5",
  521. "ST4",
  522. "ST3",
  523. "ST2",
  524. "ST1",
  525. "P",
  526. };
  527. #endregion
  528. #region ENG ban list
  529. public static CardRestriction ENGBanList = new CardRestriction(new List<CardLimitCount>()
  530. {
  531. new CardLimitCount("BT11-064", 1),
  532. new CardLimitCount("BT10-009", 1),
  533. new CardLimitCount("BT9-099", 1),
  534. new CardLimitCount("BT7-107", 1),
  535. new CardLimitCount("BT7-072", 1),
  536. new CardLimitCount("BT7-064", 1),
  537. new CardLimitCount("BT7-038", 1),
  538. new CardLimitCount("BT6-100", 1),
  539. new CardLimitCount("BT5-109", 0),
  540. new CardLimitCount("BT3-103", 1),
  541. new CardLimitCount("BT3-054", 1),
  542. new CardLimitCount("BT2-047", 1),
  543. new CardLimitCount("EX2-039", 1),
  544. new CardLimitCount("EX1-068", 1),
  545. new CardLimitCount("P-008", 1),
  546. new CardLimitCount("P-025", 1),
  547. new CardLimitCount("ST6-03", 1),
  548. new CardLimitCount("BT2-069", 1),
  549. new CardLimitCount("BT13-012", 1),
  550. new CardLimitCount("EX4-019", 1),
  551. new CardLimitCount("BT7-069", 1),
  552. new CardLimitCount("BT14-002", 1),
  553. new CardLimitCount("BT15-102", 1),
  554. new CardLimitCount("EX5-015", 1),
  555. new CardLimitCount("EX5-018", 1),
  556. new CardLimitCount("EX5-062", 1),
  557. },
  558. new List<BannedPair>()
  559. {
  560. new BannedPair("EX5-065", new List<string>(){
  561. "P-097",
  562. "BT13-102",
  563. "ST16-14",
  564. })
  565. });
  566. #endregion
  567. #region JPN ban list
  568. public static CardRestriction JPNBanList = new CardRestriction(new List<CardLimitCount>()
  569. {
  570. new CardLimitCount("BT11-064", 1),
  571. new CardLimitCount("BT10-009", 1),
  572. new CardLimitCount("BT9-099", 1),
  573. new CardLimitCount("BT7-107", 1),
  574. new CardLimitCount("BT7-072", 1),
  575. new CardLimitCount("BT7-064", 1),
  576. new CardLimitCount("BT7-038", 1),
  577. new CardLimitCount("BT6-100", 1),
  578. new CardLimitCount("BT5-109", 0),
  579. new CardLimitCount("BT3-103", 1),
  580. new CardLimitCount("BT3-054", 1),
  581. new CardLimitCount("BT2-047", 1),
  582. new CardLimitCount("EX2-039", 1),
  583. new CardLimitCount("EX1-068", 1),
  584. new CardLimitCount("P-008", 1),
  585. new CardLimitCount("P-025", 1),
  586. new CardLimitCount("ST6-03", 1),
  587. new CardLimitCount("BT2-069", 1),
  588. new CardLimitCount("BT13-012", 1),
  589. new CardLimitCount("EX4-019", 1),
  590. new CardLimitCount("BT7-069", 1),
  591. new CardLimitCount("BT14-002", 1),
  592. new CardLimitCount("BT15-102", 1),
  593. new CardLimitCount("EX5-015", 1),
  594. new CardLimitCount("EX5-018", 1),
  595. new CardLimitCount("EX5-062", 1),
  596. },
  597. new List<BannedPair>()
  598. {
  599. new BannedPair("EX5-065", new List<string>(){
  600. "P-097",
  601. "BT13-102",
  602. "ST16-14",
  603. })
  604. });
  605. #endregion
  606. }
  607. [System.Serializable]
  608. public class ColorSpriteDic : TableBase<CardColor, Sprite, SamplePair>
  609. {
  610. }
  611. [System.Serializable]
  612. public class TableBase<TKey, TValue, Type> where Type : KeyAndValue<TKey, TValue>
  613. {
  614. [SerializeField]
  615. private List<Type> list;
  616. private Dictionary<TKey, TValue> table;
  617. public Dictionary<TKey, TValue> GetTable()
  618. {
  619. if (table == null)
  620. {
  621. table = ConvertListToDictionary(list);
  622. }
  623. return table;
  624. }
  625. /// <summary>
  626. /// Editor Only
  627. /// </summary>
  628. public List<Type> GetList()
  629. {
  630. return list;
  631. }
  632. static Dictionary<TKey, TValue> ConvertListToDictionary(List<Type> list)
  633. {
  634. Dictionary<TKey, TValue> dic = new Dictionary<TKey, TValue>();
  635. foreach (KeyAndValue<TKey, TValue> pair in list)
  636. {
  637. dic.Add(pair.Key, pair.Value);
  638. }
  639. return dic;
  640. }
  641. }
  642. /// <summary>
  643. /// Serializable KeyValuePair
  644. /// </summary>
  645. [System.Serializable]
  646. public class KeyAndValue<TKey, TValue>
  647. {
  648. public TKey Key;
  649. public TValue Value;
  650. public KeyAndValue(TKey key, TValue value)
  651. {
  652. Key = key;
  653. Value = value;
  654. }
  655. public KeyAndValue(KeyValuePair<TKey, TValue> pair)
  656. {
  657. Key = pair.Key;
  658. Value = pair.Value;
  659. }
  660. }
  661. [System.Serializable]
  662. public class SamplePair : KeyAndValue<CardColor, Sprite>
  663. {
  664. public SamplePair(CardColor key, Sprite value) : base(key, value)
  665. {
  666. }
  667. }
  668. public class DictionaryUtility
  669. {
  670. public static CardColor GetCardColor(string s, Dictionary<CardColor, string> PokemonTypeStringDictionary)
  671. {
  672. CardColor pokemonType = PokemonTypeStringDictionary.First(x => x.Value == s).Key;
  673. return pokemonType;
  674. }
  675. public static CardKind GetCardKind(string CardKindName, Dictionary<CardKind, string> CardKindNameDictionary)
  676. {
  677. CardKind cardKind = CardKindNameDictionary.First(x => x.Value == CardKindName).Key;
  678. return cardKind;
  679. }
  680. public static Rarity GetEvoStage(string EvoStageName, Dictionary<Rarity, string> EvoStageNameDictionary)
  681. {
  682. Rarity evoStage = EvoStageNameDictionary.First(x => x.Value == EvoStageName).Key;
  683. return evoStage;
  684. }
  685. }
  686. public class ParmanentParameterComparer : ParameterComparer
  687. {
  688. public override bool Equals(object[] i_lhs, object[] i_rhs)
  689. {
  690. if (i_lhs.Length == i_rhs.Length)
  691. {
  692. bool same = true;
  693. List<Permanent> i_lhs_list = new List<Permanent>();
  694. List<Permanent> i_rhs_list = new List<Permanent>();
  695. for (int i = 0; i < i_lhs.Length; i++)
  696. {
  697. i_lhs_list.Add(((Permanent[])i_lhs)[i]);
  698. i_rhs_list.Add(((Permanent[])i_rhs)[i]);
  699. }
  700. i_lhs_list = i_lhs_list.OrderBy((value) => value.PermanentFrame.FrameID).ToList();
  701. i_rhs_list = i_rhs_list.OrderBy((value) => value.PermanentFrame.FrameID).ToList();
  702. for (int i = 0; i < i_lhs.Length; i++)
  703. {
  704. if (i_lhs[i] != i_rhs[i])
  705. {
  706. same = false;
  707. break;
  708. }
  709. }
  710. if (!same)
  711. {
  712. return false;
  713. }
  714. return true;
  715. }
  716. return false;
  717. }
  718. }
  719. public class ParameterComparer : IEqualityComparer<object[]>
  720. {
  721. public virtual bool Equals(object[] i_lhs, object[] i_rhs)
  722. {
  723. return false;
  724. }
  725. public virtual int GetHashCode(object[] i_obj)
  726. {
  727. return 0;
  728. }
  729. #region select k elements from n different elements
  730. public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k)
  731. {
  732. if (items.Count() < k)
  733. {
  734. k = items.Count();
  735. }
  736. if (k == 1)
  737. {
  738. foreach (var item in items)
  739. {
  740. yield return new T[] { item };
  741. }
  742. yield break;
  743. }
  744. foreach (var item in items)
  745. {
  746. var leftside = new T[] { item };
  747. var unused = items.Except(leftside);
  748. foreach (var rightside in Enumerate(unused, k - 1))
  749. {
  750. yield return leftside.Concat(rightside).ToArray();
  751. }
  752. }
  753. }
  754. #endregion
  755. }