Пример #1
0
def ships(data):

    ships = companion.listify(data.get('ships'))
    current = data['commander'].get('currentShipId')

    if isinstance(current, int) and ships[current]:
        ships.insert(0, ships.pop(current))	# Put current ship first

        if not data['commander'].get('docked'):
            # Set current system, not last docked
            return [ [ship_map.get(ships[0]['name'].lower(), ships[0]['name']), data['lastSystem']['name'], ''] ] + [ [ship_map.get(ship['name'].lower(), ship['name']), ship['starsystem']['name'], ship['station']['name']] for ship in ships[1:] if ship]

    return [ [ship_map.get(ship['name'].lower(), ship['name']), ship['starsystem']['name'], ship['station']['name']] for ship in ships if ship]
Пример #2
0
def ships(data):

    ships = companion.listify(data.get('ships'))
    current = data['commander'].get('currentShipId')

    if isinstance(current, int) and current < len(ships) and ships[current]:
        ships.insert(0, ships.pop(current))	# Put current ship first

        if not data['commander'].get('docked'):
            # Set current system, not last docked
            return ([ (str(ships[0]['id']), ship_map.get(ships[0]['name'].lower(), ships[0]['name']), ships[0].get('shipName', ''), data['lastSystem']['name'], '', credits(ships[0]['value']['total'])) ] +
                    [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], credits(ship['value']['total'])) for ship in ships[1:] if ship])

    return [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], credits(ship['value']['total'])) for ship in ships if ship]
Пример #3
0
def ships(data):

    ships = companion.listify(data.get("ships"))
    current = data["commander"].get("currentShipId")

    if isinstance(current, int) and ships[current]:
        ships.insert(0, ships.pop(current))  # Put current ship first

        if not data["commander"].get("docked"):
            # Set current system, not last docked
            return [[ship_map.get(ships[0]["name"].lower(), ships[0]["name"]), data["lastSystem"]["name"], ""]] + [
                [ship_map.get(ship["name"].lower(), ship["name"]), ship["starsystem"]["name"], ship["station"]["name"]]
                for ship in ships[1:]
                if ship
            ]

    return [
        [ship_map.get(ship["name"].lower(), ship["name"]), ship["starsystem"]["name"], ship["station"]["name"]]
        for ship in ships
        if ship
    ]
Пример #4
0
def cmdr_data(data, is_beta):

    this.cmdr = data['commander']['name']

    if config.getint('inara_out'
                     ) and not is_beta and not this.multicrew and credentials(
                         this.cmdr):

        timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
        assets = data['commander']['credits'] - data['commander'].get(
            'debt', 0)

        for ship in companion.listify(data.get('ships', [])):
            if ship:
                assets += ship['value']['total']
                if this.needfleet:
                    if ship['id'] != data['commander']['currentShipId']:
                        add_event(
                            'setCommanderShip',
                            timestamp,
                            OrderedDict([
                                ('shipType', ship['name']),
                                ('shipGameID', ship['id']),
                                ('shipName',
                                 ship.get('shipName')),  # Can be None
                                ('shipIdent',
                                 ship.get('shipID')),  # Can be None
                                ('shipHullValue', ship['value']['hull']),
                                ('shipModulesValue', ship['value']['modules']),
                                ('starsystemName', ship['starsystem']['name']),
                                ('stationName', ship['station']['name']),
                            ]))
                    else:
                        add_event(
                            'setCommanderShip',
                            timestamp,
                            OrderedDict([
                                ('shipType', ship['name']),
                                ('shipGameID', ship['id']),
                                ('shipName',
                                 ship.get('shipName')),  # Can be None
                                ('shipIdent',
                                 ship.get('shipID')),  # Can be None
                                ('isCurrentShip', True),
                                ('shipHullValue', ship['value']['hull']),
                                ('shipModulesValue', ship['value']['modules']),
                            ]))

        if not (CREDIT_RATIO > this.lastcredits / data['commander']['credits']
                > 1 / CREDIT_RATIO):
            this.events = [
                x for x in this.events
                if x['eventName'] != 'setCommanderCredits'
            ]  # Remove any unsent
            add_event(
                'setCommanderCredits', timestamp,
                OrderedDict([
                    ('commanderCredits', data['commander']['credits']),
                    ('commanderAssets', assets),
                    ('commanderLoan', data['commander'].get('debt', 0)),
                ]))
            this.lastcredits = float(data['commander']['credits'])

        # *Don't* queue a call to Inara if we're just updating credits - wait for next mandatory event
        if this.needfleet:
            call()
            this.needfleet = False