Exemplo n.º 1
0
def test_export_to_sucess_many(set_global_modifier_1):
    world = set()
    main_island = main.Island(name="main-isle", fertility={"potato": None, "grain": None}, exports={}, world=world)
    main_island.residences["workers"] = (130 / 2) * (2 / 3) * 5  # number of workers that means 5 hop field required
    hop_island = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=world)
    main_island.calculate_required_production_buildings()
    assert len(hop_island.exports_to) == 1
    assert math.ceil(hop_island.exports_to["hops"]["main-isle"]) == 5
Exemplo n.º 2
0
def test_export_hops_sucess():
    world = set()
    main_island = main.Island(name="main-isle", fertility={"potato": None, "grain": None}, exports={}, world=world)
    main_island.residences["workers"] = 1
    hop_island = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=world)
    main_island.calculate_required_production_buildings()
    assert main_island.required_buildings["hops"] == 0
    assert math.ceil(hop_island.required_buildings["hops"]) == 1
    assert math.ceil(hop_island.exports_to["hops"]["main-isle"]) == 1
Exemplo n.º 3
0
def test_exports_correct_num_with_both(artisans_dont_drink_rum, set_global_modifier_1):
    world = set()
    main_island = main.Island(name="main-isle",
                              fertility={"potato": None, "grain": None, "peppers": None, "iron_mine": None, "coal_mine": 100, "sugar": None, "cotton": None,
                                         "furs": None}, exports={}, world=world)
    # main_island.residences["farmers"] = 1000
    main_island.residences["workers"] = (130 / 2) * (2 / 3) * 5  # number of workers that means 5 hop field required
    main_island.residences["artisans"] = (65 / 2) * (2 / 3) * 5
    hop_island = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=world)
    main_island.calculate_required_production_buildings()
    hop_island.calculate_required_production_buildings()
    assert len(hop_island.exports_to) == 1
    assert math.ceil(hop_island.exports_to["hops"]["main-isle"]) == 10 == math.ceil(hop_island.required_buildings["hops"])
Exemplo n.º 4
0
def test_new_world_pop_beer_export(example_island: main.Island):
    hop_isle = main.Island(name="hop-isle", fertility={"hops": None},
                           exports={"hops": None}, world=example_island.world)
    beer_isle = main.Island(name="beer-isle", fertility={"grain": None},
                            exports={"brewery": None},
                            world=example_island.world)
    del example_island.fertility["grain"]
    example_island.residences["jornaleros"] = 1
    example_island.residences["obreros"] = 1
    example_island.calculate_required_production_buildings()
    beer_isle.calculate_required_production_buildings()
    hop_isle.calculate_required_production_buildings()
    assert math.ceil(beer_isle.required_buildings["brewery"]) == 1
    assert math.ceil(hop_isle.required_buildings["hops"]) == 1
Exemplo n.º 5
0
def test_import_some_iron(example_island: main.Island):
    example_island.fertility["iron_mine"] = 1
    iron_isle = main.Island(name="iron-isle", fertility={"iron_mine": 55}, exports={"iron_mine": 50}, world=example_island.world)
    example_island.requested_construction_buildings["steel_works"] = 6  # require 2 iron mines
    example_island.calculate_required_production_buildings()
    assert example_island.required_buildings["iron_mine"] == 1
    assert iron_isle.required_buildings["iron_mine"] == 1
Exemplo n.º 6
0
def example_island(set_global_modifier_1):
    "example island with all fertilities"
    world = set()
    example_island = main.Island(name="example_island", fertility={}, exports={}, world=world)
    for resource in main.NATURAL_RESOURCES:
        example_island.fertility[resource] = None
    example_island.fertility["coal_mine"] = 100  # Cant be none
    return example_island
Exemplo n.º 7
0
def test_export_too_much_iron():
    exporter_isle = main.Island(name="exporter-isle", world=set(),
                                fertility={"iron_mine": 1},
                                exports={"iron_mine": 1})

    isle_one = main.Island(name="i1", world=exporter_isle.world)
    isle_one.requested_construction_buildings["steel_works"] = 3
    isle_two = main.Island(name="i2", world=exporter_isle.world)
    isle_two.requested_construction_buildings["steel_works"] = 3

    isle_iron_spare = main.Island(name="ironspare", fertility={"iron_mine": 1}, exports={"iron_mine": 1}, world=exporter_isle.world)

    exporter_isle.calculate_required_production_buildings()
    isle_one.calculate_required_production_buildings()
    isle_two.calculate_required_production_buildings()
    assert exporter_isle.required_buildings["iron_mine"] <= 1
    assert isle_iron_spare.required_buildings["iron_mine"] <= 1
Exemplo n.º 8
0
def test_must_import(example_island: main.Island):
    example_island.must_import = {"fishery"}
    example_island.residences["farmers"] = 100
    fish_isle = main.Island(name="fish", exports={"fishery": None}, world=example_island.world)
    example_island.calculate_required_production_buildings()
    fish_isle.calculate_required_production_buildings()
    assert example_island.required_buildings["fishery"] == 0
    assert fish_isle.required_buildings["fishery"] > 0
Exemplo n.º 9
0
def test_more_hops(example_island: main.Island):
    del example_island.fertility["hops"]
    example_island.residences["workers"] = 130 * 2
    hop_island = main.Island(name="hop-isle", fertility={"hops": None}, exports={"hops": None}, world=example_island.world)
    example_island.calculate_required_production_buildings()
    hop_island.calculate_required_production_buildings()
    assert example_island.required_buildings["hops"] == 0
    assert example_island.required_buildings["brewery"] == 4
    assert hop_island.required_buildings["hops"] == 6
