aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diplomacy/integration/webdiplomacy_net/orders.py4
-rw-r--r--diplomacy/integration/webdiplomacy_net/tests/test_orders.py21
2 files changed, 24 insertions, 1 deletions
diff --git a/diplomacy/integration/webdiplomacy_net/orders.py b/diplomacy/integration/webdiplomacy_net/orders.py
index 73dc1a9..60cc86a 100644
--- a/diplomacy/integration/webdiplomacy_net/orders.py
+++ b/diplomacy/integration/webdiplomacy_net/orders.py
@@ -392,6 +392,7 @@ class Order():
# --- Disband (R phase) ---
# {"id": "152", "unitID": "18", "type": "Disband", "toTerrID": "", "fromTerrID": "", "viaConvoy": ""}
elif order_type == 'D' and self.phase_type == 'R':
+ # Note: For R phase, we disband with the coast
self.order_str = '%s %s D' % (short_unit_type, loc_name)
self.order_dict = {'terrID': terr_id,
'unitType': unit_type,
@@ -425,6 +426,9 @@ class Order():
# Disband (A phase)
# {"id": "152", "unitID": null, "type": "Destroy", "toTerrID": "18", "fromTerrID": "", "viaConvoy": ""}
elif order_type == 'D':
+ # For A phase, we disband without the coast
+ loc_name = loc_name[:3]
+ terr_id = CACHE[self.map_name]['loc_to_ix'][loc_name]
self.order_str = '%s %s D' % (short_unit_type, loc_name)
self.order_dict = {'terrID': terr_id,
'unitType': unit_type,
diff --git a/diplomacy/integration/webdiplomacy_net/tests/test_orders.py b/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
index c2de6e8..71e055e 100644
--- a/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
+++ b/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
@@ -309,7 +309,7 @@ def test_disband_fleet_001():
assert compare_dicts(order_from_dict.to_dict(), order_dict)
def test_disband_fleet_coast_001():
- """ Tests disband fleet """
+ """ Tests disband fleet (retreats phase) """
raw_order = 'F SPA/NC D'
order_str = 'F SPA/NC D'
order_dict = {'terrID': 76,
@@ -327,6 +327,25 @@ def test_disband_fleet_coast_001():
assert order_from_dict.to_string() == order_str
assert compare_dicts(order_from_dict.to_dict(), order_dict)
+def test_disband_fleet_coast_002():
+ """ Tests disband fleet (adjustment phase)"""
+ raw_order = 'F SPA/NC D'
+ order_str = 'F SPA D'
+ order_dict = {'terrID': 8,
+ 'unitType': 'Fleet',
+ 'type': 'Destroy',
+ 'toTerrID': 8,
+ 'fromTerrID': '',
+ 'viaConvoy': ''}
+ order_from_string = Order(raw_order, phase_type='A')
+ order_from_dict = Order(order_dict, phase_type='A')
+
+ # Validating
+ assert order_from_string.to_string() == order_str
+ assert compare_dicts(order_from_string.to_dict(), order_dict)
+ assert order_from_dict.to_string() == order_str
+ assert compare_dicts(order_from_dict.to_dict(), order_dict)
+
def test_build_army_001():
""" Tests build army """
raw_order = 'A PAR B'