chiark / gitweb /
Manual adjustment of pirates aboard
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 17 May 2009 03:10:46 +0000 (04:10 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 17 May 2009 03:10:46 +0000 (04:10 +0100)
TODO
yoweb-scrape
yoweb-scrape.txt

diff --git a/TODO b/TODO
index ecd519919bc96a948597300e432551a8d0c96b90..d7355e39ade0cecf430497a9af022554bb834b74 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 yoweb-scrape
-       parse officer chat for
-               /off /a [<ship>:] <pirate>...
-               /off /d [<ship>:] <pirate>...
        improve the docs
+       make /a and /d work for non-current vessels (even ones
+               you have yet to board)
index cc98ea3b21b869154ed0a46ca5aec941d7f71a71..43b95225638fe6731938b7d1682adb10d83c33ba 100755 (executable)
@@ -512,6 +512,11 @@ class ChatLogTracker:
                def ob1(did): ob_x(m.group(1), did); return d(did)
                def oba(did): return ob1('%s %s' % (did, m.group(2)))
 
+               def disembark(who, how):
+                       ob_x(who, 'leaving '+how)
+                       del self._v[who]
+                       del self._pl[who]
+
                m = rm('Going aboard the (\\S.*\\S)\\.\\.\\.$')
                if m:
                        pn = self._myself.name
@@ -557,7 +562,34 @@ class ChatLogTracker:
                                pa.last_chat_time = timestamp
                                pa.last_chat_chan = what
                                self.force_redisplay()
-                               return d(what+' chat')
+                               return d('chat '+what)
+
+               def chat_metacmd(what):
+                       (cmdr, metacmd) = m.groups()
+                       metacmd = regexp.sub('\\s+', ' ', metacmd).strip()
+                       m2 = regexp.match(
+                               '/([ad]) (?:([A-Za-z ]+)\\s*:)?([A-Za-z ]+)$',
+                               metacmd)
+                       if not m2: return chat(what)
+
+                       (cmd, vn, targets) = m2.groups()
+
+                       if cmdr == self._myself.name: how = 'manual: /%s' % cmd
+                       else: how = '/%s %s' % (cmd,cmdr)
+                       if cmd == 'a': each = ob_x
+                       else: each = disembark
+
+                       if vn is not None:
+                               vn = vn.title()
+                               if not regexp.match(
+                                               '(?:.* )?' + vn + '$',
+                                               self._vessel):
+                                       return chat('/%s %s:' % (cmd,vn))
+
+                       for target in targets.split(' '):
+                               if not target: continue
+                               each(target.title(), how)
+                       return d('/%s' % cmd)
 
                m = rm('(\\w+) (?:issued an order|ordered everyone) "')
                if m: return ob1('general order');
@@ -568,11 +600,14 @@ class ChatLogTracker:
                m = rm('(\\w+) tells ye, "')
                if m: return chat('private')
 
+               m = rm('Ye told (\\w+), "(.*)"$')
+               if m: return chat_metacmd('private')
+
                m = rm('(\\w+) flag officer chats, "')
                if m: return chat('flag officer')
 
-               m = rm('(\\w+) officer chats, "')
-               if m: return chat('officer')
+               m = rm('(\\w+) officer chats, "(.*)"$')
+               if m: return chat_metacmd('officer')
 
                m = rm('Game over\\.  Winners: ([A-Za-z, ]+)\\.$')
                if m:
@@ -589,10 +624,7 @@ class ChatLogTracker:
 
                m = rm('(\\w+) has left the vessel\.')
                if m:
-                       who = m.group(1)
-                       ob_x(who, 'disembarked')
-                       del self._v[who]
-                       del self._pl[who]
+                       disembark(m.group(1), 'disembarked')
                        return d('disembarked')
 
                return d('not matched')
@@ -853,7 +885,7 @@ def do_ship_aid(args, bu):
 
                displayer.show(s)
                time.sleep(1)
-               rotate_nya = rotate_nya[1:2] + rotate_nya[0]
+               rotate_nya = rotate_nya[1:3] + rotate_nya[0]
 
 #---------- main program ----------
 
index 752080a3d23fb76166217b9afe93d9cc618e6b54..452fdd2e31004cc77a562dd0d0d29df477fb4a89 100644 (file)
@@ -35,14 +35,37 @@ I know of one key defect:
    ship is empty when you return to it).
 
    This means that there needs to be a way to manually add and remove
-   pirates - but there isn't.  I think this could probably be added by
-   someone who could be bothered to replace the `sleep 1' in the main
-   loop by something which looked for keyboard input.
-
-   However it will notice that a pirate is on board if they abandon a
-   duty station (in circumstances where the game reports this in the
-   log, which doesn't seem to be all the time) or you give them a
-   stationing order, and from various other messages that might occur.
+   pirates.  This is as follows: send or receive a message on the crew
+   officer chat, or send (not receive!) a private message, of the
+   following format:
+         /a <pirate>...                        /d <pirate>...
+        /a <ship>: <pirate>...         /d <ship>: <pirate>...
+   <pirate> and <ship> can be in any case and will be converted to
+   the proper mixed-case form automatically.  <ship>, if it is not
+   provided, will be assumed to be the one you're on (so officers
+   shouldn't send these runes unless only one ship is out).  If <ship>
+   is supplied it may be the full ship name, or only the second word.
+
+   For example:
+         /a haddock: aiah
+        /d aiah
+        /a smart sunfish: copperkatie
+   These are actually sent by typing in the chat box things like:
+         /o /d plonker
+         /off /a hypiscles
+   since other formulations interpret the scraper command as a YPP
+   chat command.  This is deliberate and makes it harder to invoke by
+   mistake.
+
+   These messages can also be sent by some other officer in your crew
+   while you are off the vessel (although currently a bug means that
+   if you board some _other_ vessel then these messages for the vessel
+   you come back to may not be properly recorded).
+
+   The program will notice that a pirate is on board if you give them
+   a stationing order or they abandon a duty station (in circumstances
+   where the game reports this in the log, which doesn't seem to be
+   all the time), and from many of the other messages that occur.
 
 Other things to mention: