Exemplo n.º 1
0
    def test_two_units_can_swap_places_by_convoy(self):
        """
        The only way to swap two units, is by convoy.

        England:
        A Norway - Sweden
        F Skagerrak Convoys A Norway - Sweden

        Russia:
        A Sweden - Norway

        In most interpretation of the rules, the units in Norway and Sweden
        will be swapped. However, if explicit adjacent convoying is used (see
        issue 4.A.3), then it is just a head to head battle.

        I prefer the 2000 rules, so the units are swapped.
        """
        Army(self.state, 0, Nations.ENGLAND, self.territories.NORWAY),
        Fleet(self.state, 0, Nations.ENGLAND, self.territories.SKAGERRAK),
        Army(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN),
        orders = [
            Move(self.state, 0, Nations.ENGLAND, self.territories.NORWAY, self.territories.SWEDEN, via_convoy=True),
            Convoy(self.state, 0, Nations.ENGLAND, self.territories.SKAGERRAK, self.territories.NORWAY, self.territories.SWEDEN),
            Move(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN, self.territories.NORWAY),
        ]
        process(self.state)

        self.assertEqual(orders[0].path_decision(), Outcomes.PATH)
        self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[2].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 2
0
    def test_support_from_unreachable_coast_not_allowed(self):
        """
        A fleet can not give support to an area that can not be reached from
        the current coast of the fleet.

        France:
        F Marseilles - Gulf of Lyon
        F Spain(nc) Supports F Marseilles - Gulf of Lyon

        Italy:
        F Gulf of Lyon Hold

        The Gulf of Lyon can not be reached from the North Coast of Spain.
        Therefore, the support of Spain is invalid and the fleet in the Gulf of
        Lyon is not dislodged.
        """
        pieces = [
            Fleet(Nations.FRANCE, self.territories.MARSEILLES),
            Fleet(Nations.FRANCE, self.territories.SPAIN, self.named_coasts.SPAIN_NC),
            Fleet(Nations.ITALY, self.territories.GULF_OF_LYON)
        ]

        fleet_marseilles_move = Move(Nations.FRANCE, self.territories.MARSEILLES, self.territories.GULF_OF_LYON)
        fleet_spain_nc_support = Support(Nations.FRANCE, self.territories.SPAIN, self.territories.MARSEILLES, self.territories.GULF_OF_LYON)
        fleet_gol_hold = Hold(Nations.ITALY, self.territories.GULF_OF_LYON)

        self.state.register(*pieces, fleet_marseilles_move, fleet_spain_nc_support, fleet_gol_hold)
        self.state.post_register_updates()
        process(self.state)

        self.assertEqual(fleet_spain_nc_support.legal_decision, Outcomes.ILLEGAL)
        self.assertEqual(fleet_spain_nc_support.illegal_message, illegal_messages.S002)
        self.assertEqual(fleet_marseilles_move.move_decision, Outcomes.FAILS)
        self.assertEqual(pieces[2].dislodged_decision, Outcomes.SUSTAINS)
Exemplo n.º 3
0
    def test_support_to_unreachable_coast_allowed(self):
        """
        A fleet can give support to a coast where it can not go.

        France:
        F Gascony - Spain(nc)
        F Marseilles Supports F Gascony - Spain(nc)

        Italy:
        F Western Mediterranean - Spain(sc)

        Although the fleet in Marseilles can not go to the north coast it can
        still support targeting the north coast. So, the support is successful,
        the move of the fleet in Gascony succeeds and the move of the Italian
        fleet fails.
        """
        pieces = [
            Fleet(Nations.FRANCE, self.territories.GASCONY),
            Fleet(Nations.FRANCE, self.territories.MARSEILLES),
            Fleet(Nations.ITALY, self.territories.WESTERN_MEDITERRANEAN)
        ]

        fleet_gascony_move = Move(Nations.FRANCE, self.territories.GASCONY, self.territories.SPAIN, self.named_coasts.SPAIN_NC)
        fleet_marseilles_support = Support(Nations.FRANCE, self.territories.MARSEILLES, self.territories.GASCONY, self.territories.SPAIN)
        fleet_western_med_move = Move(Nations.ITALY, self.territories.WESTERN_MEDITERRANEAN, self.territories.SPAIN, self.named_coasts.SPAIN_SC)

        self.state.register(*pieces, fleet_gascony_move, fleet_marseilles_support, fleet_western_med_move)
        self.state.post_register_updates()
        process(self.state)

        self.assertEqual(fleet_gascony_move.move_decision, Outcomes.MOVES)
        self.assertEqual(fleet_western_med_move.move_decision, Outcomes.FAILS)
        self.assertEqual(fleet_marseilles_support.support_decision, Outcomes.GIVEN)
