| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- using System.Linq;
- using System.IO;
- using WebSocketSharp;
- public class DataBase : MonoBehaviour
- {
- public static DataBase instance = null;
- private void Awake()
- {
- instance = this;
- }
- public static Dictionary<CardKind, string> CardKindJPNameDictionary = new Dictionary<CardKind, string>()
- {
- {CardKind.Digimon,"デジモン" },
- {CardKind.Tamer,"テイマー" },
- {CardKind.Option,"オプション" },
- {CardKind.DigiEgg,"デジタマ" },
- };
- public static Dictionary<CardKind, string> CardKindENNameDictionary = new Dictionary<CardKind, string>()
- {
- {CardKind.Digimon,"Digimon" },
- {CardKind.Tamer,"Tamer" },
- {CardKind.Option,"Option" },
- {CardKind.DigiEgg,"DigiEgg" },
- };
- public static Dictionary<CardColor, string> CardColorNameDictionary = new Dictionary<CardColor, string>()
- {
- { CardColor.Green,"green"},
- { CardColor.Red,"red"},
- { CardColor.Blue,"blue"},
- { CardColor.Yellow,"yellow"},
- { CardColor.Purple,"purple"},
- { CardColor.Black,"black"},
- { CardColor.White,"white"},
- { CardColor.None,"-"},
- };
- public static Dictionary<CardColor, Color> CardColor_ColorLightDictionary = new Dictionary<CardColor, Color>()
- {
- { CardColor.Green,new Color32(55,255,49,255)},
- { CardColor.Red,new Color32(253,63,49,255)},
- { CardColor.Blue, new Color32(49,118,253,255) },
- { CardColor.Yellow, new Color32(255,231,64,255)},
- { CardColor.Purple,new Color32(234,64,176,255)},
- { CardColor.Black,new Color32(61,61,61,255)},
- { CardColor.White,new Color32(224,224,224,255)},
- { CardColor.None,new Color32(222,222,222,255)},
- };
- public static Dictionary<CardColor, Color> CardColor_ColorDarkDictionary = new Dictionary<CardColor, Color>()
- {
- { CardColor.Red,new Color32(171,12,0,255)},
- { CardColor.Blue, new Color32(0,103,171,255) },
- { CardColor.Green,new Color32(1,171,0,255)},
- { CardColor.Yellow, new Color32(255,242,64,255)},
- { CardColor.Purple,new Color32(155,0,171,255)},
- { CardColor.Black,new Color32(61,61,61,255)},
- { CardColor.White,new Color32(224,224,224,255)},
- { CardColor.None,new Color32(222,222,222,255)},
- };
- public static Dictionary<CardColor, String> CardColorInitialDictionary = new Dictionary<CardColor, String>()
- {
- { CardColor.Red,"R"},
- { CardColor.Blue, "U" },
- { CardColor.Green,"G"},
- { CardColor.Yellow, "Y"},
- { CardColor.Purple,"P"},
- { CardColor.Black,"B"},
- { CardColor.White,"W"},
- { CardColor.None,"N"},
- };
- public static List<string> CardListIDs(string SetID, bool isEnglish)
- {
- List<string> cardListID = new List<string>();
- if (isEnglish)
- {
- switch (SetID)
- {
- case "ST1":
- cardListID.Add("522101");
- break;
- case "ST2":
- cardListID.Add("522102");
- break;
- case "ST3":
- cardListID.Add("522103");
- break;
- case "ST4":
- cardListID.Add("522104");
- break;
- case "ST5":
- cardListID.Add("522105");
- break;
- case "ST6":
- cardListID.Add("522106");
- break;
- case "ST7":
- cardListID.Add("522107");
- break;
- case "ST8":
- cardListID.Add("522108");
- break;
- case "ST9":
- cardListID.Add("522109");
- break;
- case "ST10":
- cardListID.Add("522110");
- break;
- case "ST12":
- cardListID.Add("522112");
- break;
- case "ST13":
- cardListID.Add("522113");
- break;
- case "ST14":
- cardListID.Add("522114");
- break;
- case "ST15":
- cardListID.Add("522115");
- break;
- case "ST16":
- cardListID.Add("522116");
- break;
- case "ST17":
- cardListID.Add("522117");
- break;
- case "BT1":
- cardListID.Add("522001");
- cardListID.Add("522002");
- break;
- case "BT2":
- cardListID.Add("522001");
- cardListID.Add("522002");
- break;
- case "BT3":
- cardListID.Add("522001");
- cardListID.Add("522002");
- break;
- case "BT4":
- cardListID.Add("522003");
- break;
- case "BT5":
- cardListID.Add("522004");
- break;
- case "BT6":
- cardListID.Add("522005");
- break;
- case "EX1":
- cardListID.Add("522006");
- break;
- case "BT7":
- cardListID.Add("522007");
- break;
- case "BT8":
- cardListID.Add("522008");
- break;
- case "EX2":
- cardListID.Add("522009");
- break;
- case "BT9":
- cardListID.Add("522010");
- break;
- case "BT10":
- cardListID.Add("522011");
- break;
- case "EX3":
- cardListID.Add("522012");
- break;
- case "BT11":
- cardListID.Add("522013");
- break;
- case "BT12":
- cardListID.Add("522014");
- break;
- case "EX4":
- cardListID.Add("522015");
- break;
- case "BT13":
- cardListID.Add("522016");
- break;
- case "RB1":
- cardListID.Add("522017");
- break;
- case "BT14":
- cardListID.Add("522018");
- break;
- case "EX5":
- cardListID.Add("522019");
- break;
- case "BT15":
- cardListID.Add("522020");
- break;
- case "LM":
- cardListID.Add("522020");
- break;
- case "BT16":
- cardListID.Add("522021");
- break;
- case "P":
- cardListID.Add("522007");
- cardListID.Add("522901");
- break;
- }
- }
- else
- {
- switch (SetID)
- {
- case "ST1":
- cardListID.Add("503101");
- break;
- case "ST2":
- cardListID.Add("503102");
- break;
- case "ST3":
- cardListID.Add("503103");
- break;
- case "ST4":
- cardListID.Add("503104");
- break;
- case "ST5":
- cardListID.Add("503105");
- break;
- case "ST6":
- cardListID.Add("503106");
- break;
- case "ST7":
- cardListID.Add("503107");
- break;
- case "ST8":
- cardListID.Add("503108");
- break;
- case "ST9":
- cardListID.Add("503109");
- break;
- case "ST10":
- cardListID.Add("503110");
- break;
- case "ST11":
- cardListID.Add("503111");
- break;
- case "ST12":
- cardListID.Add("503112");
- break;
- case "ST13":
- cardListID.Add("503113");
- break;
- case "ST14":
- cardListID.Add("503114");
- break;
- case "ST15":
- cardListID.Add("503115");
- break;
- case "ST16":
- cardListID.Add("503116");
- break;
- case "ST17":
- cardListID.Add("503117");
- break;
- case "BT1":
- cardListID.Add("503001");
- break;
- case "BT2":
- cardListID.Add("503002");
- break;
- case "BT3":
- cardListID.Add("503003");
- break;
- case "BT4":
- cardListID.Add("503004");
- break;
- case "BT5":
- cardListID.Add("503005");
- break;
- case "BT6":
- cardListID.Add("503006");
- break;
- case "EX1":
- cardListID.Add("503007");
- break;
- case "BT7":
- cardListID.Add("503008");
- break;
- case "BT8":
- cardListID.Add("503009");
- break;
- case "EX2":
- cardListID.Add("503010");
- break;
- case "BT9":
- cardListID.Add("503011");
- break;
- case "BT10":
- cardListID.Add("503012");
- break;
- case "EX3":
- cardListID.Add("503013");
- break;
- case "BT11":
- cardListID.Add("503014");
- break;
- case "BT12":
- cardListID.Add("503015");
- break;
- case "EX4":
- cardListID.Add("503016");
- break;
- case "RB1":
- cardListID.Add("503017");
- break;
- case "BT13":
- cardListID.Add("503018");
- break;
- case "BT14":
- cardListID.Add("503019");
- break;
- case "EX5":
- cardListID.Add("503020");
- break;
- case "BT15":
- cardListID.Add("503021");
- break;
- case "LM":
- cardListID.Add("503201");
- break;
- case "BT16":
- cardListID.Add("503022");
- break;
- case "P":
- cardListID.Add("503008");
- cardListID.Add("503901");
- break;
- }
- }
- return cardListID;
- }
- public List<Sprite> ColorIcons_circle = new List<Sprite>();
- public List<Sprite> ColorIcons_bar = new List<Sprite>();
- public static Color SelectColor_Orange => new Color32(255, 98, 31, 255);
- public static Color SelectColor_Blue => new Color32(30, 246, 255, 255);
- public static Color SelectColor_Green => new Color32(57, 255, 30, 255);
- public static Color CommandColor_Attack => new Color32(255, 54, 54, 255);
- public static Color CommandColor_Move => new Color32(54, 111, 255, 255);
- public static Color CommandColor_Skill => new Color32(86, 255, 102, 255);
- public static bool IsXAntibodyString(string text) =>
- !string.IsNullOrEmpty(text) && text.Replace(" ", "").Replace("-", "").ToLower() == "xantibody";
- public static bool IsContainingXAntibodyString(string text) =>
- !string.IsNullOrEmpty(text) && text.Replace(" ", "").Replace("-", "").ToLower().Contains("xantibody");
- public static string BlockerEffectDiscription()
- {
- return "<Blocker> (When an opponent's Digimon attacks, you may suspend this Digimon to force the opponent to attack it instead.)";
- }
- public static string RebootEffectDiscription()
- {
- return "<Reboot> (Unsuspend this Digimon during your opponent's unsuspend phase.)";
- }
- public static string PierceEffectDiscription()
- {
- return "<Piercing> (When this Digimon deletes your opponent's Digimon in battle while attacking, it checks security before the attack ends.)";
- }
- public static string RetaliationEffectDiscription()
- {
- return "<Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling.)";
- }
- public static string BilitzEffectDiscription()
- {
- return "<Blitz> (This Digimon can attack when your opponent has 1 or more memory.)";
- }
- public static string ArmorPurgeEffectDiscription()
- {
- return "<Armor Purge> (When this Digimon would be deleted, you may trash the top card of this Digimon to prevent that deletion.)";
- }
- public static string SaveEffectDiscription()
- {
- return "[On Deletion] <Save> (You may place this card under one of your Tamers.)";
- }
- public static string EvadeEffectDiscription()
- {
- return "<Evade> (When this Digimon would be deleted, you may suspend it to prevent that deletion.)";
- }
- public static string RaidEffectDiscription()
- {
- 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.)";
- }
- public static string BarrierEffectDiscription()
- {
- return "<Barrier> (When this Digimon would be deleted in battle, by trashing the top card of your security stack, prevent that deletion.)";
- }
- public static string BlastDigivolveEffectDiscription()
- {
- return "[Hand] [Counter] <Blast Digivolve> (Your Digimon may digivolve into this card without paying the cost.)";
- }
- public static string BlastDNADigivolveEffectDiscription()
- {
- return "[Hand] [Counter] <Blast DNA Digivolve> (One of your specified Digimon and 1 of the specified card in the hand may DNA Digivolve into this card.)";
- }
- public static string FortitudeEffectDiscription()
- {
- return "<Fortitude> (When this Digimon with digivolution cards is deleted, play this card without paying the cost.)";
- }
- public static string AllianceEffectDiscription()
- {
- 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.)";
- }
- public static string AscensionEffectDescription()
- {
- return "<Ascension> (When this Digimon is deleted, you may place this card as the top security card.)";
- }
- public static string PartitionEffectDiscription()
- {
- return "<Partition> (When this Digimon with 1 of each specified card in its digivolution cards would leave the battle area other than by one of your effects or in battle, you may play 1 of each card without paying their costs.)";
- }
- public static string CollisionEffectDiscription()
- {
- return "<Collision> (During this Digimon's attack, all of your opponent's Digimon gain <Blocker>, and your opponent blocks if possible.)";
- }
- public static string VortexEffectDiscription()
- {
- return "<Vortex> (At the end of your turn, this Digimon may attack an opponent's Digimon. With this effect, it can attack the turn it was played.)";
- }
- public static string OverclockEffectDiscription(string trait)
- {
- return $"<Overclock [{trait}]> (At the end of your turn, by deleting 1 of your Tokens or other [{trait}] trait Digimon, this Digimon attacks a player without suspending.)";
- }
- public static string TrainingEffectDiscription()
- {
- return "<Training> (In the main phase, by suspending this Digimon, place your deck's top card face down as this Digimon's bottom digivolution card. This effect can also activate in the breeding area).";
- }
- public static string DecodeEffectDiscription(string[] decodeStrings)
- {
- return $"<Decode {decodeStrings[0]}> (When this Digimon would leave the battle area other than in battle, you may play 1 {decodeStrings[1]} Digimon card from its digivolution cards without paying the cost.)";
- }
- public static string ExecuteEffectDiscription()
- {
- return "<Execute> (At the end of your turn, this Digimon may attack. At the end of that attack, delete this Digimon. Your opponent's unsuspended Digimon can also be attacked with this effect.)";
- }
- public static string ProgressEffectDiscription()
- {
- return "<Progress> (While attacking, your opponent's effects don't affect this Digimon.)";
- }
- public static string LinkEffectDiscription()
- {
- return "[Link] (Plug this card from the hand or battle area sideways into the specified Digimon in the battle area.)";
- }
- public static string GuardEffectDescription()
- {
- return "<Guard> (When any of your other Digimon would leave the battle area by your opponent's effects, by deleting this Digimon, they don't leave.)";
- }
-
- public static string EngageEffectDescription()
- {
- return "<Engage> (At the end of your turn, this Digimon may attack.)";
- }
- public static string ReplaceToASCII(string text)
- {
- if (string.IsNullOrEmpty(text))
- {
- return "";
- }
- return text
- .Replace("<", "<")
- .Replace(">", ">")
- .Replace("、", ",")
- .Replace(",", ",")
- .Replace("“", "\"")
- .Replace("・", "")
- .Replace(" ", "")
- .Replace("!", "!");
- }
- public static string DigiburstRegex = "デジバースト[0-9]";
- public static string FirstPlayerKey = "FirstPlayerId";
- public static string FirstPlayerIndexIdKey = "FirstPlayerIndexId";
- #region use for sort
- public static CardKind[] cardKinds = new[] { CardKind.Digimon, CardKind.Tamer, CardKind.Option };
- public static CardColor[] cardColors = new[] { CardColor.Red, CardColor.Blue, CardColor.Yellow, CardColor.Green, CardColor.Black, CardColor.Purple, CardColor.White, CardColor.None };
- public static string[] SetIDs = new string[]
- {
- "BT28",
- "BT27",
- "BT26",
- "BT25",
- "BT24",
- "BT23",
- "BT22",
- "BT21",
- "BT20",
- "BT19",
- "BT18",
- "BT17",
- "BT16",
- "BT15",
- "BT14",
- "BT13",
- "BT12",
- "BT11",
- "BT10",
- "BT9",
- "BT8",
- "BT7",
- "BT6",
- "BT5",
- "BT4",
- "BT3",
- "BT2",
- "BT1",
- "EX28",
- "EX27",
- "EX26",
- "EX25",
- "EX24",
- "EX23",
- "EX22",
- "EX21",
- "EX20",
- "EX19",
- "EX18",
- "EX17",
- "EX16",
- "EX15",
- "EX14",
- "EX13",
- "EX12",
- "EX11",
- "EX10",
- "EX9",
- "EX8",
- "EX7",
- "EX6",
- "EX5",
- "EX4",
- "EX3",
- "EX2",
- "EX1",
- "RB11",
- "RB10",
- "RB9",
- "RB8",
- "RB7",
- "RB6",
- "RB5",
- "RB4",
- "RB3",
- "RB2",
- "RB1",
- "LM11",
- "LM10",
- "LM9",
- "LM8",
- "LM7",
- "LM6",
- "LM5",
- "LM4",
- "LM3",
- "LM2",
- "LM1",
- "ST28",
- "ST27",
- "ST26",
- "ST25",
- "ST24",
- "ST23",
- "ST22",
- "ST21",
- "ST20",
- "ST19",
- "ST18",
- "ST17",
- "ST16",
- "ST15",
- "ST14",
- "ST13",
- "ST12",
- "ST11",
- "ST10",
- "ST9",
- "ST8",
- "ST7",
- "ST6",
- "ST5",
- "ST4",
- "ST3",
- "ST2",
- "ST1",
- "P",
- };
- #endregion
- #region ENG ban list
- public static CardRestriction ENGBanList = new CardRestriction(new List<CardLimitCount>()
- {
- new CardLimitCount("BT11-064", 1),
- new CardLimitCount("BT10-009", 1),
- new CardLimitCount("BT7-107", 1),
- new CardLimitCount("BT7-072", 1),
- new CardLimitCount("BT7-064", 1),
- new CardLimitCount("BT7-038", 1),
- new CardLimitCount("BT6-100", 1),
- new CardLimitCount("BT5-109", 0),
- new CardLimitCount("BT3-103", 1),
- new CardLimitCount("BT3-054", 1),
- new CardLimitCount("BT2-047", 1),
- new CardLimitCount("EX2-039", 1),
- new CardLimitCount("EX1-068", 1),
- new CardLimitCount("P-008", 1),
- new CardLimitCount("P-025", 1),
- new CardLimitCount("BT2-069", 1),
- new CardLimitCount("BT13-012", 1),
- new CardLimitCount("BT7-069", 1),
- new CardLimitCount("BT14-002", 1),
- new CardLimitCount("BT15-102", 1),
- new CardLimitCount("EX5-015", 1),
- new CardLimitCount("EX5-018", 1),
- new CardLimitCount("EX5-062", 1),
- new CardLimitCount("P-123", 1),
- new CardLimitCount("P-130", 1),
- new CardLimitCount("ST2-13", 1),
- new CardLimitCount("BT9-098", 1),
- new CardLimitCount("BT15-057", 1),
- new CardLimitCount("BT14-084", 1),
- new CardLimitCount("BT2-090", 0),
- new CardLimitCount("BT4-104", 1),
- new CardLimitCount("BT4-111", 1),
- new CardLimitCount("BT11-033", 1),
- new CardLimitCount("BT17-069", 1),
- new CardLimitCount("EX4-030", 1),
- new CardLimitCount("P-029", 1),
- new CardLimitCount("P-030", 1),
- new CardLimitCount("ST9-09", 1),
- new CardLimitCount("EX5-065", 0),
- new CardLimitCount("BT1-090", 1),
- new CardLimitCount("BT16-011", 1),
- new CardLimitCount("EX3-057", 1),
- new CardLimitCount("BT6-104", 1),
- new CardLimitCount("BT13-110", 1),
- new CardLimitCount("EX4-006", 1),
- new CardLimitCount("BT19-040", 1),
- new CardLimitCount("EX2-070", 1),
- new CardLimitCount("EX1-021", 1),
- new CardLimitCount("BT23-032", 1),
- new CardLimitCount("BT3-092", 1),
- new CardLimitCount("BT10-080", 1),
- new CardLimitCount("EX5-059", 1),
- new CardLimitCount("EX5-061", 1),
- },
- new List<BannedPair>()
- {
- new BannedPair("BT20-037", new List<string>(){
- "BT17-035",
- "EX8-037",
- }),
- new BannedPair("EX2-007", new List<string>(){
- "EX7-064",
- })
- });
- #endregion
- #region JPN ban list
- public static CardRestriction JPNBanList = new CardRestriction(new List<CardLimitCount>()
- {
- new CardLimitCount("BT11-064", 1),
- new CardLimitCount("BT10-009", 1),
- new CardLimitCount("BT9-099", 1),
- new CardLimitCount("BT7-107", 1),
- new CardLimitCount("BT7-072", 1),
- new CardLimitCount("BT7-064", 1),
- new CardLimitCount("BT7-038", 1),
- new CardLimitCount("BT6-100", 1),
- new CardLimitCount("BT5-109", 0),
- new CardLimitCount("BT3-103", 1),
- new CardLimitCount("BT3-054", 1),
- new CardLimitCount("BT2-047", 1),
- new CardLimitCount("EX2-039", 1),
- new CardLimitCount("EX1-068", 1),
- new CardLimitCount("P-008", 1),
- new CardLimitCount("P-025", 1),
- new CardLimitCount("BT2-069", 1),
- new CardLimitCount("BT13-012", 1),
- new CardLimitCount("EX4-019", 1),
- new CardLimitCount("BT7-069", 1),
- new CardLimitCount("BT14-002", 1),
- new CardLimitCount("BT15-102", 1),
- new CardLimitCount("EX5-015", 1),
- new CardLimitCount("EX5-018", 1),
- new CardLimitCount("EX5-062", 1),
- new CardLimitCount("P-123", 1),
- new CardLimitCount("P-130", 1),
- new CardLimitCount("ST2-13", 1),
- new CardLimitCount("BT9-098", 1),
- new CardLimitCount("BT15-057", 1),
- new CardLimitCount("BT14-084", 1),
- },
- new List<BannedPair>()
- {
- new BannedPair("EX5-065", new List<string>(){
- "P-097",
- "BT13-102",
- "ST16-14",
- })
- });
- #endregion
- }
- [System.Serializable]
- public class ColorSpriteDic : TableBase<CardColor, Sprite, SamplePair>
- {
- }
- [System.Serializable]
- public class TableBase<TKey, TValue, Type> where Type : KeyAndValue<TKey, TValue>
- {
- [SerializeField]
- private List<Type> list;
- private Dictionary<TKey, TValue> table;
- public Dictionary<TKey, TValue> GetTable()
- {
- if (table == null)
- {
- table = ConvertListToDictionary(list);
- }
- return table;
- }
- /// <summary>
- /// Editor Only
- /// </summary>
- public List<Type> GetList()
- {
- return list;
- }
- static Dictionary<TKey, TValue> ConvertListToDictionary(List<Type> list)
- {
- Dictionary<TKey, TValue> dic = new Dictionary<TKey, TValue>();
- foreach (KeyAndValue<TKey, TValue> pair in list)
- {
- dic.Add(pair.Key, pair.Value);
- }
- return dic;
- }
- }
- /// <summary>
- /// Serializable KeyValuePair
- /// </summary>
- [System.Serializable]
- public class KeyAndValue<TKey, TValue>
- {
- public TKey Key;
- public TValue Value;
- public KeyAndValue(TKey key, TValue value)
- {
- Key = key;
- Value = value;
- }
- public KeyAndValue(KeyValuePair<TKey, TValue> pair)
- {
- Key = pair.Key;
- Value = pair.Value;
- }
- }
- [System.Serializable]
- public class SamplePair : KeyAndValue<CardColor, Sprite>
- {
- public SamplePair(CardColor key, Sprite value) : base(key, value)
- {
- }
- }
- public class DictionaryUtility
- {
- public static CardColor GetCardColor(string s, Dictionary<CardColor, string> PokemonTypeStringDictionary)
- {
- CardColor pokemonType = PokemonTypeStringDictionary.First(x => x.Value == s).Key;
- return pokemonType;
- }
- public static List<CardKind> GetCardKind(string CardKindName, Dictionary<CardKind, string> CardKindNameDictionary)
- {
- List<CardKind> Typing = new List<CardKind>();
- string[] Types = CardKindName.Split("/");
- foreach(string Type in Types)
- {
- CardKind cardKind = Type.IsNullOrEmpty() ? CardKind.Tamer : CardKindNameDictionary.First(x => x.Value == Type).Key;
- Typing.Add(cardKind);
- }
-
- return Typing;
- }
- public static Rarity GetEvoStage(string EvoStageName, Dictionary<Rarity, string> EvoStageNameDictionary)
- {
- Rarity evoStage = EvoStageNameDictionary.First(x => x.Value == EvoStageName).Key;
- return evoStage;
- }
- }
- public class ParmanentParameterComparer : ParameterComparer
- {
- public override bool Equals(object[] i_lhs, object[] i_rhs)
- {
- if (i_lhs.Length == i_rhs.Length)
- {
- bool same = true;
- List<Permanent> i_lhs_list = new List<Permanent>();
- List<Permanent> i_rhs_list = new List<Permanent>();
- for (int i = 0; i < i_lhs.Length; i++)
- {
- i_lhs_list.Add(((Permanent[])i_lhs)[i]);
- i_rhs_list.Add(((Permanent[])i_rhs)[i]);
- }
- i_lhs_list = i_lhs_list.OrderBy((value) => value.PermanentFrame.FrameID).ToList();
- i_rhs_list = i_rhs_list.OrderBy((value) => value.PermanentFrame.FrameID).ToList();
- for (int i = 0; i < i_lhs.Length; i++)
- {
- if (i_lhs[i] != i_rhs[i])
- {
- same = false;
- break;
- }
- }
- if (!same)
- {
- return false;
- }
- return true;
- }
- return false;
- }
- }
- public class ParameterComparer : IEqualityComparer<object[]>
- {
- public virtual bool Equals(object[] i_lhs, object[] i_rhs)
- {
- return false;
- }
- public virtual int GetHashCode(object[] i_obj)
- {
- return 0;
- }
- #region select k elements from n different elements
- public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k)
- {
- if (items.Count() < k)
- {
- k = items.Count();
- }
- if (k == 1)
- {
- foreach (var item in items)
- {
- yield return new T[] { item };
- }
- yield break;
- }
- foreach (var item in items)
- {
- var leftside = new T[] { item };
- var unused = items.Except(leftside);
- foreach (var rightside in Enumerate(unused, k - 1))
- {
- yield return leftside.Concat(rightside).ToArray();
- }
- }
- }
- #endregion
- }
|