示例#1
0
    def test_place_plot(self):
        # no cells
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        unusedOps = app.execute_plot(1, True, [1])
        self.assertEqual(unusedOps, 1)
        unusedOps = app.execute_plot(2, False, [1, 2])
        self.assertEqual(unusedOps, 2)
        unusedOps = app.execute_plot(3, True, [1, 2, 3])
        self.assertEqual(unusedOps, 3)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.prestige = 3
        app.get_country("Israel").sleeperCells = 0
        app.get_country("Canada").make_soft()
        app.get_country("Canada").sleeperCells = 1
        app.get_country("Spain").make_soft()
        app.get_country("Spain").sleeperCells = 0
        app.get_country("Iraq").make_good()
        app.get_country("Iraq").sleeperCells = 1
        app.get_country("Iraq").set_aid(1)
        app.get_country("Gulf States").make_fair()
        app.get_country("Gulf States").sleeperCells = 1
        app.get_country("Gulf States").set_aid(1)
        unusedOps = app.execute_plot(1, False, [1])
        self.assertEqual(unusedOps, 0)
        self.assertEqual(app.get_country("Iraq").plots, 1)
        self.assertEqual(app.get_country("Gulf States").plots, 0)
示例#2
0
    def test_resolve_non_muslim_non_us_plots(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 1, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)

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

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

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

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

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

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 1
        app.get_country("Germany").plots = 1
        app.resolve_plot("Germany", 3, 4, [], ["Spain", "Scandinavia"], [5, 4],
                         [])
        self.assertEqual(app.funding, 7)
        self.assertEqual(app.get_country("Germany").get_posture(), SOFT)
        self.assertEqual(app.get_country("Spain").get_posture(), HARD)
        self.assertEqual(app.get_country("Scandinavia").get_posture(), SOFT)
        self.assertEqual(app.prestige, 7)
        self.assertEqual(app.get_country("Germany").plots, 0)
示例#3
0
    def test_execute_recruit(self):
        # Normal
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        unused_ops = app.execute_recruit("United States", 1, [1])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("United States").sleeperCells, 1)
        self.assertEqual(app.cells, 14)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.cells = 15
        app.funding = 9
        app.get_country("Iraq").make_fair()
        app.get_country("Iraq").make_regime_change()
        unused_ops = app.execute_recruit("Iraq", 1, [6])
        self.assertEqual(unused_ops, 0)
        self.assertEqual(app.get_country("Iraq").sleeperCells, 1)
        self.assertEqual(app.cells, 14)
示例#4
0
    def test_num_cells_available(self):
        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 9
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 15)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 14)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 13)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 12)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 11)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 8
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 15)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 14)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 13)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 12)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 11)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 7
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 15)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 14)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 13)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 12)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 11)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 1)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 6
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 5
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 4
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 10)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 9)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 8)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 7)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 6)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 3
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 2
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)

        app = Labyrinth(1, 1, self.set_up_blank_test_scenario)
        app.funding = 1
        app.cells = 15
        self.assertEqual(app.num_cells_available(), 5)
        app.cells = 14
        self.assertEqual(app.num_cells_available(), 4)
        app.cells = 13
        self.assertEqual(app.num_cells_available(), 3)
        app.cells = 12
        self.assertEqual(app.num_cells_available(), 2)
        app.cells = 11
        self.assertEqual(app.num_cells_available(), 1)
        app.cells = 10
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 9
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 8
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 7
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 6
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 5
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 4
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 3
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 2
        self.assertEqual(app.num_cells_available(), 0)
        app.cells = 1
        self.assertEqual(app.num_cells_available(), 0)