PageRenderTime 53ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/app/RomViewer.Core/Quests/QuestDefinition.cs

http://romviewer.googlecode.com/
C# | 83 lines | 73 code | 8 blank | 2 comment | 5 complexity | 6689199a3fc48fd11f82b9b6283a3cb2 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using SharpLite.Domain;
  4. namespace RomViewer.Core.Quests
  5. {
  6. public class QuestDefinition : Entity
  7. {
  8. public virtual int RomId { get; set; }
  9. public virtual string Name { get; set; }
  10. public virtual int MinLevel { get; set; }
  11. public virtual int Level { get; set; }
  12. public virtual int StarterId { get; set; }
  13. public virtual int EnderId { get; set; }
  14. public virtual int Gold { get; set; }
  15. public virtual int XP { get; set; }
  16. public virtual int TP { get; set; }
  17. public virtual RewardCategory RewardCategory { get; set; }
  18. public virtual RewardSubCategory RewardSubCategory { get; set; }
  19. public virtual IList<QuestReward> Rewards { get; protected set; }
  20. public virtual QuestChain QuestChain { get; set; }
  21. public virtual int ChainIndex { get; set; }
  22. public virtual string ToDelimitedString(int delimiter)
  23. {
  24. string rewards = "";
  25. foreach (QuestReward reward in Rewards)
  26. {
  27. if (rewards.Length > 0) rewards += (char) (delimiter+1);
  28. string r = reward.ToDelimitedString(delimiter + 2);
  29. rewards += r;
  30. }
  31. return
  32. string.Format(
  33. "{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}{0}{10}{0}{11}{0}{12}{0}{13}{0}{14}", (char)delimiter, RomId, Name, MinLevel, Level,
  34. StarterId, EnderId, Gold, XP, TP, RewardCategory, RewardSubCategory, (QuestChain != null) ? QuestChain.ToDelimitedString(delimiter+1) : "", ChainIndex, rewards);
  35. }
  36. public static string GetNullDefinitionString(int delimiter)
  37. {
  38. return string.Format("{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}", (char)delimiter);
  39. }
  40. public QuestDefinition()
  41. {
  42. Rewards = new List<QuestReward>();
  43. }
  44. public QuestDefinition(string source, int delimiter): this()
  45. {
  46. char delim = (char) delimiter;
  47. string[] detail = source.Split(delim);
  48. int i = 0;
  49. RomId = Convert.ToInt32(detail[i]); i++;
  50. Name = detail[i]; i++;
  51. MinLevel = Convert.ToInt32(detail[i]); i++;
  52. Level = Convert.ToInt32(detail[i]); i++;
  53. StarterId = Convert.ToInt32(detail[i]); i++;
  54. EnderId = Convert.ToInt32(detail[i]); i++;
  55. Gold = Convert.ToInt32(detail[i]); i++;
  56. XP = Convert.ToInt32(detail[i]); i++;
  57. TP = Convert.ToInt32(detail[i]); i++;
  58. RewardCategory = (RewardCategory)Enum.Parse(typeof(RewardCategory), detail[i]); i++;
  59. RewardSubCategory = (RewardSubCategory)Enum.Parse(typeof(RewardSubCategory), detail[i]); i++;
  60. if (detail[i].Length > 0) this.QuestChain = new QuestChain(detail[i], delimiter + 1);
  61. i++;
  62. this.ChainIndex = Convert.ToInt32(detail[i]); i++;
  63. if (detail[i].Length > 0)
  64. {
  65. delim = (char) (delimiter + 1);
  66. string[] rewards = detail[i].Split(delim);
  67. for (int j = 0; j < rewards.Length; j++)
  68. {
  69. //QuestReward reward = new QuestReward(rewards[j], delimiter + 2);
  70. //Rewards.Add(reward);
  71. }
  72. }
  73. }
  74. }
  75. }