コード例 #1
0
def test_j_2a__removing_the_same_unit_twice__validated():
    # France has lost one territory to England and one to Germany, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['England'] = {
        Unit(UnitTypes.FLEET, 'English Channel'),
        Unit(UnitTypes.TROOP, 'Brest'),
        Unit(UnitTypes.TROOP, 'Edinburgh'),
    }
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Kiel Coast'),
        Unit(UnitTypes.TROOP, 'Marseilles'),
        Unit(UnitTypes.TROOP, 'Berlin'),
    }
    player_units['France'] = {
        Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'),
        Unit(UnitTypes.TROOP, 'Paris'),
        Unit(UnitTypes.TROOP, 'Gascony'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('France', [
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Paris'),
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Paris'),
            ]),
        ],
        player_units=player_units,
    )

    with pytest.raises(AssertionError):
        helper.resolve__validated()
コード例 #2
0
def test_j_1a__too_many_remove_orders__validated():
    """
    This test has been modified from the DATC -- it includes a disband of a unit that does not exist,
    which fails for a completely separate reason, before we even reach order resolution.
    """

    # France has lost one territory to England, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['England'] = {
        Unit(UnitTypes.FLEET, 'English Channel'),
        Unit(UnitTypes.TROOP, 'Brest'),
        Unit(UnitTypes.TROOP, 'Edinburgh'),
    }
    player_units['France'] = {
        Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'),
        Unit(UnitTypes.TROOP, 'Paris'),
        Unit(UnitTypes.TROOP, 'Marseilles'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('France', [
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.FLEET, 'Mid-Atlantic Ocean'),
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Paris'),
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Marseilles'),
            ]),
        ],
        player_units=player_units,
    )

    with pytest.raises(AssertionError):
        helper.resolve__validated()
コード例 #3
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_1b__too_many_build_orders():
    """
    This test has been modified from the DATC -- it includes a build from a non-home territory, which
    fails for a completely separate reason, before we even reach order resolution.
    """

    # Germany has captured one new territory, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Holland Coast'),
        Unit(UnitTypes.TROOP, 'Prussia'),
        Unit(UnitTypes.TROOP, 'Tyrolia'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('Germany', [
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Berlin'),
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Kiel'),
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Munich'),
            ]),
        ],
        player_units=player_units,
    )

    # prioritize first-issued command
    results = helper.resolve()
    expected_results = vanilla_dip.generate_starting_player_units()
    expected_results['Germany'] = {
        Unit(UnitTypes.FLEET, 'Holland Coast'),
        Unit(UnitTypes.TROOP, 'Prussia'),
        Unit(UnitTypes.TROOP, 'Tyrolia'),
        Unit(UnitTypes.TROOP, 'Berlin'),
    }
    assert results == expected_results
コード例 #4
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_7b__only_one_build_in_a_home_supply_center__not_validated():
    # Russia has captured two territories, everyone else has stayed put
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Russia'] = {
        Unit(UnitTypes.FLEET, 'Sweden Coast'),
        Unit(UnitTypes.TROOP, 'Warsaw'),
        Unit(UnitTypes.TROOP, 'Ukraine'),
        Unit(UnitTypes.FLEET, 'Rumania Coast'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('Russia', [
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Moscow'),
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Moscow'),
            ]),
        ],
        player_units=player_units,
    )

    results = helper.resolve()
    expected_results = vanilla_dip.generate_starting_player_units()
    expected_results['Russia'] = {
        Unit(UnitTypes.FLEET, 'Sweden Coast'),
        Unit(UnitTypes.TROOP, 'Warsaw'),
        Unit(UnitTypes.TROOP, 'Ukraine'),
        Unit(UnitTypes.FLEET, 'Rumania Coast'),
        Unit(UnitTypes.TROOP, 'Moscow'),
    }
    assert results == expected_results
コード例 #5
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_1a__too_many_build_orders__with_validation():
    """
    This test has been modified from the DATC -- it includes a build from a non-home territory, which
    fails for a completely separate reason, before we even reach order resolution.
    """

    # Germany has captured one new territory, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Holland Coast'),
        Unit(UnitTypes.TROOP, 'Prussia'),
        Unit(UnitTypes.TROOP, 'Tyrolia'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('Germany', [
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Berlin'),
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Kiel'),
                AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Munich'),
            ]),
        ],
        player_units=player_units,
    )

    with pytest.raises(AssertionError):
        helper.resolve__validated()
