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.' )
def test_two_separate_circular_movements(self): 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), Army(self.state, 0, Nations.FRANCE, self.territories.BREST), Army(self.state, 0, Nations.FRANCE, self.territories.PICARDY), Army(self.state, 0, Nations.FRANCE, self.territories.PARIS), 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.FRANCE, self.territories.BREST, self.territories.PICARDY), Move(self.state, 0, Nations.FRANCE, self.territories.PICARDY, self.territories.PARIS), Move(self.state, 0, Nations.FRANCE, self.territories.PARIS, self.territories.BREST), ] result = find_circular_movements(orders) self.assertEqual(len(result), 2) self.assertTrue(all([o in result[0] for o in orders[:3]])) self.assertTrue(all([o in result[1] for o in orders[3:]]))
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)
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)
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)
def test_two_separate_circular_movements(self): pieces = [ Fleet(Nations.TURKEY, self.territories.ANKARA), Army(Nations.TURKEY, self.territories.CONSTANTINOPLE), Army(Nations.TURKEY, self.territories.SMYRNA), Army(Nations.FRANCE, self.territories.BREST), Army(Nations.FRANCE, self.territories.PICARDY), Army(Nations.FRANCE, self.territories.PARIS), ] 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), Move(Nations.FRANCE, self.territories.BREST, self.territories.PICARDY), Move(Nations.FRANCE, self.territories.PICARDY, self.territories.PARIS), Move(Nations.FRANCE, self.territories.PARIS, self.territories.BREST), ] self.state.register(*pieces, *orders) self.state.post_register_updates() result = find_circular_movements(orders) self.assertEqual(len(result), 2) self.assertTrue(all([o in result[0] for o in orders[:3]])) self.assertTrue(all([o in result[1] for o in orders[3:]]))
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)
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)
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)
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)
def test_fleet_all_neighbouring_seas_occupied(self): retreating_fleet = Fleet(self.state, 0, Nations.FRANCE, self.territories.BARRENTS_SEA) Army(self.state, 0, Nations.RUSSIA, self.territories.ST_PETERSBURG) Army(self.state, 0, Nations.RUSSIA, self.territories.NORWAY) Fleet(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA) self.assertFalse(retreating_fleet.can_retreat())
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)
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.' )
def test_simple_bounce(self): """ Two armies bouncing on each other. Austria: A Vienna - Tyrolia Italy: A Venice - Tyrolia The two units bounce. """ pieces = [ Army(Nations.AUSTRIA, self.territories.VIENNA), Army(Nations.ITALY, self.territories.VENICE), ] army_vienna_move = Move(Nations.AUSTRIA, self.territories.VIENNA, self.territories.TYROLIA) army_venice_move = Move(Nations.ITALY, self.territories.VENICE, self.territories.TYROLIA) self.state.register(*pieces, army_venice_move, army_vienna_move) self.state.post_register_updates() process(self.state) self.assertEqual(army_venice_move.legal_decision, Outcomes.LEGAL) self.assertEqual(army_vienna_move.legal_decision, Outcomes.LEGAL) self.assertEqual(army_vienna_move.move_decision, Outcomes.FAILS) self.assertEqual(army_venice_move.move_decision, Outcomes.FAILS)
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)
def test_five_army_circular_movement(self): pieces = [ Fleet(Nations.TURKEY, self.territories.ANKARA), Army(Nations.TURKEY, self.territories.CONSTANTINOPLE), Army(Nations.TURKEY, self.territories.SMYRNA), Army(Nations.TURKEY, self.territories.ARMENIA), Army(Nations.TURKEY, self.territories.SYRIA), ] 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.SYRIA), Move(Nations.TURKEY, self.territories.SYRIA, self.territories.ARMENIA), Move(Nations.TURKEY, self.territories.ARMENIA, self.territories.ANKARA), ] self.state.register(*pieces, *orders) self.state.post_register_updates() result = find_circular_movements(orders) self.assertEqual(len(result), 1) self.assertTrue(all([o in result[0] for o in orders]))
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)
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)
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)
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)
def test_support_cut_on_itself_via_convoy(self): """ If a unit is attacked by a supported unit, it is not possible to prevent dislodgement by trying to cut the support. But what, if a move is attempted via a convoy? Austria: F Adriatic Sea Convoys A Trieste - Venice A Trieste - Venice via Convoy Italy: A Venice Supports F Albania - Trieste F Albania - Trieste First it should be mentioned that if for issue 4.A.3 choice b or c is taken, then the move from Trieste to Venice is just a move over land, because the army in Venice is not moving in opposite direction. In that case, the support of Venice will not be cut as normal. In any other choice for issue 4.A.3, it should be decided whether the Austrian attack is considered to be coming from Trieste or from the Adriatic Sea. If it comes from Trieste, the support in Venice is not cut and the army in Trieste is dislodged by the fleet in Albania. If the Austrian attack is considered to be coming from the Adriatic Sea, then the support is cut and the army in Trieste will not be dislodged. See also issue 4.A.4. First of all, I prefer the 1982/2000 rules for adjacent convoying. This means that I prefer the move from Trieste uses the convoy. Furthermore, I think that the two Italian units are still stronger than the army in Trieste. Therefore, I prefer that the support in Venice is not cut and that the army in Trieste is dislodged by the fleet in Albania. """ pieces = [ Fleet(0, Nations.AUSTRIA, self.territories.ADRIATIC_SEA), Army(0, Nations.AUSTRIA, self.territories.TRIESTE), Army(0, Nations.ITALY, self.territories.VENICE), Fleet(0, Nations.ITALY, self.territories.ALBANIA), ] orders = [ Convoy(0, Nations.AUSTRIA, self.territories.ADRIATIC_SEA, self.territories.TRIESTE, self.territories.VENICE), Move(0, Nations.AUSTRIA, self.territories.TRIESTE, self.territories.VENICE, via_convoy=True), Support(0, Nations.ITALY, self.territories.VENICE, self.territories.ALBANIA, self.territories.TRIESTE), Move(0, Nations.ITALY, self.territories.ALBANIA, self.territories.TRIESTE), ] self.state.register(*pieces, *orders) self.state.post_register_updates() process(self.state) self.assertEqual(pieces[1].dislodged_decision, Outcomes.DISLODGED) self.assertEqual(orders[2].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
def test_bounce_by_convoy_to_adjacent_place(self): """ Similar to test case 6.G.10, but now the other unit is taking the convoy. England: A Norway - Sweden F Denmark Supports A Norway - Sweden F Finland Supports A Norway - Sweden France: F Norwegian Sea - Norway F North Sea Supports F Norwegian Sea - Norway Germany: F Skagerrak Convoys A Sweden - Norway Russia: A Sweden - Norway via Convoy F Barents Sea Supports A Sweden - Norway Again the army in Sweden is bounced by the fleet in the Norwegian Sea. The army in Norway will move to Sweden and dislodge the Russian army. The final destination of the fleet in the Norwegian Sea depends on how issue 4.A.7 is resolved. If choice a is taken, then the fleet advances to Norway, but if choice b is taken (which I prefer) the fleet bounces and stays in the Norwegian Sea. """ pieces = [ Army(self.state, 0, Nations.ENGLAND, self.territories.NORWAY), Fleet(self.state, 0, Nations.ENGLAND, self.territories.DENMARK), Fleet(self.state, 0, Nations.ENGLAND, self.territories.FINLAND), Fleet(self.state, 0, Nations.FRANCE, self.territories.NORWEGIAN_SEA), Fleet(self.state, 0, Nations.FRANCE, self.territories.NORTH_SEA), Fleet(self.state, 0, Nations.GERMANY, self.territories.SKAGERRAK), Army(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN), Fleet(self.state, 0, Nations.RUSSIA, self.territories.BARRENTS_SEA), ] orders = [ Move(self.state, 0, Nations.ENGLAND, self.territories.NORWAY, self.territories.SWEDEN), Support(self.state, 0, Nations.ENGLAND, self.territories.DENMARK, self.territories.NORWAY, self.territories.SWEDEN), Support(self.state, 0, Nations.ENGLAND, self.territories.FINLAND, self.territories.NORWAY, self.territories.SWEDEN), Move(self.state, 0, Nations.FRANCE, self.territories.NORWEGIAN_SEA, self.territories.NORWAY), Support(self.state, 0, Nations.FRANCE, self.territories.NORTH_SEA, self.territories.NORWEGIAN_SEA, self.territories.NORWAY), Convoy(self.state, 0, Nations.GERMANY, self.territories.SKAGERRAK, self.territories.SWEDEN, self.territories.NORWAY), Move(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN, self.territories.NORWAY, via_convoy=True), Support(self.state, 0, Nations.RUSSIA, self.territories.BARRENTS_SEA, self.territories.SWEDEN, self.territories.NORWAY), ] 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.FAILS) self.assertEqual(orders[4].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[6].outcome, Outcomes.FAILS) self.assertEqual(pieces[6].dislodged_decision, Outcomes.DISLODGED) self.assertEqual(orders[7].outcome, Outcomes.SUCCEEDS)
def test_army_neighbouring_land_contested(self): retreating_army = Army(self.state, 0, Nations.FRANCE, self.territories.BREST) Army(self.state, 0, Nations.ITALY, self.territories.GASCONY) Army(self.state, 0, Nations.ITALY, self.territories.PICARDY) paris = self.state.get_territory('paris') paris.bounce_occurred = True self.assertFalse(retreating_army.can_retreat())
def test_army_neighbouring_land_contested(self): retreating_army = Army(0, Nations.FRANCE, self.territories.BREST) gascony_army = Army(0, Nations.ITALY, self.territories.GASCONY) picary_army = Army(0, Nations.ITALY, self.territories.PICARDY) self.state.register(retreating_army, gascony_army, picary_army) self.state.post_register_updates() paris = self.state.get_territory('paris') paris.bounce_occurred = True self.assertFalse(retreating_army.can_retreat())
def test_swapping_two_units_with_two_convoys(self): """ Of course, two armies can also swap by when they are both convoyed. England: A Liverpool - Edinburgh via Convoy F North Atlantic Ocean Convoys A Liverpool - Edinburgh F Norwegian Sea Convoys A Liverpool - Edinburgh Germany: A Edinburgh - Liverpool via Convoy F North Sea Convoys A Edinburgh - Liverpool F English Channel Convoys A Edinburgh - Liverpool F Irish Sea Convoys A Edinburgh - Liverpool The armies in Liverpool and Edinburgh are swapped. """ pieces = [ Army(0, Nations.ENGLAND, self.territories.LIVERPOOL), Fleet(0, Nations.ENGLAND, self.territories.NORTH_ATLANTIC), Fleet(0, Nations.ENGLAND, self.territories.NORWEGIAN_SEA), Army(0, Nations.GERMANY, self.territories.EDINBURGH), Fleet(0, Nations.GERMANY, self.territories.NORTH_SEA), Fleet(0, Nations.GERMANY, self.territories.ENGLISH_CHANNEL), Fleet(0, Nations.GERMANY, self.territories.IRISH_SEA), ] orders = [ Move(0, Nations.ENGLAND, self.territories.LIVERPOOL, self.territories.EDINBURGH, via_convoy=True), Convoy(0, Nations.ENGLAND, self.territories.NORTH_ATLANTIC, self.territories.LIVERPOOL, self.territories.EDINBURGH), Convoy(0, Nations.ENGLAND, self.territories.NORWEGIAN_SEA, self.territories.LIVERPOOL, self.territories.EDINBURGH), Move(0, Nations.GERMANY, self.territories.EDINBURGH, self.territories.LIVERPOOL, via_convoy=True), Convoy(0, Nations.GERMANY, self.territories.NORTH_SEA, self.territories.EDINBURGH, self.territories.LIVERPOOL), Convoy(0, Nations.GERMANY, self.territories.ENGLISH_CHANNEL, self.territories.EDINBURGH, self.territories.LIVERPOOL), Convoy(0, Nations.GERMANY, self.territories.IRISH_SEA, self.territories.EDINBURGH, self.territories.LIVERPOOL), ] self.state.register(*pieces, *orders) self.state.post_register_updates() process(self.state) self.assertEqual(orders[0].path_decision(), Outcomes.PATH) self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[3].path_decision(), Outcomes.PATH) self.assertEqual(orders[3].outcome, Outcomes.SUCCEEDS)
def test_two_unit_in_one_area_bug_moving_by_land(self): """ Similar to the previous test case, but now the other unit moves by convoy. England: A Norway - Sweden via Convoy A Denmark Supports A Norway - Sweden F Baltic Sea Supports A Norway - Sweden F Skagerrak Convoys A Norway - Sweden F North Sea - Norway Russia: A Sweden - Norway F Norwegian Sea Supports A Sweden - Norway Sweden and Norway are swapped, while the fleet in the North Sea will bounce. """ pieces = [ Army(0, Nations.ENGLAND, self.territories.NORWAY), Fleet(0, Nations.ENGLAND, self.territories.DENMARK), Fleet(0, Nations.ENGLAND, self.territories.BALTIC_SEA), Fleet(0, Nations.ENGLAND, self.territories.SKAGERRAK), Fleet(0, Nations.ENGLAND, self.territories.NORTH_SEA), Army(0, Nations.RUSSIA, self.territories.SWEDEN), Fleet(0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA), ] orders = [ Move(0, Nations.ENGLAND, self.territories.NORWAY, self.territories.SWEDEN, via_convoy=True), Support(0, Nations.ENGLAND, self.territories.DENMARK, self.territories.NORWAY, self.territories.SWEDEN), Support(0, Nations.ENGLAND, self.territories.BALTIC_SEA, self.territories.NORWAY, self.territories.SWEDEN), Convoy(0, Nations.ENGLAND, self.territories.SKAGERRAK, self.territories.NORWAY, self.territories.SWEDEN), Move(0, Nations.ENGLAND, self.territories.NORTH_SEA, self.territories.NORWAY), Move(0, Nations.RUSSIA, self.territories.SWEDEN, self.territories.NORWAY), Support(0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA, self.territories.SWEDEN, self.territories.NORWAY), ] self.state.register(*pieces, *orders) self.state.post_register_updates() 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[5].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[4].outcome, Outcomes.FAILS) self.assertEqual(orders[6].outcome, Outcomes.SUCCEEDS)
def test_two_unit_in_one_area_bug_moving_by_convoy(self): """ If the adjudicator is not correctly implemented, this may lead to a resolution where two units end up in the same area. England: A Norway - Sweden A Denmark Supports A Norway - Sweden F Baltic Sea Supports A Norway - Sweden F North Sea - Norway Russia: A Sweden - Norway via Convoy F Skagerrak Convoys A Sweden - Norway F Norwegian Sea Supports A Sweden - Norway See decision details 5.B.6. If the 'PREVENT STRENGTH' is incorrectly implemented, due to the fact that it does not take into account that the 'PREVENT STRENGTH' is only zero when the unit is engaged in a head to head battle, then this goes wrong in this test case. The 'PREVENT STRENGTH' of Sweden would be zero, because the opposing unit in Norway successfully moves. Since, this strength would be zero, the fleet in the North Sea would move to Norway. However, although the 'PREVENT STRENGTH' is zero, the army in Sweden would also move to Norway. So, the final result would contain two units that successfully moved to Norway. Of course, this is incorrect. Norway will indeed successfully move to Sweden while the army in Sweden ends in Norway, because it is stronger then the fleet in the North Sea. This fleet will stay in the North Sea. """ Army(self.state, 0, Nations.ENGLAND, self.territories.NORWAY), Fleet(self.state, 0, Nations.ENGLAND, self.territories.DENMARK), Fleet(self.state, 0, Nations.ENGLAND, self.territories.BALTIC_SEA), Fleet(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA), Army(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN), Fleet(self.state, 0, Nations.RUSSIA, self.territories.SKAGERRAK), Fleet(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA), orders = [ Move(self.state, 0, Nations.ENGLAND, self.territories.NORWAY, self.territories.SWEDEN), Support(self.state, 0, Nations.ENGLAND, self.territories.DENMARK, self.territories.NORWAY, self.territories.SWEDEN), Support(self.state, 0, Nations.ENGLAND, self.territories.BALTIC_SEA, self.territories.NORWAY, self.territories.SWEDEN), Move(self.state, 0, Nations.ENGLAND, self.territories.NORTH_SEA, self.territories.NORWAY), Move(self.state, 0, Nations.RUSSIA, self.territories.SWEDEN, self.territories.NORWAY, via_convoy=True), Convoy(self.state, 0, Nations.RUSSIA, self.territories.SKAGERRAK, self.territories.SWEDEN, self.territories.NORWAY), Support(self.state, 0, Nations.RUSSIA, self.territories.NORWEGIAN_SEA, self.territories.SWEDEN, self.territories.NORWAY), ] 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.FAILS) self.assertEqual(orders[4].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[6].outcome, Outcomes.SUCCEEDS)
def test_simple_bounce(self): Army(self.state, 0, Nations.FRANCE, self.territories.PICARDY), Army(self.state, 0, Nations.GERMANY, self.territories.BURGUNDY), orders = [ Move(self.state, 0, Nations.FRANCE, self.territories.PICARDY, self.territories.PARIS), Move(self.state, 0, Nations.GERMANY, self.territories.BURGUNDY, self.territories.PARIS), ] process(self.state) self.assertTrue(orders[0].target.bounce_occurred)
def test_next_turn_supply_delta(self): territory = InlandTerritory(self.state, 1, 'Paris', 2, [], True, controlled_by=self.nation.id) army = Army(self.state, 1, self.nation.id, territory) self.assertEqual(self.nation.next_turn_supply_delta, 0) army.destroyed = True self.assertEqual(self.nation.next_turn_supply_delta, 1)
def test_swapped_or_dislodged(self): """ The 1982 rulebook says that whether the move is over land or via convoy depends on the "intent" as shown by the totality of the orders written by the player governing the army (see issue 4.A.3). In this test case the English army in Norway will end in all cases in Sweden. But whether it is convoyed or not has effect on the Russian army. In case of convoy the Russian army ends in Norway and in case of a land route the Russian army is dislodged. England: A Norway - Sweden F Skagerrak Convoys A Norway - Sweden F Finland Supports A Norway - Sweden Russia: A Sweden - Norway See issue 4.A.3. For choice a, b and c the move of the army in Norway is by convoy and the armies in Norway and Sweden are swapped. If the 1982 rulebook is used with the clarification of the 2000 rulebook (choice d, which I prefer), the intent of the English player is to convoy, since it ordered the fleet in Skagerrak to convoy. Therefore, the armies in Norway and Sweden are swapped. When explicit adjacent convoying is used (DTPG, choice e), then the unit in Norway did not receive an order to move by convoy and the land route should be considered. The Russian army in Sweden is dislodged. """ pieces = [ Army(0, Nations.ENGLAND, self.territories.NORWAY), Fleet(0, Nations.ENGLAND, self.territories.SKAGERRAK), Fleet(0, Nations.ENGLAND, self.territories.FINLAND), Army(0, Nations.RUSSIA, self.territories.SWEDEN), ] orders = [ Move(0, Nations.ENGLAND, self.territories.NORWAY, self.territories.SWEDEN), Convoy(0, Nations.ENGLAND, self.territories.SKAGERRAK, self.territories.NORWAY, self.territories.SWEDEN), Support(0, Nations.ENGLAND, self.territories.FINLAND, self.territories.NORWAY, self.territories.SWEDEN), Move(0, Nations.RUSSIA, self.territories.SWEDEN, self.territories.NORWAY), ] self.state.register(*pieces, *orders) self.state.post_register_updates() process(self.state) self.assertEqual(orders[0].outcome, Outcomes.SUCCEEDS) self.assertEqual(orders[2].outcome, Outcomes.SUCCEEDS) self.assertEqual(pieces[3].dislodged_decision, Outcomes.DISLODGED)