retreat lretreat: Change query syntax to match mission

Optional arguments can save typing.  Mandatory arguments are more
easily discoverable: just run the command and answer its prompts.
Empire traditionally uses optional arguments only for expert features.
Consider mission:

    [0:640] Command : mission
    Ship, plane or land unit (p,sh,la)? s
    ship(s)? 0
    Mission (int, sup, osup, dsup, esc, res, air, query, clear)? int
    operations point? .
    frg  frigate Early Bird(#0) on an interdiction mission, centered on 21,-3, radius 0
    1 ship

Compare retreat:

    [0:638] Command : retreat
    ship(s)? 0
    shp#     ship type       x,y   fl path       as flt?  flags
       0 frg  frigate       21,-3
    1 ship

Arguments are not discoverable this way.

Change retreat to work like mission: make the second argument
mandatory, and if it's 'q', show retreat orders, else treat it as path
and ask for conditions:

    [0:637] Command : retreat
    ship(s)? 0
    Retreat path, or q to query? jj
    Retreat conditions ('?' to list available ones)? i
    shp#     ship type       x,y   fl path       as flt?  flags
       0 frg  frigate       21,-3     jj                  i
    1 ship

To reduce smart client and script breakage, keep retreat with one
argument working as before, but print a deprecation warning.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-01-10 13:43:23 +01:00
parent 4de4da259a
commit 482d54c953
7 changed files with 55 additions and 24 deletions

View file

@ -18,6 +18,7 @@ __cmd added 1 0 0
| show retreat orders
retr
0/1/2/3/4/7
q
|| lretreat command
| garbage path
lret 0 garbage i
@ -37,6 +38,7 @@ __cmd added 1 0 0
| show retreat orders
lret
0/1/2/3/4/7
q
||| Ships
|| ships failing to retreat
| sunk

View file

@ -27,7 +27,7 @@
Play#1 output Play#1 1 y u
Play#1 output Play#1 1 g j
Play#1 output Play#1 1 b n
Play#1 output Play#1 1 Usage: retreat <SHIPS|FLEET> [<PATH> <i|t|s|h|b|d|u|c>]
Play#1 output Play#1 1 Usage: retreat <SHIPS|FLEET> [q | <PATH> <i|t|s|h|b|d|u|c>]
Play#1 output Play#1 6 0 640
Play#1 input __cmd added 0 -1 0
Play#1 command __cmd
@ -47,7 +47,7 @@
Play#1 output Play#1 4 Retreat conditions ('?' to list available ones)?
Play#1 input junk
Play#1 output Play#1 1 Bad retreat condition 'j'
Play#1 output Play#1 1 Usage: retreat <SHIPS|FLEET> [<PATH> <i|t|s|h|b|d|u|c>]
Play#1 output Play#1 1 Usage: retreat <SHIPS|FLEET> [q | <PATH> <i|t|s|h|b|d|u|c>]
Play#1 output Play#1 6 0 639
Play#1 input retr 2/3 bgyujnbgyujnbgyujn itshbdu
Play#1 command retreat
@ -79,6 +79,8 @@
Play#1 command retreat
Play#1 output Play#1 4 ship(s)?
Play#1 input 0/1/2/3/4/7
Play#1 output Play#1 4 Retreat path, or q to query?
Play#1 input q
Play#1 output Play#1 1 shp# ship type x,y fl path as flt? flags
Play#1 output Play#1 1 0 lc light cruis -3,1 a
Play#1 output Play#1 1 1 lc light cruis -3,1 a
@ -95,7 +97,7 @@
Play#1 output Play#1 1 y u
Play#1 output Play#1 1 g j
Play#1 output Play#1 1 b n
Play#1 output Play#1 1 Usage: lretreat <UNITS|ARMY> [<PATH> <i|h|b|c>]
Play#1 output Play#1 1 Usage: lretreat <UNITS|ARMY> [q | <PATH> <i|h|b|c>]
Play#1 output Play#1 6 0 635
Play#1 input __cmd added 0 -1 0
Play#1 command __cmd
@ -111,7 +113,7 @@
Play#1 output Play#1 4 Retreat conditions ('?' to list available ones)?
Play#1 input junk
Play#1 output Play#1 1 Bad retreat condition 'j'
Play#1 output Play#1 1 Usage: lretreat <UNITS|ARMY> [<PATH> <i|h|b|c>]
Play#1 output Play#1 1 Usage: lretreat <UNITS|ARMY> [q | <PATH> <i|h|b|c>]
Play#1 output Play#1 6 0 634
Play#1 input lret 2/3 yujnbgyujnbgyujnbg ihb
Play#1 command lretreat
@ -143,6 +145,8 @@
Play#1 command lretreat
Play#1 output Play#1 4 land(s)?
Play#1 input 0/1/2/3/4/7
Play#1 output Play#1 4 Retreat path, or q to query?
Play#1 input q
Play#1 output Play#1 1 lnd# unit type x,y ar path as army? flags
Play#1 output Play#1 1 0 inf infantry -3,1 a
Play#1 output Play#1 1 1 inf infantry -3,1 a
@ -1596,6 +1600,9 @@
Play#0 output Play#0 6 0 640
Play#0 input retr * ?rflags#0
Play#0 command retreat
Play#0 output Play#0 1 Omitting the second argument is deprecated and will cease to work in a
Play#0 output Play#0 1 future release. Please use 'retr * ?rflags#0 q' to query retreat orders.
Play#0 output Play#0 1
Play#0 output Play#0 1 own shp# ship type x,y fl path as flt? flags
Play#0 output Play#0 1 1 2 lc light cruis -3,1 bgyujnbgy itshbdu
Play#0 output Play#0 1 1 4 lc light cruis -5,1 a b Yes h
@ -1697,6 +1704,9 @@
Play#0 output Play#0 6 0 637
Play#0 input lretr * ?rflags#0
Play#0 command lretreat
Play#0 output Play#0 1 Omitting the second argument is deprecated and will cease to work in a
Play#0 output Play#0 1 future release. Please use 'lretr * ?rflags#0 q' to query retreat orders.
Play#0 output Play#0 1
Play#0 output Play#0 1 own lnd# unit type x,y ar path as army? flags
Play#0 output Play#0 1 1 2 inf infantry -3,1 yujnbgyuj ihb
Play#0 output Play#0 1 1 4 inf infantry -4,0 a b Yes h