Exemplo n.º 1
0
		private void ParseConfigs(List<string> Lines) {
			Match m;
			Regex rMatchLine = new Regex(@"^([^=]+)=([^;{}]+)", RegexOptions.Compiled);
			Regex rTableStart = new Regex("{[ \t]*}", RegexOptions.Compiled);
			Regex rTacticLine = new Regex(@"Tact\[(.*)\].*=.*\{([^,]*),([^,]*),([^,]*),([^\}]*)\}", RegexOptions.Compiled);

			for (int i = 0; i < Lines.Count; i++) {
				string line = Lines[i];
				string pairName = "", pairValue = "";
				string skillName = "";
				m = rMatchLine.Match(line);

				#region check: start of a Table
				if (rTableStart.IsMatch(line)) {

					// A skill define?
					#region Skill defines
					if (line.StartsWith("AS_") == true && m.Groups.Count > 1 && (skillName = m.Groups[1].Value.Trim()).Length == 11) {
						string pairSubName;
						int minSP = 0, lvl = 0;
						for (int v = 0; v < 2 && i < Lines.Count; v++) {
							i++;
							line = Lines[i];
							m = Regex.Match(line, @"^([^=]+)=([^;{}]+)");
							pairName = m.Groups[1].Value.Trim();
							pairValue = m.Groups[2].Value.Trim();
							if (pairName.IndexOf('.') == -1)
								continue; // huh, wtf is this? oO

							pairSubName = pairName.Substring(pairName.IndexOf('.') + 1).Trim().ToLower();
							if (pairSubName == "minsp")
								minSP = int.Parse(pairValue);
							else if (pairSubName == "level")
								lvl = int.Parse(pairValue);
						}

						HomuSkill skill = new HomuSkill(skillName, "", minSP, lvl);
						if (SetReflectionProp(skillName, skill) == false)
							MessageBox.Show("Die Eigenschaft \"" + skillName + "\" konnte nicht gefunden werden!", "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);

						continue;
					}
					#endregion

					if (line.StartsWith("Tact") == true) {
						i++;
						for (; i < Lines.Count; i++) {
							line = Lines[i];
							if (line.StartsWith("--") == true)
								continue;
							m = rTacticLine.Match(line);
							if (m.Groups.Count < 6) {
								MessageBox.Show("Die Zeile hat ein falsches Taktik-format: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
								break; // assume no more tacts left?
							}
							int mobID = int.Parse(m.Groups[1].Value.Trim());
							string mobName = m.Groups[2].Value.Replace("\"", "").Trim();
							string attBehav = m.Groups[3].Value.Trim();
							string skillBehav = m.Groups[4].Value.Trim();
							int prio = int.Parse(m.Groups[5].Value.Trim());

							if (TactList.AddTact(mobID, mobName, attBehav, skillBehav, prio) == false)
								MessageBox.Show("Fehler beim einlesen der Taktik: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
						}

						continue;
					}
				}
				#endregion

				#region check: name = value
				if (m != null && m.Success) {
					pairName = m.Groups[1].Value.Trim();
					pairValue = m.Groups[2].Value.Trim();
					if (pairValue.EndsWith(";") == true)
						pairValue = pairValue.Substring(0, pairValue.IndexOf(';')).Trim();

					if (SetReflectionField(pairName, pairValue) == false) {
						MessageBox.Show("Die Eigenschaft \"" + pairName + "\" konnte nicht gefunden werden!", "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
						continue;
					}
					continue;
				}
				#endregion

				MessageBox.Show("Unbekanntes Zeilenformat: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}

		}
Exemplo n.º 2
0
        private void ParseConfigs(List <string> Lines)
        {
            Match m;
            Regex rMatchLine  = new Regex(@"^([^=]+)=([^;{}]+)", RegexOptions.Compiled);
            Regex rTableStart = new Regex("{[ \t]*}", RegexOptions.Compiled);
            Regex rTacticLine = new Regex(@"Tact\[(.*)\].*=.*\{([^,]*),([^,]*),([^,]*),([^\}]*)\}", RegexOptions.Compiled);

            for (int i = 0; i < Lines.Count; i++)
            {
                string line = Lines[i];
                string pairName = "", pairValue = "";
                string skillName = "";
                m = rMatchLine.Match(line);

                #region check: start of a Table
                if (rTableStart.IsMatch(line))
                {
                    // A skill define?
                    #region Skill defines
                    if (line.StartsWith("AS_") == true && m.Groups.Count > 1 && (skillName = m.Groups[1].Value.Trim()).Length == 11)
                    {
                        string pairSubName;
                        int    minSP = 0, lvl = 0;
                        for (int v = 0; v < 2 && i < Lines.Count; v++)
                        {
                            i++;
                            line      = Lines[i];
                            m         = Regex.Match(line, @"^([^=]+)=([^;{}]+)");
                            pairName  = m.Groups[1].Value.Trim();
                            pairValue = m.Groups[2].Value.Trim();
                            if (pairName.IndexOf('.') == -1)
                            {
                                continue;                                 // huh, wtf is this? oO
                            }
                            pairSubName = pairName.Substring(pairName.IndexOf('.') + 1).Trim().ToLower();
                            if (pairSubName == "minsp")
                            {
                                minSP = int.Parse(pairValue);
                            }
                            else if (pairSubName == "level")
                            {
                                lvl = int.Parse(pairValue);
                            }
                        }

                        HomuSkill skill = new HomuSkill(skillName, "", minSP, lvl);
                        if (SetReflectionProp(skillName, skill) == false)
                        {
                            MessageBox.Show("Die Eigenschaft \"" + skillName + "\" konnte nicht gefunden werden!", "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        continue;
                    }
                    #endregion

                    if (line.StartsWith("Tact") == true)
                    {
                        i++;
                        for (; i < Lines.Count; i++)
                        {
                            line = Lines[i];
                            if (line.StartsWith("--") == true)
                            {
                                continue;
                            }
                            m = rTacticLine.Match(line);
                            if (m.Groups.Count < 6)
                            {
                                MessageBox.Show("Die Zeile hat ein falsches Taktik-format: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                break;                                 // assume no more tacts left?
                            }
                            int    mobID      = int.Parse(m.Groups[1].Value.Trim());
                            string mobName    = m.Groups[2].Value.Replace("\"", "").Trim();
                            string attBehav   = m.Groups[3].Value.Trim();
                            string skillBehav = m.Groups[4].Value.Trim();
                            int    prio       = int.Parse(m.Groups[5].Value.Trim());

                            if (TactList.AddTact(mobID, mobName, attBehav, skillBehav, prio) == false)
                            {
                                MessageBox.Show("Fehler beim einlesen der Taktik: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        continue;
                    }
                }
                #endregion

                #region check: name = value
                if (m != null && m.Success)
                {
                    pairName  = m.Groups[1].Value.Trim();
                    pairValue = m.Groups[2].Value.Trim();
                    if (pairValue.EndsWith(";") == true)
                    {
                        pairValue = pairValue.Substring(0, pairValue.IndexOf(';')).Trim();
                    }

                    if (SetReflectionField(pairName, pairValue) == false)
                    {
                        MessageBox.Show("Die Eigenschaft \"" + pairName + "\" konnte nicht gefunden werden!", "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                    continue;
                }
                #endregion

                MessageBox.Show("Unbekanntes Zeilenformat: " + line, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
		private void UpdateSkill(HomuSkill Skill, HomuSkill NewData) {
			Skill.Level = NewData.Level;
			Skill.MinSP = NewData.MinSP;
		}
Exemplo n.º 4
0
 private void UpdateSkill(HomuSkill Skill, HomuSkill NewData)
 {
     Skill.Level = NewData.Level;
     Skill.MinSP = NewData.MinSP;
 }