Exemplo n.º 1
0
 def it_can_verify_too_few_teamsters_exist():
     cov = Covenant()
     cov.covenfolken.add_covenfolk("Mary", "magi")
     assert cov.meets_laborer_minimum() == False
     cov.covenfolken.add_covenfolk("Todd", "laborer")
     cov.covenfolken.add_covenfolk("Tammy", "laborer")
     assert cov.meets_laborer_minimum() == True
Exemplo n.º 2
0
 def it_calculates_lab_cost_saving_changes():
     cov = Covenant()
     cov.laboratories.add_lab("route 66")
     cov.laboratories.add_lab("route 67")
     cov.laboratories.add_lab("route 68")
     cov.laboratories.add_lab("route 69")
     assert cov.calculate_expenditures() == 4.0
     cov.covenfolken.add_covenfolk("worker", "crafter", "brickmaker", "laboratories", 2, "common")
     assert cov.calculate_expenditures() == 5.2
     cov.covenfolken.add_covenfolk("worker 2", "crafter", "brickmaker", "laboratories", 10, "rare")
     assert cov.calculate_expenditures() == 7.2
Exemplo n.º 3
0
 def it_correctly_factors_in_laborers_for_teamster_requirements():
     cov = Covenant()
     cov.covenfolken.add_covenfolk("Arg", "magi")
     cov.covenfolken.add_covenfolk("gle", "magi")
     cov.covenfolken.add_covenfolk("Barg", "magi")
     assert cov.meets_teamster_minimum() == False
     cov.covenfolken.add_covenfolk("le", "dependant")
     cov.covenfolken.add_covenfolk("woo", "dependant")
     cov.covenfolken.add_covenfolk("tem", "teamster")
     assert cov.meets_teamster_minimum() == False
     cov.covenfolken.add_covenfolk("lab", "laborer")
     cov.covenfolken.add_covenfolk("orer", "laborer")
     assert cov.meets_teamster_minimum() == False
Exemplo n.º 4
0
 def it_saves_covenant():
     from src.covenant import save_covenant
     cov = Covenant()
     cov.inflation = 100
     cov.covenfolken.add_covenfolk("Barg", "magi")
     cov.covenfolken.add_covenfolk("le", "dependant")
     cov.armory.add_equipment("earthquake machine", "heavy siege", "expensive")
     cov.laboratories.add_lab("Haunted mansion")
     save_covenant(cov, "cov.json")
     with open("cov.json", "r+") as f:
         cov_json = f.readlines()
         # TODO: find a better way to assert this succeeds without using load
         assert len(cov_json) > 1
Exemplo n.º 5
0
 def it_loads_covenant():
     from src.covenant import save_covenant, load_covenant_from_file
     cov = Covenant()
     cov.inflation = 100
     cov.covenfolken.add_covenfolk("Barg", "magi")
     cov.covenfolken.add_covenfolk("le", "dependant")
     cov.armory.add_equipment("earthquake machine", "heavy siege", "expensive")
     cov.laboratories.add_lab("Haunted mansion")
     save_covenant(cov, "cov.json")
     loaded = load_covenant_from_file("cov.json")
     assert loaded.covenfolken.covenfolk["Barg"]
     assert loaded.armory.heavy_siege["earthquake machine"] == {"expensive": 1}
     assert loaded.armory.weapons["pistol"] == {}
     assert loaded.laboratories.labs["Haunted mansion"].size == 0
     assert loaded.expenses == 9999999
Exemplo n.º 6
0
 def it_calculates_armory_increases():
     cov = Covenant()
     cov.armory.add_equipment("sword", "weapon", "expensive")
     assert cov.calculate_expenditures() == 0.05
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     cov.armory.add_equipment("Missle", "heavy siege", "expensive")
     assert cov.calculate_expenditures() == 1.05
Exemplo n.º 7
0
 def it_calculates_income_source_changes():
     cov = Covenant()
     cov.advance_year()
     assert cov.treasury == 150.0
     cov.income_sources["wishing well"] = 250
     cov.advance_year()
     assert cov.treasury == 500.0
