Esempio n. 1
0
def edr_submit_scan(scan, timestamp, source, witness):
    edt = EDTime()
    edt.from_journal_timestamp(timestamp)

    report = scan
    report["starSystem"] = witness.star_system
    report["place"] = witness.place
    report["timestamp"] = edt.as_js_epoch()
    report["source"] = source
    report["reportedBy"] = witness.name

    if not witness.in_open():
        EDRLOG.log(u"Scan not submitted due to unconfirmed Open mode", "INFO")
        EDR_CLIENT.status = _(u"not in Open? Start EDMC before Elite.")
        return

    if witness.has_partial_status():
        EDRLOG.log(u"Scan not submitted due to partial status", "INFO")
        return

    if not EDR_CLIENT.scanned(scan["cmdr"], report):
        EDR_CLIENT.status = _(u"failed to report scan.")
        EDR_CLIENT.evict_cmdr(scan["cmdr"])
    EDR_CLIENT.status = _(u"scan reported (cmdr {name}).").format(
        name=scan["cmdr"])
Esempio n. 2
0
def edr_submit_contact(cmdr_name, ship, timestamp, source, witness):
    """
    Report a contact with a cmdr
    :param cmdr:
    :param timestamp:
    :param ship:
    :param source:
    :param witness:
    :return:
    """
    edt = EDTime()
    edt.from_journal_timestamp(timestamp)

    report = {
        "cmdr": cmdr_name,
        "starSystem": witness.star_system,
        "place": witness.place,
        "timestamp": edt.as_js_epoch(),
        "ship": ship if ship else u"Unknown",
        "source": source,
        "reportedBy": witness.name
    }

    if not witness.in_open():
        EDRLOG.log(u"Skipping submit contact due to unconfirmed Open mode",
                   "INFO")
        EDR_CLIENT.status = _(u"not in Open? Start EDMC before Elite.")
        return

    if witness.has_partial_status():
        EDRLOG.log(u"Skipping cmdr update due to partial status", "INFO")
        return

    if not EDR_CLIENT.blip(cmdr_name, report):
        EDR_CLIENT.status = _(u"failed to report contact.")
        EDR_CLIENT.evict_cmdr(cmdr_name)

    EDR_CLIENT.status = _(u"contact reported (cmdr {name}).").format(
        name=cmdr_name)
    edr_submit_traffic(cmdr_name, ship, timestamp, source, witness)
Esempio n. 3
0
File: load.py Progetto: Niteship/edr
def edr_submit_traffic(cmdr_name, ship, timestamp, source, witness):
    """
    Report a contact with a cmdr
    :param cmdr:
    :param ship:
    :param timestamp:
    :param source:
    :param witness:
    :return:
    """
    edt = EDTime()
    edt.from_journal_timestamp(timestamp)

    report = {
        "cmdr" : cmdr_name,
        "starSystem": witness.star_system,
        "place": witness.place,
        "timestamp": edt.as_js_epoch(),
        "ship" : ship if ship else u"Unknown",
        "source": source,
        "reportedBy": witness.name,
        "byPledge": witness.powerplay.canonicalize() if witness.powerplay else ""
    }

    if not witness.in_open():
        EDRLOG.log(u"Skipping submit traffic due to unconfirmed Open mode", "INFO")
        EDR_CLIENT.status = _(u"not in Open? Start EDMC before Elite.")
        return

    if witness.has_partial_status():
        EDRLOG.log(u"Skipping traffic update due to partial status", "INFO")
        return

    if not EDR_CLIENT.traffic(witness.star_system, report):
        EDR_CLIENT.status = _(u"failed to report traffic.")
        EDR_CLIENT.evict_system(witness.star_system)
Esempio n. 4
0
File: load.py Progetto: Niteship/edr
def handle_multicrew_events(ed_player, entry):
    if entry["event"] in ["CrewMemberJoins", "CrewMemberRoleChange", "CrewLaunchFighter"]:
        crew = plain_cmdr_name(entry["Crew"])
        success = ed_player.add_to_crew(crew)
        if success: # only show intel on the first add 
            EDR_CLIENT.status = _(u"added to crew: ").format(crew)
            EDRLOG.log(u"Addition to crew: {}".format(ed_player.crew.members), "INFO")
            EDR_CLIENT.who(crew, autocreate=True)

    if entry["event"] in ["CrewMemberQuits", "KickCrewMember"]:
        crew = plain_cmdr_name(entry["Crew"])
        duration = ed_player.crew_time_elapsed(crew)
        kicked = entry["event"] == "KickCrewMember"
        crimes = False if not "OnCrimes" in entry else entry["OnCrimes"]
        ed_player.remove_from_crew(crew)
        EDR_CLIENT.status = _(u"{} left the crew.".format(crew))
        EDRLOG.log(u"{} left the crew.".format(crew), "INFO")
        edt = EDTime()
        edt.from_journal_timestamp(entry["timestamp"])
        report = {
            "captain": ed_player.crew.captain,
            "timestamp": edt.as_js_epoch(),
            "crew" : crew,
            "duration": duration,
            "kicked": kicked,
            "crimes": crimes,
            "destroyed":  ed_player.destroyed if ed_player.is_captain() else False
        }
        edr_submit_multicrew_session(ed_player, report)

    if entry["event"] in ["JoinACrew"]:
        captain = plain_cmdr_name(entry["Captain"])
        ed_player.join_crew(captain)
        EDR_CLIENT.status = _(u"joined a crew.")
        EDRLOG.log(u"Joined captain {}'s crew".format(captain), "INFO")
        EDR_CLIENT.who(captain, autocreate=True)

    if entry["event"] in ["QuitACrew"] and ed_player.crew:
        for member in ed_player.crew.members:
            duration = ed_player.crew_time_elapsed(member)
            edt = EDTime()
            edt.from_journal_timestamp(entry["timestamp"])
            report = {
                "captain": ed_player.crew.captain,
                "timestamp": edt.as_js_epoch(),
                "crew" : member,
                "duration": duration,
                "kicked": False,
                "crimes": False,
                "destroyed": ed_player.destroyed if ed_player.is_captain() else False
            }    
            edr_submit_multicrew_session(ed_player, report)
        ed_player.leave_crew()
        EDR_CLIENT.status = _(u"left crew.")
        EDRLOG.log(u"Left the crew.", "INFO")

    if entry["event"] in ["EndCrewSession"] and ed_player.crew:
        crimes = False if not "OnCrimes" in entry else entry["OnCrimes"]
        for member in ed_player.crew.members:
            duration = ed_player.crew_time_elapsed(member)
            edt = EDTime()
            edt.from_journal_timestamp(entry["timestamp"])
            report = {
                "captain": ed_player.crew.captain,
                "timestamp": edt.as_js_epoch(),
                "crew" : member,
                "duration": duration,
                "kicked": False,
                "crimes": crimes,
                "destroyed": ed_player.destroyed if ed_player.is_captain() else False
            }    
            edr_submit_multicrew_session(ed_player, report)
        ed_player.disband_crew()
        EDR_CLIENT.status = _(u"crew disbanded.")
        EDRLOG.log(u"Crew disbanded.", "INFO")