diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-08-09 10:40:02 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-08-09 11:39:44 -0400 |
commit | 25ee6663b8356ad3598005297e57c9c260248d2f (patch) | |
tree | e6810ce2fdcd412904159f52c8117d1008943fe4 | |
parent | 3dd0ecee0af381bf9fa19137bcb66b16b9993992 (diff) |
[API] Fixed issue when disbanding a fleet from a coast
-rw-r--r-- | diplomacy/integration/webdiplomacy_net/orders.py | 4 | ||||
-rw-r--r-- | diplomacy/integration/webdiplomacy_net/tests/test_orders.py | 19 |
2 files changed, 19 insertions, 4 deletions
diff --git a/diplomacy/integration/webdiplomacy_net/orders.py b/diplomacy/integration/webdiplomacy_net/orders.py index 77577d1..976a34b 100644 --- a/diplomacy/integration/webdiplomacy_net/orders.py +++ b/diplomacy/integration/webdiplomacy_net/orders.py @@ -374,8 +374,6 @@ class Order(): # --- Disband (R phase) --- # {"id": "152", "unitID": "18", "type": "Disband", "toTerrID": "", "fromTerrID": "", "viaConvoy": ""} elif order_type == 'D' and self.phase_type == 'R': - 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, @@ -409,8 +407,6 @@ class Order(): # Disband (A phase) # {"id": "152", "unitID": null, "type": "Destroy", "toTerrID": "18", "fromTerrID": "", "viaConvoy": ""} elif order_type == 'D': - 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 aed58c6..c2de6e8 100644 --- a/diplomacy/integration/webdiplomacy_net/tests/test_orders.py +++ b/diplomacy/integration/webdiplomacy_net/tests/test_orders.py @@ -308,6 +308,25 @@ def test_disband_fleet_001(): assert order_from_dict.to_string() == order_str assert compare_dicts(order_from_dict.to_dict(), order_dict) +def test_disband_fleet_coast_001(): + """ Tests disband fleet """ + raw_order = 'F SPA/NC D' + order_str = 'F SPA/NC D' + order_dict = {'terrID': 76, + 'unitType': 'Fleet', + 'type': 'Disband', + 'toTerrID': '', + 'fromTerrID': '', + 'viaConvoy': ''} + order_from_string = Order(raw_order, phase_type='R') + order_from_dict = Order(order_dict, phase_type='R') + + # 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' |