RuneStat.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. """
  2. This file is part of RuneOptimizer.
  3. RuneOptimizer is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation, either version 3 of the License, or (at your option)
  6. any later version.
  7. RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
  13. """
  14. class RuneStat():
  15. """
  16. A stat of a rune.
  17. Any stat of a rune. Values are validated on setting and capped
  18. automatically.
  19. Parameters
  20. ----------
  21. slot : int
  22. Position of the stat.
  23. stat : int
  24. Stat identifier (Com2Us ID).
  25. name : str
  26. Stat name.
  27. value : int
  28. Value of the stat, before grinding.
  29. grind : int
  30. Grinded value of the stat. 0 if it has not been grinded.
  31. total : int
  32. Total value of stat, including grinding.
  33. is_enchanted : bool
  34. Indicates if the stat has been enchanted (changed).
  35. """
  36. _slot = -1
  37. _stat = 0
  38. _stat_name = ""
  39. _value = 0
  40. _grind = 0
  41. _total = 0
  42. _is_enchanted = False
  43. def __init__(self):
  44. pass
  45. @property
  46. def slot(self):
  47. return self._slot
  48. @slot.setter
  49. def slot(self, value):
  50. value = int(value)
  51. if value < -1 or value > 4:
  52. value = -1;
  53. self._slot = value
  54. @property
  55. def stat(self):
  56. return self._stat
  57. @stat.setter
  58. def stat(self, value):
  59. value = int(value)
  60. if value < 0:
  61. value = 0;
  62. self._stat = value
  63. self._stat_name = STAT_NAMES[value]
  64. @property
  65. def name(self):
  66. return self._stat_name
  67. @property
  68. def value(self):
  69. return self._value
  70. @value.setter
  71. def value(self, value):
  72. value = int(value)
  73. if value < 1:
  74. value = 1;
  75. self._value = value
  76. self._total = self._value + self._grind
  77. @property
  78. def grind(self):
  79. return self._grind
  80. @grind.setter
  81. def grind(self, value):
  82. value = int(value)
  83. self._grind = value
  84. self._total = self._value + self._grind
  85. @property
  86. def total(self):
  87. return self._total
  88. @property
  89. def is_enchanted(self):
  90. return self._is_enchanted
  91. @is_enchanted.setter
  92. def is_enchanted(self, value):
  93. if (value == True or int(value) == 1):
  94. self._is_enchanted = True
  95. else:
  96. self._is_enchanted = False