Exemplo n.º 4
0
    def test_multiple_retreat_to_the_same_area_causes_disband(self):
        """
        There can only be one unit in an area.
        """
        Army(self.state,
             0,
             Nations.ENGLAND,
             self.territories.NORWAY,
             attacker_territory=self.territories.ST_PETERSBURG),
        Army(self.state,
             0,
             Nations.ENGLAND,
             self.territories.FINLAND,
             attacker_territory=self.territories.ST_PETERSBURG),
        orders = [
            Retreat(self.state, 0, Nations.ENGLAND, self.territories.NORWAY,
                    self.territories.SWEDEN),
            Retreat(self.state, 0, Nations.ENGLAND, self.territories.FINLAND,
                    self.territories.SWEDEN),
        ]
        process(self.state)

        self.assertTrue(orders[0].legal)
        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
        self.assertTrue(orders[1].legal)
        self.assertEqual(orders[1].outcome, Outcomes.FAILS)
Exemplo n.º 5
0
    def test_illegal_head_to_head_battle_can_still_defend(self):
        """
        If in a head to head battle, one of the units makes an illegal move,
        than that unit has still the possibility to defend against attacks with
        strength of one.

        England:
        A Liverpool - Edinburgh

        Russia:
        F Edinburgh - Liverpool

        The move of the Russian fleet is illegal, but can still prevent the
        English army to enter Edinburgh. So, none of the units move.
        """
        pieces = [
            Army(0, Nations.ENGLAND, self.territories.LIVERPOOL),
            Fleet(0, Nations.RUSSIA, self.territories.EDINBURGH),
        ]
        orders = [
            Move(0, Nations.ENGLAND, self.territories.LIVERPOOL,
                 self.territories.EDINBURGH),
            Move(0, Nations.RUSSIA, self.territories.EDINBURGH,
                 self.territories.LIVERPOOL),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[1].illegal)
        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
        self.assertEqual(orders[1].outcome, Outcomes.FAILS)
Exemplo n.º 6
0
    def test_bounce_of_three_units(self):
        """
        If three units move to the same place, the adjudicator should not
        bounce the first two units and then let the third unit go to the now
        open place.

        Austria:
        A Vienna - Tyrolia

        Germany:
        A Munich - Tyrolia

        Italy:
        A Venice - Tyrolia

        The three units bounce.
        """
        Army(self.state, 0, Nations.AUSTRIA, self.territories.VIENNA),
        Army(self.state, 0, Nations.ITALY, self.territories.VENICE),
        Army(self.state, 0, Nations.GERMANY, self.territories.MUNICH)

        army_vienna_move = Move(self.state, 0, Nations.AUSTRIA, self.territories.VIENNA, self.territories.TYROLIA)
        army_venice_move = Move(self.state, 0, Nations.ITALY, self.territories.VENICE, self.territories.TYROLIA)
        army_munich_move = Move(self.state, 0, Nations.GERMANY, self.territories.MUNICH, self.territories.TYROLIA)

        process(self.state)

        self.assertTrue(army_venice_move.legal)
        self.assertTrue(army_vienna_move.legal)
        self.assertTrue(army_munich_move.legal)

        self.assertEqual(army_vienna_move.outcome, Outcomes.FAILS)
        self.assertEqual(army_venice_move.outcome, Outcomes.FAILS)
        self.assertEqual(army_munich_move.outcome, Outcomes.FAILS)
