public ExspLib() { firsts = new List<Exsp>(); sql = new Utils.ReadonlySQL("psd.db3"); List<string> list = new string[] { "TYPE", "NAME", "HERO", "CODE", "SKILL", "DESC" }.ToList(); System.Data.DataRowCollection datas = sql.Query(list, "Exsp"); foreach (System.Data.DataRow data in datas) { ushort type = (ushort)((short)data["TYPE"]); string name = (string)data["NAME"]; //string heroStr = (string)data["HERO"]; //int hero = string.IsNullOrEmpty(heroStr) ? 0 : int.Parse(heroStr); int hero = (int)((long)data["HERO"]); string codeGroup = (string)data["CODE"]; string skillstr = (string)data["SKILL"]; List<string> skill = string.IsNullOrEmpty(skillstr) ? new List<string>() : skillstr.Split(',').ToList(); string descstr = (string)data["DESC"]; IDictionary<string, string> id = new Dictionary<string, string>(); string[] descSpt = string.IsNullOrEmpty(descstr) ? new string[] { } : descstr.Split('|'); for (int i = 1; i < descSpt.Length; i += 2) id.Add(descSpt[i], descSpt[i + 1]); string[] codes = codeGroup.Split(','); foreach (string code in codes) firsts.Add(new Exsp(name, type, hero, code, skill, id)); } dicts = new Dictionary<string, Exsp>(); foreach (Exsp exsp in firsts) dicts.Add(exsp.Code, exsp); }
public MonsterLib() { Firsts = new List<Monster>(); dicts = new Dictionary<ushort, Monster>(); sql = new Utils.ReadonlySQL("psd.db3"); List<string> list = new string[] { "ID", "CODE", "NAME", "VALID", "STR", "AGL", "LEVEL", "OCCURS", "PRIORS", "DEBUTTEXT", "PETTEXT", "WINTEXT", "LOSETEXT", "TERMINI", "SPI", "GENRE" }.ToList(); System.Data.DataRowCollection datas = sql.Query(list, "Monster"); foreach (System.Data.DataRow data in datas) { int mid = (int)((long)data["ID"]); string code = (string)data["CODE"]; string name = (string)data["NAME"]; int group = (int)((short)data["VALID"]); int genre = (int)((long)data["GENRE"]); FiveElement five; switch (code.Substring(0, 2)) { case "GS": five = FiveElement.AQUA; break; case "GH": five = FiveElement.AGNI; break; case "GL": five = FiveElement.THUNDER; break; case "GF": five = FiveElement.AERO; break; case "GT": five = FiveElement.SATURN; break; case "GI": five = FiveElement.YINN; break; case "GY": five = FiveElement.SOLARIS; break; default: five = FiveElement.A; break; } ushort str = (ushort)((short)data["STR"]); ushort agl = (ushort)((short)data["AGL"]); short levelCode = (short)data["LEVEL"]; Monster.ClLevel level; switch (levelCode) { case 1: level = Monster.ClLevel.WEAK; break; case 2: level = Monster.ClLevel.STRONG; break; case 3: level = Monster.ClLevel.BOSS; break; default: level = Monster.ClLevel.WOODEN; break; } string[] occurs = ((string)data["OCCURS"]).Split(';'); string[][] eaoccurs = new string[occurs.Length][]; string[] propss = ((string)data["PRIORS"]).Split(';'); int[][] eaprops = new int[occurs.Length][]; bool[][] ealocks = new bool[occurs.Length][]; bool[][] eaonces = new bool[occurs.Length][]; string[] eatermis = ((string)data["TERMINI"]).Split(';'); bool[][] eaterminies = new bool[occurs.Length][]; bool[][] eahinds = new bool[occurs.Length][]; for (int i = 0; i < occurs.Length; ++i) { if (occurs[i] == "^") { eaoccurs[i] = null; eaprops[i] = null; ealocks[i] = null; eaonces[i] = null; } else { string[] ods = occurs[i].Split(','); string[] opss = propss[i].Split(','); string[] omin = eatermis[i].Split(','); eaoccurs[i] = new string[ods.Length]; eaprops[i] = new int[ods.Length]; ealocks[i] = new bool[ods.Length]; eaonces[i] = new bool[ods.Length]; eaterminies[i] = new bool[ods.Length]; eahinds[i] = new bool[ods.Length]; for (int j = 0; j < ods.Length; ++j) { if (ods[j].StartsWith("!")) { eaoccurs[i][j] = ods[j].Substring(1); ealocks[i][j] = true; } else { eaoccurs[i][j] = ods[j]; ealocks[i][j] = false; } if (opss[j].StartsWith("!")) // Only once { eaprops[i][j] = int.Parse(opss[j].Substring("!".Length)); eaonces[i][j] = false; } else { eaprops[i][j] = int.Parse(opss[j]); eaonces[i][j] = true; } if (omin[j].StartsWith("!")) // Hind { eaterminies[i][j] = (omin[j][1] == '1'); eahinds[i][j] = true; } else { eaterminies[i][j] = (omin[j][0] == '1'); eahinds[i][j] = false; } } } } string spis = data["SPI"] as string; string debutText = data["DEBUTTEXT"] as string; string petText = data["PETTEXT"] as string; string winText = data["WINTEXT"] as string; string loseText = data["LOSETEXT"] as string; Monster monster = new Monster(name, code, group, genre, five, str, agl, level, eaoccurs, eaprops, ealocks, eaonces, eaterminies, eahinds, spis) { DebutText = debutText ?? "", PetText = petText ?? "", WinText = winText ?? "", LoseText = loseText ?? "", DBSerial = (ushort)mid }; Firsts.Add(monster); dicts.Add((ushort)mid, monster); } }
public HeroLib() { dicts = new Dictionary<int, Hero>(); sql = new Utils.ReadonlySQL("psd.db3"); List<string> list = new string[] { "ID", "GENRE", "VALID", "OFCODE", "NAME", "HP", "STR", "DEX", "GENDER", "SPOUSE", "ISO", "SKILL", "ALIAS", "BIO" }.ToList(); System.Data.DataRowCollection datas = sql.Query(list, "Hero"); foreach (System.Data.DataRow data in datas) { string gs = (string)data["VALID"]; int group = int.Parse(gs.Contains(",") ? gs.Substring(0, gs.IndexOf(',')) : gs); int genre = (int)((long)data["GENRE"]); int code = (int)((long)data["ID"]); string name = (string)data["NAME"]; ushort hp = (ushort)((short)data["HP"]); ushort str = (ushort)((short)data["STR"]); ushort dex = (ushort)((short)data["DEX"]); char gender = ((string)data["GENDER"])[0]; string spouses = (string)data["SPOUSE"]; List<string> spouse = string.IsNullOrEmpty(spouses) ? new List<string>() : spouses.Split(',').ToList(); string isoStr = (string)data["ISO"]; int archetype = 0, antecessor = 0; List<int> isos = new List<int>(); foreach (string isosr in isoStr.Split(',')) { if (isosr.StartsWith("@")) archetype = int.Parse(isosr.Substring("@".Length)); else if (isosr.StartsWith("^")) antecessor = int.Parse(isosr.Substring("^".Length)); else if (!string.IsNullOrEmpty(isosr)) isos.Add(int.Parse(isosr)); } string skills = (string)data["SKILL"]; List<string> skill, relatedSkill; if (string.IsNullOrEmpty(skills)) { skill = new List<string>(); relatedSkill = new List<string>(); } else if (skills.IndexOf('|') < 0) { skill = skills.Split(',').ToList(); relatedSkill = new List<string>(); } else { int idx = skills.IndexOf('|'); skill = skills.Substring(0, idx).Split(',').ToList(); relatedSkill = skills.Substring(idx + 1).Split(',').ToList(); } string[] aliass = (data["ALIAS"] as string ?? "").Split(','); string[] alias = new string[7]; for (int i = 0; i < aliass.Length; i += 2) { switch (aliass[i]) { case "K": alias[0] = aliass[i + 1]; break; case "C": alias[1] = aliass[i + 1]; break; case "T": alias[2] = aliass[i + 1]; break; case "E": alias[3] = aliass[i + 1]; break; case "A": alias[4] = aliass[i + 1]; break; case "F": alias[5] = aliass[i + 1]; break; case "V": alias[6] = aliass[i + 1]; break; } } string bio = data["BIO"] as string ?? ""; Hero hero = new Hero(name, code, group, genre, gender, hp, str, dex, spouse, isos, archetype, antecessor, skill, bio) { Ofcode = data["OFCODE"] as string, TokenAlias = alias[0], PeopleAlias = alias[1], PlayerTarAlias = alias[2], ExCardsAlias = alias[3], AwakeAlias = alias[4], FolderAlias = alias[5], GuestAlias = alias[6], RelatedSkills = relatedSkill }; hero.SetAvailableParam(gs); dicts.Add(code, hero); } foreach (Hero hero in dicts.Values) { if (hero.Antecessor != 0 && dicts.ContainsKey(hero.Antecessor)) dicts[hero.Antecessor].Pioneer = hero.Avatar; } }
public NPCLib() { dicts = new Dictionary<ushort, NPC>(); sql = new Utils.ReadonlySQL("psd.db3"); List<string> list = new string[] { "ID", "CODE", "VALID", "NAME", "STR", "ACTION", "ORG", "GENDER", "DEBUTTEXT", "GENRE" }.ToList(); System.Data.DataRowCollection datas = sql.Query(list, "Npc"); foreach (System.Data.DataRow data in datas) { ushort id = (ushort)((long)data["ID"]); string code = (string)data["CODE"]; int valid = (int)((short)data["VALID"]); int genre = (int)((long)data["GENRE"]); string name = (string)data["NAME"]; ushort str = (ushort)((short)data["STR"]); string action = (string)data["ACTION"]; string[] npcskills = !string.IsNullOrEmpty(action) ? action.Split(',') : new string[0]; int org = (int)((long)data["ORG"]); char gender = ((string)data["GENDER"])[0]; string debutText = data["DEBUTTEXT"] as string; dicts.Add(id, new NPC(code, valid, genre, name, str, npcskills, org, gender) { DebutText = debutText ?? "" }); } }
public EvenementLib() { firsts = new List<Evenement>(); sql = new Utils.ReadonlySQL("psd.db3"); List<string> list = new string[] { "CODE", "VALID", "NAME", "RANGE", "BACKGROUND", "EFFECT", "SPI", "GENRE" }.ToList(); System.Data.DataRowCollection datas = sql.Query(list, "Eve"); foreach (System.Data.DataRow data in datas) { ushort valid = (ushort)((short)data["VALID"]); if (valid > 0) { string code = (string)data["CODE"]; string name = (string)data["NAME"]; int genre = (int)((long)data["GENRE"]); string range = (string)data["RANGE"]; string bg = (string)data["BACKGROUND"]; string effect = (string)data["EFFECT"]; string spis = (string)data["SPI"]; firsts.Add(new Evenement(name, code, range, valid, genre, bg, effect, spis)); } } dicts = new Dictionary<ushort, Evenement>(); Refresh(); }