예제 #1
0
    def performance_by_volume(self, drive, drive_letter):
        """
        Handles checking whether a drive type is compatible and retrieves the relative jump/thrust numbers
        for a drive type
        :param drive: drive type
        :param drive_letter: letter of the drive 
        :return: None if incompatible
        """
        data = get_file_data("hull_performance.json")
        index = get_file_data("hull_performance_index.json")
        performance_list = data.get(drive_letter).get("jumps_per_hull_volume")

        # Get the nearest ton rounded down
        index = index.get(str(self.tonnage))

        # Error checking to see if drive type is incompatible with the hull size
        if index >= len(performance_list):
            return None

        value = performance_list[int(index)]

        # Error checking if the drive type is non-compatible with the hull size
        if value == 0:
            return None

        if drive == "mdrive":
            self.thrust = value
        if drive == "jdrive":
            self.jump = value

        return 1
예제 #2
0
    def __init__(self, type):
        data = get_file_data("hull_armor.json").get(type)

        self.type = type
        self.tl = data.get("tl")
        self.protection = data.get("protection")
        self.hull_amount = data.get("hull_amount")
        self.cost_by_hull_percentage = data.get("cost_by_hull_percentage")
예제 #3
0
    def __init__(self, name):
        data = get_file_data("hull_screens.json").get(name)

        self.name = name
        self.tl = data.get("tl")
        self.tonnage = data.get("tonnage")
        self.cost = data.get("cost")
        self.mod_additional = data.get("mod_additional")
예제 #4
0
    def __init__(self, name):
        data = get_file_data("hull_computer.json").get(name)

        self.model = name
        self.tl = data.get("tl")
        self.rating = data.get("rating")
        self.cost = data.get("cost")
        self.bis = False  # whether Jump Control Specialization is added
        self.fib = False  # whether EMP hardened is added
예제 #5
0
    def __init__(self, name, num):
        data = get_file_data("hull_misc.json")
        obj = data.get(name)

        self.name = name
        self.num = num
        self.cost = obj.get("cost") * num
        self.mod_additional = obj.get("mod_additional")
        self.tonnage = obj.get("tonnage") * num
예제 #6
0
    def __init__(self, drive_type):
        Drive.__init__(self, drive_type)

        # grab additional info from json
        data = get_file_data("mdrive_data.json")
        drive_item = data.get(drive_type)

        # set determined object state
        self.tonnage = drive_item.get("tonnage")
        self.cost = drive_item.get("cost")
예제 #7
0
    def get_lowest_drive(self):
        """
        Handles getting the lowest possible drive type for a given tonnage
        :return: letter of the drive type
        """
        data = get_file_data("hull_performance.json")
        index = get_file_data("hull_performance_index.json")
        idx = index.get(str(self.tonnage))

        for drive in data:
            jump_list = data.get(drive).get("jumps_per_hull_volume")

            # check invalid first, else return drive type
            if len(jump_list) <= idx:
                continue
            elif jump_list[idx] == 0:
                continue
            else:
                return drive
예제 #8
0
    def __init__(self, hull_tonnage):
        self.tonnage = 0  # total tonnage of ship
        self.discount = 1  # discount factor for the cost
        self.hull_hp = 0  # calculated as 1 per 50 tonnage
        self.structure_hp = 0  # calculated as 1 per 50 tonnage
        self.jump = 0  # max number of tiles covered in a single jump
        self.thrust = 0  # max number of G accelerations available
        self.fuel_max = 0  # amount of fuel tank
        self.fuel_jump = 0  # amount of fuel required for a jump
        self.fuel_two_weeks = 0  # amount of fuel required for 2 weeks of operation
        self.armour_total = 0  # total armour pointage
        self.num_hardpoints = 0  # total number of hardpoints
        self.hardpoints = list()  # list of added hardpoints
        self.hull_designation = None  # A, B, C, etc.
        self.hull_type = None  # steamlined, distributed, standard, etc.
        self.hull_options = list()  # list of hull options installed
        self.fuel_scoop = False  # whether fuel scoops are installed
        self.bridge = False  # whether a bridge is installed
        self.jdrive = None  # jdrive object
        self.mdrive = None  # mdrive object
        self.pplant = None  # pplant object
        self.armour = list()  # list of armour objects
        self.sensors = None  # sensor object
        self.bays = list()  # list of bay objects
        self.screens = list()  # list of screen objects
        self.computer = None  # computer object
        self.software = list()  # list of installed software
        self.misc = list()  # list of misc items

        # set the tonnage to that given at init
        if hull_tonnage > 2000:
            hull_tonnage = 2000

        self.tonnage = hull_tonnage

        # set hp based on tonnage
        self.hull_hp = self.tonnage // 50
        self.structure_hp = self.tonnage // 50
        self.num_hardpoints = self.tonnage // 100

        # pull hull cost from json, set that
        data = get_file_data("hull_data.json")

        for key in data.keys():
            # iterate through hull sizes for
            item_tonnage = data.get(key).get("tonnage")
            if self.tonnage <= item_tonnage and (item_tonnage -
                                                 self.tonnage) < 100:
                self.hull_designation = key

        # set hull type to standard
        self.hull_type = Config("Standard")

        # set sensors to standard
        self.sensors = Sensor("Standard")
