aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/integration
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-08-21 20:13:13 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-08-21 20:45:22 -0400
commit63e79a4e0e1db39bb54af22c849756d7fd7b9f57 (patch)
tree29c587ab2125bf78fcff54e1bb34a78f96890d50 /diplomacy/integration
parent22ae5e3672ff630e6db5159591e880b4ba1292cd (diff)
[API] Converting '-' to 'R' during retreats phase
Diffstat (limited to 'diplomacy/integration')
-rw-r--r--diplomacy/integration/webdiplomacy_net/orders.py5
-rw-r--r--diplomacy/integration/webdiplomacy_net/tests/test_orders.py19
2 files changed, 24 insertions, 0 deletions
diff --git a/diplomacy/integration/webdiplomacy_net/orders.py b/diplomacy/integration/webdiplomacy_net/orders.py
index 60cc86a..afacf03 100644
--- a/diplomacy/integration/webdiplomacy_net/orders.py
+++ b/diplomacy/integration/webdiplomacy_net/orders.py
@@ -166,6 +166,11 @@ class Order():
:type game: diplomacy.Game
"""
# pylint: disable=too-many-return-statements,too-many-branches,too-many-statements
+ # Converting move to retreat during retreat phase
+ if self.phase_type == 'R':
+ order = order.replace(' - ', ' R ')
+
+ # Splitting into parts
words = order.split()
# --- Wait / Waive ---
diff --git a/diplomacy/integration/webdiplomacy_net/tests/test_orders.py b/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
index 71e055e..5429c67 100644
--- a/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
+++ b/diplomacy/integration/webdiplomacy_net/tests/test_orders.py
@@ -251,6 +251,25 @@ def test_retreat_army_001():
assert order_from_dict.to_string() == order_str
assert compare_dicts(order_from_dict.to_dict(), order_dict)
+def test_retreat_army_002():
+ """ Tests retreat army """
+ raw_order = 'A PAR - LON'
+ order_str = 'A PAR R LON'
+ order_dict = {'terrID': 47,
+ 'unitType': 'Army',
+ 'type': 'Retreat',
+ 'toTerrID': 6,
+ '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_retreat_fleet_001():
""" Tests retreat fleet """
raw_order = 'F BRE R SPA/SC'