コード例 #6
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_6__building_in_owned_supply_center_that_is_not_a_home_supply_center():
    # Germany has captured Warsaw, and moved out
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Kiel Coast'),
        Unit(UnitTypes.TROOP, 'Munich'),
        Unit(UnitTypes.TROOP, 'Ukraine'),
        Unit(UnitTypes.TROOP, 'Berlin'),
    }
    player_units['Russia'] = {
        Unit(UnitTypes.FLEET, 'St. Petersburg South Coast'),
        Unit(UnitTypes.TROOP, 'Moscow'),
        Unit(UnitTypes.FLEET, 'Sevastopol Coast'),
    }

    owned_territories = vanilla_dip.generate_home_territories()
    owned_territories['Germany'] = { 'Kiel', 'Munich', 'Berlin', 'Warsaw' }
    owned_territories['Russia'] = { 'St. Petersburg', 'Sevastopol', 'Moscow' }

    with pytest.raises(AssertionError):
        AdjustmentHelper(
            [
                PlayerHelper('Germany', [
                    AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Warsaw'),
                ]),
            ],
            player_units=player_units,
            owned_territories=owned_territories,
        )
コード例 #7
0
def test_j_2b__removing_the_same_unit_twice__not_validated():
    # France has lost one territory to England and one to Germany, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['England'] = {
        Unit(UnitTypes.FLEET, 'English Channel'),
        Unit(UnitTypes.TROOP, 'Brest'),
        Unit(UnitTypes.TROOP, 'Edinburgh'),
    }
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Kiel Coast'),
        Unit(UnitTypes.TROOP, 'Marseilles'),
        Unit(UnitTypes.TROOP, 'Berlin'),
    }
    player_units['France'] = {
        Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'),
        Unit(UnitTypes.TROOP, 'Paris'),
        Unit(UnitTypes.TROOP, 'Gascony'),
    }

    helper = AdjustmentHelper(
        [
            PlayerHelper('France', [
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Paris'),
                AdjustmentCommandHelper(AdjustmentCommandType.DISBAND,
                                        UnitTypes.TROOP, 'Paris'),
            ]),
        ],
        player_units=player_units,
    )

    # Rather than using "distance", our Civil Disobedience rules will pick in alphabetical order
    results = helper.resolve()
    expected_results = deepcopy(player_units)
    expected_results['France'] = {
        Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'),
    }
    assert results == expected_results
コード例 #8
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_3__supply_center_must_be_empty_for_building():
    # Germany has captured one new territory, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Germany'] = {
        Unit(UnitTypes.FLEET, 'Holland Coast'),
        Unit(UnitTypes.TROOP, 'Berlin'),
        Unit(UnitTypes.TROOP, 'Tyrolia'),
    }

    with pytest.raises(AssertionError):
        AdjustmentHelper(
            [
                PlayerHelper('Germany', [
                    AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.TROOP, 'Berlin'),
                ]),
            ],
            player_units=player_units,
        )
コード例 #9
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_2__fleets_cannot_be_built_in_land_areas():
    # Russia has captured one new territory, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Russia'] = {
        Unit(UnitTypes.FLEET, 'Sweden Coast'),
        Unit(UnitTypes.TROOP, 'Prussia'),
        Unit(UnitTypes.TROOP, 'Galicia'),
        Unit(UnitTypes.FLEET, 'Black Sea'),
    }

    with pytest.raises(AssertionError):
        AdjustmentHelper(
            [
                PlayerHelper('Russia', [
                    AdjustmentCommandHelper(AdjustmentCommandType.CREATE, UnitTypes.FLEET, 'Moscow'),
                ]),
            ],
            player_units=player_units,
        )
コード例 #10
0
ファイル: test__i__building.py プロジェクト: lstrobel/pydip
def test_i_4__both_coasts_must_be_empty_for_building():
    # Russia has captured one new territory, all other players have stayed still
    player_units = vanilla_dip.generate_starting_player_units()
    player_units['Russia'] = {
        Unit(UnitTypes.FLEET, 'St. Petersburg South Coast'),
        Unit(UnitTypes.TROOP, 'Prussia'),
        Unit(UnitTypes.TROOP, 'Galicia'),
        Unit(UnitTypes.FLEET, 'Rumania Coast'),
    }

    with pytest.raises(AssertionError):
        AdjustmentHelper(
            [
                PlayerHelper('Russia', [
                    AdjustmentCommandHelper(
                        AdjustmentCommandType.CREATE,
                        UnitTypes.FLEET,
                        'St. Petersburg North Coast',
                    ),
                ]),
            ],
            player_units=player_units,
        )