예제 #1
0
 def test_adjacent_countries(self):
     """Adjacent countries Ally Good"""
     app = Labyrinth(1, 1, self.set_up_test_scenario)
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3)
     app.get_country('Pakistan').make_good()
     app.get_country('Pakistan').make_neutral()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3)
     app.get_country('Pakistan').make_ally()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
     app.get_country('Iraq').make_good()
     app.get_country('Iraq').make_ally()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
예제 #2
0
    def test_iran_with_nothing_in_it(self):
        # Set up
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        iran = app.get_country("Iran")

        # Invoke
        summary = iran.summary()

        # Check
        self.assertEqual(summary, "Iran, Fair")
예제 #3
0
 def test_gwot_penalty(self):
     """GWOT Penalty"""
     app = Labyrinth(1, 1, self.set_up_test_scenario)
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3)
     app.get_country("United States").make_soft()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 2)
     app.get_country("Canada").make_hard()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 1)
     app.get_country("France").make_hard()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 0)
     app.get_country("Germany").make_hard()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 0)
예제 #4
0
    def test_non_muslim_country_with_no_markers(self):
        # Set up
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        israel = app.get_country("Israel")
        israel.plots = 2

        # Invoke
        summary = israel.summary()

        # Check
        self.assertEqual(summary, "Israel - Posture: Hard\n    Plots: 2")
예제 #5
0
    def test_country_without_nato_has_no_extra_troops(self):
        # Set up
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        iran = app.get_country("Iran")
        iran.change_troops(2)

        # Invoke
        troops = iran.troops()

        # Check
        self.assertEqual(2, troops)
예제 #6
0
    def test_scenario_1_makes_afghanistan_islamist_rule_adversary(self):
        # Set up
        app = Labyrinth(1, 1)
        afghanistan = app.get_country("Afghanistan")

        # Invoke
        alignment = afghanistan.alignment()
        governance = afghanistan.get_governance()

        # Check
        self.assertEqual(ADVERSARY, alignment)
        self.assertEqual(ISLAMIST_RULE, governance)
예제 #7
0
    def test_troops_disrupting_cadre_increases_prestige(self):
        # Set up
        app = Labyrinth(1, 1, test_user_input=["Egypt"])
        prestige_before = app.prestige
        app.get_country("Egypt").cadre = 1
        app.get_country("Egypt").troopCubes = 2

        # Invoke
        app.disrupt_cells_or_cadre()

        # Check
        self.assertEqual(app.prestige, prestige_before + 1)
예제 #8
0
    def test_iran_with_things_in_it(self):
        # Set up
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        iran = app.get_country("Iran")
        iran.plots = 3
        iran.activeCells = 4

        # Invoke
        summary = iran.summary()

        # Check
        self.assertEqual(summary, "Iran, Fair\n    Active: 4, Plots: 3")
예제 #9
0
    def test_country_with_nato_has_two_extra_troops(self):
        # Set up
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        iran = app.get_country("Iran")
        iran.change_troops(2)
        iran.markers.append("NATO")

        # Invoke
        troops = iran.troops()

        # Check
        self.assertEqual(4, troops)
예제 #10
0
    def test_two_countries_have_plots(self):
        # Set up
        app = Labyrinth(1, 1)
        actual_plot_countries = ["China", "Italy"]
        for country_name in actual_plot_countries:
            app.get_country(country_name).plots = 2

        # Invoke
        plot_countries = [c.name for c in app.get_plot_countries()]

        # Check
        plot_countries.sort()
        self.assertEqual(actual_plot_countries, plot_countries)
