From b179c914a258d5f14ba11b99a05efa5580da5671 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 17 May 2009 04:10:46 +0100 Subject: [PATCH] Manual adjustment of pirates aboard --- TODO | 5 ++--- yoweb-scrape | 48 ++++++++++++++++++++++++++++++++++++++++-------- yoweb-scrape.txt | 39 +++++++++++++++++++++++++++++++-------- 3 files changed, 73 insertions(+), 19 deletions(-) diff --git a/TODO b/TODO index ecd5199..d7355e3 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ yoweb-scrape - parse officer chat for - /off /a [:] ... - /off /d [:] ... improve the docs + make /a and /d work for non-current vessels (even ones + you have yet to board) diff --git a/yoweb-scrape b/yoweb-scrape index cc98ea3..43b9522 100755 --- a/yoweb-scrape +++ b/yoweb-scrape @@ -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 ---------- diff --git a/yoweb-scrape.txt b/yoweb-scrape.txt index 752080a..452fdd2 100644 --- a/yoweb-scrape.txt +++ b/yoweb-scrape.txt @@ -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 ... /d ... + /a : ... /d : ... + and can be in any case and will be converted to + the proper mixed-case form automatically. , 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 + 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: -- 2.30.2