Add ranch retention, breakthroughs and exploration
This commit is contained in:
@@ -12,7 +12,7 @@ class EggTable(W.QTableWidget):
|
||||
|
||||
def __init__(self, catalog):
|
||||
headers = ["魔物蛋", "星", "数量", "孵化", "优先级", "孵出后", "低于补货", "补至", "补货市场",
|
||||
"培育时间", "派遣金币", "基础经验", "金币/小时", "经验/小时", "物品ID"]
|
||||
"牧场保留", "培育时间", "派遣金币", "基础经验", "金币/小时", "经验/小时", "物品ID"]
|
||||
super().__init__(0, len(headers))
|
||||
self.catalog, self.rules, self.snapshot = catalog, {}, None
|
||||
self.default_market = "sc_city1"
|
||||
@@ -21,7 +21,7 @@ class EggTable(W.QTableWidget):
|
||||
self.setEditTriggers(W.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.setSelectionBehavior(W.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.horizontalHeader().setSectionResizeMode(W.QHeaderView.ResizeMode.Interactive)
|
||||
for column, width in enumerate((130, 45, 65, 65, 90, 135, 95, 95, 220, 95, 90, 90, 100, 100, 160)):
|
||||
for column, width in enumerate((130, 45, 65, 65, 90, 135, 95, 95, 220, 90, 95, 90, 90, 100, 100, 160)):
|
||||
self.setColumnWidth(column, width)
|
||||
self.verticalHeader().setDefaultSectionSize(24)
|
||||
|
||||
@@ -58,7 +58,7 @@ class EggTable(W.QTableWidget):
|
||||
group = groups.get(key, {"count": 0, "ids": []})
|
||||
total = max(1, self.catalog.total_time(key))
|
||||
money, exp = data.get("sell_money", 0), data.get("sell_exp", 0)
|
||||
values = [data.get("name", key), data.get("star", "?"), group["count"], "", "", "", "", "", "",
|
||||
values = [data.get("name", key), data.get("star", "?"), group["count"], "", "", "", "", "", "", "",
|
||||
duration(total), money, exp, round(money * 3600 / total, 2), round(exp * 3600 / total, 2), ", ".join(group["ids"])]
|
||||
for j, value in enumerate(values):
|
||||
item = self.item(i, j)
|
||||
@@ -74,20 +74,21 @@ class EggTable(W.QTableWidget):
|
||||
item.setToolTip(f"魔物编号 {key}")
|
||||
existing = self.cellWidget(i, 3)
|
||||
if existing and existing.property("egg_type_id") == key:
|
||||
controls = [self.cellWidget(i, col) for col in range(3, 9)]
|
||||
controls = [self.cellWidget(i, col) for col in range(3, 10)]
|
||||
blockers = [C.QSignalBlocker(control) for control in controls]
|
||||
controls[0].setChecked(rule["enabled"])
|
||||
for control, field in ((controls[1], "priority"), (controls[3], "refill_below"), (controls[4], "refill_target")):
|
||||
for control, field in ((controls[1], "priority"), (controls[3], "refill_below"), (controls[4], "refill_target"),
|
||||
(controls[6], "keep_count")):
|
||||
if not control.hasFocus():
|
||||
control.setValue(rule[field])
|
||||
controls[2].setCurrentIndex(max(0, controls[2].findData(rule["action"])))
|
||||
controls[5].setCurrentIndex(max(0, controls[5].findData(rule["market_id"])))
|
||||
bind_controls(self, i, dict(zip(range(3, 9), controls)))
|
||||
bind_controls(self, i, dict(zip(range(3, 10), controls)))
|
||||
return
|
||||
enabled = CenteredCheckBox()
|
||||
enabled.setProperty("egg_type_id", key)
|
||||
enabled.setChecked(rule["enabled"])
|
||||
priority, below, target = IntegerInput(), IntegerInput(), IntegerInput()
|
||||
priority, below, target, keep_count = IntegerInput(), IntegerInput(), IntegerInput(), IntegerInput()
|
||||
for control, low, high, value in ((priority, 1, 999, rule["priority"]), (below, 0, 1000, rule["refill_below"]),
|
||||
(target, max(1, rule["refill_below"]), 1000, rule["refill_target"])):
|
||||
control.setRange(low, high)
|
||||
@@ -95,6 +96,9 @@ class EggTable(W.QTableWidget):
|
||||
priority.setToolTip("数字越小,孵化优先级越高")
|
||||
below.setToolTip("可用蛋少于此数量时补货;0表示不自动补货")
|
||||
target.setToolTip("补货希望达到的可用蛋数量;市场随机出蛋,实际结果由服务器决定")
|
||||
keep_count.setRange(0, 1000)
|
||||
keep_count.setValue(rule["keep_count"])
|
||||
keep_count.setToolTip("保留或更高资质保护下,每种魔物通常保留几只;默认1只,资质提升的新魔物可额外保留")
|
||||
action, market = ComboBox(), ComboBox()
|
||||
for name, value in (("派遣", "sell"), ("喂养", "feed"), ("保留", "keep")):
|
||||
action.addItem(name, value)
|
||||
@@ -108,8 +112,8 @@ class EggTable(W.QTableWidget):
|
||||
self.setColumnWidth(5, max(self.columnWidth(5), action.minimumSizeHint().width()))
|
||||
self.setColumnWidth(8, max(self.columnWidth(8), market.minimumSizeHint().width()))
|
||||
controls = {"enabled": enabled, "priority": priority, "action": action, "refill_below": below,
|
||||
"refill_target": target, "market_id": market}
|
||||
for column, control in zip(range(3, 9), controls.values()):
|
||||
"refill_target": target, "market_id": market, "keep_count": keep_count}
|
||||
for column, control in zip(range(3, 10), controls.values()):
|
||||
self.setCellWidget(i, column, control)
|
||||
def commit(*args, key=key, controls=controls):
|
||||
if self.updating:
|
||||
@@ -117,15 +121,16 @@ class EggTable(W.QTableWidget):
|
||||
controls["refill_target"].setMinimum(max(1, controls["refill_below"].value()))
|
||||
value = {"enabled": controls["enabled"].isChecked(), "priority": controls["priority"].value(),
|
||||
"action": controls["action"].currentData(), "refill_below": controls["refill_below"].value(),
|
||||
"refill_target": controls["refill_target"].value(), "market_id": controls["market_id"].currentData()}
|
||||
"refill_target": controls["refill_target"].value(), "market_id": controls["market_id"].currentData(),
|
||||
"keep_count": controls["keep_count"].value()}
|
||||
self.rules[key] = asdict(EggRule(**value))
|
||||
self.rules_changed.emit(copy.deepcopy(self.rules), key)
|
||||
enabled.toggled.connect(commit)
|
||||
for control in (priority, below, target):
|
||||
for control in (priority, below, target, keep_count):
|
||||
control.valueChanged.connect(commit)
|
||||
action.currentIndexChanged.connect(commit)
|
||||
market.currentIndexChanged.connect(commit)
|
||||
bind_controls(self, i, dict(zip(range(3, 9), controls.values())))
|
||||
bind_controls(self, i, dict(zip(range(3, 10), controls.values())))
|
||||
def finish():
|
||||
self.setSortingEnabled(True)
|
||||
self.updating = False
|
||||
|
||||
Reference in New Issue
Block a user