예제 #11
0
 def test_to_good(self):
     """Going to Good"""
     app = Labyrinth(1, 1, self.set_up_test_scenario)
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3)
     app.get_country("Gulf States").make_poor()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
     app.get_country("Gulf States").make_fair()
     app.get_country("Gulf States").make_neutral()
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
예제 #12
0
    def test_travel_second_box(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("Afghanistan").make_poor()
        app.get_country("Afghanistan").troopCubes = 1
        app.get_country("Afghanistan").sleeperCells = 4
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Afghanistan"])

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").make_besieged()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        dest = app.travel_destinations(2)
        self.assertEqual(dest, ["Gulf States", "Afghanistan"])
예제 #13
0
    def test_cell_placement_removes_cadre(self):
        # Set up
        mock_randomizer = mock(Randomizer())
        app = Labyrinth(1, 1, self.set_up_test_scenario, randomizer=mock_randomizer)
        country_name = "Iraq"
        when(mock_randomizer).pick_one(app.map.country_names()).thenReturn(country_name)
        when(mock_randomizer).roll_d6(1).thenReturn([4])  # Value doesn't matter
        country = app.get_country(country_name)
        country.cadre = 1
        sleepers_before = country.sleeperCells

        # Invoke
        app.handle_radicalization(1)

        # Assert
        sleepers_after = country.sleeperCells
        self.assertEqual(sleepers_after, sleepers_before + 1, "Radicalization should place a sleeper")
        self.assertEqual(country.cadre, 0, "Cell placement should have removed the cadre")
예제 #14
0
    def test_num_disruptable(self):
        # Set up
        app = Labyrinth(1, 1)
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").make_ally()
        app.get_country("Jordan").sleeperCells = 1
        app.get_country("Jordan").troopCubes = 2
        app.get_country("Libya").sleeperCells = 1
        app.get_country("Libya").troopCubes = 1  # Should not be enough

        # Invoke & assert
        self.assertEqual(app.num_disruptable(), 3)
예제 #15
0
    def _assert_adjust_posture(self,
                               user_input,
                               expected_posture,
                               expected_successful=True):
        # Set up
        app = Labyrinth(1,
                        1,
                        self.set_up_test_scenario,
                        test_user_input=[user_input])
        country = app.get_country(
            "France")  # Only non-muslim countries have a posture
        self.assertEqual(country.get_posture(), None)  # means "Untested"

        # Invoke
        successful = app.adjust_country_posture(country.name)

        # Check
        self.assertEqual(successful, expected_successful)
        self.assertEqual(country.get_posture(), expected_posture)
예제 #16
0
    def test_place_plot(self):
        # no cells
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 1)
        unusedOps = app.execute_plot(2, False, [1, 2])
        self.assertEqual(unusedOps, 2)
        unusedOps = app.execute_plot(3, True, [1, 2, 3])
        self.assertEqual(unusedOps, 3)

        # 1 cell in US
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 1
        unusedOps = app.execute_plot(1, True, [2])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.get_country("United States").plots, 0)

        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 1)
        self.assertEqual(app.get_country("United States").plots, 1)

        # 2 cells in us
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 2
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.get_country("United States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 2
        unusedOps = app.execute_plot(2, True, [1, 1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.get_country("United States").plots, 2)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 2
        unusedOps = app.execute_plot(2, True, [1, 2])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.get_country("United States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 2
        unusedOps = app.execute_plot(3, True, [1, 2, 3])
        self.assertEqual(unusedOps, 1)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.get_country("United States").plots, 1)

        # 3 cells in us
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 3
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.get_country("United States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 3
        unusedOps = app.execute_plot(2, True, [1, 1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.get_country("United States").plots, 2)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 3
        unusedOps = app.execute_plot(2, True, [1, 2])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.get_country("United States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 3
        unusedOps = app.execute_plot(2, True, [1, 2])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 2)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.get_country("United States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").sleeperCells = 3
        unusedOps = app.execute_plot(3, True, [1, 1, 3])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("United States").activeCells, 3)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.get_country("United States").plots, 2)

        # Low prestige, no GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 8
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 1)
        self.assertEqual(app.get_country("Israel").sleeperCells, 0)
        self.assertEqual(app.get_country("Israel").plots, 1)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 8
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        unusedOps = app.execute_plot(2, True, [1, 1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 1)
        self.assertEqual(app.get_country("Israel").sleeperCells, 0)
        self.assertEqual(app.get_country("Israel").plots, 1)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").activeCells, 1)
        self.assertEqual(app.get_country("Iraq").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.get_country("Israel").sleeperCells = 1
        app.get_country("United States").make_soft()
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 0)
        self.assertEqual(app.get_country("Israel").sleeperCells, 1)
        self.assertEqual(app.get_country("Israel").plots, 0)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").activeCells, 1)
        self.assertEqual(app.get_country("Iraq").plots, 1)

        # Low prestige, yes GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 0)
        self.assertEqual(app.get_country("Israel").sleeperCells, 1)
        self.assertEqual(app.get_country("Israel").plots, 0)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").plots, 1)

        # Funding section
        # Low prestige, yes GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 9
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(0)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 1)
        self.assertEqual(app.get_country("Israel").activeCells, 0)
        self.assertEqual(app.get_country("Israel").sleeperCells, 1)
        self.assertEqual(app.get_country("Israel").plots, 0)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        # Low prestige, yes GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 8
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 0
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(0)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 1)
        self.assertEqual(app.get_country("Israel").sleeperCells, 0)
        self.assertEqual(app.get_country("Israel").plots, 1)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        # Low prestige, yes GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 8
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(0)
        unusedOps = app.execute_plot(2, True, [1, 1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 1)
        self.assertEqual(app.get_country("Israel").sleeperCells, 0)
        self.assertEqual(app.get_country("Israel").plots, 1)
        self.assertEqual(app.get_country("Canada").plots, 1)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        # Low prestige, yes GWOT penalty
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.funding = 8
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(0)
        unusedOps = app.execute_plot(3, True, [1, 1, 1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 1)
        self.assertEqual(app.get_country("Israel").sleeperCells, 0)
        self.assertEqual(app.get_country("Israel").plots, 1)
        self.assertEqual(app.get_country("Canada").plots, 1)
        self.assertEqual(app.get_country("Iraq").plots, 1)

        # High prestige
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 4
        app.markers = ["Abu Sayyaf"]
        app.get_country("Israel").sleeperCells = 1
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        app.get_country("Iraq").troopCubes = 1
        app.get_country("Philippines").sleeperCells = 1
        app.get_country("Philippines").troopCubes = 1
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Israel").activeCells, 0)
        self.assertEqual(app.get_country("Israel").sleeperCells, 1)
        self.assertEqual(app.get_country("Israel").plots, 0)
        self.assertEqual(app.get_country("Canada").plots, 0)
        self.assertEqual(app.get_country("Iraq").plots, 0)
        self.assertEqual(app.get_country("Philippines").activeCells, 1)
        self.assertEqual(app.get_country("Philippines").sleeperCells, 0)
        self.assertEqual(app.get_country("Philippines").plots, 1)

        # priorities box
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.get_country("Israel").sleeperCells = 0
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Spain").sleeperCells = 0
        app.get_country("Iraq").make_good()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        app.get_country("Gulf States").make_fair()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").set_aid(1)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Iraq").plots, 0)
        self.assertEqual(app.get_country("Gulf States").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.get_country("Israel").sleeperCells = 0
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Spain").sleeperCells = 0
        app.get_country("Iraq").make_good()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        app.get_country("Gulf States").make_fair()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").set_aid(1)
        unusedOps = app.execute_plot(1, False, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Iraq").plots, 1)
        self.assertEqual(app.get_country("Gulf States").plots, 0)
예제 #17
0
    def test_travel_third_box(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("Jordan").make_fair()
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").sleeperCells = 1
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Jordan"])

        app.get_country("Gulf States").make_fair()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Gulf States").make_poor()
        app.get_country("Algeria/Tunisia").make_fair()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Jordan"])

        app.get_country("Germany").sleeperCells = 1
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Algeria/Tunisia"])
예제 #18
0
    def test_major_jihad_choice(self):
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertEqual(app.major_jihad_choice(3), False)  # 3 Ops
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 5
        app.get_country("Gulf States").activeCells = 4
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), "Gulf States")  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops
        app.get_country("Gulf States").make_fair()
        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), False)  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops
        app.get_country("Gulf States").make_good()
        self.assertEqual(app.major_jihad_choice(3), False)  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), False)  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops
        app.get_country("Gulf States").make_besieged()
        app.get_country("Gulf States").make_poor()
        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), "Gulf States")  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), "Gulf States")  # 1 Ops
        app.get_country("Gulf States").make_fair()
        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), "Gulf States")  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops
        app.get_country("Gulf States").make_good()
        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), False)  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 5
        app.get_country("Gulf States").activeCells = 4
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Afghanistan").make_poor()
        app.get_country("Afghanistan").sleeperCells = 3
        app.get_country("Afghanistan").activeCells = 3
        app.get_country("Afghanistan").troopCubes = 1
        app.get_country("Afghanistan").remove_besieged()

        self.assertEqual(app.major_jihad_choice(3), "Gulf States")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), "Gulf States")  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops

        app.get_country("Saudi Arabia").make_poor()
        app.get_country("Saudi Arabia").sleeperCells = 5
        app.get_country("Saudi Arabia").activeCells = 4
        app.get_country("Saudi Arabia").troopCubes = 4
        app.get_country("Saudi Arabia").remove_besieged()

        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops
        self.assertTrue(
            app.major_jihad_choice(3) in ["Gulf States",
                                          "Saudi Arabia"])  # 3 Ops

        app.get_country("Pakistan").make_poor()
        app.get_country("Pakistan").sleeperCells = 5
        app.get_country("Pakistan").activeCells = 4
        app.get_country("Pakistan").troopCubes = 4
        app.get_country("Pakistan").remove_besieged()

        self.assertEqual(app.major_jihad_choice(3), "Pakistan")  # 3 Ops
        self.assertEqual(app.major_jihad_choice(2), "Pakistan")  # 2 Ops
        self.assertEqual(app.major_jihad_choice(1), False)  # 1 Ops
