汤锅功能实现 3 计时 提示修改

This commit is contained in:
wenhe committed 2026-09-16 11:12:15 +08:00
1 parent df71a62d7c
commit 31bb44a409
10 files changed
+153 -56

No files matched your search

@@ -58,15 +58,48 @@ class YouguoService(BlueFoxServerSystem):
self.featureBlocks.add(r["block"])
# ---- 空手右键"炸物计时源方块"(炸物生/半熟): 放在点燃炉灶上 -> 开始计时 ----
# 提示包含"总共多少秒": 从当前级沿计时链累加(生60秒+熟30秒 / 单级60秒)
self._timerBySrc = {r["source"]: r for r in TIMER_RULES}
self._timerTotal = {} # source -> (总秒数, 每级秒数列表)
for src, r in self._timerBySrc.items():
total, stages, cur, seen = 0, [], src, set()
while cur in self._timerBySrc and cur not in seen:
seen.add(cur)
curR = self._timerBySrc[cur]
sec = curR.get("time", 60)
total += sec
stages.append(sec)
nxt = curR.get("target")
if nxt not in self._timerBySrc:
break
cur = nxt
self._timerTotal[src] = (total, stages)
# 终点方块 -> 成品名(从出锅规则 tip 的"取出 XX"提取, 用于计时提示)
self._finalNames = {}
for r in SWITCH_RULES:
if r.get("action") == "take_out":
tip = (r.get("tip") or "").replace("§a", "").replace("§e", "").replace("§c", "")
if "取出" in tip:
nm = tip.split("取出", 1)[1].split(",", 1)[0].strip()
if nm:
self._finalNames[r["block"]] = nm
self.timerSources = set()
self.startTimerTips = {}
for r in TIMER_RULES:
src = r["source"]
for src, r in self._timerBySrc.items():
self.timerSources.add(src)
self.featureBlocks.add(src)
if src not in self.startTimerTips:
sec = r.get("time", 60)
self.startTimerTips[src] = "§a开始炸制…等计时(%d秒)结束变成 下一形态" % sec
total, stages = self._timerTotal[src]
if len(stages) == 1:
stage = ""
else:
stage = "(%d级: %s)" % (len(stages), "→".join("%d秒" % s for s in stages))
tip = "§a开始炸制…共需计时%d秒%s" % (total, stage)
end = self._oilTerminalName(src)
if end:
tip += "; 计时结束变成 %s" % end
self.startTimerTips[src] = tip
# ---- 右键冷却表 ----
self.cooldown = {}
@@ -130,6 +163,14 @@ class YouguoService(BlueFoxServerSystem):
comp.CreateMsg(playerId).NotifyOneMessage(
playerId, "§c油锅需要放在点燃的炉灶上才能开始计时")
def _oilTerminalName(self, src):
"""沿计时链走到终点方块, 返回成品名(未取到则返回空串)"""
cur, seen = src, set()
while cur in self._timerBySrc and cur not in seen:
seen.add(cur)
cur = self._timerBySrc[cur]["target"]
return self._finalNames.get(cur, "")
# ============================================================================
# 二、通用转换执行
# ============================================================================