From 75e60d5da1286441964aee77d7f685ed96e4a489 Mon Sep 17 00:00:00 2001 From: Philipp Hartl Date: Mon, 24 Oct 2016 17:08:59 +0200 Subject: [PATCH 1/2] Small fix for new special cards. Temporary shows a normal TOTW instead. --- frames/playersearch.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frames/playersearch.py b/frames/playersearch.py index e9bdd39..546b9aa 100644 --- a/frames/playersearch.py +++ b/frames/playersearch.py @@ -125,6 +125,12 @@ def lookup(self, event=None): self.kill_job() payload = {'jsonParamObject': json.dumps({'name': self._playerName})} response = requests.get(self.url, params=payload).json() + # Little fix for new special cards e.g halloween cards, now shows an TOTW-Card instead + # (seems like a problem with the Api not getting the newer colors?) + j = 0 + for _len_ in response: + if response['items'][j]['color'] == "": + response['items'][j]['color'] = "totw_gold" self.controller.status.set_status('Found %d matches for "%s"' % (response['totalResults'], self._playerName)) for child in self.interior.winfo_children(): child.destroy() From e438e159a39ceb7a025e127de64e7a02ff3d0abc Mon Sep 17 00:00:00 2001 From: Philipp Hartl Date: Tue, 25 Oct 2016 10:53:24 +0200 Subject: [PATCH 2/2] Rearranged the code, now using a while-loop. I'm completely new to Python. I didn't know how to use a for-loop properly. --- frames/playersearch.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frames/playersearch.py b/frames/playersearch.py index 546b9aa..491f07e 100644 --- a/frames/playersearch.py +++ b/frames/playersearch.py @@ -127,10 +127,12 @@ def lookup(self, event=None): response = requests.get(self.url, params=payload).json() # Little fix for new special cards e.g halloween cards, now shows an TOTW-Card instead # (seems like a problem with the Api not getting the newer colors?) - j = 0 - for _len_ in response: - if response['items'][j]['color'] == "": - response['items'][j]['color'] = "totw_gold" + j = response['count'] + k = 0 + while k < j: + if response['items'][k]['color'] == "halloween" or response['items'][k]['color'] == "": + response['items'][k]['color'] = "totw_gold" + k += 1 self.controller.status.set_status('Found %d matches for "%s"' % (response['totalResults'], self._playerName)) for child in self.interior.winfo_children(): child.destroy()