def test_remove():
    """
    Tests removing a piece of armour from the ship
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4

    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 200
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 8

    # testing for removing a non-attached armour piece
    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 200
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 8
def test_swap():
    """
    Tests swapping the tonnage on the ship and making sure the ship's values
    translate accordingly
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4

    ship.set_tonnage(100)
    assert ship.get_remaining_cargo() == 95
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 2.1

    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 100
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 2
Пример #3
0
def test_config_functionality():
    """
    Tests functionality for adding configurations and swapping tonnage values
    :return:
    """
    ship = Spacecraft(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Standard"

    config = Config("Streamlined")
    ship.edit_hull_config(config)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.2
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Streamlined"

    config = Config("Standard")
    ship.edit_hull_config(config)
    ship.set_tonnage(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Standard"
Пример #4
0
def test_adding():
    """
    Tests adding both types of drives to a ship
    """
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2
    assert ship.mdrive is None
    assert ship.jdrive is None

    ship.add_jdrive(JDrive("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 90
    assert ship.get_total_cost() == 12
    assert ship.jdrive is not None

    ship.add_mdrive(MDrive("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 88
    assert ship.get_total_cost() == 16
    assert ship.mdrive is not None

    ship.add_pplant(PPlant("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 84
    assert ship.get_total_cost() == 24
    assert ship.pplant is not None
Пример #5
0
def test_fuel_add():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.fuel_max == 0

    ship.set_fuel(50)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 50
    assert ship.fuel_max == 50
Пример #6
0
def test_normal_add():
    ship = Spacecraft(100)

    # Adding and removing a Fuel Processor
    fuel_processor = Misc("Fuel Processors", 1)
    ship.modify_misc(fuel_processor)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 2.05
    ship.remove_misc("Fuel Processors")
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
Пример #7
0
def test_repair_drones():
    ship = Spacecraft(100)

    # Adding repair drones and checking dynamic costs
    repair_drones = Misc("Repair Drones", 1)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 99.0
    assert ship.get_total_cost() == 2.2

    # Removing the drone
    ship.remove_misc("Repair Drones")
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
Пример #8
0
def test_escape_pods():
    ship = Spacecraft(100)

    # Adding a stateroom then an escape pod
    stateroom = Misc("Staterooms", 1)
    ship.modify_misc(stateroom)
    assert ship.get_remaining_cargo() == 96
    assert ship.get_total_cost() == 2.5

    escape_pod = Misc("Escape Pods", 1)
    ship.modify_misc(escape_pod)
    assert ship.get_remaining_cargo() == 95.5
    assert ship.get_total_cost() == 2.6
Пример #9
0
def test_swap():
    ship = Spacecraft(100)

    # Adding repair drones and checking dynamic costs
    repair_drones = Misc("Repair Drones", 1)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 99.0
    assert ship.get_total_cost() == 2.2

    # Swapping for more drones
    repair_drones = Misc("Repair Drones", 2)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 98.0
    assert ship.get_total_cost() == 2.4
Пример #10
0
def test_removing():
    # Tests removing a screen object from the ship
    ship = Spacecraft(200)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0

    damper = Screen("Nuclear Damper")
    ship.modify_screen(damper)
    assert ship.get_remaining_cargo() == 150
    assert ship.get_total_cost() == 58.0

    new_damper = Screen("Nuclear Damper")
    ship.modify_screen(new_damper)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0
Пример #11
0
def test_adding():
    # Tests adding hull objects to the ship
    spacecraft = Spacecraft(100)
    reflec = Option("Reflec")
    stealth = Option("Stealth")

    spacecraft.modify_hull_option(reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 12.0
    assert len(spacecraft.hull_options) == 1

    spacecraft.modify_hull_option(stealth)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 22.0
    assert len(spacecraft.hull_options) == 2
Пример #12
0
def test_removing():
    # Tests removing a hull object from the ship
    spacecraft = Spacecraft(100)
    reflec = Option("Reflec")

    spacecraft.modify_hull_option(reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 12.0
    assert len(spacecraft.hull_options) == 1

    new_reflec = Option("Reflec")
    spacecraft.modify_hull_option(new_reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 2.0
    assert len(spacecraft.hull_options) == 0
Пример #13
0
def test_lowest_drive():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100

    drive = ship.get_lowest_drive()
    assert drive == "A"
Пример #14
0
def test_adding():
    # Tests adding each screen type
    damper = Screen("Nuclear Damper")
    meson = Screen("Meson Screen")
    extra = Screen("Nuclear Damper")

    ship = Spacecraft(200)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0

    ship.modify_screen(damper)
    assert ship.get_remaining_cargo() == 150
    assert ship.get_total_cost() == 58.0

    ship.modify_screen(meson)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 118.0
Пример #15
0
def test_incompatible_drive():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.mdrive is None

    ship.add_mdrive(MDrive("Z"))
    assert ship.mdrive is None
def test_add_replace():
    # Testing adding and replacing a sensor system
    ship = Spacecraft(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0

    sensor = Sensor("Advanced")

    ship.add_sensors(sensor)
    assert ship.get_remaining_cargo() == 97
    assert ship.get_total_cost() == 4.0
    assert ship.sensors is not None

    sensor = Sensor("Basic Civilian")
    ship.add_sensors(sensor)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 2.05
Пример #17
0
def test_empty_ship():
    ship = Spacecraft(0)
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.jdrive is None

    ship.add_jdrive(JDrive("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.jdrive is None

    ship.add_mdrive(MDrive("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.mdrive is None

    ship.add_pplant(PPlant("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.pplant is None
Пример #18
0
def test_turret_functionality():
    """
    Tests the functionality of adding and removing a turret from a ship
    """
    ship = Spacecraft(100)

    # Turret init with a wep and addon
    hardpoint = Hardpoint("1")
    turret = Turret("Single Turret")
    hardpoint.add_turret(turret)
    turret.modify_weapon("Beam Laser", 0)

    # Adding and removing the turret, checking ship specs
    ship.add_hardpoint(hardpoint)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 3.2

    turret.modify_weapon("---", 0)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 2.2
Пример #19
0
def test_spacecraft_init():
    """
    Tests the initialization of a new Spacecraft (hull)
    """
    spacecraft = Spacecraft(1000)
    assert spacecraft.tonnage == 1000
    assert spacecraft.get_remaining_cargo() == 1000
    assert spacecraft.hull_hp == 1000 // 50
    assert spacecraft.structure_hp == 1000 // 50
    assert spacecraft.fuel_max == 0
    assert spacecraft.armour_total == 0
    assert spacecraft.hull_type.type == "Standard"
    assert spacecraft.hull_designation == "B"
Пример #20
0
def test_set_tonnage():
    """
    Tests functionality of setting tonnage and the updates that comes with that
    """
    ship = Spacecraft(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
    assert ship.tonnage == 100
    assert ship.structure_hp == 2
    assert ship.hull_hp == 2
    assert ship.armour_total == 0

    ship.set_tonnage(200)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0
    assert ship.tonnage == 200
    assert ship.structure_hp == 4
    assert ship.hull_hp == 4
    assert ship.armour_total == 0

    armour = Armour("Titanium Steel")
    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.get_total_cost() == 8.4
    assert ship.tonnage == 200
    assert ship.structure_hp == 4
    assert ship.hull_hp == 4
    assert ship.armour_total == 2

    ship.set_tonnage(100)
    assert ship.get_remaining_cargo() == 95
    assert ship.get_total_cost() == 2.1
    assert ship.tonnage == 100
    assert ship.armour_total == 2
    assert ship.structure_hp == 2
    assert ship.hull_hp == 2
Пример #21
0
def test_add():
    """
    Tests adding a piece of armour to a ship
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4
Пример #22
0
def test_pplant_validity():
    # Tests 4 cases for pplant validities
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100

    ship.add_jdrive(JDrive("B"))
    ship.add_pplant(PPlant("B"))

    assert ship.check_pplant_validity() == True

    ship.add_pplant(PPlant("A"))
    assert ship.check_pplant_validity() == "Error: PPlant under J-Drive. A < B"

    ship = Spacecraft(100)
    ship.add_mdrive(MDrive("B"))
    ship.add_pplant(PPlant("A"))
    assert ship.check_pplant_validity() == "Error: PPlant under M-Drive. A < B"

    ship.add_jdrive(JDrive("B"))
    assert ship.check_pplant_validity(
    ) == "Error: PPlant under max M/J-Drive. A < B"
Пример #23
0
def test_changing():
    """
    Tests changing a drive type from one to another
    """
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2
    assert ship.jdrive is None

    ship.add_jdrive(JDrive("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 90
    assert ship.get_total_cost() == 12
    assert ship.jdrive.drive_type == "A"

    ship.add_jdrive(JDrive("B"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 85
    assert ship.get_total_cost() == 22
    assert ship.jdrive.drive_type == "B"

    ship.add_mdrive(MDrive("A"))
    assert ship.get_remaining_cargo() == 83
    assert ship.get_total_cost() == 26
    assert ship.mdrive.drive_type == "A"

    ship.add_mdrive(MDrive("B"))
    assert ship.get_remaining_cargo() == 82
    assert ship.get_total_cost() == 30
    assert ship.mdrive.drive_type == "B"

    ship.add_pplant(PPlant("A"))
    assert ship.get_remaining_cargo() == 78
    assert ship.get_total_cost() == 38
    assert ship.pplant.type == "A"

    ship.add_pplant(PPlant("B"))
    assert ship.get_remaining_cargo() == 75
    assert ship.get_total_cost() == 46
    assert ship.pplant.type == "B"
Пример #24
0
def test_small():
    spacecraft = Spacecraft(100)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 90
    assert spacecraft.get_total_cost() == 2.5
Пример #25
0
def test_bigly():
    spacecraft = Spacecraft(2000)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 1960
    assert spacecraft.get_total_cost() == 210.0
Пример #26
0
def test_large():
    spacecraft = Spacecraft(1200)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 1170
    assert spacecraft.get_total_cost() == 126.0
Пример #27
0
def test_medium():
    spacecraft = Spacecraft(400)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 380
    assert spacecraft.get_total_cost() == 18.0