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
Exemple #3
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
Exemple #4
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"
def test_adding():
    # Initializing a ship and adding a computer system to it, checking for correct values
    ship = Spacecraft(100)
    assert ship.get_total_cost() == 2.0

    computer = Computer("Model 3")
    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0
    assert ship.check_rating_ratio() == 15
Exemple #6
0
def test_fuel_scoop():
    ship = Spacecraft(100)
    assert ship.hull_type.type == "Standard"
    assert ship.fuel_scoop is False
    assert ship.get_total_cost() == 2.0

    ship.modify_fuel_scoops()
    assert ship.hull_type.type == "Standard"
    assert ship.fuel_scoop is True
    assert ship.get_total_cost() == 3.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
def test_adding():
    # Testing adding a single piece of software to a ship
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1
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
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
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
def test_swapping():
    # Test swapping between computer models
    ship = Spacecraft(100)
    assert ship.get_total_cost() == 2.0

    computer = Computer("Model 3")
    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0
    assert ship.check_rating_ratio() == 15

    new = Computer("Model 4")
    ship.add_computer(new)
    assert ship.get_total_cost() == 7.0
    assert ship.check_rating_ratio() == 20
Exemple #13
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
Exemple #14
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
Exemple #15
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
Exemple #16
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
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
def test_remove():
    # Tests the available rating check
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Removing
    ship.remove_software("Jump Control")
    assert ship.get_total_cost() == 4.0
    assert len(ship.software) == 0
def test_downgrading():
    # Testing adding a single piece of software to a ship
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)
    downgrade = Software("Jump Control", 1)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Downgrading to the level 1 jump
    ship.modify_software(downgrade)
    assert ship.get_total_cost() == 4.1
    assert len(ship.software) == 1
def test_check_ratio():
    # Tests the available rating check
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Check before addition
    assert ship.check_rating_ratio() == 15

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Check after addition
    assert ship.check_rating_ratio() == 5
Exemple #21
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
Exemple #22
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
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
Exemple #24
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"
def test_medium():
    spacecraft = Spacecraft(400)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 380
    assert spacecraft.get_total_cost() == 18.0
def test_large():
    spacecraft = Spacecraft(1200)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 1170
    assert spacecraft.get_total_cost() == 126.0
def test_bigly():
    spacecraft = Spacecraft(2000)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 1960
    assert spacecraft.get_total_cost() == 210.0
def test_small():
    spacecraft = Spacecraft(100)
    spacecraft.set_bridge()

    assert spacecraft.get_remaining_cargo() == 90
    assert spacecraft.get_total_cost() == 2.5