예제 #19
0
    def test_execute_recruit(self):
        # Normal
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 1, [1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 1, [2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 13)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [1, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [2, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [1, 1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 3)
        self.assertEqual(app.cells, 12)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [1, 2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 13)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [2, 1, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [2, 2, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)  # Coherent
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 1, [1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 1, [2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 13)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [1, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 2, [2, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [1, 1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 3)
        self.assertEqual(app.cells, 12)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [1, 2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 13)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [2, 1, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 3, [2, 2, 2])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        # not enough cells
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 1
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 2
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 3, [2, 2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 2
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 3, [1, 2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 2
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 3, [1, 1, 2])
        self.assertEqual(unused_ops, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 0)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 1
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 1)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 0)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 2
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 0)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 3
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 1)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 3
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 2)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 5
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [2, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 4)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 5
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 2, [1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 2)
        self.assertEqual(app.cells, 3)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 5
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 3, [1, 1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 3)
        self.assertEqual(app.cells, 2)

        app = Labyrinth(1, 2, self.set_up_blank_test_scenario)
        app.cells = 4
        app.funding = 9
        unused_ops = app.execute_recruit("United States", 3, [1, 1, 1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 3)
        self.assertEqual(app.cells, 1)

        # IR RC
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        app.funding = 9
        app.get_country("Iraq").make_poor()
        unused_ops = app.execute_recruit("Iraq", 1, [4])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("Iraq").sleeperCells, 0)
        self.assertEqual(app.cells, 15)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        app.funding = 9
        app.get_country("Iraq").make_islamist_rule()
        unused_ops = app.execute_recruit("Iraq", 1, [6])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("Iraq").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        app.funding = 9
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").make_regime_change()
        unused_ops = app.execute_recruit("Iraq", 1, [6])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("Iraq").sleeperCells, 1)
        self.assertEqual(app.cells, 14)
예제 #20
0
    def test_handle_jihad(self):
        # Many Cells
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 5
        app.get_country("Gulf States").activeCells = 4
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 1)
        self.assertEqual(ops_left, 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 5
        app.get_country("Gulf States").activeCells = 4
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 2)
        self.assertEqual(ops_left, 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 5
        app.get_country("Gulf States").activeCells = 4
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 3)
        self.assertEqual(ops_left, 0)

        # 1 cell
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 1
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 1)
        self.assertEqual(ops_left, 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 1
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 2)
        self.assertEqual(ops_left, 1)
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 1
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 3)
        self.assertEqual(ops_left, 2)

        # 2 cell
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 1)
        self.assertEqual(ops_left, 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 2)
        self.assertEqual(ops_left, 0)
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 0
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 3)
        self.assertEqual(ops_left, 1)

        # 3 cell
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 1)
        self.assertEqual(ops_left, 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 2)
        self.assertEqual(ops_left, 0)
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("Gulf States").make_neutral()
        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").activeCells = 2
        app.get_country("Gulf States").troopCubes = 4
        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").make_regime_change()
        app.get_country("Gulf States").set_aid(1)
        ops_left = app.handle_jihad("Gulf States", 3)
        self.assertEqual(ops_left, 0)
