feat: add age-based event gating, event timer, and UI polish

- Add minAge/maxAge to events so infants can't go treasure hunting
- Cache event panel DOM to prevent high-speed button destruction
- Add 10s auto-select countdown for choice events
- Fix event title/text field mapping (name/description → title/text)
- Add rotating clock icon for time flow feedback
- Fix speed/pause button active states
- Fix shop affordability check (disable + show insufficient money)
- Add red styling for unmet choice requirements
- Fix log re-rendering on every tick
This commit is contained in:
2026-05-13 09:09:42 +00:00
parent a05225b514
commit 3f741b4f0a
41 changed files with 9847 additions and 651 deletions
+287 -123
View File
@@ -1,73 +1,257 @@
{
"events": [
{
"id": "infant_cry",
"name": "啼哭",
"description": "你大声啼哭,引起了周围人的注意。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 20,
"minAge": 0,
"maxAge": 2,
"effects": [{ "type": "addStat", "stat": "body", "value": 0.5 }]
},
{
"id": "infant_sleep",
"name": "酣睡",
"description": "你睡了一个好觉,精神饱满。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 20,
"minAge": 0,
"maxAge": 2,
"effects": [{ "type": "addStat", "stat": "destiny", "value": 0.5 }]
},
{
"id": "toddler_walk",
"name": "学步",
"description": "你摇摇晃晃地迈出了人生的第一步。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 15,
"minAge": 1,
"maxAge": 4,
"effects": [{ "type": "addStat", "stat": "body", "value": 1 }]
},
{
"id": "toddler_words",
"name": "学语",
"description": "你咿咿呀呀地学着大人说话。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 15,
"minAge": 1,
"maxAge": 4,
"effects": [{ "type": "addStat", "stat": "wisdom", "value": 1 }]
},
{
"id": "child_play",
"name": "嬉戏",
"description": "你和邻家孩子在院子里玩耍,不亦乐乎。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 15,
"minAge": 3,
"maxAge": 8,
"effects": [{ "type": "addStat", "stat": "charm", "value": 1 }]
},
{
"id": "child_study",
"name": "启蒙",
"description": "先生在私塾教你认字读书,你颇有感悟。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 15,
"minAge": 5,
"maxAge": 12,
"effects": [{ "type": "addStat", "stat": "wisdom", "value": 1 }]
},
{
"id": "daily_training",
"name": "日常修炼",
"description": "你坚持日常修炼,体质有所提升。",
"trigger": {
"type": "random",
"pool": "normal"
},
"weight": 50,
"effects": [
{
"type": "addStat",
"stat": "体质",
"value": 1
}
]
"trigger": { "type": "random", "pool": "normal" },
"weight": 20,
"minAge": 6,
"effects": [{ "type": "addStat", "stat": "body", "value": 1 }]
},
{
"id": "study_hard",
"name": "刻苦学习",
"description": "你发奋读书,悟性有所提升。",
"trigger": {
"type": "random",
"pool": "normal"
},
"weight": 50,
"trigger": { "type": "random", "pool": "normal" },
"weight": 20,
"minAge": 6,
"effects": [{ "type": "addStat", "stat": "wisdom", "value": 1 }]
},
{
"id": "socialize",
"name": "广结善缘",
"description": "你与人为善,魅力有所提升。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 15,
"minAge": 8,
"effects": [{ "type": "addStat", "stat": "charm", "value": 1 }]
},
{
"id": "business_insight",
"name": "经商感悟",
"description": "你悟出了一些经商之道。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 10,
"minAge": 12,
"effects": [{ "type": "addStat", "stat": "business", "value": 1 }]
},
{
"id": "strategic_thinking",
"name": "谋略精进",
"description": "你思考国家大事,智谋有所提升。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 10,
"minAge": 14,
"effects": [{ "type": "addStat", "stat": "intelligence", "value": 1 }]
},
{
"id": "lucky_encounter",
"name": "奇遇",
"description": "你遇到了一位神秘老者,传授了你一些心法。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 5,
"minAge": 6,
"effects": [
{ "type": "addStat", "stat": "destiny", "value": 2 },
{ "type": "addStat", "stat": "wisdom", "value": 1 }
]
},
{
"id": "mountain_play",
"name": "山中玩耍",
"description": "你和伙伴去后山玩耍,发现一条隐蔽的小路。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 8,
"minAge": 6,
"isChoice": true,
"choices": [
{
"type": "addStat",
"stat": "悟性",
"value": 1
"id": "explore",
"text": "大胆进去看看",
"requirements": { "type": "stat", "op": ">=", "stat": "wisdom", "value": 5 },
"effects": [
{ "type": "addLog", "text": "你发现了一处灵气充沛的山洞!悟性+3" },
{ "type": "addStat", "stat": "wisdom", "value": 3 }
]
},
{
"id": "stay",
"text": "就在附近玩",
"effects": [{ "type": "addLog", "text": "你安全地度过了这一天。" }]
}
]
},
{
"id": "street_beggar",
"name": "街头见闻",
"description": "你在街上看到一个衣衫褴褛的老乞丐在演示奇怪的招式。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 6,
"minAge": 8,
"isChoice": true,
"choices": [
{
"id": "watch",
"text": "认真观看",
"requirements": { "type": "stat", "op": ">=", "stat": "body", "value": 5 },
"effects": [
{ "type": "addLog", "text": "老乞丐看你骨骼惊奇,传你一招半式。体质+3" },
{ "type": "addStat", "stat": "body", "value": 3 }
]
},
{
"id": "ignore",
"text": "走开不理",
"effects": [{ "type": "addLog", "text": "你转身离开。" }]
}
]
},
{
"id": "taoist_encounter",
"name": "道观遇仙",
"description": "你在山上偶遇一位道士,他似乎对你很感兴趣。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 4,
"minAge": 10,
"isChoice": true,
"choices": [
{
"id": "ask_teach",
"text": "请求拜师",
"requirements": { "type": "stat", "op": ">=", "stat": "destiny", "value": 10 },
"effects": [
{ "type": "addLog", "text": "道士收你为记名弟子,赠你道碟。" },
{ "type": "setFlag", "flag": "met_taoist_priest", "value": true },
{ "type": "addItem", "itemId": "taoist_license" }
]
},
{
"id": "polite",
"text": "礼貌告辞",
"effects": [{ "type": "addLog", "text": "你礼貌地告辞了。" }]
}
]
},
{
"id": "treasure_hunt",
"name": "寻宝探险",
"description": "你听说附近有一处古迹,可能有宝物。",
"trigger": { "type": "random", "pool": "normal" },
"weight": 4,
"minAge": 15,
"isChoice": true,
"choices": [
{
"id": "go",
"text": "前往探险",
"requirements": { "type": "stat", "op": ">=", "stat": "body", "value": 15 },
"effects": [
{ "type": "addLog", "text": "你成功找到了一处宝藏,获得银两+500!" },
{ "type": "addMoney", "value": 500 }
]
},
{
"id": "skip",
"text": "太危险了,不去",
"effects": [{ "type": "addLog", "text": "你放弃了这次探险。" }]
}
]
},
{
"id": "invasion_military_40",
"name": "蛮族入侵",
"description": "北方蛮族大举入侵,边境告急!",
"trigger": {
"type": "age",
"value": 40
},
"description": "北方蛮族大举入侵,边境告急!这是对你军事实力的第一次重大考验。",
"trigger": { "type": "age", "value": 40 },
"isChoice": true,
"choices": [
{
"id": "resist",
"text": "率军抵抗",
"requirements": {
"type": "careerLevel",
"careerId": "soldier",
"op": ">=",
"value": 50
},
"text": "率军抵抗(需要将军Lv.1000+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "general", "value": 1000 },
"effects": [
{
"type": "addLog",
"text": "你率领大军击退了蛮族入侵,威震四方!"
}
{ "type": "addLog", "text": "你率领大军击退了蛮族入侵,威震四方!军事危机解除。" },
{ "type": "setFlag", "flag": "resisted_military_invasion", "value": true },
{ "type": "addStat", "stat": "body", "value": 10 }
]
},
{
"id": "resist_weak",
"text": "勉强抵抗(需要千夫长Lv.500+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "commander", "value": 500 },
"effects": [
{ "type": "addLog", "text": "你勉强守住了城池,但损失惨重。" },
{ "type": "addStat", "stat": "body", "value": 3 },
{ "type": "addStat", "stat": "destiny", "value": -5 }
]
},
{
"id": "flee",
"text": "弃城逃跑",
"effects": [
{
"type": "addLog",
"text": "你选择了弃城逃跑,虽然保住了性命,但名声扫地。"
}
{ "type": "addLog", "text": "你选择了弃城逃跑,虽然保住了性命,但名声扫地。天命-10" },
{ "type": "addStat", "stat": "destiny", "value": -10 }
]
}
]
@@ -75,37 +259,36 @@
{
"id": "invasion_spiritual_45",
"name": "天魔降世",
"description": "天魔降世,人间陷入混乱,你该如何应对?",
"trigger": {
"type": "age",
"value": 45
},
"description": "天魔降世,人间陷入混乱,你该如何应对?这是对你修仙境界的重大考验。",
"trigger": { "type": "age", "value": 45 },
"isChoice": true,
"choices": [
{
"id": "suppress",
"text": "出手镇压",
"requirements": {
"type": "careerLevel",
"careerId": "taoist",
"op": ">=",
"value": 50
},
"text": "出手镇压(需要天仙Lv.1000+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "tian_xian", "value": 1000 },
"effects": [
{
"type": "addLog",
"text": "你以无上道法镇压天魔,拯救了苍生!"
}
{ "type": "addLog", "text": "你以无上道法镇压天魔,拯救了苍生!精神危机解除。" },
{ "type": "setFlag", "flag": "resisted_spiritual_invasion", "value": true },
{ "type": "addStat", "stat": "wisdom", "value": 10 }
]
},
{
"id": "suppress_weak",
"text": "勉强封印(需要地仙Lv.500+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "di_xian", "value": 500 },
"effects": [
{ "type": "addLog", "text": "你勉强封印了天魔,但自身也受到反噬。" },
{ "type": "addStat", "stat": "wisdom", "value": 3 },
{ "type": "addStat", "stat": "destiny", "value": -5 }
]
},
{
"id": "hide",
"text": "躲藏起来",
"effects": [
{
"type": "addLog",
"text": "你选择了躲藏起来,避开了这场浩劫。"
}
{ "type": "addLog", "text": "你选择了躲藏起来,避开了这场浩劫。天命-10" },
{ "type": "addStat", "stat": "destiny", "value": -10 }
]
}
]
@@ -113,37 +296,36 @@
{
"id": "invasion_political_50",
"name": "王朝崩坏",
"description": "王朝内部腐败,民不聊生,天下大乱。",
"trigger": {
"type": "age",
"value": 50
},
"description": "王朝内部腐败,民不聊生,天下大乱。这是对你政治智慧的重大考验。",
"trigger": { "type": "age", "value": 50 },
"isChoice": true,
"choices": [
{
"id": "assist",
"text": "辅佐明君",
"requirements": {
"type": "stat",
"stat": "智力",
"op": ">=",
"value": 50
},
"text": "辅佐明君(需要宰相Lv.1000+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "chancellor", "value": 1000 },
"effects": [
{
"type": "addLog",
"text": "你以智谋辅佐明君,力挽狂澜,拯救了王朝。"
}
{ "type": "addLog", "text": "你以宰相之智辅佐明君,力挽狂澜,拯救了王朝!政治危机解除。" },
{ "type": "setFlag", "flag": "resisted_political_invasion", "value": true },
{ "type": "addStat", "stat": "intelligence", "value": 10 }
]
},
{
"id": "assist_weak",
"text": "尽力周旋(需要尚书Lv.500+",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "shangshu", "value": 500 },
"effects": [
{ "type": "addLog", "text": "你尽力周旋,保住了自己的一席之地。" },
{ "type": "addStat", "stat": "intelligence", "value": 3 },
{ "type": "addStat", "stat": "destiny", "value": -5 }
]
},
{
"id": "selfish",
"text": "独善其身",
"effects": [
{
"type": "addLog",
"text": "你选择了独善其身,在乱世中保全了自己。"
}
{ "type": "addLog", "text": "你选择了独善其身,在乱世中保全了自己。天命-10" },
{ "type": "addStat", "stat": "destiny", "value": -10 }
]
}
]
@@ -151,69 +333,51 @@
{
"id": "final_crisis_60",
"name": "最终危机",
"description": "世界面临最终危机,这是你最后的选择。",
"trigger": {
"type": "age",
"value": 60
},
"description": "世界面临最终危机,这是你最后的选择。若实力足够,便可破局!",
"trigger": { "type": "age", "value": 60 },
"isChoice": true,
"choices": [
{
"id": "general",
"text": "以将军之力平定天下",
"requirements": {
"type": "careerLevel",
"careerId": "soldier",
"op": ">=",
"value": 50
},
"id": "general_breakthrough",
"text": "以元帅之力平定天下【将军破局】",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "marshal", "value": 5000 },
"effects": [
{
"type": "addLog",
"text": "你以将军之力平定天下,成为一代名将!"
}
{ "type": "addLog", "text": "你以元帅之力平定天下,成为一代名将!将军破局成功!" },
{ "type": "setFlag", "flag": "breakthrough_general", "value": true },
{ "type": "addStat", "stat": "body", "value": 50 }
]
},
{
"id": "chancellor",
"text": "以宰相之智治理国家",
"requirements": {
"type": "stat",
"stat": "智力",
"op": ">=",
"value": 50
},
"id": "chancellor_breakthrough",
"text": "以宰相之智治理国家【宰相破局】",
"requirements": { "type": "careerLevel", "op": ">=", "careerId": "chancellor", "value": 5000 },
"effects": [
{
"type": "addLog",
"text": "你以宰相之智治理国家,名垂青史!"
}
{ "type": "addLog", "text": "你以宰相之智治理国家,名垂青史!宰相破局成功!" },
{ "type": "setFlag", "flag": "breakthrough_chancellor", "value": true },
{ "type": "addStat", "stat": "intelligence", "value": 50 }
]
},
{
"id": "cultivator",
"text": "以仙之道超脱轮回",
"id": "immortal_breakthrough",
"text": "以仙之道超脱轮回【修仙破局】",
"requirements": {
"type": "careerLevel",
"careerId": "taoist",
"op": ">=",
"value": 50
"type": "and",
"conditions": [
{ "type": "careerLevel", "op": ">=", "careerId": "tian_xian", "value": 5000 },
{ "type": "hasArtifact", "artifactId": "immortal_sword", "level": 10 }
]
},
"effects": [
{
"type": "addLog",
"text": "你以修仙之道超脱轮回,飞升成仙!"
}
{ "type": "addLog", "text": "你以修仙之道超脱轮回,飞升成仙!修仙破局成功!" },
{ "type": "setFlag", "flag": "breakthrough_immortal", "value": true },
{ "type": "addStat", "stat": "wisdom", "value": 50 }
]
},
{
"id": "powerless",
"text": "无力回天",
"effects": [
{
"type": "addLog",
"text": "你感到无力回天,只能接受命运的安排。"
}
{ "type": "addLog", "text": "你感到无力回天,只能接受命运的安排。" }
]
}
]