Exemplo n.º 7
0
    def test_disloged_unit_has_not_effect_on_attackers_area(self):
        """
        An army can follow.

        Germany:
        A Berlin - Prussia
        F Kiel - Berlin
        A Silesia Supports A Berlin - Prussia

        Russia:
        A Prussia - Berlin

        The fleet in Kiel will move to Berlin.
        """
        Army(self.state, 0, Nations.GERMANY, self.territories.BERLIN),
        Fleet(self.state, 0, Nations.GERMANY, self.territories.KIEL),
        Army(self.state, 0, Nations.GERMANY, self.territories.SILESIA),
        Army(self.state, 0, Nations.RUSSIA, self.territories.PRUSSIA),
        orders = [
            Move(self.state, 0, Nations.GERMANY, self.territories.BERLIN,
                 self.territories.PRUSSIA),
            Move(self.state, 0, Nations.GERMANY, self.territories.KIEL,
                 self.territories.BERLIN),
            Support(self.state, 0, Nations.GERMANY, self.territories.SILESIA,
                    self.territories.BERLIN, self.territories.PRUSSIA),
            Move(self.state, 0, Nations.RUSSIA, self.territories.PRUSSIA,
                 self.territories.BERLIN),
        ]
        process(self.state)

        self.assertTrue(orders[0].outcome, Outcomes.SUCCEEDS)
        self.assertTrue(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertTrue(orders[2].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 8
0
    def test_dislodge_of_multi_route_convoy_with_foreign_fleet(self):
        """
        When the 1971 rulebook is used "unwanted" multi-route convoys are
        possible.

        England:
        F North Sea Convoys A London - Belgium
        A London - Belgium

        Germany:
        F English Channel Convoys A London - Belgium

        France:
        F Brest Supports F Mid-Atlantic Ocean - English Channel
        F Mid-Atlantic Ocean - English Channel

        If the 1982 or 2000 rulebook is used (which I prefer), it makes no
        difference that the convoying fleet in the English Channel is German.
        It will take the convoy via the North Sea anyway and the army in London
        will end in Belgium.  However, when the 1971 rules are used, the German
        convoy is "unwanted".  According to the DPTG the German fleet should be
        ignored in the English convoy, since there is a convoy path with only
        English fleets. That means that the convoy is not disrupted and the
        English army in London will end in Belgium. See also issue 4.A.1.
        """
        pieces = [
            Fleet(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA),
            Army(self.state, 0, Nations.ENGLAND, self.territories.LONDON),
            Fleet(self.state, 0, Nations.GERMANY,
                  self.territories.ENGLISH_CHANNEL),
            Fleet(self.state, 0, Nations.FRANCE, self.territories.BREST),
            Fleet(self.state, 0, Nations.FRANCE,
                  self.territories.MID_ATLANTIC),
        ]
        orders = [
            Convoy(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA,
                   self.territories.LONDON, self.territories.BELGIUM),
            Move(self.state,
                 0,
                 Nations.ENGLAND,
                 self.territories.LONDON,
                 self.territories.BELGIUM,
                 via_convoy=True),
            Convoy(self.state, 0, Nations.GERMANY,
                   self.territories.ENGLISH_CHANNEL, self.territories.LONDON,
                   self.territories.BELGIUM),
            Support(self.state, 0, Nations.FRANCE, self.territories.BREST,
                    self.territories.MID_ATLANTIC,
                    self.territories.ENGLISH_CHANNEL),
            Move(self.state, 0, Nations.FRANCE, self.territories.MID_ATLANTIC,
                 self.territories.ENGLISH_CHANNEL),
        ]
        process(self.state)

        self.assertEqual(pieces[0].dislodged_decision, Outcomes.SUSTAINS)
        self.assertEqual(orders[1].path_decision(), Outcomes.PATH)
        self.assertEqual(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(pieces[2].dislodged_decision, Outcomes.DISLODGED)
        self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[4].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 9
0
    def test_unit_may_not_retreat_from_area_from_which_it_was_attacked(self):
        """
        Well, that would be of course stupid. Still, the adjudicator must be
        tested on this.
        """
        pieces = [
            Army(0,
                 Nations.ENGLAND,
                 self.territories.NORWAY,
                 attacker_territory=self.territories.SWEDEN),
        ]
        orders = [
            Retreat(0, Nations.ENGLAND, self.territories.NORWAY,
                    self.territories.SWEDEN),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].illegal)
        self.assertEqual(
            orders[0].illegal_verbose,
            'Piece cannot retreat to the territory from which it was attacked.'
        )
        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
Exemplo n.º 10
0
    def test_disrupted_three_army_circular_movement(self):
        """
        When one of the units bounces, the whole circular movement will hold.

        Turkey:
        F Ankara - Constantinople
        A Constantinople - Smyrna
        A Smyrna - Ankara
        A Bulgaria - Constantinople

        Every unit will keep its place.
        """
        Fleet(self.state, 0, Nations.TURKEY, self.territories.ANKARA),
        Army(self.state, 0, Nations.TURKEY, self.territories.BULGARIA),
        Army(self.state, 0, Nations.TURKEY, self.territories.CONSTANTINOPLE),
        Army(self.state, 0, Nations.TURKEY, self.territories.SMYRNA)
        orders = [
            Move(self.state, 0, Nations.TURKEY, self.territories.ANKARA,
                 self.territories.CONSTANTINOPLE),
            Move(self.state, 0, Nations.TURKEY,
                 self.territories.CONSTANTINOPLE, self.territories.SMYRNA),
            Move(self.state, 0, Nations.TURKEY, self.territories.SMYRNA,
                 self.territories.ANKARA),
            Move(self.state, 0, Nations.TURKEY, self.territories.BULGARIA,
                 self.territories.CONSTANTINOPLE),
        ]

        process(self.state)

        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
        self.assertEqual(orders[1].outcome, Outcomes.FAILS)
        self.assertEqual(orders[2].outcome, Outcomes.FAILS)
        self.assertEqual(orders[3].outcome, Outcomes.FAILS)
Exemplo n.º 11
0
    def test_attacked_convoy_is_not_disrupted(self):
        """
        A convoy can only be disrupted by dislodging the fleets. Attacking is
        not sufficient.

        England:
        F North Sea Convoys A London - Holland
        A London - Holland

        Germany:
        F Skagerrak - North Sea

        The army in London will successfully convoy and end in Holland.
        """
        Fleet(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA),
        Army(self.state, 0, Nations.ENGLAND, self.territories.LONDON),
        Fleet(self.state, 0, Nations.GERMANY, self.territories.SKAGERRAK)
        orders = [
            Convoy(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA,
                   self.territories.LONDON, self.territories.HOLLAND),
            Move(self.state,
                 0,
                 Nations.ENGLAND,
                 self.territories.LONDON,
                 self.territories.HOLLAND,
                 via_convoy=True),
            Move(self.state, 0, Nations.GERMANY, self.territories.SKAGERRAK,
                 self.territories.NORTH_SEA),
        ]
        process(self.state)

        self.assertEqual(orders[1].path_decision(), Outcomes.PATH)
        self.assertEqual(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[2].outcome, Outcomes.FAILS)
Exemplo n.º 12
0
    def test_three_army_circular_movement_with_support(self):
        """
        Three units can change place, even when one gets support.

        Turkey:
        F Ankara - Constantinople
        A Constantinople - Smyrna
        A Smyrna - Ankara
        A Bulgaria Supports F Ankara - Constantinople

        Of course the three units will move, but knowing how programs are
        written, this can confuse the adjudicator.
        """
        Fleet(self.state, 0, Nations.TURKEY, self.territories.ANKARA),
        Army(self.state, 0, Nations.TURKEY, self.territories.BULGARIA),
        Army(self.state, 0, Nations.TURKEY, self.territories.CONSTANTINOPLE),
        Army(self.state, 0, Nations.TURKEY, self.territories.SMYRNA)
        orders = [
            Move(self.state, 0, Nations.TURKEY, self.territories.ANKARA,
                 self.territories.CONSTANTINOPLE),
            Move(self.state, 0, Nations.TURKEY,
                 self.territories.CONSTANTINOPLE, self.territories.SMYRNA),
            Move(self.state, 0, Nations.TURKEY, self.territories.SMYRNA,
                 self.territories.ANKARA),
            Support(self.state, 0, Nations.TURKEY, self.territories.BULGARIA,
                    self.territories.ANKARA, self.territories.CONSTANTINOPLE),
        ]
        process(self.state)

        self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[2].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 13
0
    def test_three_army_circular_movement(self):
        """
        Three units can change place, even in spring 1901.

        Turkey:
        F Ankara - Constantinople
        A Constantinople - Smyrna
        A Smyrna - Ankara

        All three units will move.
        """
        Fleet(self.state, 0, Nations.TURKEY, self.territories.ANKARA),
        Army(self.state, 0, Nations.TURKEY, self.territories.CONSTANTINOPLE),
        Army(self.state, 0, Nations.TURKEY, self.territories.SMYRNA)
        orders = [
            Move(self.state, 0, Nations.TURKEY, self.territories.ANKARA,
                 self.territories.CONSTANTINOPLE),
            Move(self.state, 0, Nations.TURKEY,
                 self.territories.CONSTANTINOPLE, self.territories.SMYRNA),
            Move(self.state, 0, Nations.TURKEY, self.territories.SMYRNA,
                 self.territories.ANKARA),
        ]
        process(self.state)

        self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[2].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 14
0
    def test_swapping_with_unintended_intent(self):
        """
        The intent is questionable.


        England:
        A Liverpool - Edinburgh
        F English Channel Convoys A Liverpool - Edinburgh

        Germany:
        A Edinburgh - Liverpool

        France:
        F Irish Sea Hold
        F North Sea Hold

        Russia:
        F Norwegian Sea Convoys A Liverpool - Edinburgh
        F North Atlantic Ocean Convoys A Liverpool - Edinburgh
        See issue 4.A.3.

        For choice a, b and c the English army in Liverpool will move by convoy
        and consequentially the two armies are swapped.

        For choice d, the 1982/2000 rulebook (which I prefer), the convoy
        depends on the "intent". England intended to convoy via the French
        fleets in the Irish Sea and the North Sea. However, the French did not
        order the convoy. The alternative route with the Russian fleets was
        unintended. The English fleet in the English Channel (with the convoy
        order) is not part of this alternative route with the Russian fleets.
        Since England still "intent" to convoy, the move from Liverpool to
        Edinburgh should be via convoy and the two armies are swapped.
        Although, you could argue that this is not really according to the
        clarification of the 2000 rulebook.

        When explicit adjacent convoying is used (DPTG, choice e), then the
        English army did not receive an order to move by convoy. So, it is just
        a head to head battle and both the army in Edinburgh and Liverpool will
        not move.
        """
        Army(self.state, 0, Nations.ENGLAND, self.territories.LIVERPOOL),
        Fleet(self.state, 0, Nations.ENGLAND, self.territories.ENGLISH_CHANNEL),
        Army(self.state, 0, Nations.GERMANY, self.territories.EDINBURGH),
        Fleet(self.state, 0, Nations.FRANCE, self.territories.IRISH_SEA),
        Fleet(self.state, 0, Nations.FRANCE, self.territories.NORTH_SEA),
        Fleet(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA),
        Fleet(self.state, 0, Nations.RUSSIA, self.territories.NORTH_ATLANTIC),
        orders = [
            Move(self.state, 0, Nations.ENGLAND, self.territories.LIVERPOOL, self.territories.EDINBURGH),
            Convoy(self.state, 0, Nations.ENGLAND, self.territories.ENGLISH_CHANNEL, self.territories.LIVERPOOL, self.territories.EDINBURGH),
            Move(self.state, 0, Nations.GERMANY, self.territories.EDINBURGH, self.territories.LIVERPOOL),
            Hold(self.state, 0, Nations.FRANCE, self.territories.IRISH_SEA),
            Hold(self.state, 0, Nations.FRANCE, self.territories.NORTH_SEA),
            Convoy(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA, self.territories.LIVERPOOL, self.territories.EDINBURGH),
            Convoy(self.state, 0, Nations.RUSSIA, self.territories.NORTH_ATLANTIC, self.territories.LIVERPOOL, self.territories.EDINBURGH),
        ]
        process(self.state)

        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
        self.assertEqual(orders[2].outcome, Outcomes.FAILS)
Exemplo n.º 15
0
    def test_support_on_unreachable_destination_not_possible(self):
        """
        The destination of the move that is supported must be reachable by the
        supporting unit.

        Austria:
        A Venice Hold

        Italy:
        F Rome Supports A Apulia - Venice
        A Apulia - Venice

        The support of Rome is illegal, because Venice can not be reached from
        Rome by a fleet. Venice is not dislodged.
        """
        Army(self.state, 0, Nations.AUSTRIA, self.territories.VENICE),
        Fleet(self.state, 0, Nations.ITALY, self.territories.ROME),
        Army(self.state, 0, Nations.ITALY, self.territories.APULIA)

        # TODO finish
        Hold(self.state, 0, Nations.AUSTRIA, self.territories.VENICE)
        fleet_rome_support = Support(self.state, 0, Nations.ITALY, self.territories.ROME, self.territories.APULIA, self.territories.VENICE)
        Move(self.state, 0, Nations.ITALY, self.territories.APULIA, self.territories.VENICE)

        process(self.state)

        self.assertTrue(fleet_rome_support.illegal)
        self.assertEqual(fleet_rome_support.illegal_code, '010')
        self.assertEqual(
            fleet_rome_support.illegal_verbose,
            'Piece cannot reach that territory.'
        )
Exemplo n.º 16
0
    def test_unit_may_not_retreat_to_contested_area(self):
        """
        Stand off prevents retreat to the area.
        """
        self.territories.SWEDEN.contested = True
        pieces = [
            Army(0,
                 Nations.ENGLAND,
                 self.territories.NORWAY,
                 attacker_territory=self.territories.FINLAND),
        ]
        orders = [
            Retreat(0, Nations.ENGLAND, self.territories.NORWAY,
                    self.territories.SWEDEN),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].illegal)
        self.assertEqual(
            orders[0].illegal_verbose,
            ('Cannot retreat to a territory which was contested on the '
             'previous turn.'))
        self.assertEqual(orders[0].outcome, Outcomes.FAILS)
Exemplo n.º 17
0
    def test_simple_bounce(self):
        """
        Two armies bouncing on each other.

        Austria:
        A Vienna - Tyrolia

        Italy:
        A Venice - Tyrolia

        The two units bounce.
        """
        Army(self.state, 0, Nations.AUSTRIA, self.territories.VIENNA),
        Army(self.state, 0, Nations.ITALY, self.territories.VENICE),

        army_vienna_move = Move(self.state, 0, Nations.AUSTRIA, self.territories.VIENNA, self.territories.TYROLIA)
        army_venice_move = Move(self.state, 0, Nations.ITALY, self.territories.VENICE, self.territories.TYROLIA)

        process(self.state)

        self.assertTrue(army_venice_move.legal)
        self.assertTrue(army_vienna_move.legal)

        self.assertEqual(army_vienna_move.outcome, Outcomes.FAILS)
        self.assertEqual(army_venice_move.outcome, Outcomes.FAILS)
Exemplo n.º 18
0
    def test_coast_cannot_be_ordered_to_change(self):
        """
        The coast can not change by just ordering the other coast.

        France has a fleet on the north coast of Spain and orders:

        France:
        F Spain(sc) - Gulf of Lyon

        The move fails.
        """
        # Not really relevant because can't specify source coast
        Fleet(self.state,
              0,
              Nations.FRANCE,
              self.territories.SPAIN,
              named_coast=self.named_coasts.SPAIN_NC)
        move = Move(self.state, 0, Nations.FRANCE, self.territories.SPAIN,
                    self.territories.SPAIN, self.named_coasts.SPAIN_SC)

        process(self.state)

        self.assertTrue(move.illegal)
        self.assertEqual(move.illegal_verbose,
                         'Source and target cannot be the same territory.')
Exemplo n.º 19
0
    def test_bounce_and_dislodge_with_double_convoy(self):
        """
        Similar to test case 6.G.10, but now both units use a convoy and
        without some support.

        England:
        F North Sea Convoys A London - Belgium
        A Holland Supports A London - Belgium
        A Yorkshire - London
        A London - Belgium via Convoy

        France:
        F English Channel Convoys A Belgium - London
        A Belgium - London via Convoy

        The French army in Belgium is bounced by the army from Yorkshire. The
        army in London move to Belgium, dislodging the unit there.

        The final destination of the army in the Yorkshire depends on how issue
        4.A.7 is resolved. If choice a is taken, then the army advances to
        London, but if choice b is taken (which I prefer) the army bounces and
        stays in Yorkshire.
        """
        pieces = [
            Fleet(0, Nations.ENGLAND, self.territories.NORTH_SEA),
            Army(0, Nations.ENGLAND, self.territories.HOLLAND),
            Army(0, Nations.ENGLAND, self.territories.YORKSHIRE),
            Army(0, Nations.ENGLAND, self.territories.LONDON),
            Fleet(0, Nations.FRANCE, self.territories.ENGLISH_CHANNEL),
            Army(0, Nations.FRANCE, self.territories.BELGIUM),
        ]
        orders = [
            Convoy(0, Nations.ENGLAND, self.territories.NORTH_SEA,
                   self.territories.LONDON, self.territories.BELGIUM),
            Support(0, Nations.ENGLAND, self.territories.HOLLAND,
                    self.territories.LONDON, self.territories.BELGIUM),
            Move(0, Nations.ENGLAND, self.territories.YORKSHIRE,
                 self.territories.LONDON),
            Move(0,
                 Nations.ENGLAND,
                 self.territories.LONDON,
                 self.territories.BELGIUM,
                 via_convoy=True),
            Convoy(0, Nations.FRANCE, self.territories.ENGLISH_CHANNEL,
                   self.territories.BELGIUM, self.territories.LONDON),
            Move(0,
                 Nations.FRANCE,
                 self.territories.BELGIUM,
                 self.territories.LONDON,
                 via_convoy=True),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertEqual(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[2].outcome, Outcomes.FAILS)
        self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[5].outcome, Outcomes.FAILS)
        self.assertEqual(pieces[5].dislodged_decision, Outcomes.DISLODGED)
Exemplo n.º 20
0
    def test_fleets_cannot_be_built_inland(self):
        """
        Physically this is possible, but it is still not allowed.

        Russia has one build and Moscow is empty.

        Russia:
        Build F Moscow
        See issue 4.C.4. Some game masters will change the order and build an
        army in Moscow.

        I prefer that the build fails.
        """
        orders = [
            Build(0, Nations.RUSSIA, self.territories.MOSCOW,
                  PieceTypes.FLEET),
        ]
        self.state.register(*orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].illegal)
        self.assertEqual(orders[0].illegal_code, '015')
        self.assertEqual(orders[0].illegal_verbose,
                         'Piece type cannot exist in this type of territory.')