예제 #21
0
 def test_aid(self):
     """Aid"""
     app = Labyrinth(1, 1, self.set_up_test_scenario)
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 3)
     app.get_country("Gulf States").set_aid(1)
     self.assertEqual(app.modified_woi_roll(3, "Gulf States"), 4)
예제 #22
0
    def test_resolve_muslim_iran_plots(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").set_aid(1)
        app.get_country("Iraq").plots = 1
        app.resolve_plot("Iraq", 1, 0, [], [], [], [3])
        self.assertEqual(app.funding, 6)
        self.assertTrue(app.get_country("Iraq").is_fair())
        self.assertEqual(app.get_country("Iraq").get_aid(), 1)
        app.resolve_plot("Iraq", 1, 0, [], [], [], [2])
        self.assertEqual(app.funding, 7)
        self.assertTrue(app.get_country("Iraq").is_poor())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_good()
        app.get_country("Iraq").set_aid(1)
        app.get_country("Iraq").plots = 1
        app.resolve_plot("Iraq", 3, 0, [], [], [], [3, 1, 2])
        self.assertEqual(app.funding, 7)
        self.assertTrue(app.get_country("Iraq").is_fair())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_good()
        app.get_country("Iraq").set_aid(1)
        app.get_country("Iraq").plots = 1
        app.resolve_plot("Iraq", "WMD", 0, [], [], [], [3, 1, 2])
        self.assertEqual(app.funding, 7)
        self.assertTrue(app.get_country("Iraq").is_fair())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").set_aid(0)
        app.get_country("Iraq").plots = 1
        app.resolve_plot("Iraq", 3, 0, [], [], [], [3, 3, 3])
        self.assertEqual(app.funding, 6)
        self.assertTrue(app.get_country("Iraq").is_poor())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iran").plots = 1
        app.resolve_plot("Iran", 3, 0, [], [], [], [3, 3, 3])
        self.assertEqual(app.funding, 6)
        self.assertTrue(app.get_country("Iran").is_fair())
        self.assertEqual(app.get_country("Iran").get_aid(), 0)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Iran").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").set_aid(0)
        app.get_country("Iraq").plots = 1
        app.get_country("Iraq").troopCubes = 1
        app.resolve_plot("Iraq", 3, 0, [], [], [], [3, 3, 3])
        self.assertEqual(app.funding, 6)
        self.assertTrue(app.get_country("Iraq").is_poor())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 6)
        self.assertEqual(app.get_country("Iraq").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").set_aid(0)
        app.get_country("Iraq").plots = 1
        app.get_country("Iraq").troopCubes = 1
        app.resolve_plot("Iraq", "WMD", 0, [], [], [], [3, 3, 3])
        self.assertEqual(app.funding, 6)
        self.assertTrue(app.get_country("Iraq").is_poor())
        self.assertEqual(app.get_country("Iraq").get_aid(), 0)
        self.assertEqual(app.prestige, 1)
        self.assertEqual(app.get_country("Iraq").plots, 0)
예제 #23
0
    def test_regime_change(self):
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_soft()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 4
        prestige_rolls = (3, 2, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 4
        prestige_rolls = (3, 2, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_poor())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 6)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 5)
        self.assertEqual(app.troops, 3)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 5
        prestige_rolls = (3, 2, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_fair())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 6)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 5)
        self.assertEqual(app.troops, 3)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 5
        prestige_rolls = (5, 2, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_fair())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 6)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 9)
        self.assertEqual(app.troops, 3)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 5
        prestige_rolls = (2, 6, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_fair())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 6)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 2)
        self.assertEqual(app.troops, 3)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 9)
        gov_roll = 5
        prestige_rolls = (6, 6, 5)
        app.handle_regime_change("Afghanistan", "track", 6, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_fair())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 6)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 12)
        self.assertEqual(app.troops, 3)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        app.troops -= 8
        app.get_country("Pakistan").change_troops(8)
        app.get_country("United States").make_hard()
        self.assertTrue(app.get_country("Afghanistan").is_islamist_rule())
        self.assertTrue(app.get_country("Afghanistan").is_adversary())
        self.assertEqual(app.get_country("Afghanistan").troops(), 0)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 4)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 0)
        self.assertFalse(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.troops, 1)
        self.assertEqual(app.get_country("Pakistan").troops(), 10)
        gov_roll = 5
        prestige_rolls = (6, 6, 5)
        app.handle_regime_change("Afghanistan", "Pakistan", 7, gov_roll,
                                 prestige_rolls)
        self.assertTrue(app.get_country("Afghanistan").is_fair())
        self.assertTrue(app.get_country("Afghanistan").is_ally())
        self.assertEqual(app.get_country("Afghanistan").troops(), 7)
        self.assertEqual(app.get_country("Afghanistan").sleeperCells, 0)
        self.assertEqual(app.get_country("Afghanistan").activeCells, 4)
        self.assertTrue(app.get_country("Afghanistan").is_regime_change())
        self.assertEqual(app.prestige, 12)
        self.assertEqual(app.troops, 1)
        self.assertEqual(app.get_country("Pakistan").troops(), 3)
