DeckData.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. [System.Serializable]
  6. public class DeckData
  7. {
  8. public static int m = 256;
  9. public static int n = 256;
  10. public static int log_n_m = (int)Mathf.Log(m, n);
  11. public static int maxCardKind = 37000;
  12. public static int CardKindCellLength = (int)Math.Ceiling(Mathf.Log(maxCardKind, m));
  13. #region コンストラクタ
  14. public DeckData(string DeckCode)
  15. {
  16. List<int> _DeckCardIDs = new List<int>();
  17. List<int> _DigitamaDeckCardIDs = new List<int>();
  18. //コンマで区切り
  19. string[] parseByComma = DeckCode.Split(',');
  20. List<int> DistinctDeckCardIDs = new List<int>();
  21. List<int> DistinctDeckCardCounts = new List<int>();
  22. List<int> DistinctDigitamaDeckCardIDs = new List<int>();
  23. List<int> DistinctDigitamaDeckCardCounts = new List<int>();
  24. for (int i = 0; i < parseByComma.Length; i++)
  25. {
  26. //デッキ名
  27. if (i == 0)
  28. {
  29. DeckName = parseByComma[i];
  30. }
  31. //デッキのカード(重複なし)
  32. else if (i == 1)
  33. {
  34. //2文字ごとに区切り
  35. string[] SplitText = SplitClass.Split(parseByComma[i], CardKindCellLength);
  36. for (int j = 0; j < SplitText.Length; j++)
  37. {
  38. DistinctDeckCardIDs.Add(ConvertBinaryNumber.NStringToInt(SplitText[j], m));
  39. }
  40. }
  41. //カード各種の枚数
  42. else if (i == 2)
  43. {
  44. //m進数の文字列
  45. string x_m = parseByComma[i];
  46. if (!string.IsNullOrEmpty(x_m))
  47. {
  48. //m進数をn進数に変換
  49. string x_n = ConvertBinaryNumber.NKStringToNString(x_m, n, log_n_m);
  50. //n進数の文字列を1文字ずつ区切り
  51. string[] Split_x_n = SplitClass.Split(x_n, 1);
  52. for (int j = 0; j < Split_x_n.Length; j++)
  53. {
  54. //n進数をintに変換
  55. DistinctDeckCardCounts.Add(ConvertBinaryNumber.NStringToInt(Split_x_n[j], n) + 1);
  56. }
  57. }
  58. }
  59. //デジタマデッキのカード(重複なし)
  60. else if (i == 3)
  61. {
  62. //2文字ごとに区切り
  63. string[] SplitText = SplitClass.Split(parseByComma[i], CardKindCellLength);
  64. for (int j = 0; j < SplitText.Length; j++)
  65. {
  66. DistinctDigitamaDeckCardIDs.Add(ConvertBinaryNumber.NStringToInt(SplitText[j], m));
  67. }
  68. }
  69. //カード各種の枚数
  70. else if (i == 4)
  71. {
  72. //m進数の文字列
  73. string x_m = parseByComma[i];
  74. if (!string.IsNullOrEmpty(x_m))
  75. {
  76. //m進数をn進数に変換
  77. string x_n = ConvertBinaryNumber.NKStringToNString(x_m, n, log_n_m);
  78. //n進数の文字列を1文字ずつ区切り
  79. string[] Split_x_n = SplitClass.Split(x_n, 1);
  80. for (int j = 0; j < Split_x_n.Length; j++)
  81. {
  82. //n進数をintに変換
  83. DistinctDigitamaDeckCardCounts.Add(ConvertBinaryNumber.NStringToInt(Split_x_n[j], n) + 1);
  84. }
  85. }
  86. }
  87. //キーカードID
  88. else if (i == 5)
  89. {
  90. if (int.TryParse(parseByComma[i], out int value))
  91. {
  92. KeyCardId = value;
  93. }
  94. }
  95. }
  96. for (int i = 0; i < DistinctDeckCardIDs.Count; i++)
  97. {
  98. if (i < DistinctDeckCardCounts.Count)
  99. {
  100. for (int j = 0; j < DistinctDeckCardCounts[i]; j++)
  101. {
  102. _DeckCardIDs.Add(DistinctDeckCardIDs[i]);
  103. }
  104. }
  105. }
  106. for (int i = 0; i < DistinctDigitamaDeckCardIDs.Count; i++)
  107. {
  108. if (i < DistinctDigitamaDeckCardCounts.Count)
  109. {
  110. for (int j = 0; j < DistinctDigitamaDeckCardCounts[i]; j++)
  111. {
  112. _DigitamaDeckCardIDs.Add(DistinctDigitamaDeckCardIDs[i]);
  113. }
  114. }
  115. }
  116. DeckCardIDs = _DeckCardIDs;
  117. DigitamaDeckCardIDs = _DigitamaDeckCardIDs;
  118. }
  119. #endregion
  120. #region デッキ名
  121. string _deckName = "";
  122. public string DeckName
  123. {
  124. get
  125. {
  126. if (string.IsNullOrEmpty(_deckName))
  127. {
  128. return "NewDeck";
  129. }
  130. return _deckName;
  131. }
  132. set
  133. {
  134. _deckName = value;
  135. }
  136. }
  137. #endregion
  138. #region デッキに含まれるカードリスト
  139. public List<CEntity_Base> DeckCards()
  140. {
  141. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  142. if (DeckCardIDs != null)
  143. {
  144. foreach (int DeckCardID in DeckCardIDs)
  145. {
  146. CEntity_Base cEntity_Base = ContinuousController.instance.getCardEntityByCardID(DeckCardID);
  147. if (cEntity_Base != null)
  148. {
  149. deckCards.Add(cEntity_Base);
  150. }
  151. }
  152. }
  153. return deckCards;
  154. }
  155. #endregion
  156. #region デジタマデッキに含まれるカードリスト
  157. public List<CEntity_Base> DigitamaDeckCards()
  158. {
  159. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  160. foreach (int DeckCardID in DigitamaDeckCardIDs)
  161. {
  162. CEntity_Base cEntity_Base = ContinuousController.instance.getCardEntityByCardID(DeckCardID);
  163. if (cEntity_Base != null)
  164. {
  165. deckCards.Add(cEntity_Base);
  166. }
  167. }
  168. return deckCards;
  169. }
  170. #endregion
  171. #region デッキの全カード
  172. public List<CEntity_Base> AllDeckCards()
  173. {
  174. List<CEntity_Base> AllDeckCards = new List<CEntity_Base>();
  175. foreach (CEntity_Base cEntity_Base in DigitamaDeckCards())
  176. {
  177. AllDeckCards.Add(cEntity_Base);
  178. }
  179. foreach (CEntity_Base cEntity_Base in DeckCards())
  180. {
  181. AllDeckCards.Add(cEntity_Base);
  182. }
  183. return AllDeckCards;
  184. }
  185. #endregion
  186. #region キーカード
  187. public int KeyCardId { get; set; } = -1;
  188. public CEntity_Base KeyCard
  189. {
  190. get
  191. {
  192. if (KeyCardId >= 0)
  193. {
  194. foreach (CEntity_Base Card in ContinuousController.instance.CardList)
  195. {
  196. if (Card.CardIndex == KeyCardId)
  197. {
  198. return Card;
  199. }
  200. }
  201. }
  202. if (DeckCards().Count >= 1)
  203. {
  204. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  205. foreach (CEntity_Base cEntity_Base in DeckCards())
  206. {
  207. deckCards.Add(cEntity_Base);
  208. }
  209. deckCards = deckCards
  210. .OrderBy(value => Array.IndexOf(DataBase.cardKinds, value.cardKind))
  211. .ThenByDescending(value => value.Level)
  212. .ThenBy(value => Array.IndexOf(DataBase.cardColors, value.cardColors[0]))
  213. .ThenByDescending(value => value.PlayCost)
  214. .ThenByDescending(value => value.DP)
  215. .ThenBy(value => value.CardIndex)
  216. .ToList();
  217. return deckCards[0];
  218. }
  219. else if (DigitamaDeckCards().Count >= 1)
  220. {
  221. return DigitamaDeckCards()[0];
  222. }
  223. return null;
  224. }
  225. }
  226. #endregion
  227. #region デッキに含まれるカードIDリスト
  228. public List<int> DeckCardIDs { get; set; } = new List<int>();
  229. public List<int> DigitamaDeckCardIDs { get; set; } = new List<int>();
  230. #region カードを追加する
  231. public void AddCard(CEntity_Base cEntity_Base)
  232. {
  233. if (cEntity_Base.cardKind == CardKind.DigiEgg)
  234. {
  235. AddDigitamaDeckCard(cEntity_Base);
  236. }
  237. else
  238. {
  239. AddDeckCard(cEntity_Base);
  240. }
  241. }
  242. #endregion
  243. #region カードを除く
  244. public void RemoveCard(CEntity_Base cEntity_Base)
  245. {
  246. if (cEntity_Base.cardKind == CardKind.DigiEgg)
  247. {
  248. RemoveDigitamaDeckCard(cEntity_Base);
  249. }
  250. else
  251. {
  252. RemoveDeckCard(cEntity_Base);
  253. }
  254. }
  255. #endregion
  256. #region デッキにカードを追加する
  257. void AddDeckCard(CEntity_Base cEntity_Base)
  258. {
  259. List<CEntity_Base> _DeckCards = DeckCards();
  260. _DeckCards.Add(cEntity_Base);
  261. _DeckCards = SortedDeckCardsList(_DeckCards);
  262. DeckCardIDs = GetDeckCardCodes(_DeckCards);
  263. }
  264. #endregion
  265. #region デッキからカードを抜く
  266. void RemoveDeckCard(CEntity_Base cEntity_Base)
  267. {
  268. List<CEntity_Base> _DeckCards = DeckCards();
  269. _DeckCards.Remove(cEntity_Base);
  270. _DeckCards = SortedDeckCardsList(_DeckCards);
  271. DeckCardIDs = GetDeckCardCodes(_DeckCards);
  272. }
  273. #endregion
  274. #region デジタマデッキにカードを追加する
  275. void AddDigitamaDeckCard(CEntity_Base cEntity_Base)
  276. {
  277. List<CEntity_Base> _DeckCards = DigitamaDeckCards();
  278. _DeckCards.Add(cEntity_Base);
  279. _DeckCards = SortedDeckCardsList(_DeckCards);
  280. DigitamaDeckCardIDs = GetDeckCardCodes(_DeckCards);
  281. }
  282. #endregion
  283. #region デジタマデッキからカードを抜く
  284. void RemoveDigitamaDeckCard(CEntity_Base cEntity_Base)
  285. {
  286. List<CEntity_Base> _DeckCards = DigitamaDeckCards();
  287. _DeckCards.Remove(cEntity_Base);
  288. _DeckCards = SortedDeckCardsList(_DeckCards);
  289. DigitamaDeckCardIDs = GetDeckCardCodes(_DeckCards);
  290. }
  291. #endregion
  292. #region カードリストからカードIDリストを取得
  293. public static List<int> GetDeckCardCodes(List<CEntity_Base> DeckCards)
  294. {
  295. List<int> _DeckCardCodes = new List<int>();
  296. foreach (CEntity_Base DeckCard in DeckCards)
  297. {
  298. _DeckCardCodes.Add(DeckCard.CardIndex);
  299. }
  300. return _DeckCardCodes;
  301. }
  302. #endregion
  303. #endregion
  304. #region カードリストをソート
  305. public static List<CEntity_Base> SortedDeckCardsList(List<CEntity_Base> DeckCards)
  306. {
  307. List<CEntity_Base> DeckCards1 = new List<CEntity_Base>();
  308. foreach (CEntity_Base cEntity_Base in DeckCards)
  309. {
  310. DeckCards1.Add(cEntity_Base);
  311. }
  312. DeckCards1 = DeckCards1
  313. .OrderBy(value => Array.IndexOf(DataBase.cardKinds, value.cardKind))
  314. .ThenBy(value => value.Level)
  315. .ThenBy(value => Array.IndexOf(DataBase.cardColors, value.cardColors[0]))
  316. .ThenByDescending(value => value.PlayCost)
  317. .ThenByDescending(value => value.DP)
  318. .ThenBy(value => value.CardIndex)
  319. .ToList();
  320. return DeckCards1;
  321. }
  322. public static List<CEntity_Base> SortedCardPoolList(List<CEntity_Base> DeckCards)
  323. {
  324. List<CEntity_Base> DeckCards1 = new List<CEntity_Base>();
  325. foreach (CEntity_Base cEntity_Base in DeckCards)
  326. {
  327. DeckCards1.Add(cEntity_Base);
  328. }
  329. DeckCards1 = DeckCards1
  330. .OrderBy(value => Array.IndexOf(DataBase.SetIDs, value.SetID))
  331. .ThenBy(value => Array.IndexOf(DataBase.cardColors, value.cardColors[0]))
  332. .ThenBy(value => value.CardID)
  333. .ThenBy(value => value.CardIndex)
  334. .ToList();
  335. return DeckCards1;
  336. }
  337. public static List<CardSource> SortedCardsList(List<CardSource> DeckCards)
  338. {
  339. List<CardSource> DeckCards1 = new List<CardSource>();
  340. foreach (CardSource cardSource in DeckCards)
  341. {
  342. DeckCards1.Add(cardSource);
  343. }
  344. DeckCards1 = DeckCards1
  345. .OrderBy(value => value.SetID)
  346. .ThenBy(value => Array.IndexOf(DataBase.cardKinds, value.CardKind))
  347. .ThenBy(value => Array.IndexOf(DataBase.cardColors, value.BaseCardColorsFromEntity[0]))
  348. .ThenByDescending(value => value.BaseEvoCostsFromEntity.Count)
  349. .ThenByDescending(value => value.CardDP)
  350. .ThenBy(value => value.CardEntityIndex)
  351. .ToList();
  352. return DeckCards1;
  353. }
  354. #endregion
  355. #region 256進数のデッキコードを取得
  356. #region デッキ名とデッキのカードから256進数のデッキコードを取得
  357. public static string GetDeckCode(string _DeckName, List<CEntity_Base> _DeckCards, List<CEntity_Base> _DigitamaDeckCards, CEntity_Base keyCard)
  358. {
  359. string _DeckDataString = null;
  360. //デッキ名
  361. _DeckDataString += _DeckName + ",";
  362. SetDeckCard(_DeckCards);
  363. SetDeckCard(_DigitamaDeckCards);
  364. if (keyCard != null)
  365. {
  366. _DeckDataString += $"{keyCard.CardIndex},";
  367. }
  368. else
  369. {
  370. _DeckDataString += $"-1,";
  371. }
  372. //Debug.Log($"生デッキコード:{_DeckDataString}");
  373. void SetDeckCard(List<CEntity_Base> cEntity_Bases)
  374. {
  375. //カードリストを重複なしリストにする
  376. List<CEntity_Base> DistinctDeckCards = cEntity_Bases.Distinct().ToList();
  377. //重複なしのカードIDリストを登録
  378. foreach (CEntity_Base cardData in DistinctDeckCards)
  379. {
  380. _DeckDataString += cardData.CardIndex_String;
  381. }
  382. _DeckDataString += ",";
  383. //各カードの種類のカード枚数を保存(1減らす)
  384. List<int> _DistinctDeckCardCounts = new List<int>();
  385. foreach (CEntity_Base cardData in DistinctDeckCards)
  386. {
  387. _DistinctDeckCardCounts.Add(cEntity_Bases.Count((_CardData) => _CardData == cardData) - 1);
  388. }
  389. string x_n = null;
  390. //デッキ内のカード枚数をn進数に変換
  391. for (int i = 0; i < _DistinctDeckCardCounts.Count; i++)
  392. {
  393. x_n += ConvertBinaryNumber.IntToNString(_DistinctDeckCardCounts[i], n);
  394. }
  395. //桁数がlog(n)m桁になるように0埋め
  396. if (x_n != null)
  397. {
  398. while (x_n.Count() % log_n_m != 0)
  399. {
  400. x_n += "0";
  401. }
  402. }
  403. //n進数をm進数に変換
  404. if (x_n != null)
  405. {
  406. string x_m = ConvertBinaryNumber.NStringToNKString(x_n, n, log_n_m);
  407. _DeckDataString += x_m;
  408. }
  409. _DeckDataString += ",";
  410. }
  411. return _DeckDataString;
  412. }
  413. #endregion
  414. #region このデッキのデッキコードを取得
  415. public string GetThisDeckCode()
  416. {
  417. return DeckData.GetDeckCode(DeckName, DeckCards(), DigitamaDeckCards(), KeyCard);
  418. }
  419. #endregion
  420. #endregion
  421. #region その文字列がデッキコードとして適するか
  422. public static bool IsValidDeckCode(string DeckCode)
  423. {
  424. if (!DeckCode.Contains(","))
  425. {
  426. return false;
  427. }
  428. string[] parseByComma = DeckCode.Split(',');
  429. if (parseByComma.Length != 5 && parseByComma.Length != 6)
  430. {
  431. return false;
  432. }
  433. if (!string.IsNullOrEmpty(parseByComma[1]))
  434. {
  435. string[] SplitText = SplitClass.Split(parseByComma[1], 1);
  436. for (int j = 0; j < SplitText.Length; j++)
  437. {
  438. if (ConvertBinaryNumber.NStringToInt(SplitText[j], m) == 114514)
  439. {
  440. return false;
  441. }
  442. }
  443. }
  444. else
  445. {
  446. return false;
  447. }
  448. if (!string.IsNullOrEmpty(parseByComma[2]))
  449. {
  450. //256進数の文字列
  451. string x_m = parseByComma[2];
  452. //256進数をn進数に変換
  453. string x_n = ConvertBinaryNumber.NKStringToNString(x_m, n, log_n_m);
  454. if (x_n == "114514")
  455. {
  456. Debug.Log("[2]:114514");
  457. return false;
  458. }
  459. }
  460. else
  461. {
  462. return false;
  463. }
  464. if (!string.IsNullOrEmpty(parseByComma[3]))
  465. {
  466. string[] SplitText = SplitClass.Split(parseByComma[3], 1);
  467. for (int j = 0; j < SplitText.Length; j++)
  468. {
  469. if (ConvertBinaryNumber.NStringToInt(SplitText[j], m) == 114514)
  470. {
  471. return false;
  472. }
  473. }
  474. }
  475. if (!string.IsNullOrEmpty(parseByComma[4]))
  476. {
  477. //256進数の文字列
  478. string x_m = parseByComma[4];
  479. //256進数をn進数に変換
  480. string x_n = ConvertBinaryNumber.NKStringToNString(x_m, n, log_n_m);
  481. if (x_n == "114514")
  482. {
  483. Debug.Log("[4]:114514");
  484. return false;
  485. }
  486. }
  487. if (parseByComma.Length >= 6)
  488. {
  489. if (!string.IsNullOrEmpty(parseByComma[5]))
  490. {
  491. if (!int.TryParse(parseByComma[5], out int value))
  492. {
  493. return false;
  494. }
  495. }
  496. }
  497. return true;
  498. }
  499. #endregion
  500. #region このデッキデータが対戦に使えるかどうか
  501. public bool IsValidDeckData()
  502. {
  503. //デッキ枚数はちょうど50枚
  504. if (DeckCards().Count != 50)
  505. {
  506. return false;
  507. }
  508. if (DigitamaDeckCards().Count > 5)
  509. {
  510. return false;
  511. }
  512. foreach (CEntity_Base cEntity_Base in DeckCards())
  513. {
  514. if (!cEntity_Base.IsStandardValid)
  515. {
  516. return false;
  517. }
  518. }
  519. foreach (CEntity_Base cEntity_Base in DigitamaDeckCards())
  520. {
  521. if (!cEntity_Base.IsStandardValid)
  522. {
  523. return false;
  524. }
  525. }
  526. return true;
  527. }
  528. #endregion
  529. #region 空白のデッキコード
  530. public static DeckData EmptyDeckData()
  531. {
  532. return new DeckData("");
  533. }
  534. #endregion
  535. #region インポートしたデッキデータを修正
  536. public DeckData ModifiedDeckData()
  537. {
  538. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  539. List<CEntity_Base> digitamaDeckCards = new List<CEntity_Base>();
  540. foreach (CEntity_Base cEntity_Base in AllDeckCards())
  541. {
  542. if (cEntity_Base.cardKind != CardKind.DigiEgg)
  543. {
  544. deckCards.Add(cEntity_Base);
  545. }
  546. else
  547. {
  548. digitamaDeckCards.Add(cEntity_Base);
  549. }
  550. }
  551. List<CEntity_Base> modifiedDeckCards = modifiedList(deckCards);
  552. List<CEntity_Base> modifiedDigitamaDeckCards = modifiedList(digitamaDeckCards);
  553. List<CEntity_Base> modifiedList(List<CEntity_Base> cEntity_Bases)
  554. {
  555. //カードリストを重複なしのリストにする
  556. List<CEntity_Base> DistinctDeckCards = cEntity_Bases.Distinct().ToList();
  557. List<CEntity_Base> DistinctDeckCards1 = new List<CEntity_Base>();
  558. foreach (CEntity_Base cEntity_Base in DistinctDeckCards)
  559. {
  560. if (DistinctDeckCards1.Count((cEntity_Base1) => cEntity_Base.CardID == cEntity_Base1.CardID) == 0)
  561. {
  562. DistinctDeckCards1.Add(cEntity_Base);
  563. }
  564. }
  565. List<CEntity_Base> deckCards = new List<CEntity_Base>();
  566. foreach (CEntity_Base cEntity_Base in cEntity_Bases)
  567. {
  568. deckCards.Add(cEntity_Base);
  569. }
  570. //規定枚数以上のカードを抜く
  571. foreach (CEntity_Base cEntity_Base in DistinctDeckCards1)
  572. {
  573. while (cEntity_Base.SameCardIDCount(deckCards) > cEntity_Base.MaxCountInDeck)
  574. {
  575. CEntity_Base removeCard = null;
  576. foreach (CEntity_Base cEntity_Base1 in deckCards)
  577. {
  578. if (cEntity_Base1.CardID == cEntity_Base.CardID)
  579. {
  580. removeCard = cEntity_Base1;
  581. break;
  582. }
  583. }
  584. if (removeCard != null)
  585. {
  586. deckCards.Remove(removeCard);
  587. }
  588. }
  589. }
  590. return deckCards;
  591. }
  592. DeckData deckData = new DeckData(GetDeckCode(ValidateDeckName(this._deckName), modifiedDeckCards, modifiedDigitamaDeckCards, KeyCard));
  593. if (!deckData.AllDeckCards().Contains(deckData.KeyCard))
  594. {
  595. deckData.KeyCardId = -1;
  596. }
  597. DeckData deckData1 = DeckBuildingRule.ModifiedDeckData(deckData);
  598. return deckData1;
  599. }
  600. #endregion
  601. #region デッキ名を修正
  602. public static string ValidateDeckName(string deckName)
  603. {
  604. if (String.IsNullOrEmpty(deckName))
  605. {
  606. return deckName;
  607. }
  608. List<string> ErrorLetters = new List<string>()
  609. {
  610. ",",
  611. "_",
  612. "*",
  613. "/",
  614. };
  615. foreach (string error in ErrorLetters)
  616. {
  617. deckName = deckName.Replace(error, "");
  618. }
  619. return deckName;
  620. }
  621. #endregion
  622. }
  623. #region 文字列を分割
  624. public static class SplitClass
  625. {
  626. public static string[] Split(this string str, int count)
  627. {
  628. var list = new List<string>();
  629. int length = (int)Math.Ceiling((double)str.Length / count);
  630. for (int i = 0; i < length; i++)
  631. {
  632. int start = count * i;
  633. if (str.Length <= start)
  634. {
  635. break;
  636. }
  637. if (str.Length < start + count)
  638. {
  639. list.Add(str.Substring(start));
  640. }
  641. else
  642. {
  643. list.Add(str.Substring(start, count));
  644. }
  645. }
  646. return list.ToArray();
  647. }
  648. }
  649. #endregion