Exemplo n.º 8
0
def create_covenant():
    print("C1:", session.get("new_covenant"))
    print("C1.1:", session.get("current_covenant"))
    if not session.get("new_covenant") and not session.get("current_covenant"):
        session["current_covenant"] = Covenant()
        session["new_covenant"] = True
        print("C1.5:", session.get("new_covenant"))

    if request.method == "GET":
        return render_template("create_covenant.html")
Exemplo n.º 9
0
def custom_covenant():
    cov = Covenant(
            name = "Lorem",
            season = "autumn",
            income_sources = {"source": 250, "source2": 100},
            tithes = {"Lord Farqua": 10},
            treasury = 75.5,
            laboratories = {},
            inflation_enabled = False,
            inflation = 10,
    )
    return cov
Exemplo n.º 10
0
 def it_initializes_with_default_values():
     cov = Covenant()
     assert cov.name == "Vernus"
     assert cov.season == "spring"
     assert cov.income_sources == {"source": 100}
     assert cov.tithes == {}
     assert cov.treasury == 50.0
     assert cov.covenfolken.covenfolk == {}
     assert cov.laboratories.labs == {}
     assert isinstance(cov.armory, Armory)
     assert cov.inflation_enabled is True
     assert cov.inflation == 0
Exemplo n.º 11
0
 def it_calculates_season_changes():
     cov = Covenant()
     folk = Covenfolk("george", "magi")
     cov.covenfolken.add_covenfolk(folk)
     assert cov.calculate_expenditures() == 5.5
     cov.change_season("autumn")
     assert cov.calculate_expenditures() == 11.0
Exemplo n.º 12
0
    def create_facilities_list(self):
        for facility in self.csv_facilities_list:
            covenants_list = [
                covenant for covenant in self.csv_covenants_list
                if covenant["bank_id"] == facility["bank_id"]
                and covenant["facility_id"] == facility["id"]
            ]
            covenant = Covenant()
            for x in covenants_list:
                covenant.add_banned_state(x["banned_state"])
                covenant.add_max_default_likelihood(
                    x["max_default_likelihood"])

            combine_facility = Facility(facility["id"], facility["amount"],
                                        facility["interest_rate"],
                                        facility["bank_id"], covenant)
            self.facilities_list.append(combine_facility)
            self.facilities_list.sort(key=lambda r: r.interest_rate)
Exemplo n.º 13
0
 def it_calculates_covenfolk_changes():
     cov = Covenant()
     folk = Covenfolk("george", "magi")
     cov.covenfolken.add_covenfolk(folk)
     assert cov.covenfolken.covenfolk["george"] == folk
Exemplo n.º 14
0
 def it_calculates_treaury_changes():
     cov = Covenant()
     cov.bank(10)
     assert cov.treasury == 60.0
     cov.bank(-100)
     assert cov.treasury == -40.0
