Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
* Add "Add card" buttom.
* Add dump card clearer.
* Add search color.
  • Loading branch information
Wind2009-Louse committed Jul 14, 2020
1 parent e2fa938 commit 85790c9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
41 changes: 36 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from threading import Thread

from PyQt5.QtCore import QRect, QRegExp, Qt, pyqtSignal
from PyQt5.QtGui import QColor, QRegExpValidator
from PyQt5.QtGui import QColor, QRegExpValidator, QFont
from PyQt5.QtWidgets import (QAction, QApplication, QComboBox, QFileDialog,
QLabel, QLineEdit, QListWidget, QMainWindow,
QMenuBar, QMessageBox, QPushButton, QTextBrowser,
Expand All @@ -20,10 +20,11 @@
import calculator

idx_represent_str = ["己方手卡", "己方魔陷_1", "己方魔陷_2", "己方魔陷_3", "己方魔陷_4", "己方魔陷_5", "己方场地", "己方灵摆_1", "己方灵摆_2", "己方怪兽_1", "己方怪兽_2", "己方怪兽_3", "己方怪兽_4", "己方怪兽_5", "己方墓地", "己方除外", "己方额外", "对方手卡", "对方魔陷_1", "对方魔陷_2", "对方魔陷_3", "对方魔陷_4", "对方魔陷_5", "对方场地", "对方灵摆_1", "对方灵摆_2", "对方怪兽_1", "对方怪兽_2", "对方怪兽_3", "对方怪兽_4", "对方怪兽_5", "对方墓地", "对方除外", "对方额外", "额外怪兽区_1", "额外怪兽区_2"]
cardcolors_dict = {0x2: QColor(10,128,0), 0x4: QColor(235,30,128), 0x10: QColor(168,168,0), 0x40: QColor(108,34,108), 0x80: QColor(16,128,235), 0x2000: QColor(168,168,168), 0x800000: QColor(0,0,0), 0x4000: QColor(98,98,98), 0x4000000: QColor(3,62,116), 0xffffffff: QColor(178,68,0)}
init_field = {"locations":{}, "desp":{}, "LP":[8000,8000], "fields":[]}
for t in range(len(idx_represent_str)):
init_field["fields"].append([])
version = 133
version = 134

class Update_Thread(Thread):
def __init__(self, window):
Expand Down Expand Up @@ -186,7 +187,8 @@ def placeframe(self):
height_4_1 = height - 410
xline_4_1 = 1000 * width / self.origin_width
self.label_cardsearch.setGeometry(QRect(xline_4_1, menu_height, width_4_1, 20))
self.NewCard_line.setGeometry(QRect(xline_4_1, menu_height + 20, width_4_1, 21))
self.NewCard_line.setGeometry(QRect(xline_4_1, menu_height + 20, width_4_1-42, 21))
self.NewCard_button.setGeometry(QRect(xline_4_1+width_4_1-40, menu_height + 20, 40, 21))
self.Newcard_List.setGeometry(QRect(xline_4_1, menu_height + 50, width_4_1, height_4_1))
self.CreateCard_Button.setGeometry(QRect(xline_4_1, menu_height + height_4_1+55, width_4_1, 28))
self.NewCard_Rename_Button.setGeometry(QRect(xline_4_1, menu_height + height_4_1+85, width_4_1, 28))
Expand Down Expand Up @@ -285,6 +287,7 @@ def init_frame(self):

self.NewCard_line = QLineEdit(self.centralwidget)
self.NewCard_line.setPlaceholderText("输入卡片名称")
self.NewCard_button = QPushButton(self.centralwidget)
self.Newcard_List = QListWidget(self.centralwidget)
self.CreateCard_Button = QPushButton(self.centralwidget)
self.NewCard_Rename_Button = QPushButton(self.centralwidget)
Expand Down Expand Up @@ -369,6 +372,7 @@ def __init__(self):
cardraces = {0x1: "战士族", 0x2: "魔法师族", 0x4: "天使族", 0x8: "恶魔族", 0x10: "不死族", 0x20: "机械族", 0x40: "水族", 0x80: "炎族", 0x100: "岩石族", 0x200: "鸟兽族", 0x400: "植物族", 0x800: "昆虫族", 0x1000: "雷族", 0x2000: "龙族", 0x4000: "兽族", 0x8000: "兽战士族", 0x10000: "恐龙族", 0x20000: "鱼族", 0x40000: "海龙族", 0x80000: "爬虫类族", 0x100000: "念动力族", 0x200000: "幻神兽族", 0x400000: "创造神族", 0x800000: "幻龙族", 0x1000000: "电子界族"}
cardattrs = {0x1: "<font color='#121516'>地</font>", 0x2: "<font color='#0993D3'>水</font>", 0x4: "<font color='red'>炎</font>", 0x8: "<font color='#1B5D33'>风</font>", 0x10: "<font color='#7F5D32'>光</font>", 0x20: "<font color='#9A2B89'>暗</font>", 0x40: "<font color='DarkGoldenRod'>神</font>"}
linkmarkers = {0x40:"[↖]", 0x80:"[↑]", 0x100:"[↗]", 0x8:"[←]", 0x20:"[→]", 0x1: "[↙]", 0x2:"[↓]", 0x4:"[↘]"}
cardcolors_list = [0x2, 0x4, 0x10, 0x40, 0x80, 0x2000, 0x800000, 0x4000000, 0x4000]

search_type = {0x1: 1, 0x2: 2, 0x4:3}
search_subtype = {0x10: 1, 0x40: 3, 0x80:4, 0x2000: 5, 0x800000:6, 0x4000000:7, 0x4000:8,
Expand Down Expand Up @@ -403,6 +407,7 @@ def __init__(self):
# 读取卡片数据库
self.card_datas = {}
self.monster_datas = {}
self.card_colors = {}
card_sorted = {}
try:
if not os.path.exists("cards.cdb"):
Expand All @@ -425,6 +430,11 @@ def __init__(self):
for c_subtype in search_subtype.keys():
if carddata[4] & c_subtype != 0:
card_sorted_index[1] = search_subtype[c_subtype]
# 卡片颜色
self.card_colors[row[1]] = 0xffffffff
for color_set in cardcolors_list:
if carddata[4] & color_set != 0:
self.card_colors[row[1]] = color_set
# 生成描述
desp = ""
# 种类
Expand Down Expand Up @@ -529,6 +539,7 @@ def __init__(self):
# 添加/删除卡片部分
self.NewCard_line.textChanged.connect(self.search_card)
self.NewCard_line.returnPressed.connect(self.create_card)
self.NewCard_button.clicked.connect(self.create_card)
self.Newcard_List.doubleClicked.connect(self.fix_cardname)
self.Newcard_List.clicked.connect(self.show_carddesp)
self.Newcard_List.itemSelectionChanged.connect(self.show_carddesp)
Expand Down Expand Up @@ -636,6 +647,7 @@ def retranslateUi(self):
self.CgeLP_Button.setText("变成基本分")
self.HalLP_Button.setText("基本分减半")
self.NewCard_Rename_Button.setText("重命名选定卡")
self.NewCard_button.setText("添加")
self.Operator_search_button.setText("↓")

def maketitle(self):
Expand Down Expand Up @@ -927,6 +939,7 @@ def remove_from_targets(self):
target_idx = target_idx[0].row()
del self.targets[target_idx]
# 刷新
self.clear_unuse_cards()
self.label_target_list.setText("操作对象(%d)"%len(self.targets))
self.Target_detail.clear()
self.update_targetlist()
Expand Down Expand Up @@ -1455,14 +1468,21 @@ def check_legal(text, included, excluded):
elif check_legal(self.card_datas[cardname], included, excluded):
hit_in_effect.append(cardname)
# 添加到列表
main_font = QFont()
main_font.setBold(True)
relevant_font = QFont()
relevant_font.setItalic(True)
for name in hit:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(QColor('green'))
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(main_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
for name in hit_in_name:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])
for name in hit_in_effect:
self.Newcard_List.addItem(name)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(QColor('grey'))
self.Newcard_List.item(self.Newcard_List.count()-1).setFont(relevant_font)
self.Newcard_List.item(self.Newcard_List.count()-1).setForeground(cardcolors_dict[self.card_colors[name]])

def search_operation_cycle(self):
self.search_operation(True)
Expand Down Expand Up @@ -1544,6 +1564,17 @@ def update_hint(self, name):
if reply == QMessageBox.Yes:
webbrowser.open("https://github.com/Wind2009-Louse/DuelEditor/releases")

def clear_unuse_cards(self):
all_cards = set(self.operators["cards"].keys())
all_cards -= set(self.targets)
for ope in self.operators["operations"]:
if ope["type"][0:2] != "LP":
all_cards = all_cards - set(ope["args"])
for c in all_cards:
self.operators["cards"].pop(c,"fail")
while(self.operators["cardindex"] > 0 and str(self.operators["cardindex"]-1) not in self.operators["cards"]):
self.operators["cardindex"] -= 1

if __name__ == "__main__":
app = QApplication(sys.argv)
m_window = Ui_MainWindow()
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name": "v1.13.3", "version":133}
{"name": "v1.13.4", "version":134}

0 comments on commit 85790c9

Please sign in to comment.