NPCPage.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Text.RegularExpressions;
  2. namespace Server.MirObjects
  3. {
  4. public class NPCPage
  5. {
  6. public string Key;
  7. public List<NPCSegment> SegmentList = new List<NPCSegment>();
  8. public List<string> Args = new List<string>();
  9. public List<string> Buttons = new List<string>();
  10. public List<int> ScriptCalls = new List<int>();
  11. public bool BreakFromSegments = false;
  12. public NPCPage(string key)
  13. {
  14. Key = key;
  15. }
  16. public string ArgumentParse(string key)
  17. {
  18. if (key.StartsWith("[@_")) return key; //Default NPC page so doesn't use arguments in this way
  19. Regex r = new Regex(@"\((.*)\)");
  20. Match match = r.Match(key);
  21. if (!match.Success) return key;
  22. key = Regex.Replace(key, r.ToString(), "()");
  23. string strValues = match.Groups[1].Value;
  24. string[] arrValues = strValues.Split(',');
  25. Args = new List<string>();
  26. foreach (var t in arrValues)
  27. Args.Add(t);
  28. return key;
  29. }
  30. }
  31. }