Exemple #1
0
def test_b_1__portugal_to_north_spain_coast():
    """
    FRANCE: F Portugal Coast -> Spain North Coast

    Adapted from original test. Original made assertions about ambiguous
    coast orders, which are not possible in this system.
    """
    game_map = generate_map()
    france_starting_configuration = [
        {
            'territory_name': 'Portugal Coast',
            'unit_type': UnitTypes.FLEET
        },
    ]
    france = Player("France", game_map, france_starting_configuration)

    commands = [
        MoveCommand(france, france.units[0], 'Spain North Coast'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'France': {
            Unit(UnitTypes.FLEET, 'Spain North Coast'): None
        },
    }
def test_a_11__simple_bounce():
    """
    AUSTRIA: A Vienna -> Tyrolia
    ITALY:   A Venice -> Tyrolia
    """
    game_map = generate_map()
    austria_starting_configuration = [
        {
            'territory_name': 'Vienna',
            'unit_type': UnitTypes.TROOP
        },
    ]
    austria = Player("Austria", game_map, austria_starting_configuration)

    italy_starting_configuration = [
        {
            'territory_name': 'Venice',
            'unit_type': UnitTypes.TROOP
        },
    ]
    italy = Player("Italy", game_map, italy_starting_configuration)

    commands = [
        MoveCommand(austria, austria.units[0], 'Tyrolia'),
        MoveCommand(italy, italy.units[0], 'Tyrolia'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'Austria': {
            Unit(UnitTypes.TROOP, 'Vienna'): None
        },
        'Italy': {
            Unit(UnitTypes.TROOP, 'Venice'): None
        },
    }
Exemple #3
0
def test_b_13__coastal_crawl_not_allowed():
    """
    TURKEY: F Bulgaria South Coast -> Constantinople
            F Constantinople -> Bulgaria North Coast
    """
    game_map = generate_map()
    turkey_starting_configuration = [
        {
            'territory_name': 'Bulgaria South Coast',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Constantinople Coast',
            'unit_type': UnitTypes.FLEET
        },
    ]
    turkey = Player("Turkey", game_map, turkey_starting_configuration)

    commands = [
        MoveCommand(turkey, turkey.units[0], 'Constantinople Coast'),
        MoveCommand(turkey, turkey.units[1], 'Bulgaria North Coast'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'Turkey': {
            Unit(UnitTypes.FLEET, 'Bulgaria South Coast'): None,
            Unit(UnitTypes.FLEET, 'Constantinople Coast'): None,
        }
    }
def test_c_7__disrupted_unit_swap():
    """
    ENGLAND: A London -> Belgium (Convoy)
             F North Sea Transports London -> Belgium

    FRANCE:  A Belgium -> London (Convoy)
             F English Channel Transports Belgium -> London
             A Burgandy -> Belgium
    """
    game_map = generate_map()

    england_starting_configuration = [
        {
            'territory_name': 'London',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'North Sea',
            'unit_type': UnitTypes.FLEET
        },
    ]
    england = Player("England", game_map, england_starting_configuration)

    france_starting_configuration = [
        {
            'territory_name': 'Belgium',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'English Channel',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Burgundy',
            'unit_type': UnitTypes.TROOP
        },
    ]
    france = Player("France", game_map, france_starting_configuration)

    commands = [
        ConvoyMoveCommand(england, england.units[0], 'Belgium'),
        ConvoyTransportCommand(england, england.units[1], england.units[0],
                               'Belgium'),
        ConvoyMoveCommand(france, france.units[0], 'London'),
        ConvoyTransportCommand(france, france.units[1], france.units[0],
                               'London'),
        MoveCommand(france, france.units[2], 'Belgium'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'England': {
            Unit(UnitTypes.TROOP, 'London'): None,
            Unit(UnitTypes.FLEET, 'North Sea'): None,
        },
        'France': {
            Unit(UnitTypes.TROOP, 'Belgium'): None,
            Unit(UnitTypes.FLEET, 'English Channel'): None,
            Unit(UnitTypes.TROOP, 'Burgundy'): None,
        },
    }
def test_c_2__three_army_circular_movement_with_support():
    """
    TURKEY: F Ankara Coast -> Constantinople Coast
            A Constantinople -> Smyrna
            A Smyrna -> Ankara
            A Bulgaria Support Ankara Coast -> Constantinople Coast
    """
    game_map = generate_map()
    turkey_starting_configuration = [
        {
            'territory_name': 'Ankara Coast',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Constantinople',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'Smyrna',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'Bulgaria',
            'unit_type': UnitTypes.TROOP
        },
    ]
    turkey = Player("Turkey", game_map, turkey_starting_configuration)

    commands = [
        MoveCommand(turkey, turkey.units[0], 'Constantinople Coast'),
        MoveCommand(turkey, turkey.units[1], 'Smyrna'),
        MoveCommand(turkey, turkey.units[2], 'Ankara'),
        SupportCommand(turkey, turkey.units[3], turkey.units[0],
                       'Constantinople Coast'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'Turkey': {
            Unit(UnitTypes.FLEET, 'Constantinople Coast'): None,
            Unit(UnitTypes.TROOP, 'Smyrna'): None,
            Unit(UnitTypes.TROOP, 'Ankara'): None,
            Unit(UnitTypes.TROOP, 'Bulgaria'): None,
        },
    }
Exemple #6
0
def test_b_4__support_to_unreachable_coast_allowed():
    """
    FRANCE: F Gascony Coast -> Spain North Coast
            F Marseilles Coast Support F Gascony Coast -> Spain North Coast
    ITALY:  F Western Mediterranean Sea -> Spain South Coast
    """
    game_map = generate_map()
    france_starting_configuration = [
        {
            'territory_name': 'Gascony Coast',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Marseilles Coast',
            'unit_type': UnitTypes.FLEET
        },
    ]
    france = Player("France", game_map, france_starting_configuration)

    italy_starting_configuration = [
        {
            'territory_name': 'Western Mediterranean Sea',
            'unit_type': UnitTypes.FLEET
        },
    ]
    italy = Player("Italy", game_map, italy_starting_configuration)

    commands = [
        MoveCommand(france, france.units[0], 'Spain North Coast'),
        SupportCommand(france, france.units[1], france.units[0],
                       'Spain North Coast'),
        MoveCommand(italy, italy.units[0], 'Spain South Coast'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'France': {
            Unit(UnitTypes.FLEET, 'Spain North Coast'): None,
            Unit(UnitTypes.FLEET, 'Marseilles Coast'): None,
        },
        'Italy': {
            Unit(UnitTypes.FLEET, 'Western Mediterranean Sea'): None,
        }
    }
Exemple #7
0
def test_b_6__support_can_be_cut_from_other_coast():
    """
    ENGLAND: F North Atlantic Ocean -> Mid-Atlantic Ocean
             F Irish Sea Supports North Atlantic Ocean -> Mid-Atlantic Ocean

    FRANCE:  F Mid-Atlantic Ocean Hold
             F Spain North Coast Support Mid-Atlantic Ocean Hold

    ITALY:   F Gulf of Lyon -> Spain South Coast
    """
    game_map = generate_map()
    england_starting_configuration = [
        {
            'territory_name': 'North Atlantic Ocean',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Irish Sea',
            'unit_type': UnitTypes.FLEET
        },
    ]
    england = Player("England", game_map, england_starting_configuration)

    france_starting_configuration = [
        {
            'territory_name': 'Mid-Atlantic Ocean',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Spain North Coast',
            'unit_type': UnitTypes.FLEET
        },
    ]
    france = Player("France", game_map, france_starting_configuration)

    italy_starting_configuration = [
        {
            'territory_name': 'Gulf of Lyon',
            'unit_type': UnitTypes.FLEET
        },
    ]
    italy = Player("Italy", game_map, italy_starting_configuration)

    commands = [
        MoveCommand(england, england.units[0], 'Mid-Atlantic Ocean'),
        SupportCommand(england, england.units[1], england.units[0],
                       'Mid-Atlantic Ocean'),
        HoldCommand(france, france.units[0]),
        SupportCommand(france, france.units[1], france.units[0],
                       'Mid-Atlantic Ocean'),
        MoveCommand(italy, italy.units[0], 'Spain South Coast'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'England': {
            Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'): None,
            Unit(UnitTypes.FLEET, 'Irish Sea'): None,
        },
        'France': {
            Unit(UnitTypes.FLEET, 'Mid-Atlantic Ocean'): {
                'English Channel',
                'Brest Coast',
                'Gascony Coast',
                'Portugal Coast',
                'Western Mediterranean Sea',
                'North Africa Coast',
            },
            Unit(UnitTypes.FLEET, 'Spain North Coast'): None,
        },
        'Italy': {
            Unit(UnitTypes.FLEET, 'Gulf of Lyon'): None,
        }
    }
def test_c_5__disrupted_circular_movement_due_to_dislodged_convoy():
    """
    AUSTRIA: A Trieste -> Serbia
             A Serbia -> Bulgaria

    TURKEY:  A Bulgaria -> Trieste (Convoy)
             F Aegean Sea Transports Bulgaria -> Trieste
             F Ionian Sea Transports Bulgaria -> Trieste
             F Adriatic Sea Transports Bulgaria -> Trieste

    ITALY:   F Naples Coast -> Ionian Sea
             F Tunis Coast Supports Naples Coast -> Ionian Sea
    """
    game_map = generate_map()

    austria_starting_configuration = [
        {
            'territory_name': 'Trieste',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'Serbia',
            'unit_type': UnitTypes.TROOP
        },
    ]
    austria = Player("Austria", game_map, austria_starting_configuration)

    turkey_starting_configuration = [
        {
            'territory_name': 'Bulgaria',
            'unit_type': UnitTypes.TROOP
        },
        {
            'territory_name': 'Aegean Sea',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Ionian Sea',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Adriatic Sea',
            'unit_type': UnitTypes.FLEET
        },
    ]
    turkey = Player("Turkey", game_map, turkey_starting_configuration)

    italy_starting_configuration = [
        {
            'territory_name': 'Naples Coast',
            'unit_type': UnitTypes.FLEET
        },
        {
            'territory_name': 'Tunis Coast',
            'unit_type': UnitTypes.FLEET
        },
    ]
    italy = Player("Italy", game_map, italy_starting_configuration)

    commands = [
        MoveCommand(austria, austria.units[0], 'Serbia'),
        MoveCommand(austria, austria.units[1], 'Bulgaria'),
        ConvoyMoveCommand(turkey, turkey.units[0], 'Trieste'),
        ConvoyTransportCommand(turkey, turkey.units[1], turkey.units[0],
                               'Trieste'),
        ConvoyTransportCommand(turkey, turkey.units[2], turkey.units[0],
                               'Trieste'),
        ConvoyTransportCommand(turkey, turkey.units[3], turkey.units[0],
                               'Trieste'),
        MoveCommand(italy, italy.units[0], 'Ionian Sea'),
        SupportCommand(italy, italy.units[1], italy.units[0], 'Ionian Sea'),
    ]
    result = resolve_turn(game_map, commands)
    assert result == {
        'Austria': {
            Unit(UnitTypes.TROOP, 'Trieste'): None,
            Unit(UnitTypes.TROOP, 'Serbia'): None,
        },
        'Turkey': {
            Unit(UnitTypes.TROOP, 'Bulgaria'): None,
            Unit(UnitTypes.FLEET, 'Aegean Sea'): None,
            Unit(UnitTypes.FLEET, 'Ionian Sea'): {
                'Apulia Coast',
                'Albania Coast',
                'Greece Coast',
                'Eastern Mediterranean Sea',
                'Tyrrhenian Sea',
            },
            Unit(UnitTypes.FLEET, 'Adriatic Sea'): None,
        },
        'Italy': {
            Unit(UnitTypes.FLEET, 'Ionian Sea'): None,
            Unit(UnitTypes.FLEET, 'Tunis Coast'): None,
        },
    }
Exemple #9
0
 def resolve(self):
     return resolve_turn(self.game_map, self.commands)