예제 #24
0
    def test_resolve_us_plots(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").plots = 1
        app.get_country("United States").make_hard()
        app.resolve_plot("United States", 1, 4, [1, 6, 1], [], [], [])
        self.assertEqual(app.funding, 9)
        self.assertEqual(app.get_country("United States").get_posture(), SOFT)
        self.assertEqual(app.prestige, 6)
        self.assertEqual(app.get_country("United States").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").plots = 1
        app.get_country("United States").make_soft()
        app.resolve_plot("United States", 2, 4, [5, 6, 1], [], [], [])
        self.assertEqual(app.funding, 9)
        self.assertEqual(app.get_country("United States").get_posture(), SOFT)
        self.assertEqual(app.prestige, 8)
        self.assertEqual(app.get_country("United States").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("United States").plots = 1
        app.get_country("United States").make_soft()
        app.resolve_plot("United States", 3, 5, [5, 6, 4], [], [], [])
        self.assertEqual(app.funding, 9)
        self.assertEqual(app.get_country("United States").get_posture(), HARD)
        self.assertEqual(app.prestige, 11)
        self.assertEqual(app.get_country("United States").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        self.assertFalse(app.gameOver)
        app.get_country("United States").plots = 1
        app.get_country("United States").make_soft()
        app.resolve_plot("United States", "WMD", 0, [], [], [], [])
        self.assertEqual(app.get_country("United States").plots, 0)
        self.assertTrue(app.gameOver)
예제 #25
0
    def test_resolve_non_muslim_non_us_plots(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Germany").plots = 2
        app.resolve_plot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 2, 5, [], ["Spain", "Scandinavia"], [4, 5],
                         [])
        self.assertEqual(app.funding, 9)
        self.assertEqual(app.get_country("Germany").get_posture(), HARD)
        self.assertEqual(app.get_country("Spain").get_posture(), SOFT)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), HARD)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Canada").plots = 1
        app.resolve_plot("Canada", 2, 5, [], [], [], [])
        self.assertEqual(app.funding, 9)
        self.assertEqual(app.get_country("Canada").get_posture(), HARD)
        self.assertEqual(app.get_country("Spain").get_posture(), None)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), None)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Canada").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Russia").plots = 1
        app.resolve_plot("Russia", 2, 4, [], [], [], [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Russia").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), None)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), None)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Russia").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 1
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 3, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)
예제 #26
0
    def test_travel_multiple(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        dest = app.travel_destinations(3)

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").make_besieged()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Afghanistan").make_poor()
        app.get_country("Afghanistan").troopCubes = 1
        app.get_country("Afghanistan").sleeperCells = 4
        dest = app.travel_destinations(2)
        self.assertEqual(dest, ["Gulf States", "Afghanistan"])

        app.get_country("Jordan").make_fair()
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").sleeperCells = 1
        dest = app.travel_destinations(3)
        self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"])

        app.get_country("United States").make_hard()
        app.get_country("Canada").make_hard()
        app.get_country("United Kingdom").make_hard()
        app.get_country("Serbia").make_hard()
        app.get_country("India").make_hard()
        app.get_country("Scandinavia").make_hard()
        app.get_country("Eastern Europe").make_hard()
        app.get_country("Benelux").make_hard()
        app.get_country("Germany").make_hard()
        app.get_country("France").make_hard()
        app.get_country("Italy").make_hard()
        app.get_country("Spain").make_hard()
        app.get_country("Russia").make_hard()
        app.get_country("Caucasus").make_hard()
        app.get_country("China").make_hard()
        app.get_country("Kenya/Tanzania").make_hard()
        app.get_country("Thailand").make_hard()
        dest = app.travel_destinations(3)
        self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"])

        app.get_country("Gulf States").make_islamist_rule()
        dest = app.travel_destinations(3)
        self.assertEqual(dest, ["Afghanistan", "Jordan", "Philippines"])

        app.get_country("Kenya/Tanzania").remove_posture()
        phCount = 0
        ktCount = 0
        for i in range(100):
            dest = app.travel_destinations(3)
            if dest == ["Afghanistan", "Jordan", "Philippines"]:
                phCount += 1
            elif dest == ["Afghanistan", "Jordan", "Kenya/Tanzania"]:
                ktCount += 1
            self.assertTrue(
                dest == ["Afghanistan", "Jordan", "Philippines"]
                or dest == ["Afghanistan", "Jordan", "Kenya/Tanzania"])
        self.assertTrue(phCount > 0)
        self.assertTrue(ktCount > 0)

        app.get_country("United States").make_soft()
        app.get_country("China").make_soft()
        dest = app.travel_destinations(3)
        self.assertEqual(dest, ["Afghanistan", "Jordan", "China"])

        app.get_country("Benelux").make_soft()
        chinaCount = 0
        beneluxCount = 0
        for i in range(100):
            dest = app.travel_destinations(3)
            if dest == ["Afghanistan", "Jordan", "China"]:
                chinaCount += 1
            elif dest == ["Afghanistan", "Jordan", "Benelux"]:
                beneluxCount += 1
            self.assertTrue(dest == ["Afghanistan", "Jordan", "China"]
                            or dest == ["Afghanistan", "Jordan", "Benelux"])
        self.assertTrue(chinaCount > 0)
        self.assertTrue(beneluxCount > 0)