Exemplo n.º 10
0
def test_some_coalmine_somekiln():
    main_island = main.Island(name="main-isle", fertility={"potato": None, "grain": None, "peppers": None, "iron_mine": 55, "coal_mine": 1}, exports={},
                              world=set())
    main_island.requested_construction_buildings["weapons"] = 12
    main_island.requested_construction_buildings["steel_works"] = 3
    main_island.calculate_required_production_buildings()
    assert main_island.required_buildings["weapons"] == 12
    assert main_island.required_buildings["coal_mine"] == 1
    assert main_island.required_buildings["charcoal_kiln"] == 4
Exemplo n.º 11
0
def test_export_rum_not_sugar(example_island: main.Island):
    example_island.residences["artisans"] = 1
    del example_island.fertility["sugar"]
    new_world = main.Island(name="newworld",
                            fertility={"sugar": None},
                            exports={"rum": None},
                            world=example_island.world)
    example_island.calculate_required_production_buildings()
    new_world.calculate_required_production_buildings()
Exemplo n.º 12
0
def test_global_modifier_imports(example_island: main.Island):
    del example_island.fertility["potato"]
    potato_isle = main.Island(name="potato-isle", fertility={"potato": None},
                              exports={"potato": None},
                              world=example_island.world)
    main.GLOBAL_CONSUMPTION_MODIFIER = .5
    example_island.residences["farmers"] = 60
    example_island.calculate_required_production_buildings()
    assert potato_isle.required_buildings["potato"] == .5
Exemplo n.º 13
0
def test_no_sugar_export(example_island: main.Island):
    example_island.residences["artisans"] = 1
    del example_island.fertility["sugar"]
    new_world = main.Island(name="newworld",
                            fertility={"sugar": None},
                            exports={},
                            world=example_island.world)
    with pytest.raises(main.NoFertility):
        example_island.calculate_required_production_buildings()
Exemplo n.º 14
0
def test_make_coats_import_raw():
    fur_island = main.Island(name="fur-isle",
                             fertility={"furs": None},
                             exports={"hunting_cabin": None},
                             world=set()
                             )
    cotton_isle = main.Island(name="cotton-isle",
                              fertility={"cotton": None},
                              exports={"cotton_mill": None},
                              world=fur_island.world)
    coat_isle = main.Island(name="coat-isle",
                            fertility={"grain": None, "hops": None, "peppers": None, "iron_mine": None, "sugar": None},
                            exports={},
                            world=fur_island.world)
    coat_isle.residences["artisans"] = 1
    coat_isle.calculate_required_production_buildings()
    fur_island.calculate_required_production_buildings()
    cotton_isle.calculate_required_production_buildings()
    assert math.ceil(cotton_isle.exports_to["cotton_mill"]["coat-isle"]) == 1
    assert math.ceil(cotton_isle.exports_to["cotton_mill"]["coat-isle"]) == 1

    assert math.ceil(fur_island.exports_to["hunting_cabin"]["coat-isle"]) == 1
    assert math.ceil(coat_isle.required_buildings["fur_dealer"]) == 1
Exemplo n.º 15
0
def test_odd_furnace_number():
    world = set()

    mainisle = main.Island(name="main-isle", fertility={"grain": None, "potato": None, "peppers": None,
                                                        "iron_mine": 2, "coal_mine": 1, "clay": 3},
                           exports={},
                           world=world)
    mainisle.requested_construction_buildings["sawmill"] = 4
    mainisle.requested_construction_buildings["brick"] = 6
    mainisle.requested_construction_buildings["sailmaker"] = 1
    mainisle.requested_construction_buildings["steel_works"] = 2
    mainisle.requested_construction_buildings["weapons"] = 3
    mainisle.requested_construction_buildings["windows"] = 1
    mainisle.calculate_required_production_buildings()
    assert mainisle.required_buildings["coal_mine"] == 1
    assert math.ceil(mainisle.required_buildings["furnace"]) == 3
    assert math.ceil(mainisle.required_buildings["charcoal_kiln"]) == 1
Exemplo n.º 16
0
def test_fertilities(example_fertility):
    world = set()
    fertile_island = main.Island(name="fertile", fertility=example_fertility, exports={}, world=world)
Exemplo n.º 17
0
def test_export_more_than_possible():
    world = set()
    with pytest.raises(AssertionError):
        coal_export_island = main.Island(name="coal_export_island", fertility={"coal_mine": 1}, exports={"coal_mine": 2}, world=world)
Exemplo n.º 18
0
def test_export_unlimited_fer_limit():
    world = set()
    with pytest.raises(AssertionError):
        bad_isle = main.Island(name="bad", fertility={"grain": 1}, exports={"grain": None}, world=world)
Exemplo n.º 19
0
def test_limit_export_allowed():
    world = set()
    coal_export_island = main.Island(name="coal_export_island", fertility={"coal_mine": None}, exports={"coal_mine": 1}, world=world)
Exemplo n.º 20
0
def test_world_creation(example_island: main.Island):
    assert example_island in example_island.world
    second_isle = main.Island(name="2nd", fertility={}, exports={}, world=example_island.world)
    assert second_isle in example_island.world