Beispiel #1
0
    def update(self):

        if self.visible():

            capi_update=self.patrol_list and self.system and self.capi_update
            journal_update=self.patrol_list and self.system

            if journal_update or capi_update:
                self.sort_patrol()
                p=Systems.edsmGetSystem(self.system)
                self.nearest=self.getNearest(p)
                self.hyperlink['text']=self.nearest.get("system")
                self.hyperlink['url']="https://www.edsm.net/en/system?systemName={}".format(quote_plus(self.nearest.get("system")))
                self.distance['text']="{}ly".format(Locale.stringFromNumber(getDistance(p,self.nearest.get("coords")),2))
                self.infolink['text']=self.nearest.get("instructions")
                self.infolink['url']=self.parseurl(self.nearest.get("url"))

                self.infolink.grid()
                self.distance.grid()
                self.prev.grid()
                self.next.grid()
                self.capi_update=False

            else:
                if self.system:
                    self.hyperlink['text'] = "Fetching patrols..."
                else:
                    self.hyperlink['text'] = "Waiting for location"
                self.infolink.grid_remove()
                self.distance.grid_remove()
                self.prev.grid_remove()
                self.next.grid_remove()
Beispiel #2
0
 def getBGSPatrol(self, bgs, BGSOSys):
     x, y, z = Systems.edsmGetSystem(bgs.get("system_name"))
     if bgs.get("system_name") in BGSOSys:
         return
     else:
         return newPatrol(
             "BGS", bgs.get("system_name"), (x, y, z),
             self.getBGSInstructions(bgs),
             "https://elitebgs.app/system/{}".format(bgs.get("system_id")))
Beispiel #3
0
def submit(cmdr, is_beta, system, station, entry, client):

    hyperdictionDetector.submit(cmdr, is_beta, system, station, entry, client)

    hdsystems = ("Electra", "Asterope", "Delphi", "Merope", "Celaeno", "Maia",
                 "HR 1185", "HIP 23759", "Witch Head Sector DL-Y d17",
                 "Pleiades Sector HR-W d1-79", "Pleione",
                 "Witch Head Sector GW-W c1-4")

    if entry.get("event") == "StartJump" and entry.get(
            "JumpType") == "Hyperspace":
        #post traffic from reference systems
        if system in hdsystems:
            post_traffic(system, entry)

        post_distance(system, 'Merope', entry)
        post_distance(system, 'Witch Head Sector IR-W c1-9', entry)

    if entry["event"] == "Statistics" and entry.get("TG_ENCOUNTERS"):
        # there is no guarentee TG_ENCOUNTER_TOTAL_LAST_SYSTEM will have a value
        if entry.get("TG_ENCOUNTERS").get("TG_ENCOUNTER_TOTAL_LAST_SYSTEM"):

            lastsystem = entry.get("TG_ENCOUNTERS").get(
                "TG_ENCOUNTER_TOTAL_LAST_SYSTEM")
            gametime = entry.get("TG_ENCOUNTERS").get(
                "TG_ENCOUNTER_TOTAL_LAST_TIMESTAMP")
            year, remainder = gametime.split("-", 1)
            tgtime = "{}-{}".format(str(int(year) - 1286), remainder)

            if lastsystem == "Pleiades Sector IR-W d1-55":
                lastsystem = "Delphi"

            debug({"cmdr": cmdr, "system": lastsystem, "timestamp": tgtime})
            x, y, z = Systems.edsmGetSystem(lastsystem)
            # we are going to submit the hyperdiction here.
            emitter.post(
                "https://europe-west1-canonn-api-236217.cloudfunctions.net/postHD",
                {
                    "cmdr": cmdr,
                    "system": lastsystem,
                    "timestamp": tgtime,
                    "x": x,
                    "y": y,
                    "z": z
                })

            if lastsystem:
                if HDReport.hdsystems.get(lastsystem) == lastsystem:
                    debug("Hyperdiction already recorded here - session ")
                else:
                    HDReport(cmdr, is_beta, lastsystem, entry, client).start()
                    gSubmitHD(cmdr, x, y, z, entry).start()
Beispiel #4
0
def submit(cmdr, is_beta, system, station, entry, client):

    # The last system isnt always set so we can ignore

    if entry["event"] == "Statistics" and entry.get("TG_ENCOUNTERS"):
        # there is no guarentee TG_ENCOUNTER_TOTAL_LAST_SYSTEM will have a value
        if entry.get("TG_ENCOUNTERS").get("TG_ENCOUNTER_TOTAL_LAST_SYSTEM"):

            lastsystem = entry.get("TG_ENCOUNTERS").get(
                "TG_ENCOUNTER_TOTAL_LAST_SYSTEM")
            if lastsystem:
                if HDReport.hdsystems.get(lastsystem) == lastsystem:
                    debug("Hyperdiction already recorded here - session ")
                else:
                    HDReport(cmdr, is_beta, lastsystem, entry, client).start()
                    x, y, z = Systems.edsmGetSystem(lastsystem)
                    gSubmitHD(cmdr, x, y, z, entry).start()
Beispiel #5
0
 def Music(cls, system, cmdr, timestamp):
     if cls.state == 2:
         debug("Hyperdiction Detected")
         cls.show()
         x, y, z = Systems.edsmGetSystem(system)
         emitter.post(
             "https://europe-west1-canonn-api-236217.cloudfunctions.net/postHDDetected",
             {
                 "cmdr": cmdr,
                 "system": system,
                 "timestamp": timestamp,
                 "x": x,
                 "y": y,
                 "z": z
             })
         plug.show_error("Hyperdiction: Exit to main menu")
     else:
         debug("FSDJUMP resetting state back")
         cls.hide()
         cls.state == 0
