コード例 #1
0
ファイル: hdreport.py プロジェクト: alterNERDtive/EDMC-Canonn
 def Music(cls, system, cmdr, timestamp, client):
     if cls.state == 2:
         debug("Hyperdiction Detected")
         cls.show()
         x, y, z = Systems.edsmGetSystem(system)
         dx, dy, dz = Systems.edsmGetSystem(cls.target_system)
         canonn.emitter.post(
             "https://europe-west1-canonn-api-236217.cloudfunctions.net/postHDDetected",
             {
                 "cmdr": cmdr,
                 "system": system,
                 "timestamp": timestamp,
                 "x": x,
                 "y": y,
                 "z": z,
                 "destination": cls.target_system,
                 "dx": dx,
                 "dy": dy,
                 "dz": dz,
                 "client": client
             })
         plug.show_error("Hyperdiction: Exit to main menu")
     else:
         debug("FSDJUMP resetting state back")
         cls.hide()
         cls.state == 0
コード例 #2
0
ファイル: load.py プロジェクト: VAKazakov/EDMC-Canonn
def journal_entry(cmdr, is_beta, system, station, entry, state):
    # capture some stats when we launch not read for that yet
    # startup_stats(cmdr)
    if "SystemFaction" in entry:

        SystemFaction = entry.get("SystemFaction")
        debug(SystemFaction)
        try:
            this.SysFactionState = SystemFaction["FactionState"]
        except:
            this.SysFactionState = None
        debug("SysFaction's state is" + str(this.SysFactionState))

    if "SystemAllegiance" in entry:

        SystemAllegiance = entry.get("SystemAllegiance")
        debug(SystemAllegiance)
        try:
            this.SysFactionAllegiance = SystemAllegiance
        except:
            this.SysFactionAllegiance = None
        debug("SysFaction's allegiance is" + str(this.SysFactionAllegiance))

    if "DistFromStarLS" in entry:
        '''"DistFromStarLS":144.821411'''
        try:
            this.DistFromStarLS = entry.get("DistFromStarLS")
        except:
            this.DistFromStarLS = None
        debug("DistFromStarLS=" + str(this.DistFromStarLS))

    if entry.get("event") == "FSDJump":
        Systems.storeSystem(system, entry.get("StarPos"))
        this.DistFromStarLS = None

    if ('Body' in entry):
        this.body_name = entry['Body']

    if system:
        x, y, z = Systems.edsmGetSystem(system)
    else:
        x = None
        y = None
        z = None

    return journal_entry_wrapper(
        cmdr, is_beta, system, this.SysFactionState, this.SysFactionAllegiance,
        this.DistFromStarLS, station, entry, state, x, y, z, this.body_name,
        this.nearloc['Latitude'], this.nearloc['Longitude'],
        this.client_version)
コード例 #3
0
ファイル: hdreport.py プロジェクト: alterNERDtive/EDMC-Canonn
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.
            canonn.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()
コード例 #4
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, urlencode(p))

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

        if not r.status_code == requests.codes.ok:
            error(getstr)
            error(r.status_code)
コード例 #5
0
ファイル: nhss.py プロジェクト: alterNERDtive/EDMC-Canonn
    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()
コード例 #6
0
ファイル: hdreport.py プロジェクト: alterNERDtive/EDMC-Canonn
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))