예제 #27
0
    def test_travel_from(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").make_besieged()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Lebanon").make_fair()
        app.get_country("Lebanon").activeCells = 1
        sources = app.travel_sources(dest, 1)
        self.assertEqual(sources, ["Lebanon"])

        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").activeCells = 1
        sources = app.travel_sources(dest, 1)
        self.assertEqual(sources, ["Iraq"])

        app.get_country("Egypt").make_fair()
        app.get_country("Egypt").activeCells = 1
        app.get_country("Egypt").make_regime_change()
        app.get_country("Egypt").troopCubes = 2
        sources = app.travel_sources(dest, 1)
        self.assertEqual(sources, ["Iraq"])
        app.get_country("Egypt").activeCells = 3
        sources = app.travel_sources(dest, 1)
        self.assertEqual(sources, ["Egypt"])

        app.get_country("Yemen").make_islamist_rule()
        app.get_country("Yemen").activeCells = 3
        app.get_country("Yemen").troopCubes = 2
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Egypt"])
        sources = app.travel_sources(dest, 2)
        self.assertEqual(sources, ["Yemen"])

        #multi

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").make_besieged()

        app.get_country("Afghanistan").make_poor()
        app.get_country("Afghanistan").troopCubes = 1
        app.get_country("Afghanistan").sleeperCells = 4

        app.get_country("Jordan").make_fair()
        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").sleeperCells = 1
        dest = app.travel_destinations(3)
        self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"])

        app.get_country("Lebanon").make_fair()
        app.get_country("Lebanon").activeCells = 1

        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").activeCells = 1

        app.get_country("Egypt").make_fair()
        app.get_country("Egypt").make_regime_change()
        app.get_country("Egypt").troopCubes = 2
        app.get_country("Egypt").activeCells = 3

        app.get_country("Yemen").make_islamist_rule()
        app.get_country("Yemen").activeCells = 4
        app.get_country("Yemen").troopCubes = 2
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Yemen", "Egypt", "Iraq"])

        app.get_country("Yemen").activeCells = 5
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Yemen", "Yemen", "Egypt"])

        app.get_country("Yemen").activeCells = 6
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Yemen", "Yemen", "Yemen"])

        app.get_country("Yemen").activeCells = 4
        sources = app.travel_sources(dest, 3)
        app.get_country("Egypt").activeCells = 4
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Yemen", "Egypt", "Egypt"])

        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").make_regime_change()
        app.get_country("Iraq").troopCubes = 2
        app.get_country("Iraq").activeCells = 4
        app.get_country("Egypt").activeCells = 0
        app.get_country("Egypt").sleeperCells = 4
        sources = app.travel_sources(dest, 3)
        self.assertEqual(sources, ["Yemen", "Iraq", "Iraq"])