Exemplo n.º 21
0
    def test_three_way_beleaguered_garrison(self):
        """
        In a beleaguered garrison from three sides, the adjudicator may not let
        two attacks fail and then let the third succeed.

        England:
        F Edinburgh Supports F Yorkshire - North Sea
        F Yorkshire - North Sea

        France:
        F Belgium - North Sea
        F English Channel Supports F Belgium - North Sea

        Germany:
        F North Sea Hold

        Russia:
        F Norwegian Sea - North Sea
        F Norway Supports F Norwegian Sea - North Sea

        None of the fleets move. The German fleet in the North Sea is not
        dislodged.
        """
        pieces = [
            Fleet(self.state, 0, Nations.ENGLAND, self.territories.EDINBURGH),
            Fleet(self.state, 0, Nations.ENGLAND, self.territories.YORKSHIRE),
            Fleet(self.state, 0, Nations.FRANCE, self.territories.BELGIUM),
            Fleet(self.state, 0, Nations.FRANCE,
                  self.territories.ENGLISH_CHANNEL),
            Fleet(self.state, 0, Nations.GERMANY, self.territories.NORTH_SEA),
            Fleet(self.state, 0, Nations.RUSSIA,
                  self.territories.NORWEGIAN_SEA),
            Fleet(self.state, 0, Nations.RUSSIA, self.territories.NORWAY),
        ]
        orders = [
            Support(self.state, 0, Nations.ENGLAND, self.territories.EDINBURGH,
                    self.territories.YORKSHIRE, self.territories.NORTH_SEA),
            Move(self.state, 0, Nations.ENGLAND, self.territories.YORKSHIRE,
                 self.territories.NORTH_SEA),
            Move(self.state, 0, Nations.FRANCE, self.territories.BELGIUM,
                 self.territories.NORTH_SEA),
            Support(self.state, 0, Nations.FRANCE,
                    self.territories.ENGLISH_CHANNEL, self.territories.BELGIUM,
                    self.territories.NORTH_SEA),
            Hold(self.state, 0, Nations.GERMANY, self.territories.NORTH_SEA),
            Move(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA,
                 self.territories.NORTH_SEA),
            Support(self.state, 0, Nations.RUSSIA, self.territories.NORWAY,
                    self.territories.NORWEGIAN_SEA,
                    self.territories.NORTH_SEA),
        ]
        process(self.state)

        self.assertEqual(pieces[4].dislodged_decision, Outcomes.SUSTAINS)
        self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[1].outcome, Outcomes.FAILS)
        self.assertEqual(orders[2].outcome, Outcomes.FAILS)
        self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
        self.assertEqual(orders[5].outcome, Outcomes.FAILS)
        self.assertEqual(orders[6].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 22
0
    def test_supply_center_must_be_empty_for_building(self):
        """
        You can't have two units in a sector. So, you can't build when there is a unit in the supply center.

        Germany may build a unit but has an army in Berlin. Germany orders the following:

        Germany:
        Build A Berlin

        Build fails.
        """
        pieces = [
            Army(0, Nations.GERMANY, self.territories.BERLIN),
        ]
        orders = [
            Build(0, Nations.GERMANY, self.territories.BERLIN,
                  PieceTypes.ARMY),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].illegal)
        self.assertEqual(orders[0].illegal_code, '011')
        self.assertEqual(orders[0].illegal_verbose,
                         'Source is already occupied by a piece.')