Beispiel #6
0
    def gSubmitAXCZ(self, payload):
        p = payload.copy()
        p["x"], p["y"], p["z"] = Systems.edsmGetSystem(
            payload.get("systemName"))
        if p.get("isBeta"):
            p["isBeta"] = 'Y'
        else:
            p["isBeta"] = 'N'

        p["rawJson"] = json.dumps(payload.get("rawJson"),
                                  ensure_ascii=False).encode('utf8')

        url = "https://us-central1-canonn-api-236217.cloudfunctions.net/submitAXCZ"
        debug("gSubmitAXCZ {}".format(p.get("systemName")))

        getstr = "{}?{}".format(url, urllib.urlencode(p))

        debug("gsubmit {}".format(getstr))
        r = requests.get(getstr)

        if not r.status_code == requests.codes.ok:
            error(getstr)
            error(r.status_code)
Beispiel #7
0
    def run(self):
        payload = {}

        if self.entry["event"] == 'FSSSignalDiscovered':
            threatLevel = self.entry.get("ThreatLevel")
            type = "FSS"
        else:
            threatLevel = self.entry.get("USSThreat")
            type = "Drop"

        payload["systemName"] = self.system
        payload["cmdrName"] = self.cmdr
        payload["nhssRawJson"] = self.entry
        payload["threatLevel"] = threatLevel
        payload["isbeta"] = self.is_beta
        payload["clientVersion"] = self.client
        payload["reportStatus"] = "accepted"
        payload["reportComment"] = type

        url = self.getUrl()
        self.send(payload, url)

        x, y, z = Systems.edsmGetSystem(self.system)
        gSubmitNHSS(self.cmdr, self.system, x, y, z, threatLevel).start()
Beispiel #8
0
    def cmdr_data(self, data, is_beta):
        """
        We have new data on our commander

        Lets get a list of ships
        """
        self.cmdr = data.get('commander').get('name')

        self.ships = []
        self.system = data.get("lastSystem").get("name")

        current_ship = data.get("commander").get("currentShipId")

        shipsystems = {}

        # debug(json.dumps(data.get("ships"),indent=4))

        for ship in data.get("ships").keys():

            if int(ship) != int(current_ship):
                ship_system = data.get("ships").get(ship).get(
                    "starsystem").get("name")
                if not shipsystems.get(ship_system):
                    debug("first: {}".format(ship_system))
                    shipsystems[ship_system] = []
                # else:
                #    debug("second: {}".format(ship_system))

                shipsystems[ship_system].append(data.get("ships").get(ship))
                # if ship_system == "Celaeno":
                #    debug(json.dumps(shipsystems[ship_system],indent=4))
            # else:
            # debug("skipping {}".format(ship))

        for system in shipsystems.keys():
            ship_pos = Systems.edsmGetSystem(system)
            ship_count = len(shipsystems.get(system))
            # if system == "Celaeno":
            #    debug(json.dumps(shipsystems.get(system),indent=4))
            if ship_count == 1:
                # debug(shipsystems.get(system))
                ship_type = getShipType(shipsystems.get(system)[0].get("name"))
                ship_name = shipsystems.get(system)[0].get("shipName")
                ship_station = shipsystems.get(system)[0].get("station").get(
                    "name")
                ship_info = "Your {}, {} is docked at {}".format(
                    ship_type, ship_name, ship_station)
            elif ship_count == 2:

                if shipsystems.get(system)[0].get("station").get(
                        "name") == shipsystems.get(system)[1].get(
                            "station").get("name"):
                    ship_info = "Your {} ({}) and {} ({}) are docked at {}".format(
                        getShipType(shipsystems.get(system)[0].get("name")),
                        getShipType(
                            shipsystems.get(system)[0].get("shipName")),
                        getShipType(shipsystems.get(system)[1].get("name")),
                        getShipType(
                            shipsystems.get(system)[1].get("shipName")),
                        shipsystems.get(system)[0].get("station").get("name"))
                    debug(ship_info)
                else:

                    ship_info = "Your {} ({}) is docked at {} and your {} ({}) is docked at {}".format(
                        getShipType(shipsystems.get(system)[0].get("name")),
                        getShipType(
                            shipsystems.get(system)[0].get("shipName")),
                        shipsystems.get(system)[1].get("station").get("name"),
                        getShipType(shipsystems.get(system)[1].get("name")),
                        getShipType(
                            shipsystems.get(system)[1].get("shipName")),
                        shipsystems.get(system)[0].get("station").get("name"))
                    debug(ship_info)
            else:
                ship_info = "You have {} ships stored in this system".format(
                    ship_count)
                debug(ship_info)

            self.ships.append(
                newPatrol("SHIPS", system, ship_pos, ship_info, None))

        self.capi_update = True
        if self.system and not self.started:
            debug("Patrol download cycle commencing")
            self.started = True
            self.patrol_update()
Beispiel #9
0
 def keyval(self, k):
     x, y, z = Systems.edsmGetSystem(self.system)
     return getDistance((x, y, z), k.get("coords"))
Beispiel #10
0
def get_distance(a, b):
    x, y, z = Systems.edsmGetSystem(a)
    a, b, c = Systems.edsmGetSystem(b)
    return math.sqrt(
        math.pow(x - a, 2) + math.pow(y - b, 2) + math.pow(z - c, 2))