From f37f05b72648af77e7725befc7c32db8dbed57ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Mon, 8 Aug 2022 16:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=8E=A8=E5=AF=BC=E5=BC=8F?= =?UTF-8?q?=E4=BB=A5=E4=BE=BFpylance=E6=98=8E=E7=A1=AE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/menubar.py | 4 +--- source/constants.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/source/component/menubar.py b/source/component/menubar.py index 19acedd..c990700 100755 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -22,9 +22,7 @@ def getSunValueImage(sun_value): return image def getCardPool(data): - card_pool = {} - for cardName in data: - card_pool[c.PLANT_CARD_INFO[c.PLANT_CARD_INDEX[cardName]]] = data[cardName] + card_pool = {c.PLANT_CARD_INFO[c.PLANT_CARD_INDEX[card_name]]: data[card_name] for card_name in data} return card_pool class Card(): diff --git a/source/constants.py b/source/constants.py index 7579e88..df09fea 100755 --- a/source/constants.py +++ b/source/constants.py @@ -376,9 +376,7 @@ PLANT_CARD_INFO = (# 元组 (植物名称, 卡片名称, 阳光, 冷却时间) ) # 卡片中的植物名称与索引序号的对应关系,指定名称以得到索引值 -PLANT_CARD_INDEX={} -for i, item in enumerate(PLANT_CARD_INFO): - PLANT_CARD_INDEX[item[PLANT_NAME_INDEX]] = i +PLANT_CARD_INDEX={item[PLANT_NAME_INDEX]: index for (index, item) in enumerate(PLANT_CARD_INFO)} # 指定了哪些卡可选(排除坚果保龄球特殊植物) CARDS_TO_CHOOSE = range(len(PLANT_CARD_INFO) - 3)