Exemplo n.º 23
0
    def test_no_self_dislodgement_in_head_to_head_battle(self):
        """
        Self dislodgement is not allowed. This also counts for head to head
        battles.

        Germany:
        A Berlin - Kiel
        F Kiel - Berlin
        A Munich Supports A Berlin - Kiel

        No unit will move.
        """
        pieces = [
            Army(0, Nations.GERMANY, self.territories.BERLIN),
            Fleet(0, Nations.GERMANY, self.territories.KIEL),
            Army(0, Nations.GERMANY, self.territories.MUNICH),
        ]
        orders = [
            Move(0, Nations.GERMANY, self.territories.BERLIN,
                 self.territories.KIEL),
            Move(0, Nations.GERMANY, self.territories.KIEL,
                 self.territories.BERLIN),
            Support(0, Nations.GERMANY, self.territories.MUNICH,
                    self.territories.BERLIN, self.territories.KIEL),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].outcome, Outcomes.FAILS)
        self.assertTrue(orders[1].outcome, Outcomes.FAILS)
        self.assertTrue(orders[2].outcome, Outcomes.SUCCEEDS)
Exemplo n.º 24
0
    def test_both_coasts_must_be_empty_for_building(self):
        """
        If a sector is occupied on one coast, the other coast can not be used
        for building.

        Russia may build a unit and has a fleet in St Petersburg(sc). Russia
        orders the following:

        Russia:
        Build A St Petersburg(nc)

        Build fails.
        """
        pieces = [
            Fleet(0, Nations.RUSSIA, self.territories.ST_PETERSBURG,
                  self.named_coasts.ST_PETERSBURG_NC),
        ]
        orders = [
            Build(0, Nations.RUSSIA, self.territories.ST_PETERSBURG,
                  PieceTypes.FLEET, self.named_coasts.ST_PETERSBURG_SC),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].illegal)
        self.assertEqual(orders[0].illegal_code, '011')
        self.assertEqual(orders[0].illegal_verbose,
                         'Source is already occupied by a piece.')
