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_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
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