From 7a896a344e75f40b5ef932e9451a8baf94f2ae98 Mon Sep 17 00:00:00 2001 From: sheychen290 Date: Fri, 15 Jun 2018 14:58:59 +0200 Subject: [PATCH] add potions --- LeekBots.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/LeekBots.py b/LeekBots.py index ba8d5d6..4a81dc0 100755 --- a/LeekBots.py +++ b/LeekBots.py @@ -522,10 +522,19 @@ class Pool: def usePotion(params, options): try: - potion = params[0] + template = params[0] for leek in Pool.get(Settings(options), Pool.parse(options)): try: - leek.usePotion(potion) + pid = None + for potion in leek.farmer.potions: + if (potion['template'] == template): + pid = potion['id'] + + if pid is None: + leek.farmer.raiseError( + 'Have any {0} available'.format(template)) + + leek.usePotion(pid) leek.raiseError('OK') #Ugly except ValueError as err: print(format(err)) @@ -757,6 +766,7 @@ class Farmer: self.name = self.data['name'] self.weapons = self.data['weapons'] self.chips = self.data['chips'] + self.potions = self.data['potions'] self.leeks = self.data['leeks'] self.fights = self.data['fights'] @@ -892,7 +902,7 @@ class Leek: self.checkRequest(lwapi.leek.remove_chip(wid, self.farmer.token)) def usePotion(self, pid): - self.checkRequest(lwapi.leek.use_potion(pid, self.farmer.token)) + self.checkRequest(lwapi.leek.use_potion(self.id, pid, self.farmer.token)) def characteristics(self, bonuses): self.checkRequest(