Exemplo n.º 25
0
    def test_no_help_in_dislodging_own_unit(self):
        """
        To help a foreign power to dislodge own unit in head to head battle is
        not possible.

        Germany:
        A Berlin - Kiel
        A Munich Supports F Kiel - Berlin

        England:
        F Kiel - Berlin

        No unit will move.
        """
        pieces = [
            Army(0, Nations.GERMANY, self.territories.BERLIN),
            Army(0, Nations.GERMANY, self.territories.MUNICH),
            Fleet(0, Nations.ENGLAND, self.territories.KIEL),
        ]
        orders = [
            Move(0, Nations.GERMANY, self.territories.BERLIN,
                 self.territories.KIEL),
            Support(0, Nations.GERMANY, self.territories.MUNICH,
                    self.territories.KIEL, self.territories.BERLIN),
            Move(0, Nations.ENGLAND, self.territories.KIEL,
                 self.territories.BERLIN),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertTrue(orders[0].outcome, Outcomes.FAILS)
        self.assertTrue(orders[1].outcome, Outcomes.SUCCEEDS)
        self.assertTrue(orders[2].outcome, Outcomes.FAILS)
Exemplo n.º 26
0
    def test_only_armies_can_be_convoyed(self):
        """
        A fleet can not be convoyed.

        England:
        F London - Belgium
        F North Sea Convoys A London - Belgium

        Move from London to Belgium should fail.
        """
        Fleet(self.state, 0, Nations.ENGLAND, self.territories.LONDON),
        Fleet(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA),
        fleet_london_move = Move(self.state, 0, Nations.ENGLAND, self.territories.LONDON, self.territories.BELGIUM, via_convoy=True)
        fleet_north_sea_convoy = Convoy(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA, self.territories.LONDON, self.territories.BELGIUM)

        process(self.state)

        self.assertTrue(fleet_london_move.illegal)
        self.assertTrue(fleet_london_move.outcome == Outcomes.FAILS)
        self.assertEqual(fleet_london_move.illegal_code, '004')
        self.assertEqual(
            fleet_london_move.illegal_verbose,
            'Fleet cannot reach non-adjacent territory.'
        )

        self.assertTrue(fleet_north_sea_convoy.illegal)
        self.assertEqual(
            fleet_north_sea_convoy.illegal_verbose,
            'Cannot convoy a fleet.'
        )
Exemplo n.º 27
0
    def test_coastal_crawl_not_allowed(self):
        """
        If a fleet is leaving a sector from a certain coast while in the
        opposite direction another fleet is moving to another coast of the
        sector, it is still a head to head battle. This has been decided in the
        great revision of the 1961 rules that resulted in the 1971 rules.

        Turkey:
        F Bulgaria(sc) - Constantinople
        F Constantinople - Bulgaria(ec)

        Both moves fail.
        """
        pieces = [
            Fleet(Nations.TURKEY, self.territories.BULGARIA, self.named_coasts.BULGARIA_SC),
            Fleet(Nations.TURKEY, self.territories.CONSTANTINOPLE),
        ]
        orders = [
            Move(Nations.TURKEY, self.territories.BULGARIA, self.territories.CONSTANTINOPLE),
            Move(Nations.TURKEY, self.territories.CONSTANTINOPLE, self.territories.BULGARIA, self.named_coasts.BULGARIA_EC),
        ]

        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertEqual(orders[0].move_decision, Outcomes.FAILS)
        self.assertEqual(orders[1].move_decision, Outcomes.FAILS)
Exemplo n.º 28
0
    def test_support_to_hold_yourself_not_possible(self):
        """
        An army can not get an additional hold power by supporting itself.

        Italy:
        A Venice - Trieste
        A Tyrolia Supports A Venice - Trieste

        Austria:
        F Trieste Supports F Trieste

        The fleet in Trieste should be dislodged.
        """
        Army(self.state, 0, Nations.ITALY, self.territories.VENICE),
        Army(self.state, 0, Nations.ITALY, self.territories.TYROLIA),
        Fleet(self.state, 0, Nations.AUSTRIA, self.territories.TRIESTE)

        Move(self.state, 0, Nations.ITALY, self.territories.VENICE, self.territories.TRIESTE)
        Support(self.state, 0, Nations.ITALY, self.territories.TYROLIA, self.territories.VENICE, self.territories.TRIESTE)
        fleet_trieste_support = Support(self.state, 0, Nations.AUSTRIA, self.territories.TRIESTE, self.territories.TRIESTE, self.territories.TRIESTE)

        process(self.state)

        self.assertTrue(fleet_trieste_support.illegal)
        self.assertEqual(
            fleet_trieste_support.illegal_verbose,
            'Source and target cannot be the same territory.'
        )
Exemplo n.º 29
0
    def test_three_army_circular_movement(self):
        """
        Three units can change place, even in spring 1901.

        Turkey:
        F Ankara - Constantinople
        A Constantinople - Smyrna
        A Smyrna - Ankara

        All three units will move.
        """
        pieces = [
            Fleet(Nations.TURKEY, self.territories.ANKARA),
            Army(Nations.TURKEY, self.territories.CONSTANTINOPLE),
            Army(Nations.TURKEY, self.territories.SMYRNA)
        ]
        orders = [
            Move(Nations.TURKEY, self.territories.ANKARA,
                 self.territories.CONSTANTINOPLE),
            Move(Nations.TURKEY, self.territories.CONSTANTINOPLE,
                 self.territories.SMYRNA),
            Move(Nations.TURKEY, self.territories.SMYRNA,
                 self.territories.ANKARA),
        ]
        self.state.register(*pieces, *orders)
        self.state.post_register_updates()
        process(self.state)

        self.assertEqual(orders[0].move_decision, Outcomes.MOVES)
        self.assertEqual(orders[1].move_decision, Outcomes.MOVES)
        self.assertEqual(orders[2].move_decision, Outcomes.MOVES)
Exemplo n.º 30
0
    def test_move_fleet_to_land(self):
        """
        Check whether a fleet can not move to land.

        Germany:
        F Kiel - Munich

        Order should fail.
        """
        fleet = Fleet(0, Nations.GERMANY, self.territories.KIEL)
        order = Move(0, Nations.GERMANY, self.territories.KIEL, self.territories.MUNICH)

        self.state.register(fleet, order)
        process(self.state)

        self.assertTrue(order.illegal)
        self.assertEqual(order.outcome, Outcomes.FAILS)
        self.assertEqual(
            order.illegal_code,
            '006'
        )
        self.assertEqual(
            order.illegal_verbose,
            'Fleet cannot enter an inland territory',
        )