UnitTeam.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 UnitTeam():
  15. """
  16. A team of a unit.
  17. Very similar to the Team class, but this one doesn't load units, so it's
  18. safe to have as property of Unit.
  19. Parameters
  20. ----------
  21. id : str
  22. Team identifier.
  23. name : str
  24. Team name.
  25. priority : int
  26. Team priority, from 1 to 50.
  27. """
  28. _id = None
  29. _name = ""
  30. _priority = 1
  31. def __init__(self, id=None):
  32. if id != None:
  33. self._load(id)
  34. def _load(self, id):
  35. cursor = conn.execute(
  36. "SELECT id, name, priority FROM teams WHERE id = ?",
  37. (id,)
  38. )
  39. row = cursor.fetchone()
  40. if row != None:
  41. self._id = str(row[0])
  42. self._name = str(row[1])
  43. self._priority = int(row[2])
  44. @property
  45. def id(self):
  46. return self._id
  47. @property
  48. def name(self):
  49. return self._name
  50. @property
  51. def priority(self):
  52. return self._priority