A corporation manager and dashboard for EVE Online
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

142 行
3.4 KiB

  1. # -*- coding: utf-8 -*-
  2. __all__ = ["Universe"]
  3. class _SolarSystem:
  4. """Represents a solar system."""
  5. def __init__(self, universe, sid, data):
  6. self._universe = universe
  7. self._id = sid
  8. self._data = data
  9. @property
  10. def id(self):
  11. """The solar system's ID, as an integer."""
  12. return self._id
  13. @property
  14. def name(self):
  15. """The solar system's name, as a string."""
  16. return self._data["name"]
  17. @property
  18. def constellation(self):
  19. """The solar system's constellation, as a _Constellation object."""
  20. return self._universe.constellation(self._data["constellation"])
  21. @property
  22. def region(self):
  23. """The solar system's region, as a _Region object."""
  24. return self._universe.region(self._data["region"])
  25. @property
  26. def security(self):
  27. """The solar system's security status, as a float."""
  28. return self._data["security"]
  29. class _Constellation:
  30. """Represents a constellation."""
  31. def __init__(self, universe, cid, data):
  32. self._universe = universe
  33. self._id = cid
  34. self._data = data
  35. @property
  36. def id(self):
  37. """The constellation's ID, as an integer."""
  38. return self._id
  39. @property
  40. def name(self):
  41. """The constellation's name, as a string."""
  42. return self._data["name"]
  43. @property
  44. def region(self):
  45. """The constellation's region, as a _Region object."""
  46. return self._universe.region(self._data["region"])
  47. class _Region:
  48. """Represents a region."""
  49. def __init__(self, universe, rid, data):
  50. self._universe = universe
  51. self._id = rid
  52. self._data = data
  53. @property
  54. def id(self):
  55. """The region's ID, as an integer."""
  56. return self._id
  57. @property
  58. def name(self):
  59. """The region's name, as a string."""
  60. return self._data["name"]
  61. class _DummySolarSystem(_SolarSystem):
  62. """Represents an unknown or invalid solar system."""
  63. def __init__(self, universe):
  64. super().__init__(universe, -1, {
  65. "name": "Unknown",
  66. "constellation": -1,
  67. "region": -1,
  68. "security": 0.0
  69. })
  70. class _DummyConstellation(_Constellation):
  71. """Represents an unknown or invalid constellation."""
  72. def __init__(self, universe):
  73. super().__init__(universe, -1, {
  74. "name": "Unknown",
  75. "region": -1
  76. })
  77. class _DummyRegion(_Region):
  78. """Represents an unknown or invalid region."""
  79. def __init__(self, universe):
  80. super().__init__(universe, -1, {
  81. "name": "Unknown"
  82. })
  83. class Universe:
  84. """EVE API module for static universe data."""
  85. def __init__(self, datadir):
  86. self._dir = datadir
  87. def system(self, sid):
  88. """Return a _SolarSystem with the given ID.
  89. If the ID is invalid, return a dummy unknown object with ID -1.
  90. """
  91. ...
  92. return _DummySolarSystem(self)
  93. def constellation(self, cid):
  94. """Return a _Constellation with the given ID.
  95. If the ID is invalid, return a dummy unknown object with ID -1.
  96. """
  97. ...
  98. return _DummyConstellation(self)
  99. def region(self, rid):
  100. """Return a _Region with the given ID.
  101. If the ID is invalid, return a dummy unknown object with ID -1.
  102. """
  103. ...
  104. return _DummyRegion(self)