Exemplo n.º 15
0
def semita():
    """A sample covenant laid out on page 68 of the covenants book."""
    cov = Covenant(
        name='Semita Errabunda',
        season='spring',
        income_sources={'trading': 100},
        treasury=100.0,
    )

    cov.laboratories.add_lab("Carolus", "Carolus", 0)
    cov.laboratories.add_lab("Mari", "Mari", 0)
    cov.laboratories.add_lab("Mortamis", "Mortamis", 0)
    cov.laboratories.add_lab("Tillitus", "Tillitus", 0)
    cov.laboratories.add_lab("Darius", "Darius", 2)

    crafters = [
        ("bookbinder", "crafter", "bookbinder", "writing", 6, "rare"),
        ("illuminator", "crafter", "illuminator", "writing", 6, "rare"),
        ("brewer1", "crafter", "brewer", "provisions", 6, "common"),
        ("brewer2", "crafter", "brewer", "provisions", 6, "common"),
        ("bass", "crafter", "carpenter", "buildings", 6, "common"),
        ("carp", "crafter", "carpenter", "buildings", 6, "common"),
        ("thatch", "crafter", "thatcher", "buildings", 6, "common"),
        ("fern", "crafter", "furniture_maker", "buildings", 6, "common"),
        ("smith", "crafter", "blacksmith", "consumables", 6, "common"),
        ("candle", "crafter", "candlemaker", "consumables", 6, "common"),
        ("tinker", "crafter", "tinker", "consumables", 6, "common"),
        ("spy", "crafter", "cobbler", "consumables", 6, "common"),
    ]

    for i in range(12):
        cov.covenfolken.add_covenfolk(*crafters[i])

    for i in range(4):
        cov.covenfolken.add_covenfolk(
            f"specialist{i}",
            "specialist",
        )

    for i in range(5):
        cov.covenfolken.add_covenfolk(
            f"dependant{i}",
            "dependant",
        )

    for i in range(20):
        cov.covenfolken.add_covenfolk(
            f"grog{i}",
            "grog",
        )

    for i in range(40):
        cov.covenfolken.add_covenfolk(
            f"laborer{i}",
            "laborer",
        )

    for i in range(16):
        cov.covenfolken.add_covenfolk(
            f"servant{i}",
            "servant",
        )

    for i in range(4):
        cov.covenfolken.add_covenfolk(
            f"teamster{i}",
            "teamster",
        )

    for i in range(4):
        cov.covenfolken.add_covenfolk(
            f"companion{i}",
            "companion",
        )

    for i in range(6):
        cov.covenfolken.add_covenfolk(
            f"horse{i}",
            "horse",
        )

    cov.covenfolken.add_covenfolk(
        "Carolus",
        "magi",
    )
    cov.covenfolken.add_covenfolk(
        "Darius",
        "magi",
    )
    cov.covenfolken.add_covenfolk(
        "Mari",
        "magi",
    )
    cov.covenfolken.add_covenfolk(
        "Moratamis",
        "magi",
    )
    cov.covenfolken.add_covenfolk(
        "Tillitus",
        "magi",
    )

    for i in range(20):
        cov.armory.add_equipment("scalemail", "full", "standard")
        cov.armory.add_equipment("longsword", "weapon", "standard")
        cov.armory.add_equipment("shield", "weapon", "standard")
        cov.armory.add_equipment("axe", "weapon", "standard")
        cov.armory.add_equipment("longsword", "weapon", "standard")

    cov.armory.add_equipment("Magic broom", "magic", "magic", "servants", 2,
                             "Does the work of 2 servants")

    cov.armory.add_equipment("Magic broom", "magic", "magic", "servants", 2,
                             "Does the work of 2 servants")

    return cov
Exemplo n.º 16
0
    def it_errors_when_bad_income_sources_are_added():
        with pytest.raises(TypeError):
            Covenant(income_sources = {"source": "abc"})

        with pytest.raises(TypeError):
            Covenant(income_sources = {1: 200})
Exemplo n.º 17
0
 def it_correctly_factors_cost_saving_caps_per_profession():
     cov = Covenant()
     cov.laboratories.add_lab("route 66", "aye", 5)
     assert cov.calculate_expenditures() == 15.0
     cov.covenfolken.add_covenfolk("worker", "crafter", "brickmaker", "laboratories", 200, "common")
     assert cov.calculate_expenditures() == 14.0
Exemplo n.º 18
0
 def it_correctly_capitalizes_season():
     cov = Covenant(season = "WINTER")
     assert cov.season == "winter"
Exemplo n.º 19
0
 def it_does_not_accept_custom_seaons():
     with pytest.raises(ValueError):
         Covenant(season = "flamebroiled")
Exemplo n.º 20
0
 def it_calculates_laboratory_changes():
     cov = Covenant()
     assert cov.calculate_expenditures() == 0.0
     cov.laboratories.add_lab("route 66")
     assert cov.calculate_expenditures() == 1.0
Exemplo n.º 21
0
 def it_can_verify_too_few_laborers_exist():
     cov = Covenant()
     cov.covenfolken.add_covenfolk("Arg", "magi")
     assert cov.meets_teamster_minimum() == False
     cov.covenfolken.add_covenfolk("Teamster", "teamster")
     assert cov.meets_teamster_minimum() == True
Exemplo n.º 22
0
 def it_correctly_calculates_inflation():
     cov = Covenant()
     cov.inflation = 0
     assert cov.calculate_inflation(100, 200) == 2
Exemplo n.º 23
0
 def it_does_not_increase_inflation_if_expenses_lowered():
     cov = Covenant()
     cov.inflation = 5
     assert cov.calculate_inflation(300, 150) == 5
Exemplo n.º 24
0
 def it_can_change_seasons():
     cov = Covenant()
     cov.change_season("autumn")
     assert cov.season == "autumn"