2023-07-10 18:12:29 +00:00
|
|
|
from .base import Base, Reference
|
|
|
|
from nullptr.models.system import System
|
2023-06-11 18:51:03 +00:00
|
|
|
from nullptr.util import *
|
2023-07-16 16:48:45 +00:00
|
|
|
from time import time
|
2024-01-04 20:34:31 +00:00
|
|
|
from math import sqrt
|
2023-06-11 18:51:03 +00:00
|
|
|
|
2023-07-10 17:25:01 +00:00
|
|
|
class Waypoint(Base):
|
2023-06-18 17:15:51 +00:00
|
|
|
def define(self):
|
|
|
|
self.x:int = 0
|
|
|
|
self.y:int = 0
|
|
|
|
self.type:str = 'unknown'
|
|
|
|
self.traits:list = []
|
|
|
|
self.faction:str = ''
|
2023-12-28 18:49:00 +00:00
|
|
|
self.is_under_construction:bool = False
|
2023-07-16 16:48:45 +00:00
|
|
|
self.uncharted = True
|
2023-12-28 18:49:00 +00:00
|
|
|
|
2023-07-10 18:12:29 +00:00
|
|
|
|
2023-06-11 18:51:03 +00:00
|
|
|
def update(self, d):
|
|
|
|
self.seta('x', d)
|
|
|
|
self.seta('y', d)
|
|
|
|
self.seta('type', d)
|
|
|
|
self.seta('faction', d, 'faction.symbol')
|
2023-12-28 18:49:00 +00:00
|
|
|
self.seta('is_under_construction', d, 'isUnderConstruction')
|
2023-06-12 08:51:01 +00:00
|
|
|
self.setlst('traits', d, 'traits', 'symbol')
|
2023-07-16 16:48:45 +00:00
|
|
|
self.uncharted = 'UNCHARTED' in self.traits
|
2024-01-13 20:42:49 +00:00
|
|
|
|
|
|
|
def created(self):
|
|
|
|
self.get_system()
|
2024-01-04 20:34:31 +00:00
|
|
|
|
|
|
|
def distance(self, other):
|
|
|
|
return int(sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2))
|
2023-07-16 16:48:45 +00:00
|
|
|
|
2023-06-11 18:51:03 +00:00
|
|
|
@classmethod
|
|
|
|
def ext(self):
|
|
|
|
return 'way'
|
|
|
|
|
2024-01-13 10:27:32 +00:00
|
|
|
def itraits(self):
|
2024-01-09 19:07:27 +00:00
|
|
|
traits = []
|
|
|
|
if self.type == 'JUMP_GATE':
|
|
|
|
traits.append('JUMP')
|
|
|
|
if self.type == 'GAS_GIANT':
|
|
|
|
traits.append('GAS')
|
|
|
|
if 'SHIPYARD' in self.traits:
|
|
|
|
traits.append('SHIPYARD')
|
|
|
|
if 'MARKETPLACE' in self.traits:
|
|
|
|
traits.append('MARKET')
|
|
|
|
|
|
|
|
|
|
|
|
if self.type == 'ASTEROID':
|
|
|
|
if 'COMMON_METAL_DEPOSITS' in self.traits:
|
|
|
|
traits.append('METAL')
|
|
|
|
if 'PRECIOUS_METAL_DEPOSITS' in self.traits:
|
|
|
|
traits.append('GOLD')
|
|
|
|
if 'MINERAL_DEPOSITS' in self.traits:
|
|
|
|
traits.append('MINS')
|
|
|
|
if 'STRIPPED' in self.traits:
|
|
|
|
traits.append('STRIPPED')
|
|
|
|
return traits
|
2024-01-13 10:27:32 +00:00
|
|
|
|
|
|
|
def f(self, detail=1):
|
|
|
|
r = self.symbol
|
|
|
|
if detail > 3:
|
|
|
|
r += f'\n{self.x} {self.y}'
|
|
|
|
return r
|