(                                                                      )
( .PMatchPlus ) ( Parade ) ( 12/20/91 ) ( s -- d ) ( TimeTraveller )
(                                                                      )
( Does pmatch with support for partial name matching                   )
( Requires use of USERS/ONLINE [ -- {D: <players>} ]                   )
(                                                                      )
  : PopN dup 0 = if pop exit then swap pop 1 - PopN ;
  : PartialMatch ( {s: <name>} {D: <connected players>} {i: <counter>}
                   -- {D: <matches>} )
    dup 3 pick > if
      pop dup 2 + rotate pop
      exit
    then
    dup 2 + pick name
    3 pick 4 + pick
    swap over strlen strcut pop swap
    stringcmp if
      dup 2 + rotate pop
      swap 1 - swap
    else
      1 +
    then
    PartialMatch
  ;
: PMatchPlus ( {s: <player name>} -- {d: <match>} )
  dup .pmatch
  dup #-1 dbcmp not if
    swap pop
    exit
  else pop
    ONLINE 1 PartialMatch
    dup 1 < if pop
      #-1
    else
      dup 1 > if
        PopN
        #-2
      else pop
      then
    then
  then
;