├── requirements.txt ├── .gitignore ├── tests ├── test_scenarios.py ├── test_map.py ├── test_status.py ├── test_deck.py ├── test_reassessment_handler.py ├── test_alert_handler.py ├── test_names_of_matching_countries.py ├── test_is_adjacent.py ├── test_country_improvement.py ├── test_country_distance.py ├── test_radicalization.py ├── test_country_resources.py ├── test_adjust_country_posture.py ├── test_randomizer.py ├── test_schengen_travel_destinations.py ├── test_governance_class.py ├── test_withdraw_handler.py ├── test_disrupt_action.py ├── test_woi_roll_modifiers.py ├── test_major_jihad_choice.py ├── labyrinth_test_case.py ├── test_handle_jihad.py ├── test_woi_handler.py ├── test_regime_change_handler.py ├── test_travel.py ├── test_num_cells_available.py ├── test_resolve_plot.py ├── test_recruit.py ├── test_place_plots.py ├── test_minor_jihad_choice.py └── test_cards_100_to_120.py ├── CHANGELOG.txt ├── CONTRIBUTING.md └── README.txt /requirements.txt: -------------------------------------------------------------------------------- 1 | funcsigs==1.0.2 2 | mockito==1.0.12 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | suspend.lwot 2 | turn.*.lwot 3 | undo.lwot 4 | venv 5 | -------------------------------------------------------------------------------- /tests/test_scenarios.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | class ScenarioTest(LabyrinthTestCase): 5 | """Scenarios""" 6 | 7 | def test_scenario_4(self): 8 | app = Labyrinth(4, 1) 9 | self.assertTrue(app.map["United Kingdom"].posture == "Hard") -------------------------------------------------------------------------------- /tests/test_map.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class Map(LabyrinthTestCase): 6 | 7 | def testDeck(self): 8 | app = Labyrinth(1, 1, self.set_up_test_scenario) 9 | for country in app.map: 10 | for link in app.map[country].links: 11 | self.assertTrue(app.map[country] in link.links) -------------------------------------------------------------------------------- /tests/test_status.py: -------------------------------------------------------------------------------- 1 | from lwotai import Labyrinth 2 | from labyrinth_test_case import LabyrinthTestCase 3 | 4 | 5 | class StatusCommandTest(LabyrinthTestCase): 6 | """Tests the "status" command""" 7 | 8 | def test_status_of_blank_scenario(self): 9 | app = Labyrinth(1, 1, LabyrinthTestCase.set_up_blank_test_scenario) 10 | status = app.do_status(None) 11 | self.assertEqual(None, status) -------------------------------------------------------------------------------- /tests/test_deck.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class DeckTest(LabyrinthTestCase): 6 | """Deck tests""" 7 | 8 | def test_deck(self): 9 | """Test Deck""" 10 | app = Labyrinth(1, 1, self.set_up_test_scenario) 11 | for i in range(121): 12 | if i > 0: 13 | self.assertEqual(i, app.deck[str(i)].number) 14 | -------------------------------------------------------------------------------- /tests/test_reassessment_handler.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class ReassessmentHandlerTest(LabyrinthTestCase): 6 | 7 | def test_reassessment(self): 8 | app = Labyrinth(1, 1, self.set_up_test_scenario) 9 | self.assertEqual(app.map["United States"].posture, "Hard") 10 | app.handleReassessment() 11 | self.assertEqual(app.map["United States"].posture, "Soft") 12 | app.handleReassessment() 13 | self.assertEqual(app.map["United States"].posture, "Hard") -------------------------------------------------------------------------------- /tests/test_alert_handler.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class AlertHandlerTest(LabyrinthTestCase): 6 | """Test Alert""" 7 | 8 | def test_alert(self): 9 | app = Labyrinth(1, 1, self.set_up_test_scenario) 10 | self.assertEqual(app.map["Iraq"].plots, 2) 11 | app.handleAlert("Iraq") 12 | self.assertEqual(app.map["Iraq"].plots, 1) 13 | app.handleAlert("Iraq") 14 | self.assertEqual(app.map["Iraq"].plots, 0) 15 | app.handleAlert("Iraq") 16 | self.assertEqual(app.map["Iraq"].plots, 0) -------------------------------------------------------------------------------- /tests/test_names_of_matching_countries.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class NamesOfCountriesMatchingPredicateTest(LabyrinthTestCase): 6 | 7 | def test_schengen_countries(self): 8 | # Set up 9 | app = Labyrinth(1, 1, self.set_up_test_scenario) 10 | 11 | # Invoke 12 | schengen_countries = app.names_of_countries(lambda c: c.schengen) 13 | 14 | # Check 15 | self.assertEqual(schengen_countries, 16 | ['France', 'Italy', 'Germany', 'Spain', 'Scandinavia', 'Eastern Europe', 'Benelux']) -------------------------------------------------------------------------------- /tests/test_is_adjacent.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class IsAdjacent(LabyrinthTestCase): 6 | """Test isAdjacent""" 7 | 8 | def test_is_adjacent(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | self.assertTrue(app.isAdjacent("Iran", "Iraq")) 11 | self.assertTrue(app.isAdjacent("Germany", "Spain")) 12 | self.assertTrue(app.isAdjacent("Libya", "Italy")) 13 | self.assertTrue(app.isAdjacent("Benelux", "Russia")) 14 | self.assertTrue(app.isAdjacent("Lebanon", "France")) 15 | self.assertFalse(app.isAdjacent("United States", "Lebanon")) -------------------------------------------------------------------------------- /tests/test_country_improvement.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Country 3 | from lwotai import FAIR 4 | 5 | 6 | class CountryImprovementTest(LabyrinthTestCase): 7 | 8 | def test_improve_country_from_fair_to_good(self): 9 | # Set up 10 | country = Country(None, "Somewhere", "Sunni", None, FAIR, False, 0, 0, 0, 0, False, 2) 11 | country.aid = 4 12 | country.besieged = 1 13 | country.regimeChange = 1 14 | 15 | # Invoke 16 | country.improve_governance() 17 | 18 | # Assert 19 | self.assertTrue(country.is_good()) 20 | self.assertEqual(0, country.aid) 21 | self.assertEqual(0, country.besieged) 22 | self.assertEqual(0, country.regimeChange) -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Version 1.11082014.1 (by sgwestrip) 2 | 3 | Changed wording for Jihadist Ideology choices. The wording is now as per the rulebook. 4 | Added: release number displays when you first run the program. 5 | 6 | 7 | Version 1.06082014.2 (by ragam) 8 | 9 | Fix: cards #84/85 will now make you Shift Ally to Neutral, if possible. 10 | Fix: card #58 will now correctly Disrupt cadres if the event is in play 11 | 12 | 13 | Version 1.04082014.1 (by sgwestrip) 14 | 15 | Add: new Jihadist Ideology (9.7) Coherent. This was added to the rules after the initial printing. 16 | Fix: card #75 now displays 'Remove card from game' when it is played for the event. 17 | Fix: numerous typos 18 | Fix: remove all "Jihadist Activity Phase finished, enter plot command." as this is incorrect. It should always be done after the 2nd US Activity Phase. -------------------------------------------------------------------------------- /tests/test_country_distance.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class CountryDistanceTest(LabyrinthTestCase): 6 | """Test countryDistance""" 7 | __app = None 8 | 9 | def setUp(self): 10 | self.__app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 11 | 12 | def assert_distance(self, from_country, to_country, expected_distance): 13 | self.assertEqual(self.__app.countryDistance(from_country, to_country), expected_distance) 14 | 15 | def test_distance(self): 16 | self.assert_distance("Iran", "Iran", 0) 17 | self.assert_distance("Iran", "Iraq", 1) 18 | self.assert_distance("Iran", "Sudan", 4) 19 | self.assert_distance("Thailand", "United States", 2) 20 | self.assert_distance("Russia", "Morocco", 2) -------------------------------------------------------------------------------- /tests/test_radicalization.py: -------------------------------------------------------------------------------- 1 | from mockito import when, mock 2 | 3 | from labyrinth_test_case import LabyrinthTestCase 4 | from lwotai import Labyrinth, Randomizer 5 | 6 | 7 | class RadicalizationTest(LabyrinthTestCase): 8 | """Test Radicalization""" 9 | 10 | def test_cell_placement_removes_cadre(self): 11 | # Set up 12 | mock_randomizer = mock(Randomizer()) 13 | app = Labyrinth(1, 1, self.set_up_test_scenario, randomizer=mock_randomizer) 14 | country_name = "Iraq" 15 | when(mock_randomizer).pick_one(app.map.keys()).thenReturn(country_name) 16 | country = app.map[country_name] 17 | country.cadre = 1 18 | sleepers_before = country.sleeperCells 19 | 20 | # Invoke 21 | app.handleRadicalization(1) 22 | 23 | # Assert 24 | sleepers_after = country.sleeperCells 25 | self.assertEqual(sleepers_after, sleepers_before + 1, "Radicalization should place a sleeper") 26 | self.assertEqual(country.cadre, 0, "Cell placement should have removed the cadre") 27 | -------------------------------------------------------------------------------- /tests/test_country_resources.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class CountryResources(LabyrinthTestCase): 6 | """Test countryResources""" 7 | 8 | def test_country_resources(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | self.assertTrue(app.countryResources("Iraq") == 3) 11 | self.assertTrue(app.countryResources("Egypt") == 3) 12 | self.assertTrue(app.countryResources("Syria") == 2) 13 | self.assertTrue(app.countryResources("Lebanon") == 1) 14 | app.lapsing.append("Oil Price Spike") 15 | self.assertTrue(app.countryResources("Iraq") == 4) 16 | self.assertTrue(app.countryResources("Egypt") == 3) 17 | self.assertTrue(app.countryResources("Syria") == 2) 18 | self.assertTrue(app.countryResources("Lebanon") == 1) 19 | app.lapsing.append("Biometrics") 20 | app.lapsing.append("Oil Price Spike") 21 | self.assertTrue(app.countryResources("Iraq") == 5) 22 | self.assertTrue(app.countryResources("Egypt") == 3) 23 | self.assertTrue(app.countryResources("Syria") == 2) 24 | self.assertTrue(app.countryResources("Lebanon") == 1) -------------------------------------------------------------------------------- /tests/test_adjust_country_posture.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class AdjustCountryPosture(LabyrinthTestCase): 6 | """Tests the 'adjustCountryPosture' method""" 7 | 8 | def test_accepts_mixed_case_input(self): 9 | self._assert_adjust_posture("Hard", "Hard") 10 | 11 | def test_accepts_lower_case_input(self): 12 | self._assert_adjust_posture("hard", "Hard") 13 | 14 | def test_accepts_upper_case_input(self): 15 | self._assert_adjust_posture("HARD", "Hard") 16 | 17 | def test_set_soft_posture(self): 18 | self._assert_adjust_posture("soft", "Soft") 19 | 20 | def test_set_untested_posture(self): 21 | self._assert_adjust_posture("UNTESTED", "") 22 | 23 | def test_set_no_posture(self): 24 | self._assert_adjust_posture("bad input lalala", "", False) 25 | 26 | def _assert_adjust_posture(self, user_input, expected_posture, expected_successful=True): 27 | # Set up 28 | non_muslim_country = "France" # Only these have a posture 29 | app = Labyrinth(1, 1, self.set_up_test_scenario, test_user_input=[user_input]) 30 | self.assertEqual(app.map[non_muslim_country].posture, "") # means "Untested" 31 | 32 | # Invoke 33 | successful = app.adjustCountryPosture(non_muslim_country) 34 | 35 | # Check 36 | self.assertEqual(successful, expected_successful) 37 | self.assertEqual(app.map[non_muslim_country].posture, expected_posture) 38 | -------------------------------------------------------------------------------- /tests/test_randomizer.py: -------------------------------------------------------------------------------- 1 | from lwotai import Randomizer 2 | from unittest import TestCase 3 | 4 | 5 | class RandomizerTest(TestCase): 6 | 7 | def setUp(self): 8 | self.randomizer = Randomizer() 9 | 10 | def test_pick_no_items_from_empty_list(self): 11 | # Invoke 12 | picks = self.randomizer.pick(0, []) 13 | 14 | # Check 15 | self.assertEqual(picks, []) 16 | 17 | def test_pick_no_items_from_single_item_list(self): 18 | # Invoke 19 | picks = self.randomizer.pick(0, ['Bob']) 20 | 21 | # Check 22 | self.assertEqual(picks, []) 23 | 24 | def test_pick_one_items_from_single_item_list(self): 25 | # Invoke 26 | item = 'Bob' 27 | pick = self.randomizer.pick_one([item]) 28 | 29 | # Check 30 | self.assertEqual(pick, item) 31 | 32 | def test_pick_single_item_from_single_item_list(self): 33 | # Invoke 34 | picks = self.randomizer.pick(1, ['Bob']) 35 | 36 | # Check 37 | self.assertEqual(picks, ['Bob']) 38 | 39 | def test_pick_one_item_from_two_item_list(self): 40 | # Set up 41 | options = ['Bob', 'Carl'] 42 | 43 | # Invoke 44 | picks = self.randomizer.pick(1, options) 45 | 46 | # Check 47 | self.assertEqual(1, len(picks)) 48 | self.assertTrue(picks[0] in options) 49 | 50 | def test_roll_d6(self): 51 | # Invoke 52 | roll_count = 1000 53 | rolls = self.randomizer.roll_d6(roll_count) 54 | 55 | # Check 56 | self.assertEqual(len(rolls), roll_count) 57 | for roll in rolls: 58 | self.assertIn(roll, [1, 2, 3, 4, 5, 6]) 59 | -------------------------------------------------------------------------------- /tests/test_schengen_travel_destinations.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth, Randomizer 3 | from mockito import when, mock 4 | 5 | 6 | class TravelDestinationsForSchengenVisasTest(LabyrinthTestCase): 7 | 8 | def test_us_hard_and_one_unmarked_schengen(self): 9 | # Set up 10 | app = Labyrinth(1, 1, self.set_up_test_scenario) 11 | app.map["United States"].posture = "Hard" 12 | schengen_countries = self.schengen_countries(app) 13 | for schengen_country in schengen_countries[1:]: 14 | schengen_country.posture = "Anything" 15 | unmarked_country = schengen_countries[0] 16 | unmarked_country.posture = "" 17 | 18 | # Invoke 19 | destinations = app.travelDestinationsSchengenVisas() 20 | 21 | # Check 22 | expected_country = unmarked_country.name 23 | self.assertEqual(destinations, [expected_country, expected_country]) 24 | 25 | def test_us_hard_and_multiple_unmarked_schengens(self): 26 | # Set up 27 | mock_randomizer = mock(Randomizer()) 28 | app = Labyrinth(1, 1, self.set_up_test_scenario, randomizer=mock_randomizer) 29 | schengen_countries = self.schengen_countries(app) 30 | schengen_country_names = [country.name for country in schengen_countries] 31 | chosen_countries = ['c1', 'c2'] 32 | when(mock_randomizer).pick(2, schengen_country_names).thenReturn(chosen_countries) 33 | app.map["United States"].posture = "Hard" 34 | for country in schengen_countries: 35 | country.posture = "" 36 | 37 | # Invoke 38 | destinations = app.travelDestinationsSchengenVisas() 39 | 40 | # Check 41 | self.assertEqual(destinations, chosen_countries) -------------------------------------------------------------------------------- /tests/test_governance_class.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import FAIR 3 | from lwotai import Governance 4 | from lwotai import Governances 5 | 6 | 7 | class GovernanceClassTest(LabyrinthTestCase): 8 | 9 | def test_with_good_index(self): 10 | gov = Governances.with_index(2) 11 | self.assertEquals(FAIR, gov) 12 | 13 | def test_with_too_high_index(self): 14 | try: 15 | Governances.with_index(5) 16 | self.fail("Should have raised a ValueError") 17 | except ValueError as e: 18 | self.assertEquals("Invalid governance value - 5", e.message) 19 | 20 | def test_str(self): 21 | gov = Governance("Anarchy", 5, -2) 22 | self.assertEquals("Anarchy", str(gov)) 23 | 24 | def test_repr(self): 25 | gov = Governance("Anarchy", 5, -2) 26 | self.assertEquals('Governance("Anarchy", 5, -2)', repr(gov)) 27 | 28 | def test_equality(self): 29 | name = "some name" 30 | max_roll = 3 31 | gov1 = Governance(name, max_roll, 0) 32 | gov2 = Governance(name, max_roll, 0) 33 | self.assertEquals(gov1, gov2) 34 | 35 | def test_inequality_by_name(self): 36 | gov1 = Governance("name 1", 0, 1) 37 | gov2 = Governance("name 2", 0, 1) 38 | self.assertNotEqual(gov1, gov2) 39 | 40 | def test_inequality_by_max_roll(self): 41 | gov1 = Governance("name 1", 1, 2) 42 | gov2 = Governance("name 1", 2, 2) 43 | self.assertEqual(gov1, gov2) 44 | 45 | def test_successful_roll(self): 46 | max_roll = 4 47 | gov = Governance("some name", max_roll, 0) 48 | for roll in range(1, max_roll + 1): 49 | self.assertTrue(gov.is_success(roll)) 50 | for roll in range(max_roll + 1, max_roll + 2): 51 | self.assertFalse(gov.is_success(roll)) 52 | 53 | @staticmethod 54 | def test_instances_are_hashable(): 55 | gov = Governance("anything", 0, 0) 56 | hash(gov) -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | This file explains how to contribute work to this project. 3 | 4 | # Development setup 5 | 6 | 1. Install [Git](https://git-scm.com/). 7 | 1. Install [Python 2.7](https://www.python.org/downloads/). It's strongly recommended to use 8 | [virtualenv](https://virtualenv.pypa.io/en/stable/) to manage your Python environments, to prevent different Python 9 | projects on your machine from interfering with each other (because they use different versions of Python or different 10 | versions of the same library). 11 | 1. Install the required packages, e.g. Mockito, by running `pip install -r requirements.txt` from the project directory. 12 | 13 | # Getting the source code 14 | 15 | 1. Create a [GitHub](https://github.com/) account if you don't already have one. 16 | 1. [Create your own fork](https://help.github.com/articles/fork-a-repo/) of the [lwotai project](https://github.com/tharkad/lwotai). 17 | 1. Clone your fork onto your development machine. 18 | 19 | # Coding style 20 | 21 | This section provides guidance about how to structure and format the code. 22 | 23 | ## Formatting 24 | 25 | In general, try to adhere to the industry-standard [PEP 8](https://www.python.org/dev/peps/pep-0008/) style. This will 26 | make it easy for experienced Python developers to understand the code. 27 | 28 | ## Testing 29 | 30 | * Write unit tests for the code you are adding or changing. This allows other developers to refactor the code without 31 | fear of breaking it. 32 | * Where code seems untestable (e.g. it selects a country at random), refactor that code to remove the randomness, e.g. 33 | change the method to accept a mock randomizer whose behaviour you can control. 34 | * Use [Mockito](https://github.com/kaste/mockito-python) as the mocking library. 35 | 36 | # Submitting changes 37 | 38 | When your change is done, e.g. fully covered by unit tests and properly formatted, 39 | [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on GitHub. Mike (the project owner) 40 | will review your change and merge it into his fork if he's happy with it. 41 | -------------------------------------------------------------------------------- /tests/test_withdraw_handler.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class WithdrawHandlerTest(LabyrinthTestCase): 6 | """Test Withdraw""" 7 | 8 | def test_withdraw(self): 9 | app = Labyrinth(1, 1, self.set_up_test_scenario_2) 10 | app.map["United States"].posture = "Soft" 11 | self.assertTrue(app.map["Afghanistan"].is_good()) 12 | self.assertTrue(app.map["Afghanistan"].is_ally()) 13 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 14 | self.assertEqual(app.map["Afghanistan"].aid, 1) 15 | self.assertEqual(app.map["Afghanistan"].besieged, 0) 16 | self.assertEqual(app.map["Saudi Arabia"].troops(), 2) 17 | self.assertEqual(app.prestige, 7) 18 | self.assertEqual(app.troops, 3) 19 | prestigeRolls = (5, 2, 5) 20 | app.handleWithdraw("Afghanistan", "Saudi Arabia", 4, prestigeRolls) 21 | self.assertTrue(app.map["Afghanistan"].is_good()) 22 | self.assertTrue(app.map["Afghanistan"].is_ally()) 23 | self.assertEqual(app.map["Afghanistan"].troops(), 2) 24 | self.assertEqual(app.map["Afghanistan"].aid, 0) 25 | self.assertEqual(app.map["Afghanistan"].besieged, 1) 26 | self.assertEqual(app.map["Saudi Arabia"].troops(), 6) 27 | self.assertEqual(app.prestige, 9) 28 | self.assertEqual(app.troops, 3) 29 | 30 | app = Labyrinth(1, 1, self.set_up_test_scenario_2) 31 | app.map["United States"].posture = "Soft" 32 | self.assertTrue(app.map["Afghanistan"].is_good()) 33 | self.assertTrue(app.map["Afghanistan"].is_ally()) 34 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 35 | self.assertEqual(app.map["Afghanistan"].aid, 1) 36 | self.assertEqual(app.map["Afghanistan"].besieged, 0) 37 | self.assertEqual(app.map["Saudi Arabia"].troops(), 2) 38 | self.assertEqual(app.prestige, 7) 39 | self.assertEqual(app.troops, 3) 40 | prestigeRolls = (2, 3, 5) 41 | app.handleWithdraw("Afghanistan", "track", 5, prestigeRolls) 42 | self.assertTrue(app.map["Afghanistan"].is_good()) 43 | self.assertTrue(app.map["Afghanistan"].is_ally()) 44 | self.assertEqual(app.map["Afghanistan"].troops(), 1) 45 | self.assertEqual(app.map["Afghanistan"].aid, 0) 46 | self.assertEqual(app.map["Afghanistan"].besieged, 1) 47 | self.assertEqual(app.map["Saudi Arabia"].troops(), 2) 48 | self.assertEqual(app.prestige, 4) 49 | self.assertEqual(app.troops, 8) -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | LWOTai is a command line program. You need to have Python installed on your system to use it. You can run it from a command line as follows: python lwotai.py The most important thing to know is that the program does not track the deck, cards, hands or use of Reserves. You have to do that either with the board game or on Vassal. 2 | Set up the game as usual and pick the scenario and ideology. You will then be at the Command prompt. You can enter "?" to see the various commands. The most important are the "j" and "u" commands. When it is a player's turn, pick the card they will play and enter that command and the card number. For instance, it is the Jihadist turn at the beginning of the game. Turn over the top card of their hand and then enter j and that card number (e.g. j 22). The program will then tell you what the Jihadist did so you can update your map. It's the same with your plays using the u command. If more information is necessary the program will ask for it. 3 | 4 | When you use a card for Ops you then use the command for the operation you want. For instance if you want to disrupt, you enter "disrupt" at the Command prompt. The program will then ask what it needs to know about the disrupt. 5 | 6 | There are two timekeeping functions you have to remember to use. After each US Activity Phase, you must enter the "plot" command so that unblocked plots are handled. And at the end of a turn you must enter the "turn" command to handle all the end of turn activities. 7 | 8 | At any time you can use the "status" command to get a printout of the entire board position. And you can use the "history" command to see everything that has happened in the game. 9 | 10 | Thanks to Dave Horn for implementing the Save and Undo system. 11 | 12 | 1. A save game is created after every single command whether you want it or not. If someone screws up and closes the window, PC battery dies, crashes, whatever, no problem, load it up again and you will be asked if you want to load the suspended game. 13 | 14 | 2. Rollback files are created at the beginning of each turn. You can roll back to any previous turn using the 'roll' or 'rollback' command. You will be prompted to enter which turn you want to roll back to. 15 | 16 | 3. An undo file is created after every card played. The player can undo to the last card at any time (two exceptions) by typing 'undo'. Exceptions are when you load from a previously suspended game or after executing a rollback. The undo file is removed at that exact point to prevent the player from undoing themselves to some other game in the past! 17 | 18 | Thanks to Peter Shaw for implementing the Adjust system and for a bunch of bug fixes and cleanup. 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/test_disrupt_action.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Country 3 | from lwotai import FAIR 4 | from lwotai import Labyrinth 5 | 6 | 7 | class DisruptTest(LabyrinthTestCase): 8 | 9 | def test_cannot_disrupt_in_neutral_muslim_country_with_no_troops(self): 10 | # Set up 11 | country = Country(None, "Somewhere", "Shia-Mix", None, FAIR, False, 0, 0, 0, 0, False, 0) 12 | country.cadre = 1 13 | country.make_neutral() 14 | country.troopCubes = 0 15 | 16 | # Invoke & assert 17 | self.assertFalse(country.is_disruptable()) 18 | 19 | def test_cannot_disrupt_in_neutral_muslim_country_with_one_troop(self): 20 | # Set up 21 | country = Country(None, "Somewhere", "Shia-Mix", None, FAIR, False, 0, 0, 0, 0, False, 0) 22 | country.cadre = 1 23 | country.make_neutral() 24 | country.troopCubes = 1 25 | 26 | # Invoke & assert 27 | self.assertFalse(country.is_disruptable()) 28 | 29 | def test_can_disrupt_in_neutral_muslim_country_with_two_troops(self): 30 | # Set up 31 | country = Country(None, "Somewhere", "Shia-Mix", None, FAIR, False, 0, 0, 0, 0, False, 0) 32 | country.cadre = 1 33 | country.make_neutral() 34 | country.troopCubes = 2 35 | 36 | # Invoke & assert 37 | self.assertTrue(country.is_disruptable()) 38 | 39 | def test_can_disrupt_in_allied_muslim_country_with_no_troops(self): 40 | # Set up 41 | country = Country(None, "Somewhere", "Shia-Mix", None, FAIR, False, 0, 0, 0, 0, False, 0) 42 | country.cadre = 1 43 | country.make_ally() 44 | country.troopCubes = 0 45 | 46 | # Invoke & assert 47 | self.assertTrue(country.is_disruptable()) 48 | 49 | def test_can_disrupt_in_non_muslim_country_with_no_troops(self): 50 | # Set up 51 | country = Country(None, "Somewhere", "Non-Muslim", None, FAIR, False, 0, 0, 0, 0, False, 0) 52 | country.cadre = 1 53 | country.troopCubes = 0 54 | 55 | # Invoke & assert 56 | self.assertTrue(country.is_disruptable()) 57 | 58 | def test_num_disruptable(self): 59 | # Set up 60 | app = Labyrinth(1, 1) 61 | app.map["Canada"].sleeperCells = 1 62 | app.map["Iraq"].sleeperCells = 1 63 | app.map["Iraq"].make_ally() 64 | app.map["Jordan"].sleeperCells = 1 65 | app.map["Jordan"].troopCubes = 2 66 | app.map["Libya"].sleeperCells = 1 67 | app.map["Libya"].troopCubes = 1 # Should not be enough 68 | 69 | # Invoke & assert 70 | self.assertEqual(app.num_disruptable(), 3) -------------------------------------------------------------------------------- /tests/test_woi_roll_modifiers.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class WOIRollModifiers(LabyrinthTestCase): 6 | """Test War of Ideas Roll Modifiers""" 7 | 8 | def test_prestige(self): 9 | """Prestige""" 10 | app = Labyrinth(1, 1, self.set_up_test_scenario) 11 | app.prestige = 1 12 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 1) 13 | app.prestige = 2 14 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 1) 15 | app.prestige = 3 16 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 1) 17 | app.prestige = 4 18 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 2) 19 | app.prestige = 5 20 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 2) 21 | app.prestige = 6 22 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 2) 23 | app.prestige = 7 24 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 25 | app.prestige = 8 26 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 27 | app.prestige = 9 28 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 29 | app.prestige = 10 30 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 31 | app.prestige = 11 32 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 33 | app.prestige = 12 34 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 35 | 36 | def test_aid(self): 37 | """Aid""" 38 | app = Labyrinth(1, 1, self.set_up_test_scenario) 39 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 40 | app.map["Gulf States"].aid = 1 41 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 42 | 43 | def test_to_good(self): 44 | """Going to Good""" 45 | app = Labyrinth(1, 1, self.set_up_test_scenario) 46 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 47 | app.map["Gulf States"].make_poor() 48 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 49 | app.map["Gulf States"].make_fair() 50 | app.map["Gulf States"].make_neutral() 51 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 52 | 53 | def test_gwot_penalty(self): 54 | """GWOT Penalty""" 55 | app = Labyrinth(1, 1, self.set_up_test_scenario) 56 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 57 | app.map["United States"].posture = "Soft" 58 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 2) 59 | app.map["Canada"].posture = "Hard" 60 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 1) 61 | app.map["France"].posture = "Hard" 62 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 0) 63 | app.map["Germany"].posture = "Hard" 64 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 0) 65 | 66 | def test_adjacent_countries(self): 67 | """Adjacent countries Ally Good""" 68 | app = Labyrinth(1, 1, self.set_up_test_scenario) 69 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 70 | app.map['Pakistan'].make_good() 71 | app.map['Pakistan'].make_neutral() 72 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 3) 73 | app.map['Pakistan'].make_ally() 74 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) 75 | app.map['Iraq'].make_good() 76 | app.map['Iraq'].make_ally() 77 | self.assertEqual(app.modifiedWoIRoll(3, "Gulf States"), 4) -------------------------------------------------------------------------------- /tests/test_major_jihad_choice.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class MajorJihadChoice(LabyrinthTestCase): 6 | """Major Jihad possible?""" 7 | # For Major Jihad to be possible you need: 8 | # - A muslim country 9 | # - Not under Islamist Rule 10 | # - with at least 5 more cells than troops 11 | # - At least 2 rolls if the country is poor and not besieged 12 | # - At least 1 roll if the country is poor and is besieged 13 | # - At least 3 rolls if the country is fair and not besieged 14 | # - At least 2 rolls if the country is fair and is besieged 15 | # - At least 3 rolls if the country is good and is besieged 16 | # - NOT possible if the country is good and not besieged 17 | 18 | def test_major_jihad_choice(self): 19 | app = Labyrinth(1, 1, self.set_up_test_scenario) 20 | self.assertEqual(app.majorJihadChoice(3), False) # 3 Ops 21 | app.map["Gulf States"].make_poor() 22 | app.map["Gulf States"].sleeperCells = 5 23 | app.map["Gulf States"].activeCells = 4 24 | app.map["Gulf States"].troopCubes = 4 25 | app.map["Gulf States"].besieged = 0 26 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 27 | self.assertEqual(app.majorJihadChoice(2), "Gulf States") # 2 Ops 28 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 29 | app.map["Gulf States"].make_fair() 30 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 31 | self.assertEqual(app.majorJihadChoice(2), False) # 2 Ops 32 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 33 | app.map["Gulf States"].make_good() 34 | self.assertEqual(app.majorJihadChoice(3), False) # 3 Ops 35 | self.assertEqual(app.majorJihadChoice(2), False) # 2 Ops 36 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 37 | app.map["Gulf States"].besieged = 1 38 | app.map["Gulf States"].make_poor() 39 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 40 | self.assertEqual(app.majorJihadChoice(2), "Gulf States") # 2 Ops 41 | self.assertEqual(app.majorJihadChoice(1), "Gulf States") # 1 Ops 42 | app.map["Gulf States"].make_fair() 43 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 44 | self.assertEqual(app.majorJihadChoice(2), "Gulf States") # 2 Ops 45 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 46 | app.map["Gulf States"].make_good() 47 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 48 | self.assertEqual(app.majorJihadChoice(2), False) # 2 Ops 49 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 50 | 51 | app.map["Gulf States"].make_poor() 52 | app.map["Gulf States"].sleeperCells = 5 53 | app.map["Gulf States"].activeCells = 4 54 | app.map["Gulf States"].troopCubes = 4 55 | app.map["Gulf States"].besieged = 0 56 | app.map["Afghanistan"].make_poor() 57 | app.map["Afghanistan"].sleeperCells = 3 58 | app.map["Afghanistan"].activeCells = 3 59 | app.map["Afghanistan"].troopCubes = 1 60 | app.map["Afghanistan"].besieged = 0 61 | 62 | self.assertEqual(app.majorJihadChoice(3), "Gulf States") # 3 Ops 63 | self.assertEqual(app.majorJihadChoice(2), "Gulf States") # 2 Ops 64 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops 65 | 66 | app.map["Saudi Arabia"].make_poor() 67 | app.map["Saudi Arabia"].sleeperCells = 5 68 | app.map["Saudi Arabia"].activeCells = 4 69 | app.map["Saudi Arabia"].troopCubes = 4 70 | app.map["Saudi Arabia"].besieged = 0 71 | 72 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 73 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 74 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 75 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 76 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 77 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 78 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 79 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 80 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 81 | self.assertTrue(app.majorJihadChoice(3) in ["Gulf States", "Saudi Arabia"]) # 3 Ops 82 | 83 | app.map["Pakistan"].make_poor() 84 | app.map["Pakistan"].sleeperCells = 5 85 | app.map["Pakistan"].activeCells = 4 86 | app.map["Pakistan"].troopCubes = 4 87 | app.map["Pakistan"].besieged = 0 88 | 89 | self.assertEqual(app.majorJihadChoice(3), "Pakistan") # 3 Ops 90 | self.assertEqual(app.majorJihadChoice(2), "Pakistan") # 2 Ops 91 | self.assertEqual(app.majorJihadChoice(1), False) # 1 Ops -------------------------------------------------------------------------------- /tests/labyrinth_test_case.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | class LabyrinthTestCase(unittest.TestCase): 4 | """Assertions, setup functions, etc. for reuse by subclasses""" 5 | 6 | def assertCells(self, app, country, expected_cells, include_sadr = False): 7 | """Asserts that the given country contains the given number of cells""" 8 | self.assertEqual(expected_cells, app.map[country].totalCells(include_sadr)) 9 | 10 | def assert_new_messages(self, app, message_count_before, expected_messages): 11 | expected_message_count = len(expected_messages) 12 | self.assertEquals(len(app.history), message_count_before + expected_message_count) 13 | new_messages = app.history[-expected_message_count:] 14 | self.assertEquals(new_messages, expected_messages) 15 | 16 | @staticmethod 17 | def schengen_countries(app): 18 | """Returns the Country objects for the Schengen countries""" 19 | return [app.map[country] for country in app.map if app.map[country].schengen] 20 | 21 | @staticmethod 22 | def set_up_test_scenario(app): 23 | app.prestige = 7 24 | app.troops = 9 25 | app.funding = 5 26 | app.cells = 11 27 | app.map["Libya"].make_poor() 28 | app.map["Libya"].make_adversary() 29 | app.map["Syria"].make_fair() 30 | app.map["Syria"].make_adversary() 31 | app.map["Iraq"].make_poor() 32 | app.map["Iraq"].make_adversary() 33 | app.map["Iraq"].plots = 2 34 | app.map["Saudi Arabia"].make_poor() 35 | app.map["Saudi Arabia"].make_ally() 36 | app.map["Saudi Arabia"].troopCubes = 2 37 | app.map["Pakistan"].make_fair() 38 | app.map["Pakistan"].make_neutral() 39 | app.map["Pakistan"].troopCubes = 2 40 | app.map["Pakistan"].activeCells = 4 41 | app.map["Gulf States"].make_fair() 42 | app.map["Gulf States"].make_ally() 43 | app.map["Gulf States"].troopCubes = 4 44 | app.map["Gulf States"].sleeperCells = 1 45 | app.map["Gulf States"].activeCells = 4 46 | app.map["Afghanistan"].make_islamist_rule() 47 | app.map["Afghanistan"].make_adversary() 48 | app.map["Afghanistan"].sleeperCells = 4 49 | app.map["Somalia"].besieged = 1 50 | app.map["United States"].posture = "Hard" 51 | 52 | @staticmethod 53 | def set_up_test_scenario_2(app): 54 | app.prestige = 7 55 | app.troops = 3 56 | app.funding = 9 57 | app.cells = 11 58 | app.map["Libya"].make_poor() 59 | app.map["Libya"].make_adversary() 60 | app.map["Syria"].make_fair() 61 | app.map["Syria"].make_adversary() 62 | app.map["Iraq"].make_poor() 63 | app.map["Iraq"].make_adversary() 64 | app.map["Iraq"].plots = 2 65 | app.map["Saudi Arabia"].make_poor() 66 | app.map["Saudi Arabia"].make_ally() 67 | app.map["Saudi Arabia"].troopCubes = 2 68 | app.map["Pakistan"].make_fair() 69 | app.map["Pakistan"].make_neutral() 70 | app.map["Pakistan"].troopCubes = 2 71 | app.map["Pakistan"].activeCells = 4 72 | app.map["Gulf States"].make_fair() 73 | app.map["Gulf States"].make_ally() 74 | app.map["Gulf States"].troopCubes = 2 75 | app.map["Gulf States"].sleeperCells = 1 76 | app.map["Gulf States"].activeCells = 4 77 | app.map["Afghanistan"].make_good() 78 | app.map["Afghanistan"].make_ally() 79 | app.map["Afghanistan"].activeCells = 4 80 | app.map["Afghanistan"].regimeChange = 1 81 | app.map["Afghanistan"].troopCubes = 6 82 | app.map["Afghanistan"].aid = 1 83 | app.map["Afghanistan"].besieged = 0 84 | app.map["Somalia"].besieged = 1 85 | app.map["United States"].posture = "Hard" 86 | 87 | @staticmethod 88 | def set_up_test_scenario_3(app): 89 | app.prestige = 7 90 | app.troops = 9 91 | app.funding = 5 92 | app.cells = 11 93 | app.map["Libya"].make_poor() 94 | app.map["Libya"].make_adversary() 95 | app.map["Syria"].make_fair() 96 | app.map["Syria"].make_adversary() 97 | app.map["Iraq"].make_poor() 98 | app.map["Iraq"].make_adversary() 99 | app.map["Iraq"].plots = 2 100 | app.map["Saudi Arabia"].make_poor() 101 | app.map["Saudi Arabia"].make_ally() 102 | app.map["Saudi Arabia"].troopCubes = 2 103 | app.map["Pakistan"].make_fair() 104 | app.map["Pakistan"].make_neutral() 105 | app.map["Pakistan"].troopCubes = 2 106 | app.map["Pakistan"].activeCells = 4 107 | app.map["Gulf States"].make_fair() 108 | app.map["Gulf States"].make_ally() 109 | app.map["Gulf States"].troopCubes = 4 110 | app.map["Gulf States"].sleeperCells = 1 111 | app.map["Gulf States"].activeCells = 4 112 | app.map["Afghanistan"].make_islamist_rule() 113 | app.map["Afghanistan"].make_adversary() 114 | app.map["Afghanistan"].sleeperCells = 4 115 | app.map["Somalia"].besieged = 1 116 | app.map["United States"].posture = "Hard" 117 | app.map["France"].posture = "Hard" 118 | app.map["France"].cadre = 1 119 | app.map["Spain"].posture = "Soft" 120 | app.map["Spain"].sleeperCells = 1 121 | app.map["Germany"].posture = "Hard" 122 | app.map["Germany"].activeCells = 1 123 | app.map["Germany"].sleeperCells = 1 124 | 125 | @staticmethod 126 | def set_up_blank_test_scenario(app): 127 | app.prestige = 7 128 | app.troops = 9 129 | app.funding = 5 130 | app.cells = 11 131 | -------------------------------------------------------------------------------- /tests/test_handle_jihad.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class HandleJihadTest(LabyrinthTestCase): 6 | """Test handleJihad""" 7 | 8 | def test_handle_jihad(self): 9 | # Many Cells 10 | app = Labyrinth(1, 1, self.set_up_test_scenario) 11 | app.map["Gulf States"].make_neutral() 12 | app.map["Gulf States"].make_poor() 13 | app.map["Gulf States"].sleeperCells = 5 14 | app.map["Gulf States"].activeCells = 4 15 | app.map["Gulf States"].troopCubes = 4 16 | app.map["Gulf States"].besieged = 0 17 | app.map["Gulf States"].regimeChange = 1 18 | app.map["Gulf States"].aid = 1 19 | opsLeft = app.handleJihad("Gulf States", 1) 20 | self.assertEqual(opsLeft, 0) 21 | 22 | app = Labyrinth(1, 1, self.set_up_test_scenario) 23 | app.map["Gulf States"].make_neutral() 24 | app.map["Gulf States"].make_poor() 25 | app.map["Gulf States"].sleeperCells = 5 26 | app.map["Gulf States"].activeCells = 4 27 | app.map["Gulf States"].troopCubes = 4 28 | app.map["Gulf States"].besieged = 0 29 | app.map["Gulf States"].regimeChange = 1 30 | app.map["Gulf States"].aid = 1 31 | opsLeft = app.handleJihad("Gulf States", 2) 32 | self.assertEqual(opsLeft, 0) 33 | 34 | app = Labyrinth(1, 1, self.set_up_test_scenario) 35 | app.map["Gulf States"].make_neutral() 36 | app.map["Gulf States"].make_poor() 37 | app.map["Gulf States"].sleeperCells = 5 38 | app.map["Gulf States"].activeCells = 4 39 | app.map["Gulf States"].troopCubes = 4 40 | app.map["Gulf States"].besieged = 0 41 | app.map["Gulf States"].regimeChange = 1 42 | app.map["Gulf States"].aid = 1 43 | opsLeft = app.handleJihad("Gulf States", 3) 44 | self.assertEqual(opsLeft, 0) 45 | 46 | # 1 cell 47 | app = Labyrinth(1, 1, self.set_up_test_scenario) 48 | app.map["Gulf States"].make_neutral() 49 | app.map["Gulf States"].make_poor() 50 | app.map["Gulf States"].sleeperCells = 0 51 | app.map["Gulf States"].activeCells = 1 52 | app.map["Gulf States"].troopCubes = 4 53 | app.map["Gulf States"].besieged = 0 54 | app.map["Gulf States"].regimeChange = 1 55 | app.map["Gulf States"].aid = 1 56 | opsLeft = app.handleJihad("Gulf States", 1) 57 | self.assertEqual(opsLeft, 0) 58 | 59 | app = Labyrinth(1, 1, self.set_up_test_scenario) 60 | app.map["Gulf States"].make_neutral() 61 | app.map["Gulf States"].make_poor() 62 | app.map["Gulf States"].sleeperCells = 0 63 | app.map["Gulf States"].activeCells = 1 64 | app.map["Gulf States"].troopCubes = 4 65 | app.map["Gulf States"].besieged = 0 66 | app.map["Gulf States"].regimeChange = 1 67 | app.map["Gulf States"].aid = 1 68 | opsLeft = app.handleJihad("Gulf States", 2) 69 | self.assertEqual(opsLeft, 1) 70 | app = Labyrinth(1, 1, self.set_up_test_scenario) 71 | app.map["Gulf States"].make_neutral() 72 | app.map["Gulf States"].make_poor() 73 | app.map["Gulf States"].sleeperCells = 0 74 | app.map["Gulf States"].activeCells = 1 75 | app.map["Gulf States"].troopCubes = 4 76 | app.map["Gulf States"].besieged = 0 77 | app.map["Gulf States"].regimeChange = 1 78 | app.map["Gulf States"].aid = 1 79 | opsLeft = app.handleJihad("Gulf States", 3) 80 | self.assertEqual(opsLeft, 2) 81 | 82 | # 2 cell 83 | app = Labyrinth(1, 1, self.set_up_test_scenario) 84 | app.map["Gulf States"].make_neutral() 85 | app.map["Gulf States"].make_poor() 86 | app.map["Gulf States"].sleeperCells = 0 87 | app.map["Gulf States"].activeCells = 2 88 | app.map["Gulf States"].troopCubes = 4 89 | app.map["Gulf States"].besieged = 0 90 | app.map["Gulf States"].regimeChange = 1 91 | app.map["Gulf States"].aid = 1 92 | opsLeft = app.handleJihad("Gulf States", 1) 93 | self.assertEqual(opsLeft, 0) 94 | 95 | app = Labyrinth(1, 1, self.set_up_test_scenario) 96 | app.map["Gulf States"].make_neutral() 97 | app.map["Gulf States"].make_poor() 98 | app.map["Gulf States"].sleeperCells = 0 99 | app.map["Gulf States"].activeCells = 2 100 | app.map["Gulf States"].troopCubes = 4 101 | app.map["Gulf States"].besieged = 0 102 | app.map["Gulf States"].regimeChange = 1 103 | app.map["Gulf States"].aid = 1 104 | opsLeft = app.handleJihad("Gulf States", 2) 105 | self.assertEqual(opsLeft, 0) 106 | app = Labyrinth(1, 1, self.set_up_test_scenario) 107 | app.map["Gulf States"].make_neutral() 108 | app.map["Gulf States"].make_poor() 109 | app.map["Gulf States"].sleeperCells = 0 110 | app.map["Gulf States"].activeCells = 2 111 | app.map["Gulf States"].troopCubes = 4 112 | app.map["Gulf States"].besieged = 0 113 | app.map["Gulf States"].regimeChange = 1 114 | app.map["Gulf States"].aid = 1 115 | opsLeft = app.handleJihad("Gulf States", 3) 116 | self.assertEqual(opsLeft, 1) 117 | 118 | # 3 cell 119 | app = Labyrinth(1, 1, self.set_up_test_scenario) 120 | app.map["Gulf States"].make_neutral() 121 | app.map["Gulf States"].make_poor() 122 | app.map["Gulf States"].sleeperCells = 1 123 | app.map["Gulf States"].activeCells = 2 124 | app.map["Gulf States"].troopCubes = 4 125 | app.map["Gulf States"].besieged = 0 126 | app.map["Gulf States"].regimeChange = 1 127 | app.map["Gulf States"].aid = 1 128 | opsLeft = app.handleJihad("Gulf States", 1) 129 | self.assertEqual(opsLeft, 0) 130 | 131 | app = Labyrinth(1, 1, self.set_up_test_scenario) 132 | app.map["Gulf States"].make_neutral() 133 | app.map["Gulf States"].make_poor() 134 | app.map["Gulf States"].sleeperCells = 1 135 | app.map["Gulf States"].activeCells = 2 136 | app.map["Gulf States"].troopCubes = 4 137 | app.map["Gulf States"].besieged = 0 138 | app.map["Gulf States"].regimeChange = 1 139 | app.map["Gulf States"].aid = 1 140 | opsLeft = app.handleJihad("Gulf States", 2) 141 | self.assertEqual(opsLeft, 0) 142 | app = Labyrinth(1, 1, self.set_up_test_scenario) 143 | app.map["Gulf States"].make_neutral() 144 | app.map["Gulf States"].make_poor() 145 | app.map["Gulf States"].sleeperCells = 1 146 | app.map["Gulf States"].activeCells = 2 147 | app.map["Gulf States"].troopCubes = 4 148 | app.map["Gulf States"].besieged = 0 149 | app.map["Gulf States"].regimeChange = 1 150 | app.map["Gulf States"].aid = 1 151 | opsLeft = app.handleJihad("Gulf States", 3) 152 | self.assertEqual(opsLeft, 0) -------------------------------------------------------------------------------- /tests/test_woi_handler.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class WarOfIdeasHandlerTest(LabyrinthTestCase): 6 | """Test War of Ideas Handler""" 7 | 8 | def test_fail_rolls(self): 9 | app = Labyrinth(1, 1, self.set_up_test_scenario) 10 | self.assertTrue(app.map["Gulf States"].is_fair()) 11 | self.assertTrue(app.map["Gulf States"].is_ally()) 12 | self.assertEqual(app.map["Gulf States"].aid, 0) 13 | app.handleMuslimWoI(1, "Gulf States") 14 | self.assertTrue(app.map["Gulf States"].is_fair()) 15 | self.assertTrue(app.map["Gulf States"].is_ally()) 16 | self.assertEqual(app.map["Gulf States"].aid, 0) 17 | 18 | app = Labyrinth(1, 1, self.set_up_test_scenario) 19 | self.assertTrue(app.map["Gulf States"].is_fair()) 20 | self.assertTrue(app.map["Gulf States"].is_ally()) 21 | self.assertEqual(app.map["Gulf States"].aid, 0) 22 | app.handleMuslimWoI(2, "Gulf States") 23 | self.assertTrue(app.map["Gulf States"].is_fair()) 24 | self.assertTrue(app.map["Gulf States"].is_ally()) 25 | self.assertEqual(app.map["Gulf States"].aid, 0) 26 | 27 | app = Labyrinth(1, 1, self.set_up_test_scenario) 28 | self.assertTrue(app.map["Gulf States"].is_fair()) 29 | self.assertTrue(app.map["Gulf States"].is_ally()) 30 | self.assertEqual(app.map["Gulf States"].aid, 0) 31 | app.handleMuslimWoI(3, "Gulf States") 32 | self.assertTrue(app.map["Gulf States"].is_fair()) 33 | self.assertTrue(app.map["Gulf States"].is_ally()) 34 | self.assertEqual(app.map["Gulf States"].aid, 0) 35 | 36 | app = Labyrinth(1, 1, self.set_up_test_scenario) 37 | self.assertTrue(app.map["Gulf States"].is_fair()) 38 | self.assertTrue(app.map["Gulf States"].is_ally()) 39 | self.assertEqual(app.map["Gulf States"].aid, 0) 40 | app.handleMuslimWoI(4, "Gulf States") 41 | self.assertTrue(app.map["Gulf States"].is_fair()) 42 | self.assertTrue(app.map["Gulf States"].is_ally()) 43 | self.assertEqual(app.map["Gulf States"].aid, 1) 44 | 45 | app = Labyrinth(1, 1, self.set_up_test_scenario) 46 | self.assertTrue(app.map["Gulf States"].is_fair()) 47 | self.assertTrue(app.map["Gulf States"].is_ally()) 48 | self.assertEqual(app.map["Gulf States"].aid, 0) 49 | app.handleMuslimWoI(5, "Gulf States") 50 | self.assertTrue(app.map["Gulf States"].is_good()) 51 | self.assertTrue(app.map["Gulf States"].is_ally()) 52 | self.assertEqual(app.map["Gulf States"].aid, 0) 53 | 54 | app = Labyrinth(1, 1, self.set_up_test_scenario) 55 | self.assertTrue(app.map["Gulf States"].is_fair()) 56 | self.assertTrue(app.map["Gulf States"].is_ally()) 57 | self.assertEqual(app.map["Gulf States"].aid, 0) 58 | app.handleMuslimWoI(6, "Gulf States") 59 | self.assertTrue(app.map["Gulf States"].is_good()) 60 | self.assertTrue(app.map["Gulf States"].is_ally()) 61 | self.assertEqual(app.map["Gulf States"].aid, 0) 62 | 63 | app = Labyrinth(1, 1, self.set_up_test_scenario) 64 | self.assertTrue(app.map["Pakistan"].is_fair()) 65 | self.assertTrue(app.map["Pakistan"].is_neutral()) 66 | self.assertEqual(app.map["Pakistan"].aid, 0) 67 | app.handleMuslimWoI(1, "Pakistan") 68 | self.assertTrue(app.map["Pakistan"].is_fair()) 69 | self.assertTrue(app.map["Pakistan"].is_neutral()) 70 | self.assertEqual(app.map["Pakistan"].aid, 0) 71 | 72 | app = Labyrinth(1, 1, self.set_up_test_scenario) 73 | self.assertTrue(app.map["Pakistan"].is_fair()) 74 | self.assertTrue(app.map["Pakistan"].is_neutral()) 75 | self.assertEqual(app.map["Pakistan"].aid, 0) 76 | app.handleMuslimWoI(2, "Pakistan") 77 | self.assertTrue(app.map["Pakistan"].is_fair()) 78 | self.assertTrue(app.map["Pakistan"].is_neutral()) 79 | self.assertEqual(app.map["Pakistan"].aid, 0) 80 | 81 | app = Labyrinth(1, 1, self.set_up_test_scenario) 82 | self.assertTrue(app.map["Pakistan"].is_fair()) 83 | self.assertTrue(app.map["Pakistan"].is_neutral()) 84 | self.assertEqual(app.map["Pakistan"].aid, 0) 85 | app.handleMuslimWoI(3, "Pakistan") 86 | self.assertTrue(app.map["Pakistan"].is_fair()) 87 | self.assertTrue(app.map["Pakistan"].is_neutral()) 88 | self.assertEqual(app.map["Pakistan"].aid, 0) 89 | 90 | app = Labyrinth(1, 1, self.set_up_test_scenario) 91 | self.assertTrue(app.map["Pakistan"].is_fair()) 92 | self.assertTrue(app.map["Pakistan"].is_neutral()) 93 | self.assertEqual(app.map["Pakistan"].aid, 0) 94 | app.handleMuslimWoI(4, "Pakistan") 95 | self.assertTrue(app.map["Pakistan"].is_fair()) 96 | self.assertTrue(app.map["Pakistan"].is_neutral()) 97 | self.assertEqual(app.map["Pakistan"].aid, 1) 98 | 99 | app = Labyrinth(1, 1, self.set_up_test_scenario) 100 | self.assertTrue(app.map["Pakistan"].is_fair()) 101 | self.assertTrue(app.map["Pakistan"].is_neutral()) 102 | self.assertEqual(app.map["Pakistan"].aid, 0) 103 | app.handleMuslimWoI(5, "Pakistan") 104 | self.assertTrue(app.map["Pakistan"].is_fair()) 105 | self.assertTrue(app.map["Pakistan"].is_ally()) 106 | self.assertEqual(app.map["Pakistan"].aid, 0) 107 | 108 | app = Labyrinth(1, 1, self.set_up_test_scenario) 109 | self.assertTrue(app.map["Pakistan"].is_fair()) 110 | self.assertTrue(app.map["Pakistan"].is_neutral()) 111 | self.assertEqual(app.map["Pakistan"].aid, 0) 112 | app.handleMuslimWoI(6, "Pakistan") 113 | self.assertTrue(app.map["Pakistan"].is_fair()) 114 | self.assertTrue(app.map["Pakistan"].is_ally()) 115 | self.assertEqual(app.map["Pakistan"].aid, 0) 116 | 117 | app = Labyrinth(1, 1, self.set_up_test_scenario) 118 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 119 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 120 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 121 | app.handleMuslimWoI(1, "Saudi Arabia") 122 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 123 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 124 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 125 | 126 | app = Labyrinth(1, 1, self.set_up_test_scenario) 127 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 128 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 129 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 130 | app.handleMuslimWoI(2, "Saudi Arabia") 131 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 132 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 133 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 134 | 135 | app = Labyrinth(1, 1, self.set_up_test_scenario) 136 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 137 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 138 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 139 | app.handleMuslimWoI(3, "Saudi Arabia") 140 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 141 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 142 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 143 | 144 | app = Labyrinth(1, 1, self.set_up_test_scenario) 145 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 146 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 147 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 148 | app.handleMuslimWoI(4, "Saudi Arabia") 149 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 150 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 151 | self.assertEqual(app.map["Saudi Arabia"].aid, 1) 152 | 153 | app = Labyrinth(1, 1, self.set_up_test_scenario) 154 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 155 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 156 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 157 | app.handleMuslimWoI(5, "Saudi Arabia") 158 | self.assertTrue(app.map["Saudi Arabia"].is_fair()) 159 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 160 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 161 | 162 | app = Labyrinth(1, 1, self.set_up_test_scenario) 163 | self.assertTrue(app.map["Saudi Arabia"].is_poor()) 164 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 165 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) 166 | app.handleMuslimWoI(6, "Saudi Arabia") 167 | self.assertTrue(app.map["Saudi Arabia"].is_fair()) 168 | self.assertTrue(app.map["Saudi Arabia"].is_ally()) 169 | self.assertEqual(app.map["Saudi Arabia"].aid, 0) -------------------------------------------------------------------------------- /tests/test_regime_change_handler.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class RegimeChangeHandlerTest(LabyrinthTestCase): 6 | """Test Regime Change""" 7 | 8 | def test_regime_change(self): 9 | app = Labyrinth(1, 1, self.set_up_test_scenario) 10 | app.map["United States"].posture = "Soft" 11 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 12 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 13 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 14 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 15 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 16 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 17 | self.assertEqual(app.prestige, 7) 18 | self.assertEqual(app.troops, 9) 19 | govRoll = 4 20 | prestigeRolls = (3, 2, 5) 21 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 22 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 23 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 24 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 25 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 26 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 27 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 28 | self.assertEqual(app.prestige, 7) 29 | self.assertEqual(app.troops, 9) 30 | 31 | app = Labyrinth(1, 1, self.set_up_test_scenario) 32 | app.map["United States"].posture = "Hard" 33 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 34 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 35 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 36 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 37 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 38 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 39 | self.assertEqual(app.prestige, 7) 40 | self.assertEqual(app.troops, 9) 41 | govRoll = 4 42 | prestigeRolls = (3, 2, 5) 43 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 44 | self.assertTrue(app.map["Afghanistan"].is_poor()) 45 | self.assertTrue(app.map["Afghanistan"].is_ally()) 46 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 47 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 48 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 49 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 50 | self.assertEqual(app.prestige, 5) 51 | self.assertEqual(app.troops, 3) 52 | 53 | app = Labyrinth(1, 1, self.set_up_test_scenario) 54 | app.map["United States"].posture = "Hard" 55 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 56 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 57 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 58 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 59 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 60 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 61 | self.assertEqual(app.prestige, 7) 62 | self.assertEqual(app.troops, 9) 63 | govRoll = 5 64 | prestigeRolls = (3, 2, 5) 65 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 66 | self.assertTrue(app.map["Afghanistan"].is_fair()) 67 | self.assertTrue(app.map["Afghanistan"].is_ally()) 68 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 69 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 70 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 71 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 72 | self.assertEqual(app.prestige, 5) 73 | self.assertEqual(app.troops, 3) 74 | 75 | app = Labyrinth(1, 1, self.set_up_test_scenario) 76 | app.map["United States"].posture = "Hard" 77 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 78 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 79 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 80 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 81 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 82 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 83 | self.assertEqual(app.prestige, 7) 84 | self.assertEqual(app.troops, 9) 85 | govRoll = 5 86 | prestigeRolls = (5, 2, 5) 87 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 88 | self.assertTrue(app.map["Afghanistan"].is_fair()) 89 | self.assertTrue(app.map["Afghanistan"].is_ally()) 90 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 91 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 92 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 93 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 94 | self.assertEqual(app.prestige, 9) 95 | self.assertEqual(app.troops, 3) 96 | 97 | app = Labyrinth(1, 1, self.set_up_test_scenario) 98 | app.map["United States"].posture = "Hard" 99 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 100 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 101 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 102 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 103 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 104 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 105 | self.assertEqual(app.prestige, 7) 106 | self.assertEqual(app.troops, 9) 107 | govRoll = 5 108 | prestigeRolls = (2, 6, 5) 109 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 110 | self.assertTrue(app.map["Afghanistan"].is_fair()) 111 | self.assertTrue(app.map["Afghanistan"].is_ally()) 112 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 113 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 114 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 115 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 116 | self.assertEqual(app.prestige, 2) 117 | self.assertEqual(app.troops, 3) 118 | 119 | app = Labyrinth(1, 1, self.set_up_test_scenario) 120 | app.map["United States"].posture = "Hard" 121 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 122 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 123 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 124 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 125 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 126 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 127 | self.assertEqual(app.prestige, 7) 128 | self.assertEqual(app.troops, 9) 129 | govRoll = 5 130 | prestigeRolls = (6, 6, 5) 131 | app.handleRegimeChange("Afghanistan", "track", 6, govRoll, prestigeRolls) 132 | self.assertTrue(app.map["Afghanistan"].is_fair()) 133 | self.assertTrue(app.map["Afghanistan"].is_ally()) 134 | self.assertEqual(app.map["Afghanistan"].troops(), 6) 135 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 136 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 137 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 138 | self.assertEqual(app.prestige, 12) 139 | self.assertEqual(app.troops, 3) 140 | 141 | app = Labyrinth(1, 1, self.set_up_test_scenario) 142 | app.troops -= 8 143 | app.map["Pakistan"].changeTroops(8) 144 | app.map["United States"].posture = "Hard" 145 | self.assertTrue(app.map["Afghanistan"].is_islamist_rule()) 146 | self.assertTrue(app.map["Afghanistan"].is_adversary()) 147 | self.assertEqual(app.map["Afghanistan"].troops(), 0) 148 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 4) 149 | self.assertEqual(app.map["Afghanistan"].activeCells, 0) 150 | self.assertEqual(app.map["Afghanistan"].regimeChange, 0) 151 | self.assertEqual(app.prestige, 7) 152 | self.assertEqual(app.troops, 1) 153 | self.assertEqual(app.map["Pakistan"].troops(), 10) 154 | govRoll = 5 155 | prestigeRolls = (6, 6, 5) 156 | app.handleRegimeChange("Afghanistan", "Pakistan", 7, govRoll, prestigeRolls) 157 | self.assertTrue(app.map["Afghanistan"].is_fair()) 158 | self.assertTrue(app.map["Afghanistan"].is_ally()) 159 | self.assertEqual(app.map["Afghanistan"].troops(), 7) 160 | self.assertEqual(app.map["Afghanistan"].sleeperCells, 0) 161 | self.assertEqual(app.map["Afghanistan"].activeCells, 4) 162 | self.assertEqual(app.map["Afghanistan"].regimeChange, 1) 163 | self.assertEqual(app.prestige, 12) 164 | self.assertEqual(app.troops, 1) 165 | self.assertEqual(app.map["Pakistan"].troops(), 3) -------------------------------------------------------------------------------- /tests/test_travel.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class TravelTest(LabyrinthTestCase): 6 | """Test Travel""" 7 | 8 | def test_travel_first_box(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | 11 | app.map["Gulf States"].make_poor() 12 | app.map["Gulf States"].besieged = 1 13 | dest = app.travelDestinations(1) 14 | self.assertEqual(dest, ["Gulf States"]) 15 | 16 | app.map["Gulf States"].besieged = 0 17 | app.map["Gulf States"].aid = 1 18 | dest = app.travelDestinations(1) 19 | self.assertEqual(dest, ["Gulf States"]) 20 | 21 | app.map["Gulf States"].aid = 0 22 | app.map["Gulf States"].regimeChange = 1 23 | dest = app.travelDestinations(1) 24 | self.assertEqual(dest, ["Gulf States"]) 25 | 26 | app.map["Gulf States"].make_islamist_rule() 27 | app.map["Afghanistan"].make_poor() 28 | app.map["Afghanistan"].besieged = 1 29 | dest = app.travelDestinations(1) 30 | self.assertEqual(dest, ["Afghanistan"]) 31 | 32 | app.map["Gulf States"].make_poor() 33 | dest = app.travelDestinations(1) 34 | self.assertEqual(dest, ["Gulf States"]) 35 | 36 | app.map["Iraq"].make_poor() 37 | app.map["Iraq"].aid = 1 38 | iraqCount = 0 39 | gulfCount = 0 40 | for i in range(100): 41 | dest = app.travelDestinations(1) 42 | if dest == ["Gulf States"]: 43 | gulfCount += 1 44 | elif dest == ["Iraq"]: 45 | iraqCount += 1 46 | self.assertTrue(dest == ["Gulf States"] or dest == ["Iraq"]) 47 | self.assertTrue(iraqCount > 0) 48 | self.assertTrue(gulfCount > 0) 49 | 50 | app.map["Pakistan"].make_poor() 51 | app.map["Pakistan"].aid = 1 52 | dest = app.travelDestinations(1) 53 | self.assertEqual(dest, ["Pakistan"]) 54 | 55 | def test_travel_second_box(self): 56 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 57 | 58 | app.map["Afghanistan"].make_poor() 59 | app.map["Afghanistan"].troopCubes = 1 60 | app.map["Afghanistan"].sleeperCells = 4 61 | dest = app.travelDestinations(1) 62 | self.assertEqual(dest, ["Afghanistan"]) 63 | 64 | app.map["Gulf States"].make_poor() 65 | app.map["Gulf States"].besieged = 1 66 | dest = app.travelDestinations(1) 67 | self.assertEqual(dest, ["Gulf States"]) 68 | 69 | dest = app.travelDestinations(2) 70 | self.assertEqual(dest, ["Gulf States", "Afghanistan"]) 71 | 72 | def test_travel_third_box(self): 73 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 74 | 75 | app.map["Jordan"].make_fair() 76 | app.map["Iraq"].make_poor() 77 | app.map["Iraq"].sleeperCells = 1 78 | dest = app.travelDestinations(1) 79 | self.assertEqual(dest, ["Jordan"]) 80 | 81 | app.map["Gulf States"].make_fair() 82 | dest = app.travelDestinations(1) 83 | self.assertEqual(dest, ["Gulf States"]) 84 | 85 | app.map["Gulf States"].make_poor() 86 | app.map["Algeria/Tunisia"].make_fair() 87 | dest = app.travelDestinations(1) 88 | self.assertEqual(dest, ["Jordan"]) 89 | 90 | app.map["Germany"].sleeperCells = 1 91 | dest = app.travelDestinations(1) 92 | self.assertEqual(dest, ["Algeria/Tunisia"]) 93 | 94 | def test_travel_fourth_box(self): 95 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 96 | 97 | app.map["United States"].posture = "Hard" 98 | 99 | app.map["Canada"].posture = "Hard" 100 | app.map["United Kingdom"].posture = "Hard" 101 | app.map["Serbia"].posture = "Hard" 102 | app.map["India"].posture = "Hard" 103 | app.map["Scandinavia"].posture = "Hard" 104 | app.map["Eastern Europe"].posture = "Hard" 105 | app.map["Benelux"].posture = "Hard" 106 | app.map["Germany"].posture = "Hard" 107 | app.map["France"].posture = "Hard" 108 | app.map["Italy"].posture = "Hard" 109 | app.map["Spain"].posture = "Hard" 110 | app.map["Russia"].posture = "Hard" 111 | app.map["Caucasus"].posture = "Hard" 112 | app.map["China"].posture = "Hard" 113 | app.map["Kenya/Tanzania"].posture = "Hard" 114 | app.map["Thailand"].posture = "Hard" 115 | dest = app.travelDestinations(1) 116 | self.assertEqual(dest, ["Philippines"]) 117 | 118 | def test_travel_multiple(self): 119 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 120 | dest = app.travelDestinations(3) 121 | 122 | app.map["Gulf States"].make_poor() 123 | app.map["Gulf States"].besieged = 1 124 | dest = app.travelDestinations(1) 125 | self.assertEqual(dest, ["Gulf States"]) 126 | 127 | app.map["Afghanistan"].make_poor() 128 | app.map["Afghanistan"].troopCubes = 1 129 | app.map["Afghanistan"].sleeperCells = 4 130 | dest = app.travelDestinations(2) 131 | self.assertEqual(dest, ["Gulf States", "Afghanistan"]) 132 | 133 | app.map["Jordan"].make_fair() 134 | app.map["Iraq"].make_poor() 135 | app.map["Iraq"].sleeperCells = 1 136 | dest = app.travelDestinations(3) 137 | self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"]) 138 | 139 | app.map["United States"].posture = "Hard" 140 | app.map["Canada"].posture = "Hard" 141 | app.map["United Kingdom"].posture = "Hard" 142 | app.map["Serbia"].posture = "Hard" 143 | app.map["India"].posture = "Hard" 144 | app.map["Scandinavia"].posture = "Hard" 145 | app.map["Eastern Europe"].posture = "Hard" 146 | app.map["Benelux"].posture = "Hard" 147 | app.map["Germany"].posture = "Hard" 148 | app.map["France"].posture = "Hard" 149 | app.map["Italy"].posture = "Hard" 150 | app.map["Spain"].posture = "Hard" 151 | app.map["Russia"].posture = "Hard" 152 | app.map["Caucasus"].posture = "Hard" 153 | app.map["China"].posture = "Hard" 154 | app.map["Kenya/Tanzania"].posture = "Hard" 155 | app.map["Thailand"].posture = "Hard" 156 | dest = app.travelDestinations(3) 157 | self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"]) 158 | 159 | app.map["Gulf States"].make_islamist_rule() 160 | dest = app.travelDestinations(3) 161 | self.assertEqual(dest, ["Afghanistan", "Jordan", "Philippines"]) 162 | 163 | app.map["Kenya/Tanzania"].posture = "" 164 | phCount = 0 165 | ktCount = 0 166 | for i in range(100): 167 | dest = app.travelDestinations(3) 168 | if dest == ["Afghanistan", "Jordan", "Philippines"]: 169 | phCount += 1 170 | elif dest == ["Afghanistan", "Jordan", "Kenya/Tanzania"]: 171 | ktCount += 1 172 | self.assertTrue(dest == ["Afghanistan", "Jordan", "Philippines"] or 173 | dest == ["Afghanistan", "Jordan", "Kenya/Tanzania"]) 174 | self.assertTrue(phCount > 0) 175 | self.assertTrue(ktCount > 0) 176 | 177 | app.map["United States"].posture = "Soft" 178 | app.map["China"].posture = "Soft" 179 | dest = app.travelDestinations(3) 180 | self.assertEqual(dest, ["Afghanistan", "Jordan", "China"]) 181 | 182 | app.map["Benelux"].posture = "Soft" 183 | chinaCount = 0 184 | beneluxCount = 0 185 | for i in range(100): 186 | dest = app.travelDestinations(3) 187 | if dest == ["Afghanistan", "Jordan", "China"]: 188 | chinaCount += 1 189 | elif dest == ["Afghanistan", "Jordan", "Benelux"]: 190 | beneluxCount += 1 191 | self.assertTrue(dest == ["Afghanistan", "Jordan", "China"] or dest == ["Afghanistan", "Jordan", "Benelux"]) 192 | self.assertTrue(chinaCount > 0) 193 | self.assertTrue(beneluxCount > 0) 194 | 195 | def test_travel_from(self): 196 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 197 | 198 | app.map["Gulf States"].make_poor() 199 | app.map["Gulf States"].besieged = 1 200 | dest = app.travelDestinations(1) 201 | self.assertEqual(dest, ["Gulf States"]) 202 | 203 | app.map["Lebanon"].make_fair() 204 | app.map["Lebanon"].activeCells = 1 205 | sources = app.travelSources(dest, 1) 206 | self.assertEqual(sources, ["Lebanon"]) 207 | 208 | app.map["Iraq"].make_fair() 209 | app.map["Iraq"].activeCells = 1 210 | sources = app.travelSources(dest, 1) 211 | self.assertEqual(sources, ["Iraq"]) 212 | 213 | app.map["Egypt"].make_fair() 214 | app.map["Egypt"].activeCells = 1 215 | app.map["Egypt"].regimeChange = 1 216 | app.map["Egypt"].troopCubes = 2 217 | sources = app.travelSources(dest, 1) 218 | self.assertEqual(sources, ["Iraq"]) 219 | app.map["Egypt"].activeCells = 3 220 | sources = app.travelSources(dest, 1) 221 | self.assertEqual(sources, ["Egypt"]) 222 | 223 | app.map["Yemen"].make_islamist_rule() 224 | app.map["Yemen"].activeCells = 3 225 | app.map["Yemen"].troopCubes = 2 226 | sources = app.travelSources(dest, 3) 227 | self.assertEqual(sources, ["Egypt"]) 228 | sources = app.travelSources(dest, 2) 229 | self.assertEqual(sources, ["Yemen"]) 230 | 231 | #multi 232 | 233 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 234 | 235 | app.map["Gulf States"].make_poor() 236 | app.map["Gulf States"].besieged = 1 237 | 238 | app.map["Afghanistan"].make_poor() 239 | app.map["Afghanistan"].troopCubes = 1 240 | app.map["Afghanistan"].sleeperCells = 4 241 | 242 | app.map["Jordan"].make_fair() 243 | app.map["Iraq"].make_poor() 244 | app.map["Iraq"].sleeperCells = 1 245 | dest = app.travelDestinations(3) 246 | self.assertEqual(dest, ["Gulf States", "Afghanistan", "Jordan"]) 247 | 248 | app.map["Lebanon"].make_fair() 249 | app.map["Lebanon"].activeCells = 1 250 | 251 | app.map["Iraq"].make_fair() 252 | app.map["Iraq"].activeCells = 1 253 | 254 | app.map["Egypt"].make_fair() 255 | app.map["Egypt"].regimeChange = 1 256 | app.map["Egypt"].troopCubes = 2 257 | app.map["Egypt"].activeCells = 3 258 | 259 | app.map["Yemen"].make_islamist_rule() 260 | app.map["Yemen"].activeCells = 4 261 | app.map["Yemen"].troopCubes = 2 262 | sources = app.travelSources(dest, 3) 263 | self.assertEqual(sources, ["Yemen", "Egypt", "Iraq"]) 264 | 265 | app.map["Yemen"].activeCells = 5 266 | sources = app.travelSources(dest, 3) 267 | self.assertEqual(sources, ["Yemen", "Yemen", "Egypt"]) 268 | 269 | app.map["Yemen"].activeCells = 6 270 | sources = app.travelSources(dest, 3) 271 | self.assertEqual(sources, ["Yemen", "Yemen", "Yemen"]) 272 | 273 | app.map["Yemen"].activeCells = 4 274 | sources = app.travelSources(dest, 3) 275 | app.map["Egypt"].activeCells = 4 276 | sources = app.travelSources(dest, 3) 277 | self.assertEqual(sources, ["Yemen", "Egypt", "Egypt"]) 278 | 279 | app.map["Iraq"].make_fair() 280 | app.map["Iraq"].regimeChange = 1 281 | app.map["Iraq"].troopCubes = 2 282 | app.map["Iraq"].activeCells = 4 283 | app.map["Egypt"].activeCells = 0 284 | app.map["Egypt"].sleeperCells = 4 285 | sources = app.travelSources(dest, 3) 286 | self.assertEqual(sources, ["Yemen", "Iraq", "Iraq"]) -------------------------------------------------------------------------------- /tests/test_num_cells_available.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class NumCellsAvailableTest(LabyrinthTestCase): 6 | """Test num cells available""" 7 | 8 | def test_num_cells_available(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | app.funding = 9 11 | app.cells = 15 12 | self.assertEqual(app.numCellsAvailable(), 15) 13 | app.cells = 14 14 | self.assertEqual(app.numCellsAvailable(), 14) 15 | app.cells = 13 16 | self.assertEqual(app.numCellsAvailable(), 13) 17 | app.cells = 12 18 | self.assertEqual(app.numCellsAvailable(), 12) 19 | app.cells = 11 20 | self.assertEqual(app.numCellsAvailable(), 11) 21 | app.cells = 10 22 | self.assertEqual(app.numCellsAvailable(), 10) 23 | app.cells = 9 24 | self.assertEqual(app.numCellsAvailable(), 9) 25 | app.cells = 8 26 | self.assertEqual(app.numCellsAvailable(), 8) 27 | app.cells = 7 28 | self.assertEqual(app.numCellsAvailable(), 7) 29 | app.cells = 6 30 | self.assertEqual(app.numCellsAvailable(), 6) 31 | app.cells = 5 32 | self.assertEqual(app.numCellsAvailable(), 5) 33 | app.cells = 4 34 | self.assertEqual(app.numCellsAvailable(), 4) 35 | app.cells = 3 36 | self.assertEqual(app.numCellsAvailable(), 3) 37 | app.cells = 2 38 | self.assertEqual(app.numCellsAvailable(), 2) 39 | app.cells = 1 40 | self.assertEqual(app.numCellsAvailable(), 1) 41 | 42 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 43 | app.funding = 8 44 | app.cells = 15 45 | self.assertEqual(app.numCellsAvailable(), 15) 46 | app.cells = 14 47 | self.assertEqual(app.numCellsAvailable(), 14) 48 | app.cells = 13 49 | self.assertEqual(app.numCellsAvailable(), 13) 50 | app.cells = 12 51 | self.assertEqual(app.numCellsAvailable(), 12) 52 | app.cells = 11 53 | self.assertEqual(app.numCellsAvailable(), 11) 54 | app.cells = 10 55 | self.assertEqual(app.numCellsAvailable(), 10) 56 | app.cells = 9 57 | self.assertEqual(app.numCellsAvailable(), 9) 58 | app.cells = 8 59 | self.assertEqual(app.numCellsAvailable(), 8) 60 | app.cells = 7 61 | self.assertEqual(app.numCellsAvailable(), 7) 62 | app.cells = 6 63 | self.assertEqual(app.numCellsAvailable(), 6) 64 | app.cells = 5 65 | self.assertEqual(app.numCellsAvailable(), 5) 66 | app.cells = 4 67 | self.assertEqual(app.numCellsAvailable(), 4) 68 | app.cells = 3 69 | self.assertEqual(app.numCellsAvailable(), 3) 70 | app.cells = 2 71 | self.assertEqual(app.numCellsAvailable(), 2) 72 | app.cells = 1 73 | self.assertEqual(app.numCellsAvailable(), 1) 74 | 75 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 76 | app.funding = 7 77 | app.cells = 15 78 | self.assertEqual(app.numCellsAvailable(), 15) 79 | app.cells = 14 80 | self.assertEqual(app.numCellsAvailable(), 14) 81 | app.cells = 13 82 | self.assertEqual(app.numCellsAvailable(), 13) 83 | app.cells = 12 84 | self.assertEqual(app.numCellsAvailable(), 12) 85 | app.cells = 11 86 | self.assertEqual(app.numCellsAvailable(), 11) 87 | app.cells = 10 88 | self.assertEqual(app.numCellsAvailable(), 10) 89 | app.cells = 9 90 | self.assertEqual(app.numCellsAvailable(), 9) 91 | app.cells = 8 92 | self.assertEqual(app.numCellsAvailable(), 8) 93 | app.cells = 7 94 | self.assertEqual(app.numCellsAvailable(), 7) 95 | app.cells = 6 96 | self.assertEqual(app.numCellsAvailable(), 6) 97 | app.cells = 5 98 | self.assertEqual(app.numCellsAvailable(), 5) 99 | app.cells = 4 100 | self.assertEqual(app.numCellsAvailable(), 4) 101 | app.cells = 3 102 | self.assertEqual(app.numCellsAvailable(), 3) 103 | app.cells = 2 104 | self.assertEqual(app.numCellsAvailable(), 2) 105 | app.cells = 1 106 | self.assertEqual(app.numCellsAvailable(), 1) 107 | 108 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 109 | app.funding = 6 110 | app.cells = 15 111 | self.assertEqual(app.numCellsAvailable(), 10) 112 | app.cells = 14 113 | self.assertEqual(app.numCellsAvailable(), 9) 114 | app.cells = 13 115 | self.assertEqual(app.numCellsAvailable(), 8) 116 | app.cells = 12 117 | self.assertEqual(app.numCellsAvailable(), 7) 118 | app.cells = 11 119 | self.assertEqual(app.numCellsAvailable(), 6) 120 | app.cells = 10 121 | self.assertEqual(app.numCellsAvailable(), 5) 122 | app.cells = 9 123 | self.assertEqual(app.numCellsAvailable(), 4) 124 | app.cells = 8 125 | self.assertEqual(app.numCellsAvailable(), 3) 126 | app.cells = 7 127 | self.assertEqual(app.numCellsAvailable(), 2) 128 | app.cells = 6 129 | self.assertEqual(app.numCellsAvailable(), 1) 130 | app.cells = 5 131 | self.assertEqual(app.numCellsAvailable(), 0) 132 | app.cells = 4 133 | self.assertEqual(app.numCellsAvailable(), 0) 134 | app.cells = 3 135 | self.assertEqual(app.numCellsAvailable(), 0) 136 | app.cells = 2 137 | self.assertEqual(app.numCellsAvailable(), 0) 138 | app.cells = 1 139 | self.assertEqual(app.numCellsAvailable(), 0) 140 | 141 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 142 | app.funding = 5 143 | app.cells = 15 144 | self.assertEqual(app.numCellsAvailable(), 10) 145 | app.cells = 14 146 | self.assertEqual(app.numCellsAvailable(), 9) 147 | app.cells = 13 148 | self.assertEqual(app.numCellsAvailable(), 8) 149 | app.cells = 12 150 | self.assertEqual(app.numCellsAvailable(), 7) 151 | app.cells = 11 152 | self.assertEqual(app.numCellsAvailable(), 6) 153 | app.cells = 10 154 | self.assertEqual(app.numCellsAvailable(), 5) 155 | app.cells = 9 156 | self.assertEqual(app.numCellsAvailable(), 4) 157 | app.cells = 8 158 | self.assertEqual(app.numCellsAvailable(), 3) 159 | app.cells = 7 160 | self.assertEqual(app.numCellsAvailable(), 2) 161 | app.cells = 6 162 | self.assertEqual(app.numCellsAvailable(), 1) 163 | app.cells = 5 164 | self.assertEqual(app.numCellsAvailable(), 0) 165 | app.cells = 4 166 | self.assertEqual(app.numCellsAvailable(), 0) 167 | app.cells = 3 168 | self.assertEqual(app.numCellsAvailable(), 0) 169 | app.cells = 2 170 | self.assertEqual(app.numCellsAvailable(), 0) 171 | app.cells = 1 172 | self.assertEqual(app.numCellsAvailable(), 0) 173 | 174 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 175 | app.funding = 4 176 | app.cells = 15 177 | self.assertEqual(app.numCellsAvailable(), 10) 178 | app.cells = 14 179 | self.assertEqual(app.numCellsAvailable(), 9) 180 | app.cells = 13 181 | self.assertEqual(app.numCellsAvailable(), 8) 182 | app.cells = 12 183 | self.assertEqual(app.numCellsAvailable(), 7) 184 | app.cells = 11 185 | self.assertEqual(app.numCellsAvailable(), 6) 186 | app.cells = 10 187 | self.assertEqual(app.numCellsAvailable(), 5) 188 | app.cells = 9 189 | self.assertEqual(app.numCellsAvailable(), 4) 190 | app.cells = 8 191 | self.assertEqual(app.numCellsAvailable(), 3) 192 | app.cells = 7 193 | self.assertEqual(app.numCellsAvailable(), 2) 194 | app.cells = 6 195 | self.assertEqual(app.numCellsAvailable(), 1) 196 | app.cells = 5 197 | self.assertEqual(app.numCellsAvailable(), 0) 198 | app.cells = 4 199 | self.assertEqual(app.numCellsAvailable(), 0) 200 | app.cells = 3 201 | self.assertEqual(app.numCellsAvailable(), 0) 202 | app.cells = 2 203 | self.assertEqual(app.numCellsAvailable(), 0) 204 | app.cells = 1 205 | self.assertEqual(app.numCellsAvailable(), 0) 206 | 207 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 208 | app.funding = 3 209 | app.cells = 15 210 | self.assertEqual(app.numCellsAvailable(), 5) 211 | app.cells = 14 212 | self.assertEqual(app.numCellsAvailable(), 4) 213 | app.cells = 13 214 | self.assertEqual(app.numCellsAvailable(), 3) 215 | app.cells = 12 216 | self.assertEqual(app.numCellsAvailable(), 2) 217 | app.cells = 11 218 | self.assertEqual(app.numCellsAvailable(), 1) 219 | app.cells = 10 220 | self.assertEqual(app.numCellsAvailable(), 0) 221 | app.cells = 9 222 | self.assertEqual(app.numCellsAvailable(), 0) 223 | app.cells = 8 224 | self.assertEqual(app.numCellsAvailable(), 0) 225 | app.cells = 7 226 | self.assertEqual(app.numCellsAvailable(), 0) 227 | app.cells = 6 228 | self.assertEqual(app.numCellsAvailable(), 0) 229 | app.cells = 5 230 | self.assertEqual(app.numCellsAvailable(), 0) 231 | app.cells = 4 232 | self.assertEqual(app.numCellsAvailable(), 0) 233 | app.cells = 3 234 | self.assertEqual(app.numCellsAvailable(), 0) 235 | app.cells = 2 236 | self.assertEqual(app.numCellsAvailable(), 0) 237 | app.cells = 1 238 | self.assertEqual(app.numCellsAvailable(), 0) 239 | 240 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 241 | app.funding = 2 242 | app.cells = 15 243 | self.assertEqual(app.numCellsAvailable(), 5) 244 | app.cells = 14 245 | self.assertEqual(app.numCellsAvailable(), 4) 246 | app.cells = 13 247 | self.assertEqual(app.numCellsAvailable(), 3) 248 | app.cells = 12 249 | self.assertEqual(app.numCellsAvailable(), 2) 250 | app.cells = 11 251 | self.assertEqual(app.numCellsAvailable(), 1) 252 | app.cells = 10 253 | self.assertEqual(app.numCellsAvailable(), 0) 254 | app.cells = 9 255 | self.assertEqual(app.numCellsAvailable(), 0) 256 | app.cells = 8 257 | self.assertEqual(app.numCellsAvailable(), 0) 258 | app.cells = 7 259 | self.assertEqual(app.numCellsAvailable(), 0) 260 | app.cells = 6 261 | self.assertEqual(app.numCellsAvailable(), 0) 262 | app.cells = 5 263 | self.assertEqual(app.numCellsAvailable(), 0) 264 | app.cells = 4 265 | self.assertEqual(app.numCellsAvailable(), 0) 266 | app.cells = 3 267 | self.assertEqual(app.numCellsAvailable(), 0) 268 | app.cells = 2 269 | self.assertEqual(app.numCellsAvailable(), 0) 270 | app.cells = 1 271 | self.assertEqual(app.numCellsAvailable(), 0) 272 | 273 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 274 | app.funding = 1 275 | app.cells = 15 276 | self.assertEqual(app.numCellsAvailable(), 5) 277 | app.cells = 14 278 | self.assertEqual(app.numCellsAvailable(), 4) 279 | app.cells = 13 280 | self.assertEqual(app.numCellsAvailable(), 3) 281 | app.cells = 12 282 | self.assertEqual(app.numCellsAvailable(), 2) 283 | app.cells = 11 284 | self.assertEqual(app.numCellsAvailable(), 1) 285 | app.cells = 10 286 | self.assertEqual(app.numCellsAvailable(), 0) 287 | app.cells = 9 288 | self.assertEqual(app.numCellsAvailable(), 0) 289 | app.cells = 8 290 | self.assertEqual(app.numCellsAvailable(), 0) 291 | app.cells = 7 292 | self.assertEqual(app.numCellsAvailable(), 0) 293 | app.cells = 6 294 | self.assertEqual(app.numCellsAvailable(), 0) 295 | app.cells = 5 296 | self.assertEqual(app.numCellsAvailable(), 0) 297 | app.cells = 4 298 | self.assertEqual(app.numCellsAvailable(), 0) 299 | app.cells = 3 300 | self.assertEqual(app.numCellsAvailable(), 0) 301 | app.cells = 2 302 | self.assertEqual(app.numCellsAvailable(), 0) 303 | app.cells = 1 304 | self.assertEqual(app.numCellsAvailable(), 0) -------------------------------------------------------------------------------- /tests/test_resolve_plot.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class ResolvePlotTest(LabyrinthTestCase): 6 | """Resolve _plots""" 7 | 8 | def test_resolve_non_muslim_non_us_plots(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | app.map["Germany"].plots = 1 11 | app.resolvePlot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4], []) 12 | self.assertEqual(app.funding, 7) 13 | self.assertEqual(app.map["Germany"].posture, "Soft") 14 | self.assertEqual(app.map["Spain"].posture, "Hard") 15 | self.assertEqual(app.map["Scandinavia"].posture, "Soft") 16 | self.assertEqual(app.prestige, 7) 17 | self.assertEqual(app.map["Germany"].plots, 0) 18 | 19 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 20 | app.map["Germany"].plots = 2 21 | app.resolvePlot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4], []) 22 | self.assertEqual(app.funding, 7) 23 | self.assertEqual(app.map["Germany"].posture, "Soft") 24 | self.assertEqual(app.map["Spain"].posture, "Hard") 25 | self.assertEqual(app.map["Scandinavia"].posture, "Soft") 26 | self.assertEqual(app.prestige, 7) 27 | self.assertEqual(app.map["Germany"].plots, 1) 28 | 29 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 30 | app.map["Germany"].plots = 1 31 | app.resolvePlot("Germany", 2, 5, [], ["Spain", "Scandinavia"], [4, 5], []) 32 | self.assertEqual(app.funding, 9) 33 | self.assertEqual(app.map["Germany"].posture, "Hard") 34 | self.assertEqual(app.map["Spain"].posture, "Soft") 35 | self.assertEqual(app.map["Scandinavia"].posture, "Hard") 36 | self.assertEqual(app.prestige, 7) 37 | self.assertEqual(app.map["Germany"].plots, 0) 38 | 39 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 40 | app.map["Canada"].plots = 1 41 | app.resolvePlot("Canada", 2, 5, [], [], [], []) 42 | self.assertEqual(app.funding, 9) 43 | self.assertEqual(app.map["Canada"].posture, "Hard") 44 | self.assertEqual(app.map["Spain"].posture, "") 45 | self.assertEqual(app.map["Scandinavia"].posture, "") 46 | self.assertEqual(app.prestige, 7) 47 | self.assertEqual(app.map["Canada"].plots, 0) 48 | 49 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 50 | app.map["Russia"].plots = 1 51 | app.resolvePlot("Russia", 2, 4, [], [], [], []) 52 | self.assertEqual(app.funding, 7) 53 | self.assertEqual(app.map["Russia"].posture, "Soft") 54 | self.assertEqual(app.map["Spain"].posture, "") 55 | self.assertEqual(app.map["Scandinavia"].posture, "") 56 | self.assertEqual(app.prestige, 7) 57 | self.assertEqual(app.map["Russia"].plots, 0) 58 | 59 | app = Labyrinth(1, "WMD", self.set_up_blank_test_scenario) 60 | app.map["Germany"].plots = 1 61 | app.resolvePlot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4], []) 62 | self.assertEqual(app.funding, 7) 63 | self.assertEqual(app.map["Germany"].posture, "Soft") 64 | self.assertEqual(app.map["Spain"].posture, "Hard") 65 | self.assertEqual(app.map["Scandinavia"].posture, "Soft") 66 | self.assertEqual(app.prestige, 7) 67 | self.assertEqual(app.map["Germany"].plots, 0) 68 | 69 | app = Labyrinth(1, "WMD", self.set_up_blank_test_scenario) 70 | app.funding = 1 71 | app.map["Germany"].plots = 1 72 | app.resolvePlot("Germany", 3, 4, [], ["Spain", "Scandinavia"], [5, 4], []) 73 | self.assertEqual(app.funding, 7) 74 | self.assertEqual(app.map["Germany"].posture, "Soft") 75 | self.assertEqual(app.map["Spain"].posture, "Hard") 76 | self.assertEqual(app.map["Scandinavia"].posture, "Soft") 77 | self.assertEqual(app.prestige, 7) 78 | self.assertEqual(app.map["Germany"].plots, 0) 79 | 80 | def test_resolve_muslim_iran_plots(self): 81 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 82 | app.map["Iraq"].make_fair() 83 | app.map["Iraq"].aid = 1 84 | app.map["Iraq"].plots = 1 85 | app.resolvePlot("Iraq", 1, 0, [], [], [], [3]) 86 | self.assertEqual(app.funding, 6) 87 | self.assertTrue(app.map["Iraq"].is_fair()) 88 | self.assertEqual(app.map["Iraq"].aid, 1) 89 | app.resolvePlot("Iraq", 1, 0, [], [], [], [2]) 90 | self.assertEqual(app.funding, 7) 91 | self.assertTrue(app.map["Iraq"].is_poor()) 92 | self.assertEqual(app.map["Iraq"].aid, 0) 93 | self.assertEqual(app.prestige, 7) 94 | self.assertEqual(app.map["Iraq"].plots, 0) 95 | 96 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 97 | app.map["Iraq"].make_good() 98 | app.map["Iraq"].aid = 1 99 | app.map["Iraq"].plots = 1 100 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 1, 2]) 101 | self.assertEqual(app.funding, 7) 102 | self.assertTrue(app.map["Iraq"].is_fair()) 103 | self.assertEqual(app.map["Iraq"].aid, 0) 104 | self.assertEqual(app.prestige, 7) 105 | self.assertEqual(app.map["Iraq"].plots, 0) 106 | 107 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 108 | app.map["Iraq"].make_good() 109 | app.map["Iraq"].aid = 1 110 | app.map["Iraq"].plots = 1 111 | app.resolvePlot("Iraq", "WMD", 0, [], [], [], [3, 1, 2]) 112 | self.assertEqual(app.funding, 7) 113 | self.assertTrue(app.map["Iraq"].is_fair()) 114 | self.assertEqual(app.map["Iraq"].aid, 0) 115 | self.assertEqual(app.prestige, 7) 116 | self.assertEqual(app.map["Iraq"].plots, 0) 117 | 118 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 119 | app.map["Iraq"].make_poor() 120 | app.map["Iraq"].aid = 0 121 | app.map["Iraq"].plots = 1 122 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 3, 3]) 123 | self.assertEqual(app.funding, 6) 124 | self.assertTrue(app.map["Iraq"].is_poor()) 125 | self.assertEqual(app.map["Iraq"].aid, 0) 126 | self.assertEqual(app.prestige, 7) 127 | self.assertEqual(app.map["Iraq"].plots, 0) 128 | 129 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 130 | app.map["Iran"].plots = 1 131 | app.resolvePlot("Iran", 3, 0, [], [], [], [3, 3, 3]) 132 | self.assertEqual(app.funding, 6) 133 | self.assertTrue(app.map["Iran"].is_fair()) 134 | self.assertEqual(app.map["Iran"].aid, 0) 135 | self.assertEqual(app.prestige, 7) 136 | self.assertEqual(app.map["Iran"].plots, 0) 137 | 138 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 139 | app.map["Iraq"].make_poor() 140 | app.map["Iraq"].aid = 0 141 | app.map["Iraq"].plots = 1 142 | app.map["Iraq"].troopCubes = 1 143 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 3, 3]) 144 | self.assertEqual(app.funding, 6) 145 | self.assertTrue(app.map["Iraq"].is_poor()) 146 | self.assertEqual(app.map["Iraq"].aid, 0) 147 | self.assertEqual(app.prestige, 6) 148 | self.assertEqual(app.map["Iraq"].plots, 0) 149 | 150 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 151 | app.map["Iraq"].make_poor() 152 | app.map["Iraq"].aid = 0 153 | app.map["Iraq"].plots = 1 154 | app.map["Iraq"].troopCubes = 1 155 | app.resolvePlot("Iraq", "WMD", 0, [], [], [], [3, 3, 3]) 156 | self.assertEqual(app.funding, 6) 157 | self.assertTrue(app.map["Iraq"].is_poor()) 158 | self.assertEqual(app.map["Iraq"].aid, 0) 159 | self.assertEqual(app.prestige, 1) 160 | self.assertEqual(app.map["Iraq"].plots, 0) 161 | 162 | def test_resolve_us_plots(self): 163 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 164 | app.map["United States"].plots = 1 165 | app.map["United States"].posture = "Hard" 166 | app.resolvePlot("United States", 1, 4, [1, 6, 1], [], [], []) 167 | self.assertEqual(app.funding, 9) 168 | self.assertEqual(app.map["United States"].posture, "Soft") 169 | self.assertEqual(app.prestige, 6) 170 | self.assertEqual(app.map["United States"].plots, 0) 171 | 172 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 173 | app.map["United States"].plots = 1 174 | app.map["United States"].posture = "Soft" 175 | app.resolvePlot("United States", 2, 4, [5, 6, 1], [], [], []) 176 | self.assertEqual(app.funding, 9) 177 | self.assertEqual(app.map["United States"].posture, "Soft") 178 | self.assertEqual(app.prestige, 8) 179 | self.assertEqual(app.map["United States"].plots, 0) 180 | 181 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 182 | app.map["United States"].plots = 1 183 | app.map["United States"].posture = "Soft" 184 | app.resolvePlot("United States", 3, 5, [5, 6, 4], [], [], []) 185 | self.assertEqual(app.funding, 9) 186 | self.assertEqual(app.map["United States"].posture, "Hard") 187 | self.assertEqual(app.prestige, 11) 188 | self.assertEqual(app.map["United States"].plots, 0) 189 | 190 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 191 | self.assertFalse(app.gameOver) 192 | app.map["United States"].plots = 1 193 | app.map["United States"].posture = "Soft" 194 | app.resolvePlot("United States", "WMD", 0, [], [], [], []) 195 | self.assertEqual(app.map["United States"].plots, 0) 196 | self.assertTrue(app.gameOver) 197 | 198 | def test_resolve_muslim_iran_plots_with_backlash(self): 199 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 200 | app.map["Iraq"].make_fair() 201 | app.map["Iraq"].aid = 1 202 | app.map["Iraq"].plots = 1 203 | app.resolvePlot("Iraq", 1, 0, [], [], [], [3], True) 204 | self.assertEqual(app.funding, 4) 205 | self.assertTrue(app.map["Iraq"].is_fair()) 206 | self.assertEqual(app.map["Iraq"].aid, 1) 207 | app.resolvePlot("Iraq", 1, 0, [], [], [], [2], True) 208 | self.assertEqual(app.funding, 3) 209 | self.assertTrue(app.map["Iraq"].is_poor()) 210 | self.assertEqual(app.map["Iraq"].aid, 0) 211 | self.assertEqual(app.prestige, 7) 212 | self.assertEqual(app.map["Iraq"].plots, 0) 213 | 214 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 215 | app.map["Iraq"].make_good() 216 | app.map["Iraq"].aid = 1 217 | app.map["Iraq"].plots = 1 218 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 1, 2], True) 219 | self.assertEqual(app.funding, 3) 220 | self.assertTrue(app.map["Iraq"].is_fair()) 221 | self.assertEqual(app.map["Iraq"].aid, 0) 222 | self.assertEqual(app.prestige, 7) 223 | self.assertEqual(app.map["Iraq"].plots, 0) 224 | 225 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 226 | app.map["Iraq"].make_good() 227 | app.map["Iraq"].aid = 1 228 | app.map["Iraq"].plots = 1 229 | app.resolvePlot("Iraq", "WMD", 0, [], [], [], [3, 1, 2], True) 230 | self.assertEqual(app.funding, 1) 231 | self.assertTrue(app.map["Iraq"].is_fair()) 232 | self.assertEqual(app.map["Iraq"].aid, 0) 233 | self.assertEqual(app.prestige, 7) 234 | self.assertEqual(app.map["Iraq"].plots, 0) 235 | 236 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 237 | app.map["Iraq"].make_poor() 238 | app.map["Iraq"].aid = 0 239 | app.map["Iraq"].plots = 1 240 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 3, 3], True) 241 | self.assertEqual(app.funding, 4) 242 | self.assertTrue(app.map["Iraq"].is_poor()) 243 | self.assertEqual(app.map["Iraq"].aid, 0) 244 | self.assertEqual(app.prestige, 7) 245 | self.assertEqual(app.map["Iraq"].plots, 0) 246 | 247 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 248 | app.map["Iran"].plots = 1 249 | app.resolvePlot("Iran", 3, 0, [], [], [], [3, 3, 3], True) 250 | self.assertEqual(app.funding, 4) 251 | self.assertTrue(app.map["Iran"].is_fair()) 252 | self.assertEqual(app.map["Iran"].aid, 0) 253 | self.assertEqual(app.prestige, 7) 254 | self.assertEqual(app.map["Iran"].plots, 0) 255 | 256 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 257 | app.map["Iraq"].make_poor() 258 | app.map["Iraq"].aid = 0 259 | app.map["Iraq"].plots = 1 260 | app.map["Iraq"].troopCubes = 1 261 | app.resolvePlot("Iraq", 3, 0, [], [], [], [3, 3, 3], True) 262 | self.assertEqual(app.funding, 4) 263 | self.assertTrue(app.map["Iraq"].is_poor()) 264 | self.assertEqual(app.map["Iraq"].aid, 0) 265 | self.assertEqual(app.prestige, 6) 266 | self.assertEqual(app.map["Iraq"].plots, 0) 267 | 268 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 269 | app.map["Iraq"].make_poor() 270 | app.map["Iraq"].aid = 0 271 | app.map["Iraq"].plots = 1 272 | app.map["Iraq"].troopCubes = 1 273 | app.resolvePlot("Iraq", "WMD", 0, [], [], [], [3, 3, 3], True) 274 | self.assertEqual(app.funding, 1) 275 | self.assertTrue(app.map["Iraq"].is_poor()) 276 | self.assertEqual(app.map["Iraq"].aid, 0) 277 | self.assertEqual(app.prestige, 1) 278 | self.assertEqual(app.map["Iraq"].plots, 0) 279 | -------------------------------------------------------------------------------- /tests/test_recruit.py: -------------------------------------------------------------------------------- 1 | from lwotai import Labyrinth 2 | from labyrinth_test_case import LabyrinthTestCase 3 | 4 | 5 | class RecruitTest(LabyrinthTestCase): 6 | """Test Recruiting""" 7 | 8 | def test_recruit_choice(self): 9 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 10 | self.assertFalse(app.recruitChoice(3)) 11 | app.map["Gulf States"].make_good() 12 | app.map["Gulf States"].activeCells = 1 13 | self.assertEqual(app.recruitChoice(1), "Gulf States") 14 | app.map["Gulf States"].activeCells = 0 15 | app.map["Gulf States"].cadre = 1 16 | self.assertEqual(app.recruitChoice(1), "Gulf States") 17 | app.map["Gulf States"].activeCells = 1 18 | app.map["Gulf States"].cadre = 0 19 | app.map["Iraq"].make_good() 20 | app.map["Iraq"].activeCells = 1 21 | for i in range(10): 22 | retVal = app.recruitChoice(i) 23 | self.assertTrue(retVal in ["Iraq", "Gulf States"]) 24 | app.map["Iraq"].activeCells = 0 25 | app.map["Iraq"].cadre = 1 26 | self.assertEqual(app.recruitChoice(1), "Gulf States") 27 | app.map["Iraq"].troopCubes = 2 28 | self.assertEqual(app.recruitChoice(1), "Iraq") 29 | app.map["Gulf States"].besieged = 1 30 | self.assertEqual(app.recruitChoice(1), "Gulf States") 31 | app.map["Russia"].sleeperCells = 1 32 | self.assertEqual(app.recruitChoice(1), "Russia") 33 | app.map["Philippines"].sleeperCells = 1 34 | self.assertEqual(app.recruitChoice(1), "Philippines") 35 | app.map["Iraq"].make_islamist_rule() 36 | app.map["Iraq"].activeCells = 6 37 | self.assertEqual(app.recruitChoice(1), "Philippines") 38 | app.map["Iraq"].activeCells = 5 39 | self.assertEqual(app.recruitChoice(3), "Iraq") 40 | app.map["Gulf States"].regimeChange = 1 41 | app.map["Gulf States"].activeCells = 1 42 | app.map["Gulf States"].troopCubes = 5 43 | self.assertEqual(app.recruitChoice(3), "Iraq") 44 | app.map["Gulf States"].troopCubes = 6 45 | self.assertEqual(app.recruitChoice(1), "Gulf States") 46 | 47 | def test_execute_recruit(self): 48 | # Normal 49 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 50 | app.cells = 15 51 | unusedOps = app.executeRecruit("United States", 1, [1]) 52 | self.assertEqual(unusedOps, 0) 53 | self.assertEqual(app.map["United States"].sleeperCells, 1) 54 | self.assertEqual(app.cells, 14) 55 | 56 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 57 | app.cells = 15 58 | unusedOps = app.executeRecruit("United States", 1, [2]) 59 | self.assertEqual(unusedOps, 0) 60 | self.assertEqual(app.map["United States"].sleeperCells, 0) 61 | self.assertEqual(app.cells, 15) 62 | 63 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 64 | app.cells = 15 65 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 66 | self.assertEqual(unusedOps, 0) 67 | self.assertEqual(app.map["United States"].sleeperCells, 2) 68 | self.assertEqual(app.cells, 13) 69 | 70 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 71 | app.cells = 15 72 | unusedOps = app.executeRecruit("United States", 2, [1, 2]) 73 | self.assertEqual(unusedOps, 0) 74 | self.assertEqual(app.map["United States"].sleeperCells, 1) 75 | self.assertEqual(app.cells, 14) 76 | 77 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 78 | app.cells = 15 79 | unusedOps = app.executeRecruit("United States", 2, [2, 2]) 80 | self.assertEqual(unusedOps, 0) 81 | self.assertEqual(app.map["United States"].sleeperCells, 0) 82 | self.assertEqual(app.cells, 15) 83 | 84 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 85 | app.cells = 15 86 | unusedOps = app.executeRecruit("United States", 3, [1, 1, 1]) 87 | self.assertEqual(unusedOps, 0) 88 | self.assertEqual(app.map["United States"].sleeperCells, 3) 89 | self.assertEqual(app.cells, 12) 90 | 91 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 92 | app.cells = 15 93 | unusedOps = app.executeRecruit("United States", 3, [1, 2, 1]) 94 | self.assertEqual(unusedOps, 0) 95 | self.assertEqual(app.map["United States"].sleeperCells, 2) 96 | self.assertEqual(app.cells, 13) 97 | 98 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 99 | app.cells = 15 100 | unusedOps = app.executeRecruit("United States", 3, [2, 1, 2]) 101 | self.assertEqual(unusedOps, 0) 102 | self.assertEqual(app.map["United States"].sleeperCells, 1) 103 | self.assertEqual(app.cells, 14) 104 | 105 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 106 | app.cells = 15 107 | unusedOps = app.executeRecruit("United States", 3, [2, 2, 2]) 108 | self.assertEqual(unusedOps, 0) 109 | self.assertEqual(app.map["United States"].sleeperCells, 0) 110 | self.assertEqual(app.cells, 15) 111 | 112 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) # Coherent 113 | app.cells = 15 114 | unusedOps = app.executeRecruit("United States", 1, [1]) 115 | self.assertEqual(unusedOps, 0) 116 | self.assertEqual(app.map["United States"].sleeperCells, 1) 117 | self.assertEqual(app.cells, 14) 118 | 119 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 120 | app.cells = 15 121 | unusedOps = app.executeRecruit("United States", 1, [2]) 122 | self.assertEqual(unusedOps, 0) 123 | self.assertEqual(app.map["United States"].sleeperCells, 0) 124 | self.assertEqual(app.cells, 15) 125 | 126 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 127 | app.cells = 15 128 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 129 | self.assertEqual(unusedOps, 0) 130 | self.assertEqual(app.map["United States"].sleeperCells, 2) 131 | self.assertEqual(app.cells, 13) 132 | 133 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 134 | app.cells = 15 135 | unusedOps = app.executeRecruit("United States", 2, [1, 2]) 136 | self.assertEqual(unusedOps, 0) 137 | self.assertEqual(app.map["United States"].sleeperCells, 1) 138 | self.assertEqual(app.cells, 14) 139 | 140 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 141 | app.cells = 15 142 | unusedOps = app.executeRecruit("United States", 2, [2, 2]) 143 | self.assertEqual(unusedOps, 0) 144 | self.assertEqual(app.map["United States"].sleeperCells, 0) 145 | self.assertEqual(app.cells, 15) 146 | 147 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 148 | app.cells = 15 149 | unusedOps = app.executeRecruit("United States", 3, [1, 1, 1]) 150 | self.assertEqual(unusedOps, 0) 151 | self.assertEqual(app.map["United States"].sleeperCells, 3) 152 | self.assertEqual(app.cells, 12) 153 | 154 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 155 | app.cells = 15 156 | unusedOps = app.executeRecruit("United States", 3, [1, 2, 1]) 157 | self.assertEqual(unusedOps, 0) 158 | self.assertEqual(app.map["United States"].sleeperCells, 2) 159 | self.assertEqual(app.cells, 13) 160 | 161 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 162 | app.cells = 15 163 | unusedOps = app.executeRecruit("United States", 3, [2, 1, 2]) 164 | self.assertEqual(unusedOps, 0) 165 | self.assertEqual(app.map["United States"].sleeperCells, 1) 166 | self.assertEqual(app.cells, 14) 167 | 168 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 169 | app.cells = 15 170 | unusedOps = app.executeRecruit("United States", 3, [2, 2, 2]) 171 | self.assertEqual(unusedOps, 0) 172 | self.assertEqual(app.map["United States"].sleeperCells, 0) 173 | self.assertEqual(app.cells, 15) 174 | 175 | # not enough cells 176 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 177 | app.cells = 1 178 | app.funding = 9 179 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 180 | self.assertEqual(unusedOps, 1) 181 | self.assertEqual(app.map["United States"].sleeperCells, 1) 182 | self.assertEqual(app.cells, 0) 183 | 184 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 185 | app.cells = 2 186 | app.funding = 9 187 | unusedOps = app.executeRecruit("United States", 3, [2, 2, 1]) 188 | self.assertEqual(unusedOps, 0) 189 | self.assertEqual(app.map["United States"].sleeperCells, 1) 190 | self.assertEqual(app.cells, 1) 191 | 192 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 193 | app.cells = 2 194 | app.funding = 9 195 | unusedOps = app.executeRecruit("United States", 3, [1, 2, 1]) 196 | self.assertEqual(unusedOps, 0) 197 | self.assertEqual(app.map["United States"].sleeperCells, 2) 198 | self.assertEqual(app.cells, 0) 199 | 200 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 201 | app.cells = 2 202 | app.funding = 9 203 | unusedOps = app.executeRecruit("United States", 3, [1, 1, 2]) 204 | self.assertEqual(unusedOps, 1) 205 | self.assertEqual(app.map["United States"].sleeperCells, 2) 206 | self.assertEqual(app.cells, 0) 207 | 208 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 209 | app.cells = 1 210 | app.funding = 9 211 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 212 | self.assertEqual(unusedOps, 1) 213 | self.assertEqual(app.map["United States"].sleeperCells, 1) 214 | self.assertEqual(app.cells, 0) 215 | 216 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 217 | app.cells = 2 218 | app.funding = 9 219 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 220 | self.assertEqual(unusedOps, 0) 221 | self.assertEqual(app.map["United States"].sleeperCells, 2) 222 | self.assertEqual(app.cells, 0) 223 | 224 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 225 | app.cells = 3 226 | app.funding = 9 227 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 228 | self.assertEqual(unusedOps, 0) 229 | self.assertEqual(app.map["United States"].sleeperCells, 2) 230 | self.assertEqual(app.cells, 1) 231 | 232 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 233 | app.cells = 3 234 | app.funding = 9 235 | unusedOps = app.executeRecruit("United States", 2, [2, 1]) 236 | self.assertEqual(unusedOps, 0) 237 | self.assertEqual(app.map["United States"].sleeperCells, 1) 238 | self.assertEqual(app.cells, 2) 239 | 240 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 241 | app.cells = 5 242 | app.funding = 9 243 | unusedOps = app.executeRecruit("United States", 2, [2, 1]) 244 | self.assertEqual(unusedOps, 0) 245 | self.assertEqual(app.map["United States"].sleeperCells, 1) 246 | self.assertEqual(app.cells, 4) 247 | 248 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 249 | app.cells = 5 250 | app.funding = 9 251 | unusedOps = app.executeRecruit("United States", 2, [1, 1]) 252 | self.assertEqual(unusedOps, 0) 253 | self.assertEqual(app.map["United States"].sleeperCells, 2) 254 | self.assertEqual(app.cells, 3) 255 | 256 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 257 | app.cells = 5 258 | app.funding = 9 259 | unusedOps = app.executeRecruit("United States", 3, [1, 1, 1]) 260 | self.assertEqual(unusedOps, 0) 261 | self.assertEqual(app.map["United States"].sleeperCells, 3) 262 | self.assertEqual(app.cells, 2) 263 | 264 | app = Labyrinth(1, 2, self.set_up_blank_test_scenario) 265 | app.cells = 4 266 | app.funding = 9 267 | unusedOps = app.executeRecruit("United States", 3, [1, 1, 1]) 268 | self.assertEqual(unusedOps, 0) 269 | self.assertEqual(app.map["United States"].sleeperCells, 3) 270 | self.assertEqual(app.cells, 1) 271 | 272 | # IR RC 273 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 274 | app.cells = 15 275 | app.funding = 9 276 | app.map["Iraq"].make_poor() 277 | unusedOps = app.executeRecruit("Iraq", 1, [4]) 278 | self.assertEqual(unusedOps, 0) 279 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 280 | self.assertEqual(app.cells, 15) 281 | 282 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 283 | app.cells = 15 284 | app.funding = 9 285 | app.map["Iraq"].make_islamist_rule() 286 | unusedOps = app.executeRecruit("Iraq", 1, [6]) 287 | self.assertEqual(unusedOps, 0) 288 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 289 | self.assertEqual(app.cells, 14) 290 | 291 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 292 | app.cells = 15 293 | app.funding = 9 294 | app.map["Iraq"].make_fair() 295 | app.map["Iraq"].regimeChange = 1 296 | unusedOps = app.executeRecruit("Iraq", 1, [6]) 297 | self.assertEqual(unusedOps, 0) 298 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 299 | self.assertEqual(app.cells, 14) -------------------------------------------------------------------------------- /tests/test_place_plots.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class PlacePlotsTest(LabyrinthTestCase): 6 | """Place Plots""" 7 | 8 | def test_place_plot(self): 9 | # no cells 10 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 11 | unusedOps = app.executePlot(1, True, [1]) 12 | self.assertEqual(unusedOps, 1) 13 | unusedOps = app.executePlot(2, False, [1, 2]) 14 | self.assertEqual(unusedOps, 2) 15 | unusedOps = app.executePlot(3, True, [1, 2, 3]) 16 | self.assertEqual(unusedOps, 3) 17 | 18 | # 1 cell in US 19 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 20 | app.map["United States"].sleeperCells = 1 21 | unusedOps = app.executePlot(1, True, [2]) 22 | self.assertEqual(unusedOps, 0) 23 | self.assertEqual(app.map["United States"].activeCells, 1) 24 | self.assertEqual(app.map["United States"].sleeperCells, 0) 25 | self.assertEqual(app.map["United States"].plots, 0) 26 | 27 | unusedOps = app.executePlot(1, True, [1]) 28 | self.assertEqual(unusedOps, 0) 29 | self.assertEqual(app.map["United States"].activeCells, 1) 30 | self.assertEqual(app.map["United States"].plots, 1) 31 | 32 | # 2 cells in us 33 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 34 | app.map["United States"].sleeperCells = 2 35 | unusedOps = app.executePlot(1, True, [1]) 36 | self.assertEqual(unusedOps, 0) 37 | self.assertEqual(app.map["United States"].activeCells, 1) 38 | self.assertEqual(app.map["United States"].sleeperCells, 1) 39 | self.assertEqual(app.map["United States"].plots, 1) 40 | 41 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 42 | app.map["United States"].sleeperCells = 2 43 | unusedOps = app.executePlot(2, True, [1, 1]) 44 | self.assertEqual(unusedOps, 0) 45 | self.assertEqual(app.map["United States"].activeCells, 2) 46 | self.assertEqual(app.map["United States"].sleeperCells, 0) 47 | self.assertEqual(app.map["United States"].plots, 2) 48 | 49 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 50 | app.map["United States"].sleeperCells = 2 51 | unusedOps = app.executePlot(2, True, [1, 2]) 52 | self.assertEqual(unusedOps, 0) 53 | self.assertEqual(app.map["United States"].activeCells, 2) 54 | self.assertEqual(app.map["United States"].sleeperCells, 0) 55 | self.assertEqual(app.map["United States"].plots, 1) 56 | 57 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 58 | app.map["United States"].sleeperCells = 2 59 | unusedOps = app.executePlot(3, True, [1, 2, 3]) 60 | self.assertEqual(unusedOps, 1) 61 | self.assertEqual(app.map["United States"].activeCells, 2) 62 | self.assertEqual(app.map["United States"].sleeperCells, 0) 63 | self.assertEqual(app.map["United States"].plots, 1) 64 | 65 | # 3 cells in us 66 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 67 | app.map["United States"].sleeperCells = 3 68 | unusedOps = app.executePlot(1, True, [1]) 69 | self.assertEqual(unusedOps, 0) 70 | self.assertEqual(app.map["United States"].activeCells, 1) 71 | self.assertEqual(app.map["United States"].sleeperCells, 2) 72 | self.assertEqual(app.map["United States"].plots, 1) 73 | 74 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 75 | app.map["United States"].sleeperCells = 3 76 | unusedOps = app.executePlot(2, True, [1, 1]) 77 | self.assertEqual(unusedOps, 0) 78 | self.assertEqual(app.map["United States"].activeCells, 2) 79 | self.assertEqual(app.map["United States"].sleeperCells, 1) 80 | self.assertEqual(app.map["United States"].plots, 2) 81 | 82 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 83 | app.map["United States"].sleeperCells = 3 84 | unusedOps = app.executePlot(2, True, [1, 2]) 85 | self.assertEqual(unusedOps, 0) 86 | self.assertEqual(app.map["United States"].activeCells, 2) 87 | self.assertEqual(app.map["United States"].sleeperCells, 1) 88 | self.assertEqual(app.map["United States"].plots, 1) 89 | 90 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 91 | app.map["United States"].sleeperCells = 3 92 | unusedOps = app.executePlot(2, True, [1, 2]) 93 | self.assertEqual(unusedOps, 0) 94 | self.assertEqual(app.map["United States"].activeCells, 2) 95 | self.assertEqual(app.map["United States"].sleeperCells, 1) 96 | self.assertEqual(app.map["United States"].plots, 1) 97 | 98 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 99 | app.map["United States"].sleeperCells = 3 100 | unusedOps = app.executePlot(3, True, [1, 1, 3]) 101 | self.assertEqual(unusedOps, 0) 102 | self.assertEqual(app.map["United States"].activeCells, 3) 103 | self.assertEqual(app.map["United States"].sleeperCells, 0) 104 | self.assertEqual(app.map["United States"].plots, 2) 105 | 106 | # Low prestige, no GWOT penalty 107 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 108 | app.prestige = 3 109 | app.funding = 8 110 | app.map["Israel"].sleeperCells = 1 111 | app.map["Canada"].posture = "Soft" 112 | app.map["Canada"].sleeperCells = 1 113 | app.map["Iraq"].sleeperCells = 1 114 | app.map["Iraq"].aid = 1 115 | unusedOps = app.executePlot(1, True, [1]) 116 | self.assertEqual(unusedOps, 0) 117 | self.assertEqual(app.map["Israel"].activeCells, 1) 118 | self.assertEqual(app.map["Israel"].sleeperCells, 0) 119 | self.assertEqual(app.map["Israel"].plots, 1) 120 | self.assertEqual(app.map["Canada"].plots, 0) 121 | self.assertEqual(app.map["Iraq"].plots, 0) 122 | 123 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 124 | app.prestige = 3 125 | app.funding = 8 126 | app.map["Israel"].sleeperCells = 1 127 | app.map["Canada"].posture = "Soft" 128 | app.map["Canada"].sleeperCells = 1 129 | app.map["Iraq"].make_fair() 130 | app.map["Iraq"].sleeperCells = 1 131 | app.map["Iraq"].aid = 1 132 | unusedOps = app.executePlot(2, True, [1, 1]) 133 | self.assertEqual(unusedOps, 0) 134 | self.assertEqual(app.map["Israel"].activeCells, 1) 135 | self.assertEqual(app.map["Israel"].sleeperCells, 0) 136 | self.assertEqual(app.map["Israel"].plots, 1) 137 | self.assertEqual(app.map["Canada"].plots, 0) 138 | self.assertEqual(app.map["Iraq"].activeCells, 1) 139 | self.assertEqual(app.map["Iraq"].plots, 1) 140 | 141 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 142 | app.prestige = 3 143 | app.map["Israel"].sleeperCells = 1 144 | app.map["United States"].posture = "Soft" 145 | app.map["Iraq"].make_fair() 146 | app.map["Iraq"].sleeperCells = 1 147 | app.map["Iraq"].aid = 1 148 | unusedOps = app.executePlot(1, True, [1]) 149 | self.assertEqual(unusedOps, 0) 150 | self.assertEqual(app.map["Israel"].activeCells, 0) 151 | self.assertEqual(app.map["Israel"].sleeperCells, 1) 152 | self.assertEqual(app.map["Israel"].plots, 0) 153 | self.assertEqual(app.map["Canada"].plots, 0) 154 | self.assertEqual(app.map["Iraq"].activeCells, 1) 155 | self.assertEqual(app.map["Iraq"].plots, 1) 156 | 157 | # Low prestige, yes GWOT penalty 158 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 159 | app.prestige = 3 160 | app.map["Israel"].sleeperCells = 1 161 | app.map["Spain"].posture = "Soft" 162 | app.map["Canada"].posture = "Soft" 163 | app.map["Canada"].sleeperCells = 1 164 | app.map["Iraq"].make_fair() 165 | app.map["Iraq"].sleeperCells = 1 166 | app.map["Iraq"].aid = 1 167 | unusedOps = app.executePlot(1, True, [1]) 168 | self.assertEqual(unusedOps, 0) 169 | self.assertEqual(app.map["Israel"].activeCells, 0) 170 | self.assertEqual(app.map["Israel"].sleeperCells, 1) 171 | self.assertEqual(app.map["Israel"].plots, 0) 172 | self.assertEqual(app.map["Canada"].plots, 0) 173 | self.assertEqual(app.map["Iraq"].plots, 1) 174 | 175 | # Funding section 176 | # Low prestige, yes GWOT penalty 177 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 178 | app.prestige = 3 179 | app.funding = 9 180 | app.map["Israel"].sleeperCells = 1 181 | app.map["Spain"].posture = "Soft" 182 | app.map["Canada"].posture = "Soft" 183 | app.map["Canada"].sleeperCells = 1 184 | app.map["Iraq"].make_fair() 185 | app.map["Iraq"].sleeperCells = 1 186 | app.map["Iraq"].aid = 0 187 | unusedOps = app.executePlot(1, True, [1]) 188 | self.assertEqual(unusedOps, 1) 189 | self.assertEqual(app.map["Israel"].activeCells, 0) 190 | self.assertEqual(app.map["Israel"].sleeperCells, 1) 191 | self.assertEqual(app.map["Israel"].plots, 0) 192 | self.assertEqual(app.map["Canada"].plots, 0) 193 | self.assertEqual(app.map["Iraq"].plots, 0) 194 | 195 | # Low prestige, yes GWOT penalty 196 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 197 | app.prestige = 3 198 | app.funding = 8 199 | app.map["Israel"].sleeperCells = 1 200 | app.map["Spain"].posture = "Soft" 201 | app.map["Canada"].posture = "Soft" 202 | app.map["Canada"].sleeperCells = 0 203 | app.map["Iraq"].make_fair() 204 | app.map["Iraq"].sleeperCells = 1 205 | app.map["Iraq"].aid = 0 206 | unusedOps = app.executePlot(1, True, [1]) 207 | self.assertEqual(unusedOps, 0) 208 | self.assertEqual(app.map["Israel"].activeCells, 1) 209 | self.assertEqual(app.map["Israel"].sleeperCells, 0) 210 | self.assertEqual(app.map["Israel"].plots, 1) 211 | self.assertEqual(app.map["Canada"].plots, 0) 212 | self.assertEqual(app.map["Iraq"].plots, 0) 213 | 214 | # Low prestige, yes GWOT penalty 215 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 216 | app.prestige = 3 217 | app.funding = 8 218 | app.map["Israel"].sleeperCells = 1 219 | app.map["Spain"].posture = "Soft" 220 | app.map["Canada"].posture = "Soft" 221 | app.map["Canada"].sleeperCells = 1 222 | app.map["Iraq"].make_fair() 223 | app.map["Iraq"].sleeperCells = 1 224 | app.map["Iraq"].aid = 0 225 | unusedOps = app.executePlot(2, True, [1, 1]) 226 | self.assertEqual(unusedOps, 0) 227 | self.assertEqual(app.map["Israel"].activeCells, 1) 228 | self.assertEqual(app.map["Israel"].sleeperCells, 0) 229 | self.assertEqual(app.map["Israel"].plots, 1) 230 | self.assertEqual(app.map["Canada"].plots, 1) 231 | self.assertEqual(app.map["Iraq"].plots, 0) 232 | 233 | # Low prestige, yes GWOT penalty 234 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 235 | app.prestige = 3 236 | app.funding = 8 237 | app.map["Israel"].sleeperCells = 1 238 | app.map["Spain"].posture = "Soft" 239 | app.map["Canada"].posture = "Soft" 240 | app.map["Canada"].sleeperCells = 1 241 | app.map["Iraq"].make_fair() 242 | app.map["Iraq"].sleeperCells = 1 243 | app.map["Iraq"].aid = 0 244 | unusedOps = app.executePlot(3, True, [1, 1, 1]) 245 | self.assertEqual(unusedOps, 0) 246 | self.assertEqual(app.map["Israel"].activeCells, 1) 247 | self.assertEqual(app.map["Israel"].sleeperCells, 0) 248 | self.assertEqual(app.map["Israel"].plots, 1) 249 | self.assertEqual(app.map["Canada"].plots, 1) 250 | self.assertEqual(app.map["Iraq"].plots, 1) 251 | 252 | # High prestige 253 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 254 | app.prestige = 4 255 | app.markers = ["Abu Sayyaf"] 256 | app.map["Israel"].sleeperCells = 1 257 | app.map["Canada"].posture = "Soft" 258 | app.map["Canada"].sleeperCells = 1 259 | app.map["Iraq"].make_fair() 260 | app.map["Iraq"].sleeperCells = 1 261 | app.map["Iraq"].aid = 1 262 | app.map["Iraq"].troopCubes = 1 263 | app.map["Philippines"].sleeperCells = 1 264 | app.map["Philippines"].troopCubes = 1 265 | unusedOps = app.executePlot(1, True, [1]) 266 | self.assertEqual(unusedOps, 0) 267 | self.assertEqual(app.map["Israel"].activeCells, 0) 268 | self.assertEqual(app.map["Israel"].sleeperCells, 1) 269 | self.assertEqual(app.map["Israel"].plots, 0) 270 | self.assertEqual(app.map["Canada"].plots, 0) 271 | self.assertEqual(app.map["Iraq"].plots, 0) 272 | self.assertEqual(app.map["Philippines"].activeCells, 1) 273 | self.assertEqual(app.map["Philippines"].sleeperCells, 0) 274 | self.assertEqual(app.map["Philippines"].plots, 1) 275 | 276 | # priorities box 277 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 278 | app.prestige = 3 279 | app.map["Israel"].sleeperCells = 0 280 | app.map["Canada"].posture = "Soft" 281 | app.map["Canada"].sleeperCells = 1 282 | app.map["Spain"].posture = "Soft" 283 | app.map["Spain"].sleeperCells = 0 284 | app.map["Iraq"].make_good() 285 | app.map["Iraq"].sleeperCells = 1 286 | app.map["Iraq"].aid = 1 287 | app.map["Gulf States"].make_fair() 288 | app.map["Gulf States"].sleeperCells = 1 289 | app.map["Gulf States"].aid = 1 290 | unusedOps = app.executePlot(1, True, [1]) 291 | self.assertEqual(unusedOps, 0) 292 | self.assertEqual(app.map["Iraq"].plots, 0) 293 | self.assertEqual(app.map["Gulf States"].plots, 1) 294 | 295 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 296 | app.prestige = 3 297 | app.map["Israel"].sleeperCells = 0 298 | app.map["Canada"].posture = "Soft" 299 | app.map["Canada"].sleeperCells = 1 300 | app.map["Spain"].posture = "Soft" 301 | app.map["Spain"].sleeperCells = 0 302 | app.map["Iraq"].make_good() 303 | app.map["Iraq"].sleeperCells = 1 304 | app.map["Iraq"].aid = 1 305 | app.map["Gulf States"].make_fair() 306 | app.map["Gulf States"].sleeperCells = 1 307 | app.map["Gulf States"].aid = 1 308 | unusedOps = app.executePlot(1, False, [1]) 309 | self.assertEqual(unusedOps, 0) 310 | self.assertEqual(app.map["Iraq"].plots, 1) 311 | self.assertEqual(app.map["Gulf States"].plots, 0) -------------------------------------------------------------------------------- /tests/test_minor_jihad_choice.py: -------------------------------------------------------------------------------- 1 | from labyrinth_test_case import LabyrinthTestCase 2 | from lwotai import Labyrinth 3 | 4 | 5 | class MinorJihadChoiceTest(LabyrinthTestCase): 6 | """Test minorJihadInGoodFairChoice""" 7 | 8 | def test_minor_jihad_one_cell_one_ops(self): 9 | # one cell in each country, one ops case 10 | 11 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 12 | # only Islamist rule has cells 13 | app.map["Gulf States"].activeCells = 0 14 | app.map["Gulf States"].sleeperCells = 0 15 | app.map["Pakistan"].activeCells = 0 16 | self.assertEqual(app.minorJihadInGoodFairChoice(1), False) 17 | # fair governance 18 | app.map["Gulf States"].make_fair() 19 | app.map["Gulf States"].activeCells = 1 20 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 21 | # good governance 22 | app.map["Saudi Arabia"].make_good() 23 | app.map["Saudi Arabia"].activeCells = 1 24 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Saudi Arabia", 1)]) 25 | # 2 good governance 26 | app.map["Gulf States"].make_good() 27 | for i in range(10): 28 | retVal = app.minorJihadInGoodFairChoice(1) 29 | self.assertTrue((retVal == [("Gulf States", 1)]) or (retVal == [("Saudi Arabia", 1)])) 30 | # 2 good governance but Jordan has less resources 31 | app.map["Saudi Arabia"].make_poor() 32 | app.map["Jordan"].make_good() 33 | app.map["Jordan"].activeCells = 1 34 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 35 | # but the other is besieged 36 | app.map["Jordan"].besieged = 1 37 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Jordan", 1)]) 38 | # but the other has aid 39 | app.map["Gulf States"].aid = 1 40 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 41 | # but yet another is Pakistan 42 | app.map["Pakistan"].make_good() 43 | app.map["Pakistan"].activeCells = 1 44 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Pakistan", 1)]) 45 | # but Pakistan does not win against good if it is fair 46 | app.map["Pakistan"].make_fair() 47 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 48 | 49 | def test_minor_jihad_one_cell_two_ops(self): 50 | # one cell in each country, two ops case 51 | 52 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 53 | # only Islamist rule has cells 54 | app.map["Gulf States"].activeCells = 0 55 | app.map["Gulf States"].sleeperCells = 0 56 | app.map["Pakistan"].activeCells = 0 57 | self.assertEqual(app.minorJihadInGoodFairChoice(2), False) 58 | # fair governance 59 | app.map["Gulf States"].make_fair() 60 | app.map["Gulf States"].activeCells = 1 61 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 1)]) 62 | # good governance 63 | app.map["Saudi Arabia"].make_good() 64 | app.map["Saudi Arabia"].activeCells = 1 65 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Saudi Arabia", 1), ("Gulf States", 1)]) 66 | # 2 good governance 67 | app.map["Gulf States"].make_good() 68 | retVal = app.minorJihadInGoodFairChoice(2) 69 | self.assertTrue((("Gulf States", 1) in retVal) and (("Saudi Arabia", 1) in retVal) and len(retVal) == 2) 70 | # 2 good governance but Jordan has less resources 71 | app.map["Saudi Arabia"].make_poor() 72 | app.map["Jordan"].make_good() 73 | app.map["Jordan"].activeCells = 1 74 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 1), ("Jordan", 1)]) 75 | # but the other is besieged 76 | app.map["Jordan"].besieged = 1 77 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Jordan", 1), ("Gulf States", 1)]) 78 | # but the other has aid 79 | app.map["Gulf States"].aid = 1 80 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 1), ("Jordan", 1)]) 81 | # but yet another is Pakistan 82 | app.map["Pakistan"].make_good() 83 | app.map["Pakistan"].activeCells = 1 84 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Pakistan", 1), ("Gulf States", 1)]) 85 | # but Pakistan does not win against good if it is fair 86 | app.map["Pakistan"].make_fair() 87 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 1), ("Jordan", 1)]) 88 | 89 | def test_minor_jihad_one_cell_three_ops(self): 90 | # one cell in each country, three ops case 91 | 92 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 93 | # only Islamist rule has cells 94 | app.map["Gulf States"].activeCells = 0 95 | app.map["Gulf States"].sleeperCells = 0 96 | app.map["Pakistan"].activeCells = 0 97 | self.assertEqual(app.minorJihadInGoodFairChoice(3), False) 98 | # fair governance 99 | app.map["Gulf States"].make_fair() 100 | app.map["Gulf States"].activeCells = 1 101 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 1)]) 102 | # good governance 103 | app.map["Saudi Arabia"].make_good() 104 | app.map["Saudi Arabia"].activeCells = 1 105 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Saudi Arabia", 1), ("Gulf States", 1)]) 106 | # 2 good governance 107 | app.map["Gulf States"].make_good() 108 | self.assertTrue((("Gulf States", 1) in app.minorJihadInGoodFairChoice(3)) and 109 | (("Saudi Arabia", 1) in app.minorJihadInGoodFairChoice(3)) 110 | and len(app.minorJihadInGoodFairChoice(3)) == 2) 111 | # 2 good governance but Jordan has less resources 112 | app.map["Saudi Arabia"].make_poor() 113 | app.map["Jordan"].make_good() 114 | app.map["Jordan"].activeCells = 1 115 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 1), ("Jordan", 1)]) 116 | # but the other is besieged 117 | app.map["Jordan"].besieged = 1 118 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Jordan", 1), ("Gulf States", 1)]) 119 | # but the other has aid 120 | app.map["Gulf States"].aid = 1 121 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 1), ("Jordan", 1)]) 122 | # but yet another is Pakistan 123 | app.map["Pakistan"].make_good() 124 | app.map["Pakistan"].activeCells = 1 125 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Pakistan", 1), ("Gulf States", 1), ("Jordan", 1)]) 126 | # but Pakistan does not win against good if it is fair 127 | app.map["Pakistan"].make_fair() 128 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 1), ("Jordan", 1), ("Pakistan", 1)]) 129 | 130 | def test_minor_jihad_two_cell_one_ops(self): 131 | # two cells in each country, one ops case 132 | 133 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 134 | # only Islamist rule has cells 135 | app.map["Gulf States"].activeCells = 0 136 | app.map["Gulf States"].sleeperCells = 0 137 | app.map["Pakistan"].activeCells = 0 138 | self.assertEqual(app.minorJihadInGoodFairChoice(1), False) 139 | # fair governance 140 | app.map["Gulf States"].make_fair() 141 | app.map["Gulf States"].activeCells = 2 142 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 143 | # good governance 144 | app.map["Saudi Arabia"].make_good() 145 | app.map["Saudi Arabia"].activeCells = 2 146 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Saudi Arabia", 1)]) 147 | # 2 good governance 148 | app.map["Gulf States"].make_good() 149 | for i in range(10): 150 | retVal = app.minorJihadInGoodFairChoice(1) 151 | self.assertTrue(retVal == [("Gulf States", 1)] or retVal == [("Saudi Arabia", 1)]) 152 | # 2 good governance but Jordan has less resources 153 | app.map["Saudi Arabia"].make_poor() 154 | app.map["Jordan"].make_good() 155 | app.map["Jordan"].activeCells = 2 156 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 157 | # but the other is besieged 158 | app.map["Jordan"].besieged = 1 159 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Jordan", 1)]) 160 | # but the other has aid 161 | app.map["Gulf States"].aid = 1 162 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 163 | # but yet another is Pakistan 164 | app.map["Pakistan"].make_good() 165 | app.map["Pakistan"].activeCells = 2 166 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Pakistan", 1)]) 167 | # but Pakistan does not win against good if it is fair 168 | app.map["Pakistan"].make_fair() 169 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 170 | 171 | def test_minor_jihad_two_cell_two_ops(self): 172 | # two cell in each country, two ops case 173 | 174 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 175 | # only Islamist rule has cells 176 | app.map["Gulf States"].activeCells = 0 177 | app.map["Gulf States"].sleeperCells = 0 178 | app.map["Pakistan"].activeCells = 0 179 | self.assertEqual(app.minorJihadInGoodFairChoice(2), False) 180 | # fair governance 181 | app.map["Gulf States"].make_fair() 182 | app.map["Gulf States"].activeCells = 2 183 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 184 | # good governance 185 | app.map["Saudi Arabia"].make_good() 186 | app.map["Saudi Arabia"].activeCells = 2 187 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Saudi Arabia", 2)]) 188 | # 2 good governance 189 | app.map["Gulf States"].make_good() 190 | for i in range(10): 191 | retVal = app.minorJihadInGoodFairChoice(2) 192 | self.assertTrue(retVal == [("Gulf States", 2)] or retVal == [("Saudi Arabia", 2)]) 193 | # 2 good governance but Jordan has less resources 194 | app.map["Saudi Arabia"].make_poor() 195 | app.map["Jordan"].make_good() 196 | app.map["Jordan"].activeCells = 2 197 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 198 | # but the other is besieged 199 | app.map["Jordan"].besieged = 1 200 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Jordan", 2)]) 201 | # but the other has aid 202 | app.map["Gulf States"].aid = 1 203 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 204 | # but yet another is Pakistan 205 | app.map["Pakistan"].make_good() 206 | app.map["Pakistan"].activeCells = 2 207 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Pakistan", 2)]) 208 | # but Pakistan does not win against good if it is fair 209 | app.map["Pakistan"].make_fair() 210 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 211 | 212 | def test_minor_jihad_two_cell_three_ops(self): 213 | # two cell in each country, three ops case 214 | 215 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 216 | # only Islamist rule has cells 217 | app.map["Gulf States"].activeCells = 0 218 | app.map["Gulf States"].sleeperCells = 0 219 | app.map["Pakistan"].activeCells = 0 220 | self.assertEqual(app.minorJihadInGoodFairChoice(3), False) 221 | # fair governance 222 | app.map["Gulf States"].make_fair() 223 | app.map["Gulf States"].activeCells = 2 224 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 2)]) 225 | # good governance 226 | app.map["Saudi Arabia"].make_good() 227 | app.map["Saudi Arabia"].activeCells = 2 228 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Saudi Arabia", 2), ("Gulf States", 1)]) 229 | # 2 good governance 230 | app.map["Gulf States"].make_good() 231 | for i in range(10): 232 | retVal = app.minorJihadInGoodFairChoice(3) 233 | self.assertTrue(retVal == [("Saudi Arabia", 2), ("Gulf States", 1)] or 234 | retVal == [("Gulf States", 2), ("Saudi Arabia", 1)]) 235 | # 2 good governance but Jordan has less resources 236 | app.map["Saudi Arabia"].make_poor() 237 | app.map["Jordan"].make_good() 238 | app.map["Jordan"].activeCells = 2 239 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 2), ("Jordan", 1)]) 240 | # but the other is besieged 241 | app.map["Jordan"].besieged = 1 242 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Jordan", 2), ("Gulf States", 1)]) 243 | # but the other has aid 244 | app.map["Gulf States"].aid = 1 245 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 2), ("Jordan", 1)]) 246 | # but yet another is Pakistan 247 | app.map["Pakistan"].make_good() 248 | app.map["Pakistan"].activeCells = 2 249 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Pakistan", 2), ("Gulf States", 1)]) 250 | # but Pakistan does not win against good if it is fair 251 | app.map["Pakistan"].make_fair() 252 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 2), ("Jordan", 1)]) 253 | 254 | def test_minor_jihad_three_cell_one_ops(self): 255 | # three cells in each country, one ops case 256 | 257 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 258 | # only Islamist rule has cells 259 | app.map["Gulf States"].activeCells = 0 260 | app.map["Gulf States"].sleeperCells = 0 261 | app.map["Pakistan"].activeCells = 0 262 | self.assertEqual(app.minorJihadInGoodFairChoice(1), False) 263 | # fair governance 264 | app.map["Gulf States"].make_fair() 265 | app.map["Gulf States"].activeCells = 3 266 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 267 | # good governance 268 | app.map["Saudi Arabia"].make_good() 269 | app.map["Saudi Arabia"].activeCells = 3 270 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Saudi Arabia", 1)]) 271 | # 2 good governance 272 | app.map["Gulf States"].make_good() 273 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 274 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 275 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 276 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 277 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 278 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 279 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 280 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 281 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 282 | self.assertTrue(app.minorJihadInGoodFairChoice(1) in [[("Gulf States", 1)], [("Saudi Arabia", 1)]]) 283 | # 2 good governance but Jordan has less resources 284 | app.map["Saudi Arabia"].make_poor() 285 | app.map["Jordan"].make_good() 286 | app.map["Jordan"].activeCells = 3 287 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 288 | # but the other is besieged 289 | app.map["Jordan"].besieged = 1 290 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Jordan", 1)]) 291 | # but the other has aid 292 | app.map["Gulf States"].aid = 1 293 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 294 | # but yet another is Pakistan 295 | app.map["Pakistan"].make_good() 296 | app.map["Pakistan"].activeCells = 3 297 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Pakistan", 1)]) 298 | # but Pakistan does not win against good if it is fair 299 | app.map["Pakistan"].make_fair() 300 | self.assertEqual(app.minorJihadInGoodFairChoice(1), [("Gulf States", 1)]) 301 | 302 | def test_minor_jihad_three_cell_two_ops(self): 303 | # three cell in each country, two ops case 304 | 305 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 306 | # only Islamist rule has cells 307 | app.map["Gulf States"].activeCells = 0 308 | app.map["Gulf States"].sleeperCells = 0 309 | app.map["Pakistan"].activeCells = 0 310 | self.assertEqual(app.minorJihadInGoodFairChoice(2), False) 311 | # fair governance 312 | app.map["Gulf States"].make_fair() 313 | app.map["Gulf States"].activeCells = 3 314 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 315 | # good governance 316 | app.map["Saudi Arabia"].make_good() 317 | app.map["Saudi Arabia"].activeCells = 3 318 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Saudi Arabia", 2)]) 319 | # 2 good governance 320 | app.map["Gulf States"].make_good() 321 | for i in range(10): 322 | retVal = app.minorJihadInGoodFairChoice(2) 323 | self.assertTrue(retVal == [("Gulf States", 2)] or retVal == [("Saudi Arabia", 2)]) 324 | # 2 good governance but Jordan has less resources 325 | app.map["Saudi Arabia"].make_poor() 326 | app.map["Jordan"].make_good() 327 | app.map["Jordan"].activeCells = 3 328 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 329 | # but the other is besieged 330 | app.map["Jordan"].besieged = 1 331 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Jordan", 2)]) 332 | # but the other has aid 333 | app.map["Gulf States"].aid = 1 334 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 335 | # but yet another is Pakistan 336 | app.map["Pakistan"].make_good() 337 | app.map["Pakistan"].activeCells = 3 338 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Pakistan", 2)]) 339 | # but Pakistan does not win against good if it is fair 340 | app.map["Pakistan"].make_fair() 341 | self.assertEqual(app.minorJihadInGoodFairChoice(2), [("Gulf States", 2)]) 342 | 343 | def test_minor_jihad_three_cell_three_ops(self): 344 | # three cell in each country, three ops case 345 | 346 | app = Labyrinth(1, 1, self.set_up_test_scenario_3) 347 | # only Islamist rule has cells 348 | app.map["Gulf States"].activeCells = 0 349 | app.map["Gulf States"].sleeperCells = 0 350 | app.map["Pakistan"].activeCells = 0 351 | self.assertEqual(app.minorJihadInGoodFairChoice(3), False) 352 | # fair governance 353 | app.map["Gulf States"].make_fair() 354 | app.map["Gulf States"].activeCells = 3 355 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 3)]) 356 | # good governance 357 | app.map["Saudi Arabia"].make_good() 358 | app.map["Saudi Arabia"].activeCells = 3 359 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Saudi Arabia", 3)]) 360 | # 2 good governance 361 | app.map["Gulf States"].make_good() 362 | for i in range(10): 363 | retVal = app.minorJihadInGoodFairChoice(3) 364 | self.assertTrue((retVal == [("Saudi Arabia", 3)]) or (retVal == [("Gulf States", 3)])) 365 | # 2 good governance but Jordan has less resources 366 | app.map["Saudi Arabia"].make_poor() 367 | app.map["Jordan"].make_good() 368 | app.map["Jordan"].activeCells = 3 369 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 3)]) 370 | # but the other is besieged 371 | app.map["Jordan"].besieged = 1 372 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Jordan", 3)]) 373 | # but the other has aid 374 | app.map["Gulf States"].aid = 1 375 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 3)]) 376 | # but yet another is Pakistan 377 | app.map["Pakistan"].make_good() 378 | app.map["Pakistan"].activeCells = 3 379 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Pakistan", 3)]) 380 | # but Pakistan does not win against good if it is fair 381 | app.map["Pakistan"].make_fair() 382 | self.assertEqual(app.minorJihadInGoodFairChoice(3), [("Gulf States", 3)]) -------------------------------------------------------------------------------- /tests/test_cards_100_to_120.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from labyrinth_test_case import LabyrinthTestCase 4 | from lwotai import GOOD 5 | from lwotai import Labyrinth 6 | 7 | 8 | class Card100(LabyrinthTestCase): 9 | """His Ut-Tahrir""" 10 | 11 | def test_playable(self): 12 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 13 | self.assertTrue(app.deck["100"].playable("US", app, True)) 14 | self.assertTrue(app.deck["100"].playable("Jihadist", app, False)) 15 | 16 | def test_puts_cell(self): 17 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 18 | self.assertFalse(app.deck["100"].putsCell(app)) 19 | 20 | def test_event(self): 21 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 22 | app.deck["100"].playEvent("US", app) 23 | self.assertEqual(app.funding, 5) 24 | 25 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 26 | app.deck["100"].playEvent("Jihadist", app) 27 | self.assertEqual(app.funding, 5) 28 | 29 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 30 | app.troops = 4 31 | app.deck["100"].playEvent("US", app) 32 | self.assertEqual(app.funding, 7) 33 | 34 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 35 | app.troops = 4 36 | app.deck["100"].playEvent("Jihadist", app) 37 | self.assertEqual(app.funding, 7) 38 | 39 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 40 | app.troops = 10 41 | app.deck["100"].playEvent("US", app) 42 | self.assertEqual(app.funding, 3) 43 | 44 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 45 | app.troops = 10 46 | app.deck["100"].playEvent("Jihadist", app) 47 | self.assertEqual(app.funding, 3) 48 | 49 | 50 | class Card101(LabyrinthTestCase): 51 | """Kosovo""" 52 | 53 | def test_playable(self): 54 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 55 | self.assertTrue(app.deck["101"].playable("US", app, True)) 56 | self.assertTrue(app.deck["101"].playable("Jihadist", app, False)) 57 | 58 | def test_puts_cell(self): 59 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 60 | self.assertFalse(app.deck["101"].putsCell(app)) 61 | 62 | def test_event(self): 63 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 64 | app.deck["101"].playEvent("US", app) 65 | self.assertEqual(app.prestige, 8) 66 | self.assertEqual(app.map["Serbia"].posture, "Soft") 67 | 68 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 69 | app.map["United States"].posture = "Soft" 70 | app.deck["101"].playEvent("Jihadist", app) 71 | self.assertEqual(app.prestige, 8) 72 | self.assertEqual(app.map["Serbia"].posture, "Hard") 73 | 74 | 75 | class Card102(LabyrinthTestCase): 76 | """Former Soviet Union""" 77 | 78 | def test_playable(self): 79 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 80 | self.assertTrue(app.deck["102"].playable("US", app, True)) 81 | self.assertTrue(app.deck["102"].playable("Jihadist", app, False)) 82 | 83 | def test_puts_cell(self): 84 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 85 | self.assertFalse(app.deck["102"].putsCell(app)) 86 | 87 | def test_event(self): 88 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 89 | app.deck["102"].playEvent("US", app) 90 | self.assertTrue(app.map["Central Asia"].is_neutral()) 91 | 92 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 93 | app.testCountry("Central Asia") 94 | app.map["Central Asia"].make_good() 95 | app.map["Central Asia"].make_ally() 96 | app.deck["102"].playEvent("Jihadist", app) 97 | self.assertFalse(app.map["Central Asia"].is_good()) 98 | self.assertTrue(app.map["Central Asia"].is_neutral()) 99 | 100 | 101 | class Card103(LabyrinthTestCase): 102 | """Hizballah""" 103 | 104 | def test_playable(self): 105 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 106 | self.assertTrue(app.deck["103"].playable("US", app, True)) 107 | self.assertTrue(app.deck["103"].playable("Jihadist", app, False)) 108 | 109 | def test_puts_cell(self): 110 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 111 | self.assertFalse(app.deck["103"].putsCell(app)) 112 | 113 | def test_event(self): 114 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 115 | app.testCountry("Iraq") 116 | app.map["Iraq"].sleeperCells = 1 117 | app.deck["103"].playEvent("US", app) 118 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 119 | 120 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 121 | app.deck["103"].playEvent("Jihadist", app) 122 | self.assertTrue(app.map["Lebanon"].is_poor()) 123 | self.assertTrue(app.map["Lebanon"].is_neutral()) 124 | 125 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 126 | app.testCountry("Lebanon") 127 | app.map["Lebanon"].make_good() 128 | app.map["Lebanon"].make_ally() 129 | app.map["Jordan"].make_good() 130 | app.map["Jordan"].make_ally() 131 | app.deck["103"].playEvent("Jihadist", app) 132 | self.assertTrue(app.map["Lebanon"].is_poor()) 133 | self.assertTrue(app.map["Lebanon"].is_neutral()) 134 | 135 | # no countries 136 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Iraq"]) 137 | app.deck["103"].playEvent("US", app) 138 | 139 | # one country 140 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Iraq"]) 141 | app.testCountry("Iraq") 142 | app.map["Iraq"].sleeperCells = 1 143 | app.testCountry("Gulf States") 144 | app.map["Gulf States"].sleeperCells = 1 145 | app.deck["103"].playEvent("US", app) 146 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 147 | 148 | 149 | class Card104(LabyrinthTestCase): 150 | """Iran""" 151 | 152 | def test_playable(self): 153 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 154 | self.assertTrue(app.deck["104"].playable("US", app, True)) 155 | self.assertTrue(app.deck["104"].playable("Jihadist", app, False)) 156 | 157 | def test_puts_cell(self): 158 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 159 | self.assertFalse(app.deck["104"].putsCell(app)) 160 | 161 | def test_event(self): 162 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Iraq"]) 163 | app.testCountry("Iraq") 164 | app.map["Iraq"].sleeperCells = 1 165 | app.deck["104"].playEvent("US", app) 166 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 167 | 168 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Yemen"]) 169 | app.testCountry("Iraq") 170 | app.map["Iraq"].sleeperCells = 1 171 | app.testCountry("Yemen") 172 | app.map["Yemen"].sleeperCells = 1 173 | app.deck["104"].playEvent("US", app) 174 | self.assertEqual(app.map["Yemen"].sleeperCells, 0) 175 | 176 | app.deck["104"].playEvent("Jihadist", app) 177 | 178 | 179 | class Card105(LabyrinthTestCase): 180 | """Iran""" 181 | 182 | def test_playable(self): 183 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 184 | self.assertTrue(app.deck["105"].playable("US", app, True)) 185 | self.assertTrue(app.deck["105"].playable("Jihadist", app, False)) 186 | 187 | def test_puts_cell(self): 188 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 189 | self.assertFalse(app.deck["105"].putsCell(app)) 190 | 191 | def test_event(self): 192 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Iraq"]) 193 | app.testCountry("Iraq") 194 | app.map["Iraq"].sleeperCells = 1 195 | app.deck["105"].playEvent("US", app) 196 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 197 | 198 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Yemen"]) 199 | app.testCountry("Iraq") 200 | app.map["Iraq"].sleeperCells = 1 201 | app.testCountry("Yemen") 202 | app.map["Yemen"].sleeperCells = 1 203 | app.deck["105"].playEvent("US", app) 204 | self.assertEqual(app.map["Yemen"].sleeperCells, 0) 205 | 206 | app.deck["105"].playEvent("Jihadist", app) 207 | 208 | 209 | class Card106(LabyrinthTestCase): 210 | """Jaysh al-Mahdi""" 211 | 212 | def test_playable(self): 213 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 214 | self.assertFalse(app.deck["106"].playable("US", app, True)) 215 | self.assertFalse(app.deck["106"].playable("Jihadist", app, False)) 216 | app.testCountry("Iraq") 217 | app.map["Iraq"].sleeperCells = 1 218 | self.assertFalse(app.deck["106"].playable("US", app, True)) 219 | self.assertFalse(app.deck["106"].playable("Jihadist", app, False)) 220 | app.map["Iraq"].troopCubes = 1 221 | self.assertTrue(app.deck["106"].playable("US", app, True)) 222 | self.assertTrue(app.deck["106"].playable("Jihadist", app, False)) 223 | app.map["Iraq"].sleeperCells = 0 224 | self.assertFalse(app.deck["106"].playable("US", app, True)) 225 | self.assertFalse(app.deck["106"].playable("Jihadist", app, False)) 226 | 227 | def test_puts_cell(self): 228 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 229 | self.assertFalse(app.deck["106"].putsCell(app)) 230 | 231 | def test_event(self): 232 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 233 | app.testCountry("Iraq") 234 | app.map["Iraq"].sleeperCells = 3 235 | app.map["Iraq"].troopCubes = 1 236 | app.deck["106"].playEvent("US", app) 237 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 238 | 239 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 240 | app.testCountry("Iraq") 241 | app.map["Iraq"].sleeperCells = 2 242 | app.map["Iraq"].troopCubes = 1 243 | app.deck["106"].playEvent("US", app) 244 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 245 | 246 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 247 | app.testCountry("Iraq") 248 | app.map["Iraq"].sleeperCells = 1 249 | app.map["Iraq"].troopCubes = 1 250 | app.deck["106"].playEvent("US", app) 251 | self.assertEqual(app.map["Iraq"].sleeperCells, 0) 252 | 253 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Lebanon"]) 254 | app.testCountry("Iraq") 255 | app.map["Iraq"].sleeperCells = 2 256 | app.map["Iraq"].troopCubes = 1 257 | app.map["Lebanon"].sleeperCells = 2 258 | app.map["Lebanon"].troopCubes = 1 259 | print "Choose Lebanon" 260 | app.deck["106"].playEvent("US", app) 261 | self.assertEqual(app.map["Lebanon"].sleeperCells, 0) 262 | 263 | print "HERE" 264 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 265 | app.testCountry("Iraq") 266 | app.map["Iraq"].make_fair() 267 | app.map["Iraq"].sleeperCells = 2 268 | app.map["Iraq"].troopCubes = 1 269 | app.deck["106"].playEvent("Jihadist", app) 270 | 271 | 272 | class Card107(LabyrinthTestCase): 273 | """Kurdistan""" 274 | 275 | def test_playable(self): 276 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 277 | self.assertTrue(app.deck["107"].playable("US", app, True)) 278 | self.assertTrue(app.deck["107"].playable("Jihadist", app, False)) 279 | 280 | def test_puts_cell(self): 281 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 282 | self.assertFalse(app.deck["107"].putsCell(app)) 283 | 284 | def test_event(self): 285 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 286 | app.testCountry("Iraq") 287 | app.deck["107"].playEvent("US", app) 288 | self.assertEqual(app.map["Iraq"].aid, 1) 289 | 290 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 291 | app.deck["107"].playEvent("Jihadist", app) 292 | self.assertTrue(app.map["Turkey"].is_poor()) 293 | 294 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 295 | app.testCountry("Iraq") 296 | app.map["Iraq"].make_good() 297 | app.deck["107"].playEvent("Jihadist", app) 298 | self.assertTrue(app.map["Turkey"].governance_is_worse_than(GOOD)) 299 | self.assertTrue(app.map["Iraq"].is_fair()) 300 | 301 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 302 | app.testCountry("Iraq") 303 | app.map["Iraq"].make_fair() 304 | app.testCountry("Turkey") 305 | app.map["Turkey"].make_fair() 306 | app.map["Turkey"].aid = 1 307 | app.deck["107"].playEvent("Jihadist", app) 308 | self.assertTrue(app.map["Turkey"].is_poor()) 309 | self.assertTrue(app.map["Iraq"].is_fair()) 310 | 311 | 312 | class Card108(LabyrinthTestCase): 313 | """Musharraf""" 314 | 315 | def test_playable(self): 316 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 317 | self.assertFalse(app.deck["108"].playable("US", app, True)) 318 | self.assertFalse(app.deck["108"].playable("Jihadist", app, False)) 319 | app.testCountry("Pakistan") 320 | app.map["Pakistan"].activeCells = 1 321 | self.assertTrue(app.deck["108"].playable("US", app, True)) 322 | self.assertTrue(app.deck["108"].playable("Jihadist", app, False)) 323 | app.markers.append("Benazir Bhutto") 324 | self.assertFalse(app.deck["108"].playable("US", app, True)) 325 | self.assertFalse(app.deck["108"].playable("Jihadist", app, False)) 326 | 327 | def test_puts_cell(self): 328 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 329 | self.assertFalse(app.deck["108"].putsCell(app)) 330 | 331 | def test_event(self): 332 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 333 | app.testCountry("Pakistan") 334 | app.map["Pakistan"].sleeperCells = 1 335 | app.map["Pakistan"].make_good() 336 | app.deck["108"].playEvent("US", app) 337 | self.assertCells(app, "Pakistan", 0, True) 338 | self.assertTrue(app.map["Pakistan"].is_poor()) 339 | self.assertTrue(app.map["Pakistan"].is_ally()) 340 | 341 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 342 | app.testCountry("Pakistan") 343 | app.map["Pakistan"].sleeperCells = 3 344 | app.map["Pakistan"].make_islamist_rule() 345 | app.map["Pakistan"].make_adversary() 346 | app.deck["108"].playEvent("Jihadist", app) 347 | self.assertCells(app, "Pakistan", 2, True) 348 | self.assertTrue(app.map["Pakistan"].is_poor()) 349 | self.assertTrue(app.map["Pakistan"].is_ally()) 350 | 351 | 352 | class Card109(LabyrinthTestCase): 353 | """Tora Bora""" 354 | 355 | def test_playable(self): 356 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 357 | self.assertFalse(app.deck["109"].playable("US", app, True)) 358 | self.assertFalse(app.deck["109"].playable("Jihadist", app, False)) 359 | app.testCountry("Pakistan") 360 | app.map["Pakistan"].activeCells = 2 361 | self.assertFalse(app.deck["109"].playable("US", app, True)) 362 | self.assertFalse(app.deck["109"].playable("Jihadist", app, False)) 363 | app.map["Pakistan"].regimeChange = 1 364 | self.assertTrue(app.deck["109"].playable("US", app, True)) 365 | self.assertTrue(app.deck["109"].playable("Jihadist", app, False)) 366 | 367 | def test_puts_cell(self): 368 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 369 | self.assertFalse(app.deck["109"].putsCell(app)) 370 | 371 | def test_event(self): 372 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 373 | app.testCountry("Pakistan") 374 | app.map["Pakistan"].sleeperCells = 2 375 | app.map["Pakistan"].regimeChange = 1 376 | app.deck["109"].playEvent("US", app) 377 | self.assertCells(app, "Pakistan", 0, True) 378 | self.assertTrue(app.prestige != 7) 379 | 380 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 381 | app.testCountry("Pakistan") 382 | app.map["Pakistan"].sleeperCells = 2 383 | app.map["Pakistan"].regimeChange = 1 384 | app.deck["109"].playEvent("Jihadist", app) 385 | self.assertCells(app, "Pakistan", 0, True) 386 | self.assertTrue(app.prestige != 7) 387 | 388 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Iraq"]) 389 | app.testCountry("Pakistan") 390 | app.map["Pakistan"].sleeperCells = 2 391 | app.map["Pakistan"].regimeChange = 1 392 | app.testCountry("Iraq") 393 | app.map["Iraq"].sleeperCells = 2 394 | app.map["Iraq"].regimeChange = 1 395 | print "Choose Iraq" 396 | app.deck["109"].playEvent("US", app) 397 | self.assertCells(app, "Iraq", 0, True) 398 | self.assertTrue(app.prestige != 7) 399 | 400 | 401 | class Card110(LabyrinthTestCase): 402 | """Zarqawi""" 403 | 404 | def test_playable(self): 405 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 406 | self.assertFalse(app.deck["110"].playable("US", app, True)) 407 | self.assertFalse(app.deck["110"].playable("Jihadist", app, False)) 408 | app.testCountry("Iraq") 409 | app.map["Iraq"].troopCubes = 1 410 | self.assertTrue(app.deck["110"].playable("US", app, True)) 411 | self.assertTrue(app.deck["110"].playable("Jihadist", app, False)) 412 | 413 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 414 | self.assertFalse(app.deck["110"].playable("US", app, True)) 415 | self.assertFalse(app.deck["110"].playable("Jihadist", app, False)) 416 | app.testCountry("Syria") 417 | app.map["Syria"].troopCubes = 1 418 | self.assertTrue(app.deck["110"].playable("US", app, True)) 419 | self.assertTrue(app.deck["110"].playable("Jihadist", app, False)) 420 | 421 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 422 | self.assertFalse(app.deck["110"].playable("US", app, True)) 423 | self.assertFalse(app.deck["110"].playable("Jihadist", app, False)) 424 | app.testCountry("Lebanon") 425 | app.map["Lebanon"].troopCubes = 1 426 | self.assertTrue(app.deck["110"].playable("US", app, True)) 427 | self.assertTrue(app.deck["110"].playable("Jihadist", app, False)) 428 | 429 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 430 | self.assertFalse(app.deck["110"].playable("US", app, True)) 431 | self.assertFalse(app.deck["110"].playable("Jihadist", app, False)) 432 | app.testCountry("Jordan") 433 | app.map["Jordan"].troopCubes = 1 434 | self.assertTrue(app.deck["110"].playable("US", app, True)) 435 | self.assertTrue(app.deck["110"].playable("Jihadist", app, False)) 436 | 437 | def test_puts_cell(self): 438 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 439 | self.assertTrue(app.deck["110"].putsCell(app)) 440 | 441 | def test_event(self): 442 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 443 | app.testCountry("Iraq") 444 | app.map["Iraq"].troopCubes = 2 445 | app.deck["110"].playEvent("US", app) 446 | self.assertEqual(app.prestige, 10) 447 | 448 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 449 | app.testCountry("Iraq") 450 | app.map["Iraq"].troopCubes = 2 451 | app.deck["110"].playEvent("Jihadist", app) 452 | self.assertEqual(app.map["Iraq"].totalCells(True), 3) 453 | self.assertEqual(app.map["Iraq"].plots, 1) 454 | 455 | 456 | class Card111(LabyrinthTestCase): 457 | """Zawahiri""" 458 | 459 | def test_playable(self): 460 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 461 | self.assertTrue(app.deck["111"].playable("US", app, True)) 462 | self.assertTrue(app.deck["111"].playable("Jihadist", app, False)) 463 | 464 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 465 | app.testCountry("Iraq") 466 | app.map["Iraq"].make_islamist_rule() 467 | self.assertFalse(app.deck["111"].playable("US", app, True)) 468 | self.assertTrue(app.deck["111"].playable("Jihadist", app, False)) 469 | 470 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 471 | app.testCountry("Pakistan") 472 | app.map["Pakistan"].markers.append("FATA") 473 | self.assertFalse(app.deck["111"].playable("US", app, True)) 474 | self.assertTrue(app.deck["111"].playable("Jihadist", app, False)) 475 | 476 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 477 | app.testCountry("Pakistan") 478 | app.markers.append("Al-Anbar") 479 | self.assertFalse(app.deck["111"].playable("US", app, True)) 480 | self.assertTrue(app.deck["111"].playable("Jihadist", app, False)) 481 | 482 | def test_puts_cell(self): 483 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 484 | self.assertFalse(app.deck["111"].putsCell(app)) 485 | 486 | def test_event(self): 487 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 488 | app.deck["111"].playEvent("US", app) 489 | self.assertEqual(app.funding, 3) 490 | 491 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 492 | app.deck["111"].playEvent("Jihadist", app) 493 | self.assertEqual(app.prestige, 6) 494 | 495 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 496 | app.testCountry("Iraq") 497 | app.map["Iraq"].make_islamist_rule() 498 | app.deck["111"].playEvent("Jihadist", app) 499 | self.assertEqual(app.prestige, 4) 500 | 501 | 502 | class Card112(LabyrinthTestCase): 503 | """Bin Ladin""" 504 | 505 | def test_playable(self): 506 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 507 | self.assertTrue(app.deck["112"].playable("US", app, True)) 508 | self.assertTrue(app.deck["112"].playable("Jihadist", app, False)) 509 | 510 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 511 | app.testCountry("Iraq") 512 | app.map["Iraq"].make_islamist_rule() 513 | self.assertFalse(app.deck["112"].playable("US", app, True)) 514 | self.assertTrue(app.deck["112"].playable("Jihadist", app, False)) 515 | 516 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 517 | app.testCountry("Pakistan") 518 | app.map["Pakistan"].markers.append("FATA") 519 | self.assertFalse(app.deck["112"].playable("US", app, True)) 520 | self.assertTrue(app.deck["112"].playable("Jihadist", app, False)) 521 | 522 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 523 | app.testCountry("Pakistan") 524 | app.markers.append("Al-Anbar") 525 | self.assertFalse(app.deck["112"].playable("US", app, True)) 526 | self.assertTrue(app.deck["112"].playable("Jihadist", app, False)) 527 | 528 | def test_puts_cell(self): 529 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 530 | self.assertFalse(app.deck["112"].putsCell(app)) 531 | 532 | def test_event(self): 533 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 534 | app.deck["112"].playEvent("US", app) 535 | self.assertEqual(app.funding, 1) 536 | 537 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 538 | app.deck["112"].playEvent("Jihadist", app) 539 | self.assertEqual(app.prestige, 5) 540 | 541 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 542 | app.testCountry("Iraq") 543 | app.map["Iraq"].make_islamist_rule() 544 | app.deck["112"].playEvent("Jihadist", app) 545 | self.assertEqual(app.prestige, 3) 546 | 547 | 548 | class Card113(LabyrinthTestCase): 549 | """Darfur""" 550 | 551 | def test_playable(self): 552 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 553 | self.assertTrue(app.deck["113"].playable("US", app, True)) 554 | self.assertTrue(app.deck["113"].playable("Jihadist", app, False)) 555 | 556 | def test_puts_cell(self): 557 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 558 | self.assertFalse(app.deck["113"].putsCell(app)) 559 | 560 | def test_event(self): 561 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 562 | app.deck["113"].playEvent("US", app) 563 | self.assertTrue(app.map["Sudan"].is_governed()) 564 | self.assertEqual(app.map["Sudan"].aid, 1) 565 | self.assertTrue(app.map["Sudan"].is_ally()) 566 | 567 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 568 | app.testCountry("Sudan") 569 | app.map["Sudan"].make_adversary() 570 | app.deck["113"].playEvent("US", app) 571 | self.assertTrue(app.map["Sudan"].is_governed()) 572 | self.assertEqual(app.map["Sudan"].aid, 1) 573 | self.assertTrue(app.map["Sudan"].is_neutral()) 574 | 575 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 576 | app.prestige = 6 577 | app.deck["113"].playEvent("US", app) 578 | self.assertTrue(app.map["Sudan"].is_governed()) 579 | self.assertEqual(app.map["Sudan"].besieged, 1) 580 | self.assertTrue(app.map["Sudan"].is_adversary()) 581 | 582 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 583 | app.prestige = 6 584 | app.testCountry("Sudan") 585 | app.map["Sudan"].make_ally() 586 | app.deck["113"].playEvent("US", app) 587 | self.assertTrue(app.map["Sudan"].is_governed()) 588 | self.assertEqual(app.map["Sudan"].besieged, 1) 589 | self.assertTrue(app.map["Sudan"].is_neutral()) 590 | 591 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 592 | app.deck["113"].playEvent("Jihadist", app) 593 | self.assertTrue(app.map["Sudan"].is_governed()) 594 | self.assertEqual(app.map["Sudan"].aid, 1) 595 | self.assertTrue(app.map["Sudan"].is_ally()) 596 | 597 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 598 | app.testCountry("Sudan") 599 | app.map["Sudan"].make_adversary() 600 | app.deck["113"].playEvent("Jihadist", app) 601 | self.assertTrue(app.map["Sudan"].is_governed()) 602 | self.assertEqual(app.map["Sudan"].aid, 1) 603 | self.assertTrue(app.map["Sudan"].is_neutral()) 604 | 605 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 606 | app.prestige = 6 607 | app.deck["113"].playEvent("Jihadist", app) 608 | self.assertTrue(app.map["Sudan"].is_governed()) 609 | self.assertEqual(app.map["Sudan"].besieged, 1) 610 | self.assertTrue(app.map["Sudan"].is_adversary()) 611 | 612 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 613 | app.prestige = 6 614 | app.testCountry("Sudan") 615 | app.map["Sudan"].make_ally() 616 | app.deck["113"].playEvent("Jihadist", app) 617 | self.assertTrue(app.map["Sudan"].is_governed()) 618 | self.assertEqual(app.map["Sudan"].besieged, 1) 619 | self.assertTrue(app.map["Sudan"].is_neutral()) 620 | 621 | 622 | class Card114(LabyrinthTestCase): 623 | """GTMO""" 624 | 625 | def test_playable(self): 626 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 627 | self.assertTrue(app.deck["114"].playable("US", app, True)) 628 | self.assertTrue(app.deck["114"].playable("Jihadist", app, False)) 629 | 630 | def test_puts_cell(self): 631 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 632 | self.assertFalse(app.deck["114"].putsCell(app)) 633 | 634 | def test_event(self): 635 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 636 | app.deck["114"].playEvent("US", app) 637 | self.assertTrue("GTMO" in app.lapsing) 638 | self.assertTrue(app.prestige != 7) 639 | 640 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 641 | app.deck["114"].playEvent("Jihadist", app) 642 | self.assertTrue("GTMO" in app.lapsing) 643 | self.assertTrue(app.prestige != 7) 644 | 645 | 646 | class Card115(LabyrinthTestCase): 647 | """Hambali""" 648 | 649 | def test_playable(self): 650 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 651 | self.assertFalse(app.deck["115"].playable("US", app, True)) 652 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 653 | app.testCountry("Indonesia/Malaysia") 654 | app.map["Indonesia/Malaysia"].sleeperCells = 1 655 | app.map["Indonesia/Malaysia"].make_ally() 656 | self.assertTrue(app.deck["115"].playable("US", app, True)) 657 | self.assertTrue(app.deck["115"].playable("Jihadist", app, False)) 658 | app.map["Indonesia/Malaysia"].sleeperCells = 0 659 | self.assertFalse(app.deck["115"].playable("US", app, True)) 660 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 661 | app.map["Indonesia/Malaysia"].sleeperCells = 1 662 | app.map["Indonesia/Malaysia"].make_neutral() 663 | self.assertFalse(app.deck["115"].playable("US", app, True)) 664 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 665 | 666 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 667 | self.assertFalse(app.deck["115"].playable("US", app, True)) 668 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 669 | app.testCountry("Pakistan") 670 | app.map["Pakistan"].sleeperCells = 1 671 | app.map["Pakistan"].make_ally() 672 | self.assertTrue(app.deck["115"].playable("US", app, True)) 673 | self.assertTrue(app.deck["115"].playable("Jihadist", app, False)) 674 | app.map["Pakistan"].sleeperCells = 0 675 | self.assertFalse(app.deck["115"].playable("US", app, True)) 676 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 677 | app.map["Pakistan"].sleeperCells = 1 678 | app.map["Pakistan"].make_neutral() 679 | self.assertFalse(app.deck["115"].playable("US", app, True)) 680 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 681 | 682 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 683 | self.assertFalse(app.deck["115"].playable("US", app, True)) 684 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 685 | app.testCountry("India") 686 | app.map["India"].sleeperCells = 1 687 | app.map["India"].posture = "Hard" 688 | self.assertTrue(app.deck["115"].playable("US", app, True)) 689 | self.assertTrue(app.deck["115"].playable("Jihadist", app, False)) 690 | app.map["India"].sleeperCells = 0 691 | self.assertFalse(app.deck["115"].playable("US", app, True)) 692 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 693 | app.map["India"].sleeperCells = 1 694 | app.map["India"].posture = "Soft" 695 | self.assertFalse(app.deck["115"].playable("US", app, True)) 696 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 697 | 698 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 699 | self.assertFalse(app.deck["115"].playable("US", app, True)) 700 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 701 | app.testCountry("Thailand") 702 | app.map["Thailand"].sleeperCells = 1 703 | app.map["Thailand"].posture = "Hard" 704 | self.assertTrue(app.deck["115"].playable("US", app, True)) 705 | self.assertTrue(app.deck["115"].playable("Jihadist", app, False)) 706 | app.map["Thailand"].sleeperCells = 0 707 | self.assertFalse(app.deck["115"].playable("US", app, True)) 708 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 709 | app.map["Thailand"].sleeperCells = 1 710 | app.map["Thailand"].posture = "Soft" 711 | self.assertFalse(app.deck["115"].playable("US", app, True)) 712 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 713 | 714 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 715 | self.assertFalse(app.deck["115"].playable("US", app, True)) 716 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 717 | app.testCountry("Philippines") 718 | app.map["Philippines"].sleeperCells = 1 719 | app.map["Philippines"].posture = "Hard" 720 | self.assertTrue(app.deck["115"].playable("US", app, True)) 721 | self.assertTrue(app.deck["115"].playable("Jihadist", app, False)) 722 | app.map["Philippines"].sleeperCells = 0 723 | self.assertFalse(app.deck["115"].playable("US", app, True)) 724 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 725 | app.map["Philippines"].sleeperCells = 1 726 | app.map["Philippines"].posture = "Soft" 727 | self.assertFalse(app.deck["115"].playable("US", app, True)) 728 | self.assertFalse(app.deck["115"].playable("Jihadist", app, False)) 729 | 730 | def test_puts_cell(self): 731 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 732 | self.assertFalse(app.deck["115"].putsCell(app)) 733 | 734 | def test_event(self): 735 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 736 | app.testCountry("Philippines") 737 | app.map["Philippines"].sleeperCells = 1 738 | app.map["Philippines"].posture = "Hard" 739 | app.deck["115"].playEvent("US", app) 740 | self.assertEqual(app.map["Philippines"].sleeperCells, 0) 741 | 742 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["Indonesia/Malaysia"]) 743 | app.testCountry("Indonesia/Malaysia") 744 | app.map["Indonesia/Malaysia"].sleeperCells = 1 745 | app.map["Indonesia/Malaysia"].make_ally() 746 | app.testCountry("Philippines") 747 | app.map["Philippines"].sleeperCells = 1 748 | app.map["Philippines"].posture = "Hard" 749 | print "Choose Indonesia/Malaysia" 750 | app.deck["115"].playEvent("US", app) 751 | self.assertEqual(app.map["Indonesia/Malaysia"].sleeperCells, 0) 752 | 753 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 754 | app.testCountry("Indonesia/Malaysia") 755 | app.map["Indonesia/Malaysia"].sleeperCells = 1 756 | app.map["Indonesia/Malaysia"].make_ally() 757 | app.deck["115"].playEvent("Jihadist", app) 758 | self.assertEqual(app.map["Indonesia/Malaysia"].plots, 1) 759 | 760 | 761 | class Card116(LabyrinthTestCase): 762 | """KSM""" 763 | 764 | def test_playable(self): 765 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 766 | self.assertTrue(app.deck["116"].playable("Jihadist", app, False)) 767 | self.assertFalse(app.deck["116"].playable("US", app, True)) 768 | app.testCountry("Iraq") 769 | app.map["Iraq"].make_ally() 770 | app.map["Iraq"].plots = 1 771 | self.assertTrue(app.deck["116"].playable("US", app, True)) 772 | 773 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 774 | self.assertTrue(app.deck["116"].playable("Jihadist", app, False)) 775 | self.assertFalse(app.deck["116"].playable("US", app, True)) 776 | app.testCountry("Canada") 777 | app.map["Canada"].plots = 1 778 | self.assertTrue(app.deck["116"].playable("US", app, True)) 779 | 780 | def test_puts_cell(self): 781 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 782 | self.assertFalse(app.deck["116"].putsCell(app)) 783 | 784 | def test_event(self): 785 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 786 | app.testCountry("Iraq") 787 | app.map["Iraq"].make_ally() 788 | app.map["Iraq"].plots = 2 789 | app.testCountry("Pakistan") 790 | app.map["Pakistan"].make_neutral() 791 | app.map["Pakistan"].plots = 2 792 | app.testCountry("Canada") 793 | app.map["Canada"].plots = 1 794 | app.deck["116"].playEvent("US", app) 795 | self.assertEqual(app.map["Iraq"].plots, 0) 796 | self.assertEqual(app.map["Pakistan"].plots, 2) 797 | self.assertEqual(app.map["Canada"].plots, 0) 798 | 799 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 800 | app.testCountry("Iraq") 801 | app.map["Iraq"].sleeperCells = 1 802 | app.deck["116"].playEvent("Jihadist", app) 803 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 804 | self.assertEqual(app.map["Iraq"].activeCells, 0) 805 | self.assertEqual(app.map["Iraq"].plots, 1) 806 | 807 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 808 | app.testCountry("Iraq") 809 | app.map["Iraq"].make_islamist_rule() 810 | app.map["Iraq"].sleeperCells = 1 811 | app.deck["116"].playEvent("Jihadist", app) 812 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 813 | self.assertEqual(app.map["Iraq"].activeCells, 0) 814 | self.assertEqual(app.map["Iraq"].plots, 0) 815 | 816 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 817 | app.testCountry("Iraq") 818 | app.map["Iraq"].sleeperCells = 1 819 | app.map["United States"].sleeperCells = 1 820 | app.deck["116"].playEvent("Jihadist", app) 821 | self.assertEqual(app.map["Iraq"].sleeperCells, 1) 822 | self.assertEqual(app.map["Iraq"].activeCells, 0) 823 | self.assertEqual(app.map["Iraq"].plots, 0) 824 | self.assertEqual(app.map["United States"].sleeperCells, 1) 825 | self.assertEqual(app.map["United States"].activeCells, 0) 826 | self.assertEqual(app.map["United States"].plots, 1) 827 | 828 | 829 | class Card117(LabyrinthTestCase): 830 | """Oil Price Spike""" 831 | 832 | def test_playable(self): 833 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 834 | self.assertTrue(app.deck["117"].playable("Jihadist", app, False)) 835 | self.assertTrue(app.deck["117"].playable("US", app, True)) 836 | 837 | def test_puts_cell(self): 838 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 839 | self.assertFalse(app.deck["117"].putsCell(app)) 840 | 841 | def test_event(self): 842 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 843 | app.deck["117"].playEvent("US", app) 844 | self.assertEqual(app.countryResources("Saudi Arabia"), 4) 845 | 846 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["y"]) 847 | app.deck["117"].playEvent("Jihadist", app) 848 | self.assertEqual(app.countryResources("Saudi Arabia"), 4) 849 | app.deck["117"].playEvent("US", app) 850 | self.assertEqual(app.countryResources("Saudi Arabia"), 5) 851 | 852 | 853 | class Card118(LabyrinthTestCase): 854 | """Oil Price Spike""" 855 | 856 | def test_playable(self): 857 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 858 | self.assertTrue(app.deck["118"].playable("Jihadist", app, False)) 859 | self.assertTrue(app.deck["118"].playable("US", app, True)) 860 | 861 | def test_puts_cell(self): 862 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 863 | self.assertFalse(app.deck["118"].putsCell(app)) 864 | 865 | def test_event(self): 866 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 867 | app.deck["118"].playEvent("US", app) 868 | self.assertEqual(app.countryResources("Saudi Arabia"), 4) 869 | 870 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario, ["y"]) 871 | app.deck["118"].playEvent("Jihadist", app) 872 | self.assertEqual(app.countryResources("Saudi Arabia"), 4) 873 | app.deck["118"].playEvent("US", app) 874 | self.assertEqual(app.countryResources("Saudi Arabia"), 5) 875 | 876 | 877 | class Card119(LabyrinthTestCase): 878 | """Saleh""" 879 | 880 | def test_playable(self): 881 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 882 | self.assertTrue(app.deck["119"].playable("Jihadist", app, False)) 883 | self.assertTrue(app.deck["119"].playable("US", app, True)) 884 | 885 | def test_puts_cell(self): 886 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 887 | self.assertFalse(app.deck["119"].putsCell(app)) 888 | 889 | def test_event(self): 890 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 891 | app.deck["119"].playEvent("US", app) 892 | self.assertTrue(app.map["Yemen"].is_governed()) 893 | self.assertTrue(app.map["Yemen"].is_ally()) 894 | self.assertEqual(app.map["Yemen"].aid, 1) 895 | 896 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 897 | app.map["Yemen"].make_islamist_rule() 898 | app.map["Yemen"].make_neutral() 899 | app.deck["119"].playEvent("US", app) 900 | self.assertTrue(app.map["Yemen"].is_governed()) 901 | self.assertTrue(app.map["Yemen"].is_neutral()) 902 | self.assertEqual(app.map["Yemen"].aid, 0) 903 | 904 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 905 | app.deck["119"].playEvent("Jihadist", app) 906 | self.assertTrue(app.map["Yemen"].is_governed()) 907 | self.assertTrue(app.map["Yemen"].is_adversary()) 908 | self.assertEqual(app.map["Yemen"].besieged, 1) 909 | 910 | 911 | class Card120(LabyrinthTestCase): 912 | """US Election""" 913 | 914 | def test_playable(self): 915 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 916 | self.assertTrue(app.deck["120"].playable("Jihadist", app, False)) 917 | self.assertTrue(app.deck["120"].playable("US", app, True)) 918 | 919 | def test_puts_cell(self): 920 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 921 | self.assertFalse(app.deck["120"].putsCell(app)) 922 | 923 | def test_event(self): 924 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 925 | app.executeCardUSElection(5) 926 | self.assertEqual(app.prestige, 8) 927 | 928 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 929 | app.executeCardUSElection(4) 930 | self.assertEqual(app.prestige, 6) 931 | 932 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 933 | app.deck["120"].playEvent("US", app) 934 | self.assertTrue(app.prestige != 7) 935 | 936 | app = Labyrinth(1, 1, self.set_up_blank_test_scenario) 937 | app.deck["120"].playEvent("US", app) 938 | self.assertTrue(app.prestige != 7) 939 | 940 | 941 | if __name__ == "__main__": 942 | unittest.main() --------------------------------------------------------------------------------