InvStat.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. [Serializable]
  3. public class InvStat
  4. {
  5. public static string GetName(InvStat.Identifier i)
  6. {
  7. return i.ToString();
  8. }
  9. public static string GetDescription(InvStat.Identifier i)
  10. {
  11. switch (i)
  12. {
  13. case InvStat.Identifier.Strength:
  14. return "Strength increases melee damage";
  15. case InvStat.Identifier.Constitution:
  16. return "Constitution increases health";
  17. case InvStat.Identifier.Agility:
  18. return "Agility increases armor";
  19. case InvStat.Identifier.Intelligence:
  20. return "Intelligence increases mana";
  21. case InvStat.Identifier.Damage:
  22. return "Damage adds to the amount of damage done in combat";
  23. case InvStat.Identifier.Crit:
  24. return "Crit increases the chance of landing a critical strike";
  25. case InvStat.Identifier.Armor:
  26. return "Armor protects from damage";
  27. case InvStat.Identifier.Health:
  28. return "Health prolongs life";
  29. case InvStat.Identifier.Mana:
  30. return "Mana increases the number of spells that can be cast";
  31. default:
  32. return null;
  33. }
  34. }
  35. public static int CompareArmor(InvStat a, InvStat b)
  36. {
  37. int num = (int)a.id;
  38. int num2 = (int)b.id;
  39. if (a.id == InvStat.Identifier.Armor)
  40. {
  41. num -= 10000;
  42. }
  43. else if (a.id == InvStat.Identifier.Damage)
  44. {
  45. num -= 5000;
  46. }
  47. if (b.id == InvStat.Identifier.Armor)
  48. {
  49. num2 -= 10000;
  50. }
  51. else if (b.id == InvStat.Identifier.Damage)
  52. {
  53. num2 -= 5000;
  54. }
  55. if (a.amount < 0)
  56. {
  57. num += 1000;
  58. }
  59. if (b.amount < 0)
  60. {
  61. num2 += 1000;
  62. }
  63. if (a.modifier == InvStat.Modifier.Percent)
  64. {
  65. num += 100;
  66. }
  67. if (b.modifier == InvStat.Modifier.Percent)
  68. {
  69. num2 += 100;
  70. }
  71. if (num < num2)
  72. {
  73. return -1;
  74. }
  75. if (num > num2)
  76. {
  77. return 1;
  78. }
  79. return 0;
  80. }
  81. public static int CompareWeapon(InvStat a, InvStat b)
  82. {
  83. int num = (int)a.id;
  84. int num2 = (int)b.id;
  85. if (a.id == InvStat.Identifier.Damage)
  86. {
  87. num -= 10000;
  88. }
  89. else if (a.id == InvStat.Identifier.Armor)
  90. {
  91. num -= 5000;
  92. }
  93. if (b.id == InvStat.Identifier.Damage)
  94. {
  95. num2 -= 10000;
  96. }
  97. else if (b.id == InvStat.Identifier.Armor)
  98. {
  99. num2 -= 5000;
  100. }
  101. if (a.amount < 0)
  102. {
  103. num += 1000;
  104. }
  105. if (b.amount < 0)
  106. {
  107. num2 += 1000;
  108. }
  109. if (a.modifier == InvStat.Modifier.Percent)
  110. {
  111. num += 100;
  112. }
  113. if (b.modifier == InvStat.Modifier.Percent)
  114. {
  115. num2 += 100;
  116. }
  117. if (num < num2)
  118. {
  119. return -1;
  120. }
  121. if (num > num2)
  122. {
  123. return 1;
  124. }
  125. return 0;
  126. }
  127. public InvStat.Identifier id;
  128. public InvStat.Modifier modifier;
  129. public int amount;
  130. public enum Identifier
  131. {
  132. Strength,
  133. Constitution,
  134. Agility,
  135. Intelligence,
  136. Damage,
  137. Crit,
  138. Armor,
  139. Health,
  140. Mana,
  141. Other
  142. }
  143. public enum Modifier
  144. {
  145. Added,
  146. Percent
  147. }
  148. }