예제 #28
0
    def test_fail_rolls(self):
        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(1, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(2, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(3, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(4, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 1)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(5, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_good())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Gulf States").is_fair())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)
        app.handle_muslim_woi(6, "Gulf States")
        self.assertTrue(app.get_country("Gulf States").is_good())
        self.assertTrue(app.get_country("Gulf States").is_ally())
        self.assertEqual(app.get_country("Gulf States").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(1, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(2, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(3, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(4, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 1)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(5, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_ally())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_neutral())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)
        app.handle_muslim_woi(6, "Pakistan")
        self.assertTrue(app.get_country("Pakistan").is_fair())
        self.assertTrue(app.get_country("Pakistan").is_ally())
        self.assertEqual(app.get_country("Pakistan").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(1, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(2, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(3, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(4, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 1)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(5, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_fair())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)

        app = Labyrinth(1, 1, self.set_up_test_scenario)
        self.assertTrue(app.get_country("Saudi Arabia").is_poor())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
        app.handle_muslim_woi(6, "Saudi Arabia")
        self.assertTrue(app.get_country("Saudi Arabia").is_fair())
        self.assertTrue(app.get_country("Saudi Arabia").is_ally())
        self.assertEqual(app.get_country("Saudi Arabia").get_aid(), 0)
예제 #29
0
    def test_travel_fourth_box(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("United States").make_hard()

        app.get_country("Canada").make_hard()
        app.get_country("United Kingdom").make_hard()
        app.get_country("Serbia").make_hard()
        app.get_country("India").make_hard()
        app.get_country("Scandinavia").make_hard()
        app.get_country("Eastern Europe").make_hard()
        app.get_country("Benelux").make_hard()
        app.get_country("Germany").make_hard()
        app.get_country("France").make_hard()
        app.get_country("Italy").make_hard()
        app.get_country("Spain").make_hard()
        app.get_country("Russia").make_hard()
        app.get_country("Caucasus").make_hard()
        app.get_country("China").make_hard()
        app.get_country("Kenya/Tanzania").make_hard()
        app.get_country("Thailand").make_hard()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Philippines"])
예제 #30
0
    def test_travel_first_box(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)

        app.get_country("Gulf States").make_poor()
        app.get_country("Gulf States").make_besieged()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Gulf States").remove_besieged()
        app.get_country("Gulf States").set_aid(1)
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Gulf States").set_aid(0)
        app.get_country("Gulf States").make_regime_change()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Gulf States").make_islamist_rule()
        app.get_country("Afghanistan").make_poor()
        app.get_country("Afghanistan").make_besieged()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Afghanistan"])

        app.get_country("Gulf States").make_poor()
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Gulf States"])

        app.get_country("Iraq").make_poor()
        app.get_country("Iraq").set_aid(1)
        iraqCount = 0
        gulfCount = 0
        for i in range(100):
            dest = app.travel_destinations(1)
            if dest == ["Gulf States"]:
                gulfCount += 1
            elif dest == ["Iraq"]:
                iraqCount += 1
            self.assertTrue(dest == ["Gulf States"] or dest == ["Iraq"])
        self.assertTrue(iraqCount > 0)
        self.assertTrue(gulfCount > 0)

        app.get_country("Pakistan").make_poor()
        app.get_country("Pakistan").set_aid(1)
        dest = app.travel_destinations(1)
        self.assertEqual(dest, ["Pakistan"])