Skip to content

Commit

Permalink
add multi-keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Wind2009-Louse committed Jul 13, 2020
1 parent 8bff838 commit 8ecf03b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- 1.2. 卡片搜索/注释栏支持回车。
- 1.3. 操作列表支持Del键。
- 1.4. 卡片搜素双击可以补全卡名;操作列表双击可以进行复制。
- 1.4.1. 支持多关键词进行卡片搜索,每个关键词前加上“-”则说明排除该关键词。
2. 支持cdb,将**cards.cdb**和项目放在同一目录中,项目可以读取卡片内容,进行卡名补全、效果快查、简易伤害计算等操作。
3. 按住Shift点击场上的卡片,可以进行效果快查。
- 3.1. 快查中,**狮子男巫****狮子男巫1****狮子男巫k**均可以查到**狮子男巫**,建议创建卡片时按照格式(卡名+0~1位序号)命名,方便快查。
Expand Down
31 changes: 26 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
init_field = {"locations":{}, "desp":{}, "LP":[8000,8000], "fields":[]}
for t in range(len(idx_represent_str)):
init_field["fields"].append([])
version = 131
version = 132

class Update_Thread(Thread):
def __init__(self, window):
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def ope_addcomment(self):
self.Comment_Line.clear()

def ope_addcarddesp(self):
'''添加卡片描述'''
'''添加��片描述'''
comment = self.Comment_Line.text()
if len(comment) == 0 or len(self.targets) == 0:
return
Expand Down Expand Up @@ -1407,13 +1407,34 @@ def search_card(self):
hit = []
hit_in_name = []
hit_in_effect = []
# 多条件搜索
included = []
excluded = []
split_text = text.split(" ")
for sub_text in split_text:
if len(sub_text) == 0:
continue
if sub_text[0] == "-":
excluded.append(sub_text[1:])
else:
included.append(sub_text)
if len(included)+len(excluded)==0:
return
def check_legal(text, included, excluded):
for i in included:
if i not in text:
return False
for e in excluded:
if e in text:
return False
return True
# 遍历搜索符合条件的卡片
for cardname in self.card_datas.keys():
if text == cardname:
hit.append(cardname)
elif text in cardname:
elif check_legal(cardname, included, excluded):
hit_in_name.append(cardname)
elif text in self.card_datas[cardname]:
elif check_legal(self.card_datas[cardname], included, excluded):
hit_in_effect.append(cardname)
# 添加到列表
for name in hit:
Expand Down Expand Up @@ -1510,4 +1531,4 @@ def update_hint(self, name):
m_window = Ui_MainWindow()

m_window.show()
sys.exit(app.exec_())
sys.exit(app.exec_())

0 comments on commit 8ecf03b

Please sign in to comment.