예제 #9
0
    def __init__(self, name, level):
        data = get_file_data("hull_software.json").get(name)
        software = data.get(str(level))

        if software is None:
            print("Error: invalid software level for {}".format(name))
            return

        self.type = name
        self.level = level
        self.tl = software.get("tl")
        self.rating = software.get("rating")
        self.cost = software.get("cost")
        self.mod_additional = data.get("mod_additional")
예제 #10
0
    def set_tonnage(self, new_tonnage):
        """
        Sets the tonnage of an existing Spacecraft
        :param new_tonnage: The tonnage to update to
        """
        tonnage_cost_data = get_file_data("hull_data.json")
        for key in tonnage_cost_data:
            item = tonnage_cost_data.get(key)
            if item.get('tonnage') == int(new_tonnage):
                self.hull_designation = key

        self.tonnage = new_tonnage

        # set hp based on tonnage
        self.hull_hp = self.tonnage // 50
        self.structure_hp = self.tonnage // 50
        self.num_hardpoints = self.tonnage // 100
예제 #11
0
    def __init__(self, plant_type):
        self.type = None  # the drive designation (A, F, H, etc.)
        self.tonnage = 0  # the size of the drive in tons
        self.cost = 0  # the cost of the drive
        self.fuel_two_weeks = 0  # fuel consumption every 2 weeks

        # set drive type from init
        self.type = plant_type

        # grab additional info from json
        data = get_file_data("pplant_data.json")
        plant_item = data.get(plant_type)

        # set determined object state
        self.tonnage = plant_item.get("tonnage")
        self.cost = plant_item.get("cost")
        self.fuel_two_weeks = plant_item.get("fuel_two_weeks")
예제 #12
0
    def __init__(self, model_type):
        data = get_file_data("hull_turrets.json")

        self.data = data
        self.name = model_type  # name of the model
        self.model = data.get("models").get(model_type)  # model of the turret
        self.tonnage = self.model.get(
            "tonnage")  # size of the turret and addons
        self.max_wep = self.model.get(
            "num_weapons")  # max number of weapons per turret type
        self.weapons = [None for _ in range(self.max_wep)
                        ]  # list of the weapons on this turret
        self.cost = self.model.get("cost")  # cost of the turret and addons

        # Setting up missile dictionary for display
        self.missiles = dict()
        for mtype in data.get("weapons").get("Missile Rack").get(
                "types").keys():
            self.missiles[mtype] = 0

        self.sandcaster_barrels = 0  # number of sandcaster barrels on turret
예제 #13
0
    def get_total_cost(self):
        """
        Gets total cost of all objects for the ship
        :return: total cost
        """
        cost_total = 0

        # Tonnage / Bridge
        if self.tonnage != 0:
            ton = get_file_data("hull_data.json")
            cost = ton.get(self.hull_designation).get("cost")
            cost_total += cost * self.hull_type.mod_hull_cost
        if self.bridge is True:
            cost_total += self.tonnage * .005

        # Hull options
        for opt in self.hull_options:
            cost_total += self.tonnage * opt.cost_per_hull_ton

        # Fuel scoops
        if self.hull_type.type != "Streamlined" and self.fuel_scoop is True:
            cost_total += 1

        # Drives
        if self.jdrive is not None:
            cost_total += self.jdrive.cost
        if self.mdrive is not None:
            cost_total += self.mdrive.cost
        if self.pplant is not None:
            cost_total += self.pplant.cost

        # Armour
        for armour_item in self.armour:
            percent = armour_item.cost_by_hull_percentage
            ton = get_file_data("hull_data.json")
            cost = ton.get(self.hull_designation).get("cost")
            cost_total += percent * cost

        # Sensors
        if self.sensors is not None:
            cost_total += self.sensors.cost

        # Screens / Computer / Software
        for screen in self.screens:
            cost_total += screen.cost
        if self.computer is not None:
            cost_total += self.computer.get_cost()
        for software in self.software:
            cost_total += software.cost

        # Misc
        for misc in self.misc:
            if misc.name == "Repair Drones":
                cost_total += 0.2 * (misc.tonnage * self.tonnage)
            else:
                cost_total += misc.cost

        # Adding discount to items
        cost_total *= self.discount

        # Turrets / Bayweapons (after discount because its included
        for hardpoint in self.hardpoints:
            cost_total += hardpoint.get_cost()

        return cost_total
예제 #14
0
 def __init__(self, id):
     self.data = get_file_data("hull_turrets.json")
     self.id = id  # hardpoint id
     self.turret = None  # turret object
     self.popup = False
     self.fixed = False
예제 #15
0
    def __init__(self, type):
        data = get_file_data("hull_config.json").get(type)

        self.type = type
        self.mod_hull_cost = data.get("mod_hull_cost")
        self.mod_additional = data.get("mod_additional")
예제 #16
0
    def __init__(self, name):
        data = get_file_data("hull_options.json").get(name)

        self.name = name
        self.cost_per_hull_ton = data.get("cost_per_hull_ton")