class Plugin(GUIClass): """ LOTROAssist loot bag plugin class """ metadata={ 'PLUGIN_NAME': 'Loot Bag', 'PLUGIN_CODENAME': 'lootbag', 'PLUGIN_VERSION': '0.1', 'PLUGIN_DESC': 'Lord Of The Rings Online Assistant plugin for loot counting', 'PLUGIN_COPYRIGHT': '(C) 2010 Oliver Gutiérrez <*****@*****.**>', 'PLUGIN_WEBSITE': 'http://www.evosistemas.com', 'PLUGIN_DOCK': 'lists', } def initialize(self): """ Initialization function """ self.lootbag=TreeViewFactory('list', ['int','str'], ['Items','Item Name',], treeview=self.widgets.tvLootBag) self.itemregexp=re.compile(r'You have acquired .*\[(?P<items>\d*\s)*(?P<name>.*)\]\.$') self.itemremregexp=re.compile(r'Item Removed: \[(?P<items>\d*\s)*(?P<name>.*)\].$') # TODO: lotroassist: purchased and sold items def copyItems(self,widget): """ Copy loot bag items to clipboard """ clipboard=gtk.Clipboard() # Get stored data data=self.lootbag.getData() # Copy data to clipboard textdata='' for row in data: textdata+='%s x %s\n' % tuple(row) if textdata: clipboard.set_text('Loot Bag\n' + textdata) def removeItem(self,widget): """ Remove selected item """ self.lootbag.remove() def clearItems(self,widget): """ Clears item list """ self.lootbag.clear() def newLine(self,line): """ New line analysing function """ return (self.gotItem(line) or self.lostItem(line)) def gotItem(self,line): """ Check if line is a item line and process it """ # Analyze log line resp=self.itemregexp.search(line) if resp: # Get line information items=resp.group('items') itemname=resp.group('name') if not items: items=1 else: items=int(items) # Check if we have adquired the item before item=self.lootbag.getRow(itemname,1) if item: self.lootbag.update(itemname,[item[0]+items],1) else: # Add the new quest to tree view self.lootbag.append([items,itemname]) return True def lostItem(self,line): """ Check if line is a item removing line and process it """ # Analyze log line resp=self.itemremregexp.search(line) if resp: # Get line information items=resp.group('items') itemname=resp.group('name') if not items: items=1 else: items=int(items) # Check if we have adquired the item before item=self.lootbag.getRow(itemname,1) if item and item[0]>0: self.lootbag.update(itemname,[item[0]-items],1) return True
class Plugin(GUIClass): """ LOTROAssist quest items plugin class """ metadata={ 'PLUGIN_NAME': 'Quest Items', 'PLUGIN_CODENAME': 'questitems', 'PLUGIN_VERSION': '0.1', 'PLUGIN_DESC': 'Lord Of The Rings Online Assistant plugin for quest item count', 'PLUGIN_COPYRIGHT': '(C) 2010 Oliver Gutiérrez <*****@*****.**>', 'PLUGIN_WEBSITE': 'http://www.evosistemas.com', 'PLUGIN_DOCK': 'main', } def initialize(self): """ Initialization function """ self.questlist=TreeViewFactory('list', ['bool','str','int','int','progress'], ['Finished','Quest','Done','Pending','Progress'], treeview=self.widgets.tvQuestItems) self.regexp=re.compile(r'(?P<name>.*)\s\((?P<done>\d+)\/(?P<pending>\d+)\)$') def copyQuestItems(self,widget): """ Copy quest items to clipboard """ clipboard=gtk.Clipboard() # Get stored data data=self.questlist.getData() # Copy data to clipboard textdata='' for row in data: textdata+='%s (%s/%s)\n' % tuple(row[1:-1]) if textdata: clipboard.set_text('Quest Items\n' + textdata) def removeQuestItem(self,widget): """ Remove selected quest item """ self.questlist.remove() def clearQuestItems(self,widget): """ Clears quest item list """ self.questlist.clear() def newLine(self,line): """ New line analysing function """ # Analyze log line resp=self.regexp.search(line) if resp: # Get line information questname=resp.group('name') questdone=int(resp.group('done')) questpending=int(resp.group('pending')) questfinished=(questdone==questpending) questprogress=questdone*100/questpending # If autoremove is active, remove quest if questfinished and self.widgets.tlbcAutoRemoveQuestItem.get_active(): self.questlist.remove(questname,1) else: # Modify quest if already added if not self.questlist.update(questname,[questfinished,questname,questdone,questpending,questprogress],1): # Add the new quest to tree view self.questlist.append([questfinished,questname,questdone,questpending,questprogress]) return True