Ethscriptions commited on
Commit
da52002
·
verified ·
1 Parent(s): 9d5cc0c

女巫的魔药 2.8:PDF 关注提示、托盘倾斜与层级、杯子位置、全面修 BUG

Browse files
README.md CHANGED
@@ -7,6 +7,32 @@ sdk: static
7
  pinned: false
8
  ---
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # 本轮:「女巫的魔药」第 2.7 版——女主角(素材 8)+ 选择角色
11
 
12
  计划与步骤:
 
7
  pinned: false
8
  ---
9
 
10
+ # 本轮:「女巫的魔药」第 2.8 版——PDF 关注提示、托盘、杯子位置 + 全面查 BUG
11
+
12
+ 计划与步骤:
13
+ 1. 领取 PDF:调用 `followAuthor` 关注作者成功后(或本来就已关注),弹出作者卡片(@子木土土 · 小红书号 95424555310)并提示「PDF 文件在作者的置顶笔记里」,附三步领取说明
14
+ 2. 托盘:用透视把托盘压成更倾斜的平面;图层放到两个角色之下(杯子仍在最前面,方便点);对话框打字变高时托盘跟着上移,不再被遮
15
+ 3. 杯子在手上的位置:上一版略低,往上调一点
16
+ 4. 全面检查 BUG(逐条复现后修复),再打包、三种屏幕测试、推送
17
+
18
+ - [x] PDF:关注成功 / 已关注 → 弹出作者卡片与置顶笔记领取步骤;关注失败(follow_status = −1)单独提示;领取卡片与面板文案统一为「置顶笔记」
19
+ - [x] 托盘更倾斜、在两个角色之下;托盘始终贴着对话框上沿
20
+ - [x] 杯子位置上调
21
+ - [x] BUG 修复:
22
+ - 在「原文」里点「去喝魔药」后游戏打不开、背景音乐不停 → 退出统一收尾(停计时、动画、音乐、存档)
23
+ - 喝药动画中途退出可以逃掉扣分、旧动画写进新开的游戏 → 先结算存档再播动画,退出后旧动画不再执行
24
+ - 答题时打开设置 / 成就 / 属性面板,15 秒倒计时还在走 → 弹窗打开时暂停,关闭后继续
25
+ - 连点两下书会跳过一句剧情 → 只认第一次
26
+ - 老版本小红书内核(Chrome 61)不认识 `env()`,对话框、工具栏位置失效 → 全部加上兼容写法
27
+ - 寿终弹窗关掉后无法复活 → 对话框里保留「晒账单复活」按钮
28
+ - 跨过零点继续玩,昨天的喝错次数还在 → 大厅、继续挑战、晒账单前都会检查换天
29
+ - 年龄到 18 岁封顶时喝对显示「老了 0.0 岁」→ 改为显示分数变化
30
+ - 喝药过程中点工具栏会打乱流程 → 动画期间只响应「退出」
31
+ - 复活 / 遗忘之药水后误报「综合等级下降」→ 重置基准
32
+ - 存档还没读完就开局会让老用户重选角色 → 等存档读完再开局;切后台立即存档,退出后挂起音频
33
+ - 360×640 等矮屏:角色脚被对话框挡住 → 整幅画面(背景 + 角色)一起上移,对话框最高 40% 屏高
34
+ - [x] 体积:女巫的魔药版 48 个文件、9.06 MB;红薯冒险版 63 个文件、3.85 MB
35
+
36
  # 本轮:「女巫的魔药」第 2.7 版——女主角(素材 8)+ 选择角色
37
 
38
  计划与步骤:
htlb/miniapp/dist-potato/app.js CHANGED
The diff for this file is too large to render. See raw diff
 
htlb/miniapp/dist-potato/style.css CHANGED
@@ -251,7 +251,7 @@
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
- .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
@@ -371,7 +371,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
- .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
@@ -460,7 +460,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
- .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
@@ -471,7 +471,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
- .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
@@ -520,7 +520,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
- .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
@@ -562,7 +562,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
- .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
@@ -683,7 +683,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
- .w2-dialog{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
@@ -717,7 +717,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
- .w2-dlg{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
@@ -739,7 +739,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
- .w2-dlg{bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
@@ -760,3 +760,24 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
+ .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
 
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
+ .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
 
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
+ .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
 
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
+ .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:14px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
 
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
+ .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
 
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
+ .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:6px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
 
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
+ .w2-dialog{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
 
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
+ .w2-dlg{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
 
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
+ .w2-dlg{bottom:92px!important;bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
 
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
763
+ /* 托盘:更倾斜,像桌面上的一个平面;层级在两个角色之下 */
764
+ .w2-scene .w2-tray{z-index:auto}
765
+ .w2-scene .w2-tray-img{z-index:2}
766
+ .w2-scene .w2-cup{z-index:4}
767
+ .w2-scene .wt-actor{z-index:3;pointer-events:none}
768
+ .w2-scene .wt-fx{z-index:5}
769
+ .w2-tray-img{-webkit-transform-origin:50% 100%;transform-origin:50% 100%;-webkit-transform:perspective(520px) rotateX(52deg);transform:perspective(520px) rotateX(52deg)}
770
+ /* PDF:关注后提示 */
771
+ .pdf-tip{padding:6px 18px 18px}
772
+ .pt-author{display:flex;align-items:center;background:var(--white);border-radius:14px;padding:12px 14px;box-shadow:var(--sticker)}
773
+ .pt-av{width:46px;height:46px;border-radius:23px;flex-shrink:0;background:var(--red-d);color:#fff;font-size:20px;font-weight:900;line-height:46px;text-align:center;margin-right:12px;box-shadow:0 0 0 2.5px #fff,0 3px 8px rgba(23,23,27,.2)}
774
+ .pt-author div{flex:1;min-width:0}
775
+ .pt-author b{display:block;font-size:16px;font-weight:900;line-height:1.4}
776
+ .pt-author small{display:block;font-size:12px;color:var(--muted);font-weight:700}
777
+ .pt-ok{flex-shrink:0;height:30px;line-height:30px;padding:0 12px;border-radius:15px;background:rgba(23,23,27,.07);color:var(--muted);font-size:13px;font-weight:800}
778
+ .pdf-tip h2{font-size:18px;font-weight:900;margin:18px 2px 8px}
779
+ .pt-steps{margin:0;padding:0 0 0 1.3em}
780
+ .pt-steps li{font-size:14.5px;line-height:1.75;margin-bottom:6px}
781
+ .pt-steps b{color:var(--red-d)}
782
+ /* 矮屏:对话框不要太高,角色和托盘不被挡住 */
783
+ @media (max-height:700px){.w2-dlg .w2-dialog{max-height:40vh}.w2-opt{min-height:52px}}
htlb/miniapp/dist-witch/app.js CHANGED
The diff for this file is too large to render. See raw diff
 
htlb/miniapp/dist-witch/style.css CHANGED
@@ -251,7 +251,7 @@
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
- .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
@@ -371,7 +371,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
- .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
@@ -460,7 +460,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
- .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
@@ -471,7 +471,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
- .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
@@ -520,7 +520,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
- .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
@@ -562,7 +562,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
- .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
@@ -683,7 +683,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
- .w2-dialog{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
@@ -717,7 +717,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
- .w2-dlg{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
@@ -739,7 +739,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
- .w2-dlg{bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
@@ -760,3 +760,24 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
+ .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
 
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
+ .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
 
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
+ .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
 
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
+ .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:14px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
 
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
+ .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
 
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
+ .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:6px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
 
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
+ .w2-dialog{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
 
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
+ .w2-dlg{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
 
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
+ .w2-dlg{bottom:92px!important;bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
 
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
763
+ /* 托盘:更倾斜,像桌面上的一个平面;层级在两个角色之下 */
764
+ .w2-scene .w2-tray{z-index:auto}
765
+ .w2-scene .w2-tray-img{z-index:2}
766
+ .w2-scene .w2-cup{z-index:4}
767
+ .w2-scene .wt-actor{z-index:3;pointer-events:none}
768
+ .w2-scene .wt-fx{z-index:5}
769
+ .w2-tray-img{-webkit-transform-origin:50% 100%;transform-origin:50% 100%;-webkit-transform:perspective(520px) rotateX(52deg);transform:perspective(520px) rotateX(52deg)}
770
+ /* PDF:关注后提示 */
771
+ .pdf-tip{padding:6px 18px 18px}
772
+ .pt-author{display:flex;align-items:center;background:var(--white);border-radius:14px;padding:12px 14px;box-shadow:var(--sticker)}
773
+ .pt-av{width:46px;height:46px;border-radius:23px;flex-shrink:0;background:var(--red-d);color:#fff;font-size:20px;font-weight:900;line-height:46px;text-align:center;margin-right:12px;box-shadow:0 0 0 2.5px #fff,0 3px 8px rgba(23,23,27,.2)}
774
+ .pt-author div{flex:1;min-width:0}
775
+ .pt-author b{display:block;font-size:16px;font-weight:900;line-height:1.4}
776
+ .pt-author small{display:block;font-size:12px;color:var(--muted);font-weight:700}
777
+ .pt-ok{flex-shrink:0;height:30px;line-height:30px;padding:0 12px;border-radius:15px;background:rgba(23,23,27,.07);color:var(--muted);font-size:13px;font-weight:800}
778
+ .pdf-tip h2{font-size:18px;font-weight:900;margin:18px 2px 8px}
779
+ .pt-steps{margin:0;padding:0 0 0 1.3em}
780
+ .pt-steps li{font-size:14.5px;line-height:1.75;margin-bottom:6px}
781
+ .pt-steps b{color:var(--red-d)}
782
+ /* 矮屏:对话框不要太高,角色和托盘不被挡住 */
783
+ @media (max-height:700px){.w2-dlg .w2-dialog{max-height:40vh}.w2-opt{min-height:52px}}
htlb/miniapp/dist-witch/witch.js CHANGED
@@ -92,7 +92,7 @@
92
  return { v: 2, y: 0, phy: 0, look: 0, money: 0, day: '', wrong: 0, unlock: 0, intro: false, combo: 0, seen: {}, ach: {},
93
  today: { right: 0, wrong: 0 }, total: { right: 0, wrong: 0, deaths: 0, revives: 0 }, peak: { m: 0, age: AGE0 }, dead: false, pendingRevive: '', snd: { sfx: true, bgm: true }, gender: '' };
94
  }
95
- var S = blank(), loaded = false, saveT = 0;
96
  function save(now) { clearTimeout(saveT); var go = function () { return B.save('witch2', S); }; if (now) return go(); saveT = setTimeout(go, 200); return Promise.resolve(true); }
97
  function rollDay() { var k = B.today().key; if (S.day !== k) { S.day = k; S.wrong = 0; S.unlock = 0; S.today = { right: 0, wrong: 0 }; save(); } }
98
  B.load('witch2').then(function (d) {
@@ -102,7 +102,8 @@
102
  S.pendingRevive = '';
103
  if (!S.gender && S.intro) S.gender = 'm'; // 老用户:默认男主角
104
  loaded = true; rollDay(); save();
105
- if (B.tab() === 'quiz' && !L) landing();
 
106
  });
107
  function cap() { return WRONG_CAP * (1 + S.unlock); }
108
  function age() { return ageOf(S.y); }
@@ -212,6 +213,7 @@
212
  if (!SND.ctx) return;
213
  try { if (document.hidden) SND.ctx.suspend(); else if (L) SND.ctx.resume(); } catch (e) {}
214
  });
 
215
 
216
  /* ---------------- 精灵 ---------------- */
217
  var pre = {};
@@ -287,7 +289,8 @@
287
  function open(queue) {
288
  whenReady(function () {
289
  if (L) return;
290
- rollDay(); gameMode(true); B.buzz('light'); actx(); musicOn();
 
291
  ['ui-divider', 'ui-tray', 'ui-close', 'cup-1', 'icons', 'frames', 'witch-idle2', 'witch-idle3', actKey() + '-idle2', actKey() + '-idle3', 'fx-good', 'fx-bad', 'fx-change', 'witch-idle', 'witch-appear', 'witch-nod', 'witch-laugh', 'witch-wand', 'witch-stop',
292
  'house-' + moneyStage(), 'car-' + moneyStage(), heroKey() + '-idle', actKey() + '-drink', actKey() + '-good', actKey() + '-bad', faceKey(), who() + '-ride'].forEach(img);
293
  L = B.sheet('w2', { label: '女巫的魔药', render: function (lay) {
@@ -320,20 +323,34 @@
320
  var el = L.el, W = el.offsetWidth || 390, H = el.offsetHeight || 844;
321
  var sc = Math.max(W / 720, H / 1280), ih = 1280 * sc, oy = (H - ih) / 2;
322
  G.W = W; G.H = H; G.ground = oy + ih * 0.62;
 
 
 
 
 
 
323
  var scene = $('#w2-scene', el); scene.style.height = G.ground + 'px';
324
  }
325
  function heroT() { return Math.min(G.H * 0.22, G.W * 0.48); }
326
  function alive() { return L && L.el.parentNode; }
327
  function exitHome() { close(); if (B.tab() !== 'today' && B.go) B.go('today'); window.scrollTo(0, 0); }
 
 
 
 
 
 
 
 
 
 
 
328
  function close() {
329
  if (!L) return;
330
- stopTimer(); if (G) { G.hero.stop(); G.witch.stop(); }
331
- var lay = L; L = null; G = null;
332
- musicOff();
333
- save(); B.close(lay); gameMode(false);
334
  if (B.tab() === 'quiz') (window.__HTLB_CH__ && !STANDALONE ? window.__HTLB_CH__.show() : landing());
335
  }
336
- setInterval(function () { if (L && !L.el.parentNode) { stopTimer(); L = null; G = null; gameMode(false); } }, 800);
337
  function setBg(ms, instant) {
338
  var a = $('#w2-bg', L.el), b = $('#w2-bg2', L.el), url = 'url(' + DIR + 'house-' + ms + '.webp)';
339
  if (instant) { a.style.backgroundImage = url; return; }
@@ -533,16 +550,20 @@
533
  if (k === 3) { B.buzz('medium'); we.classList.remove('pre-in'); we.classList.add('rise-in'); }
534
  if (k === 4) bk.className = 'w2-book';
535
  } });
 
536
  await done; box.innerHTML = '';
 
537
  we.classList.remove('rise-in');
538
  witchIdle();
539
  }
540
  async function bookTapped() {
541
- if (!G || G.mode !== 'story' || !STORY[G.storyK].book) return;
 
542
  B.buzz('medium'); sfx('book');
543
  say('', '……');
544
  await witchAppear();
545
- G.busy = false;
 
546
  story(G.storyK + 1);
547
  }
548
  function storyNext() {
@@ -562,13 +583,16 @@
562
  var tm = SPR['ui-tray'] || { w: 426, h: 219 }, w = Math.min(G.W * (items.length > 2 ? 0.66 : 0.5), 320), h = w * tm.h / tm.w, cw = Math.min(w * 0.8 / items.length, 66);
563
  t.style.display = 'block'; t.style.width = w + 'px'; t.style.height = h + 'px'; t.style.left = (G.W * 0.5 - w / 2) + 'px';
564
  // 矮屏:对话框会盖住托盘时,把托盘抬到对话框上方
565
- setTimeout(function () {
566
- if (!alive()) return;
567
- var d = $('#w2-dialog', L.el), rr = L.el.getBoundingClientRect(), dTop = d.getBoundingClientRect().top - rr.top;
568
- t.style.bottom = (G.ground - (dTop - 2)) + 'px';
569
- }, 60);
 
 
 
570
  t.innerHTML = '<i class="w2-tray-img" style="background-image:url(' + DIR + 'ui-tray.webp)"></i>' + items.map(function (it, i) {
571
- return '<button class="w2-cup" type="button" data-act="wt-cup" data-i="' + i + '" style="left:' + (10 + (i + 0.5) / items.length * 80) + '%;width:' + cw + 'px;height:' + cw + 'px;margin-left:' + (-cw / 2) + 'px;bottom:' + (h * 0.4) + 'px"><i class="smoke" style="' + cupBg(it.k) + '"></i></button>';
572
  }).join('');
573
  G.items = items;
574
  // 选项名牌放在对话框里,带同色小杯子
@@ -584,6 +608,7 @@
584
  stopTimer();
585
  G.mode = 'lobby'; G.busy = false;
586
  showWitch(false); tray([]); setCar(true);
 
587
  $('#w2-hero', L.el).className = 'wt-actor hero lobby';
588
  heroIdle(); refreshHud();
589
  var M = MONEY[moneyStage()], over = S.wrong >= cap();
@@ -618,8 +643,10 @@
618
  setCar(false);
619
  $('#w2-hero', L.el).className = 'wt-actor hero';
620
  if (!G.appeared) {
 
621
  G.appeared = true; tray([]); say('', '书页一闪,女巫飘了出来……');
622
  await witchAppear();
 
623
  }
624
  showWitch(true); witchIdle();
625
  ask();
@@ -638,10 +665,10 @@
638
  }
639
  function stopTimer() { if (G) cancelAnimationFrame(G.timer); }
640
  function startTimer() {
641
- stopTimer();
642
  G.left = ANSWER_SEC * 1000; G.deadline = Date.now() + G.left; G.warned = false;
643
  (function tick() {
644
- if (!alive() || G.busy || G.mode !== 'play') return;
645
  var left = Math.max(0, G.deadline - Date.now()), bar = $('#w2-timer-bar', L.el), num = $('#w2-timer-n', L.el);
646
  if (bar) { bar.style.width = (left / (ANSWER_SEC * 10)) + '%'; bar.className = left < 5000 ? 'low' : ''; }
647
  if (num) num.textContent = Math.ceil(left / 1000);
@@ -652,7 +679,7 @@
652
  })();
653
  }
654
  document.addEventListener('visibilitychange', function () {
655
- if (!G || G.busy || G.mode !== 'play') return;
656
  if (document.hidden) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); }
657
  else { G.deadline = Date.now() + (G.left || 0); startTimerResume(); }
658
  });
@@ -686,22 +713,24 @@
686
  f = document.createElement('i'); f.className = 'wt-fly smoke'; f.setAttribute('style', cupBtn.firstChild.getAttribute('style'));
687
  f.style.left = (from.left - rr.left) + 'px'; f.style.top = (from.top - rr.top) + 'px'; f.style.width = from.width + 'px'; f.style.height = from.height + 'px';
688
  L.el.appendChild(f); cupBtn.style.visibility = 'hidden'; void f.offsetWidth;
689
- var tx = hp.x - (from.left - rr.left + from.width / 2), ty = hp.y + sz * 0.72 - (from.top - rr.top + from.height / 2), sc = sz / from.width;
690
  base = 'translate(' + tx + 'px,' + ty + 'px) scale(' + sc + ')';
691
  f.style.webkitTransform = f.style.transform = base;
692
  B.buzz('light'); sfx('cup');
693
  }
 
694
  await wait(480);
 
695
  await hero(ak + '-drink', 6, false, function (k) {
696
  if (!f) return;
697
  if (k >= 3 && k <= 5) { f.style.webkitTransform = f.style.transform = base + ' rotate(' + (-25 - (k - 3) * 12) + 'deg)'; if (k === 4) { B.buzz('medium'); sfx('gulp'); } }
698
  if (k === 6) f.classList.add('gone');
699
  });
700
  if (f) setTimeout(function () { f.parentNode && f.parentNode.removeChild(f); }, 450);
701
- G.drinking = false;
702
  }
703
  function fx(name, fps) {
704
- var box = $('#w2-fx', L.el); if (!box) return Promise.resolve();
705
  box.innerHTML = '';
706
  var a = new Actor(box, '', heroT() * (name === 'fx-good' ? 1.3 : 1.15));
707
  return a.play(name, { fps: fps || 9 }).then(function () { box.innerHTML = ''; });
@@ -713,9 +742,11 @@
713
  var it = G.items && G.items[i]; if (!it) return;
714
  if (G.mode === 'story') { // 「你准备好了吗?」
715
  G.busy = true; B.buzz('light');
716
- if (it.v === 'no') { say('女巫', '那就等你准备好再来,书我先放这儿。'); await wait(900); close(); return; }
717
- await drinkAnim(i, who() + '-a2p2'); B.buzz('success'); hero(who() + '-a2p2-good', 6).then(heroIdle);
718
- await fx('fx-good', 10);
 
 
719
  G.busy = false; G.appeared = true; start();
720
  return;
721
  }
@@ -723,37 +754,43 @@
723
  }
724
  async function drink(v, i) {
725
  if (!G || G.busy || G.mode !== 'play') return;
 
726
  G.busy = true; stopTimer();
727
  var q = G.q, ok = v === q.a, timeout = v < 0;
728
  $$('.w2-opt', L.el).forEach(function (b, k) { var it = G.items[k]; b.disabled = true; b.classList.add(it.v === q.a ? 'is-right' : it.v === v ? 'is-wrong' : 'is-dim'); });
 
729
  var sn = S.seen[q.qid] || (S.seen[q.qid] = [0, 0, 0]); sn[0]++; if (ok) sn[1]++; sn[2] = Date.now();
730
  var ak = actKey();
 
 
 
 
 
 
 
 
 
 
 
731
  if (!timeout) await drinkAnim(i, ak); else { B.buzz('medium'); await hero(ak + '-drink', 6); }
732
- var before = { hero: heroKey(), ms: moneyStage(), ag: ageGroup(age()) }, delta = ok ? q.lv : -2 * q.lv, what = '';
733
  if (ok) {
734
  B.buzz('success'); sfx('right'); flash();
735
- clearTimeout(G.wIdleT); G.witch.play('witch-nod', { fps: 5 }).then(function () { if (alive()) witchIdle(); });
736
  hero(ak + '-good', 6);
737
  await fx('fx-good', 10);
738
- S.today.right++; S.total.right++; S.combo++;
739
  } else {
740
- B.buzz('error'); sfx('wrong'); setTimeout(function () { sfx('laugh'); }, 350); shake();
741
- clearTimeout(G.wIdleT); G.witch.play('witch-laugh', { fps: 5 }).then(function () { if (alive()) witchIdle(); });
742
  hero(ak + '-bad', 6);
743
  await fx('fx-bad', 9);
744
- S.today.wrong++; S.total.wrong++; S.wrong++; S.combo = 0;
745
  }
746
- if (q.at === 'b') {
747
- var r = Math.random(), sub = r < 0.4 ? 'y' : r < 0.7 ? 'phy' : 'look', a0 = age();
748
- if (sub === 'y') { S.y = Math.max(Y_MIN, Math.min(SUB, S.y + delta)); var da = age() - a0; what = (da < 0 ? '年轻了 ' + (-da).toFixed(1) + ' 岁' : '老了 ' + da.toFixed(1) + ' 岁'); G.bump = ['age', delta]; }
749
- else if (sub === 'phy') { S.phy = Math.max(S_MIN, Math.min(SUB, S.phy + delta)); what = '身材 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['phy', delta]; }
750
- else { S.look = Math.max(S_MIN, Math.min(SUB, S.look + delta)); what = '颜值 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['look', delta]; }
751
- } else { S.money = Math.max(0, Math.min(TOP, S.money + delta)); S.peak.m = Math.max(S.peak.m, S.money); what = '财富 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['money', delta]; }
752
  var change = '';
753
  if (heroKey() !== before.hero || moneyStage() !== before.ms) change = await transform(before);
 
754
  checkAch();
755
- if (age() >= AGE_MAX - 0.01) { S.dead = true; S.total.deaths++; S.ach.dead = S.ach.dead || Date.now(); }
756
- save(); refreshHud(); if (G.bump) { bump(G.bump[0], G.bump[1]); G.bump = null; }
757
  if (gAll() !== G.lastAll) { if (G.lastAll !== undefined) { B.buzz(gAll() > G.lastAll ? 'success' : 'heavy'); sfx(gAll() > G.lastAll ? 'level' : 'death'); B.toast('综合等级' + (gAll() > G.lastAll ? '提升' : '下降') + ':' + GRADE[gAll()][0] + '色头像框'); } G.lastAll = gAll(); }
758
  if (!S.dead) heroIdle();
759
  var over = !S.dead && S.wrong >= cap();
@@ -778,11 +815,14 @@
778
  }
779
  async function transform(before) {
780
  if (!alive()) return '';
781
- clearTimeout(G.wIdleT); G.witch.play('witch-wand', { fps: 7 }).then(function () { if (alive()) witchIdle(); });
 
782
  await wait(450);
 
783
  sfx('magic');
784
  var p = fx('fx-change', 8), lines = [];
785
  await wait(4 * 125); // 旋涡第 5 帧白光:换形象 / 换房子
 
786
  if (heroKey() !== before.hero) {
787
  heroIdle();
788
  var ag = ageGroup(age());
@@ -794,6 +834,7 @@
794
  lines.push((ms > before.ms ? '发财了!' : '变穷了……') + '现在住' + MONEY[ms].house + ',开' + MONEY[ms].car);
795
  }
796
  await p;
 
797
  vibrateLong();
798
  return lines.join('<br>');
799
  }
@@ -801,6 +842,7 @@
801
  /* ---------------- 喝错满 10 杯 ---------------- */
802
  function capPopup() {
803
  if (!alive()) return;
 
804
  stopTimer(); G.mode = 'cap'; G.busy = true;
805
  showWitch(true); tray([]);
806
  sfx('stop');
@@ -823,7 +865,7 @@
823
  vibrateLong(); sfx('death'); tray([]);
824
  $('#w2-hero', L.el).className = 'wt-actor hero dead';
825
  G.hero.stop(); G.hero.frame(heroKey() + '-idle', 0);
826
- say('女巫', '魔药喝错太多,你已经 ' + ageTxt() + ' 岁,寿终正寝了……', '');
827
  var mini = B.mini(), canComment = !!(mini && typeof mini.interactionOpenApi === 'function');
828
  popup('寿终正寝……', '<p>晒一下你的人生账单,女巫会把你变回 22 岁(金钱保留),不限次数。</p>' + shareRows('revive', canComment) +
829
  '<button class="w2-btn ghost wide" type="button" data-act="wt-forget">喝下「遗忘之药水」,重新投胎</button>');
@@ -837,12 +879,18 @@
837
  } else { S.unlock++; S.ach.unlock = S.ach.unlock || Date.now(); B.toast('女巫又给你备好了 10 杯魔药'); }
838
  save(true); B.buzz('success');
839
  closePopup();
840
- if (alive()) { refreshHud(); lobby(); }
841
  }
842
 
843
  /* ---------------- 弹窗(游戏风格;点空白处关闭) ---------------- */
 
 
 
 
 
 
844
  function popup(title, body, cls) {
845
- closePopup();
846
  var p = document.createElement('div'); p.className = 'w2-pop' + (cls ? ' ' + cls : ''); p.id = 'w2-pop';
847
  var x = SPR['ui-close'] ? '<i style="' + bg('ui-close') + '"></i>' : '✕';
848
  p.innerHTML = '<div class="w2-pop-box rise">' + DECO + (title ? '<div class="w2-title">' + title + '</div>' : '') + '<div class="w2-pop-body">' + body + '</div><button class="w2-pop-x" type="button" data-act="wt-popclose" aria-label="关闭">' + x + '</button></div>';
@@ -855,7 +903,7 @@
855
  L.el.appendChild(t); clearTimeout(G.tipT);
856
  G.tipT = setTimeout(function () { t.classList.add('out'); setTimeout(function () { t.parentNode && t.parentNode.removeChild(t); }, 300); }, 2000);
857
  }
858
- function closePopup() { var p = L && $('#w2-pop', L.el); if (p) { p.parentNode.removeChild(p); sfx('close'); } if (G && G.panelA) { G.panelA.stop(); G.panelA = null; } }
859
  function badge(a, got) {
860
  var art = SPR['badge-' + a[0]] ? '<i style="' + bg('badge-' + a[0]) + '"></i>' : '<i class="t">' + a[1].slice(0, 1) + '</i>';
861
  return '<button class="w2-badge' + (got ? ' got' : '') + '" type="button" data-act="wt-badge" data-id="' + a[0] + '">' + art + '<span>' + a[1] + '</span></button>';
@@ -871,8 +919,9 @@
871
  '<h4>每天的限制</h4><p>每天最多喝错 10 杯。超过后,晒一下人生账单(发图文、做成图集或发评论)可以再喝 10 杯,不限次数;也可以第二天再来。</p>' +
872
  '<h4>寿终</h4><p>晒人生账单可以复活:回到 22 岁,身材、颜值回到普通,财富保留。也可以喝下遗忘之药水,全部清零重来。</p></div>';
873
  function toolTap(k) {
 
 
874
  B.buzz('light'); sfx('tap');
875
- if (k === 'exit') { exitHome(); return; }
876
  if (k === 'share') { share('note', ''); return; }
877
  if (k === 'ach') {
878
  var n = 0; ACH.forEach(function (a) { if (S.ach[a[0]]) n++; });
@@ -1008,7 +1057,7 @@
1008
  case 'wt-cup': cupPicked(Number(el.getAttribute('data-i'))); break;
1009
  case 'wt-start': start(); break;
1010
  case 'wt-skip': if (G) { $('#w2-book', L.el).className = 'w2-book'; $('#w2-hero', L.el).className = 'wt-actor hero'; G.busy = false; lobby(); } break;
1011
- case 'wt-next': if (G) { G.busy = false; ask(); } break;
1012
  case 'wt-cap': capPopup(); break;
1013
  case 'wt-death': death(); break;
1014
  case 'wt-share': share(el.getAttribute('data-k'), el.getAttribute('data-why') || ''); break;
@@ -1022,7 +1071,7 @@
1022
  B.buzz('light'); sfx('tap');
1023
  break;
1024
  case 'wt-friend': S.ach.bill = S.ach.bill || Date.now(); afterShare('unlock'); break;
1025
- case 'wt-replay': closePopup(); G.appeared = false; story(0); break;
1026
  case 'wt-badge':
1027
  var aa = ACH.filter(function (x) { return x[0] === el.getAttribute('data-id'); })[0];
1028
  if (aa) { var gt = S.ach[aa[0]]; centerTip('<b>' + aa[1] + '</b><br>' + aa[2] + '<br><small>' + (gt ? new Date(gt).toLocaleDateString() + ' 获得' : '未获得') + '</small>'); B.buzz('light'); }
@@ -1031,10 +1080,11 @@
1031
  case 'wt-orig': B.openDetail(el.getAttribute('data-id')); break;
1032
  case 'wt-popclose': closePopup(); if (el.getAttribute('data-then') === 'lobby') lobby(); break;
1033
  case 'wt-forget':
 
1034
  if (Date.now() - forgetAt < 2500) {
1035
  var keep = S.intro, keepSnd = S.snd; S = blank(); S.intro = keep; S.snd = keepSnd; loaded = true; rollDay(); save(true); forgetAt = 0;
1036
  B.toast('喝下遗忘之药水:一切从 22 岁重新开始,重新选择你的角色');
1037
- if (alive()) { closePopup(); $('#w2-hero', L.el).className = 'wt-actor hero'; setBg(0, true); refreshHud(); chooseGender(function () { lobby(); }); }
1038
  } else { forgetAt = Date.now(); B.toast('再点一次,喝下遗忘之药水(年龄、身材、颜值、金钱、成就全部清零)'); }
1039
  break;
1040
  }
@@ -1052,7 +1102,7 @@
1052
  // 「女巫的魔药」版:冒险页与「去喝魔药」入口
1053
  if (STANDALONE) {
1054
  window.__HTLB_CH__ = { show: function () { landing(); if (!L) open(); }, act: function (a, el) {
1055
- if (a === 'ch-item') { var l = (BY_ADV[el.getAttribute('data-id')] || []).slice(); var tp; while ((tp = B.top())) B.close(tp); open(l); }
1056
  }, bankSize: function () { return ALL.length; } };
1057
  }
1058
  })();
 
92
  return { v: 2, y: 0, phy: 0, look: 0, money: 0, day: '', wrong: 0, unlock: 0, intro: false, combo: 0, seen: {}, ach: {},
93
  today: { right: 0, wrong: 0 }, total: { right: 0, wrong: 0, deaths: 0, revives: 0 }, peak: { m: 0, age: AGE0 }, dead: false, pendingRevive: '', snd: { sfx: true, bgm: true }, gender: '' };
94
  }
95
+ var S = blank(), loaded = false, saveT = 0, loadWait = [];
96
  function save(now) { clearTimeout(saveT); var go = function () { return B.save('witch2', S); }; if (now) return go(); saveT = setTimeout(go, 200); return Promise.resolve(true); }
97
  function rollDay() { var k = B.today().key; if (S.day !== k) { S.day = k; S.wrong = 0; S.unlock = 0; S.today = { right: 0, wrong: 0 }; save(); } }
98
  B.load('witch2').then(function (d) {
 
102
  S.pendingRevive = '';
103
  if (!S.gender && S.intro) S.gender = 'm'; // 老用户:默认男主角
104
  loaded = true; rollDay(); save();
105
+ var lw = loadWait; loadWait = []; lw.forEach(function (f) { try { f(); } catch (e) {} });
106
+ if (B.tab() === 'quiz' && !L && !lw.length) landing();
107
  });
108
  function cap() { return WRONG_CAP * (1 + S.unlock); }
109
  function age() { return ageOf(S.y); }
 
213
  if (!SND.ctx) return;
214
  try { if (document.hidden) SND.ctx.suspend(); else if (L) SND.ctx.resume(); } catch (e) {}
215
  });
216
+ document.addEventListener('visibilitychange', function () { if (document.hidden && loaded) save(true); });
217
 
218
  /* ---------------- 精灵 ---------------- */
219
  var pre = {};
 
289
  function open(queue) {
290
  whenReady(function () {
291
  if (L) return;
292
+ if (!loaded) { if (!loadWait.length) loadWait.push(function () { open(queue); }); return; }
293
+ rollDay(); gameMode(true); B.buzz('light'); var ac = actx(); try { if (ac && ac.state === 'suspended') ac.resume(); } catch (e) {} musicOn();
294
  ['ui-divider', 'ui-tray', 'ui-close', 'cup-1', 'icons', 'frames', 'witch-idle2', 'witch-idle3', actKey() + '-idle2', actKey() + '-idle3', 'fx-good', 'fx-bad', 'fx-change', 'witch-idle', 'witch-appear', 'witch-nod', 'witch-laugh', 'witch-wand', 'witch-stop',
295
  'house-' + moneyStage(), 'car-' + moneyStage(), heroKey() + '-idle', actKey() + '-drink', actKey() + '-good', actKey() + '-bad', faceKey(), who() + '-ride'].forEach(img);
296
  L = B.sheet('w2', { label: '女巫的魔药', render: function (lay) {
 
323
  var el = L.el, W = el.offsetWidth || 390, H = el.offsetHeight || 844;
324
  var sc = Math.max(W / 720, H / 1280), ih = 1280 * sc, oy = (H - ih) / 2;
325
  G.W = W; G.H = H; G.ground = oy + ih * 0.62;
326
+ var lim = H - 92 - 228, bgs = [$('#w2-bg', el), $('#w2-bg2', el)];
327
+ if (lim < G.ground) { // 矮屏:对话框会挡住脚,整幅画面(背景 + 角色)一起上移
328
+ var ih2 = Math.max(ih, (H - lim) / 0.38), oy2 = lim - ih2 * 0.62;
329
+ G.ground = lim;
330
+ bgs.forEach(function (b) { if (b) { b.style.backgroundSize = (720 * ih2 / 1280) + 'px ' + ih2 + 'px'; b.style.backgroundPosition = '50% ' + oy2 + 'px'; } });
331
+ } else bgs.forEach(function (b) { if (b) { b.style.backgroundSize = ''; b.style.backgroundPosition = ''; } });
332
  var scene = $('#w2-scene', el); scene.style.height = G.ground + 'px';
333
  }
334
  function heroT() { return Math.min(G.H * 0.22, G.W * 0.48); }
335
  function alive() { return L && L.el.parentNode; }
336
  function exitHome() { close(); if (B.tab() !== 'today' && B.go) B.go('today'); window.scrollTo(0, 0); }
337
+ function teardown() {
338
+ stopTimer();
339
+ if (G) {
340
+ G.hero.stop(); G.witch.stop(); if (G.panelA) G.panelA.stop();
341
+ (G.chooseA || []).forEach(function (a) { a.stop(); });
342
+ clearInterval(G.typer); clearTimeout(G.hIdleT); clearTimeout(G.wIdleT); clearTimeout(G.tipT);
343
+ }
344
+ L = null; G = null;
345
+ musicOff(); save(true); gameMode(false);
346
+ setTimeout(function () { try { if (!L && SND.ctx && SND.ctx.state === 'running') SND.ctx.suspend(); } catch (e) {} }, 700);
347
+ }
348
  function close() {
349
  if (!L) return;
350
+ var lay = L; teardown(); B.close(lay);
 
 
 
351
  if (B.tab() === 'quiz') (window.__HTLB_CH__ && !STANDALONE ? window.__HTLB_CH__.show() : landing());
352
  }
353
+ setInterval(function () { if (L && !L.el.parentNode) teardown(); }, 800);
354
  function setBg(ms, instant) {
355
  var a = $('#w2-bg', L.el), b = $('#w2-bg2', L.el), url = 'url(' + DIR + 'house-' + ms + '.webp)';
356
  if (instant) { a.style.backgroundImage = url; return; }
 
550
  if (k === 3) { B.buzz('medium'); we.classList.remove('pre-in'); we.classList.add('rise-in'); }
551
  if (k === 4) bk.className = 'w2-book';
552
  } });
553
+ var g = G;
554
  await done; box.innerHTML = '';
555
+ if (G !== g) return;
556
  we.classList.remove('rise-in');
557
  witchIdle();
558
  }
559
  async function bookTapped() {
560
+ if (!G || G.mode !== 'story' || !STORY[G.storyK].book || G.bookBusy) return;
561
+ var g = G; g.bookBusy = true;
562
  B.buzz('medium'); sfx('book');
563
  say('', '……');
564
  await witchAppear();
565
+ if (G !== g) return;
566
+ g.bookBusy = false; G.busy = false;
567
  story(G.storyK + 1);
568
  }
569
  function storyNext() {
 
583
  var tm = SPR['ui-tray'] || { w: 426, h: 219 }, w = Math.min(G.W * (items.length > 2 ? 0.66 : 0.5), 320), h = w * tm.h / tm.w, cw = Math.min(w * 0.8 / items.length, 66);
584
  t.style.display = 'block'; t.style.width = w + 'px'; t.style.height = h + 'px'; t.style.left = (G.W * 0.5 - w / 2) + 'px';
585
  // 矮屏:对话框会盖住托盘时,把托盘抬到对话框上方
586
+ // 对话框打字时会长高,多量几次,托盘始终贴在对话框上沿
587
+ [60, 400, 900, 1600].forEach(function (ms) {
588
+ setTimeout(function () {
589
+ if (!alive() || !G || t.style.display === 'none') return;
590
+ var d = $('#w2-dialog', L.el), rr = L.el.getBoundingClientRect(), dTop = d.getBoundingClientRect().top - rr.top;
591
+ t.style.bottom = (G.ground - (dTop - 4)) + 'px';
592
+ }, ms);
593
+ });
594
  t.innerHTML = '<i class="w2-tray-img" style="background-image:url(' + DIR + 'ui-tray.webp)"></i>' + items.map(function (it, i) {
595
+ return '<button class="w2-cup" type="button" data-act="wt-cup" data-i="' + i + '" style="left:' + (10 + (i + 0.5) / items.length * 80) + '%;width:' + cw + 'px;height:' + cw + 'px;margin-left:' + (-cw / 2) + 'px;bottom:' + (h * 0.2) + 'px"><i class="smoke" style="' + cupBg(it.k) + '"></i></button>';
596
  }).join('');
597
  G.items = items;
598
  // 选项名牌放在对话框里,带同色小杯子
 
608
  stopTimer();
609
  G.mode = 'lobby'; G.busy = false;
610
  showWitch(false); tray([]); setCar(true);
611
+ rollDay();
612
  $('#w2-hero', L.el).className = 'wt-actor hero lobby';
613
  heroIdle(); refreshHud();
614
  var M = MONEY[moneyStage()], over = S.wrong >= cap();
 
643
  setCar(false);
644
  $('#w2-hero', L.el).className = 'wt-actor hero';
645
  if (!G.appeared) {
646
+ var g = G;
647
  G.appeared = true; tray([]); say('', '书页一闪,女巫飘了出来……');
648
  await witchAppear();
649
+ if (G !== g) return;
650
  }
651
  showWitch(true); witchIdle();
652
  ask();
 
665
  }
666
  function stopTimer() { if (G) cancelAnimationFrame(G.timer); }
667
  function startTimer() {
668
+ stopTimer(); G.paused = false;
669
  G.left = ANSWER_SEC * 1000; G.deadline = Date.now() + G.left; G.warned = false;
670
  (function tick() {
671
+ if (!alive() || G.busy || G.paused || G.mode !== 'play') return;
672
  var left = Math.max(0, G.deadline - Date.now()), bar = $('#w2-timer-bar', L.el), num = $('#w2-timer-n', L.el);
673
  if (bar) { bar.style.width = (left / (ANSWER_SEC * 10)) + '%'; bar.className = left < 5000 ? 'low' : ''; }
674
  if (num) num.textContent = Math.ceil(left / 1000);
 
679
  })();
680
  }
681
  document.addEventListener('visibilitychange', function () {
682
+ if (!G || G.busy || G.paused || G.mode !== 'play') return;
683
  if (document.hidden) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); }
684
  else { G.deadline = Date.now() + (G.left || 0); startTimerResume(); }
685
  });
 
713
  f = document.createElement('i'); f.className = 'wt-fly smoke'; f.setAttribute('style', cupBtn.firstChild.getAttribute('style'));
714
  f.style.left = (from.left - rr.left) + 'px'; f.style.top = (from.top - rr.top) + 'px'; f.style.width = from.width + 'px'; f.style.height = from.height + 'px';
715
  L.el.appendChild(f); cupBtn.style.visibility = 'hidden'; void f.offsetWidth;
716
+ var tx = hp.x - (from.left - rr.left + from.width / 2), ty = hp.y + sz * 0.55 - (from.top - rr.top + from.height / 2), sc = sz / from.width;
717
  base = 'translate(' + tx + 'px,' + ty + 'px) scale(' + sc + ')';
718
  f.style.webkitTransform = f.style.transform = base;
719
  B.buzz('light'); sfx('cup');
720
  }
721
+ var g = G;
722
  await wait(480);
723
+ if (G !== g) return;
724
  await hero(ak + '-drink', 6, false, function (k) {
725
  if (!f) return;
726
  if (k >= 3 && k <= 5) { f.style.webkitTransform = f.style.transform = base + ' rotate(' + (-25 - (k - 3) * 12) + 'deg)'; if (k === 4) { B.buzz('medium'); sfx('gulp'); } }
727
  if (k === 6) f.classList.add('gone');
728
  });
729
  if (f) setTimeout(function () { f.parentNode && f.parentNode.removeChild(f); }, 450);
730
+ if (G === g) G.drinking = false;
731
  }
732
  function fx(name, fps) {
733
+ var box = alive() && $('#w2-fx', L.el); if (!box) return Promise.resolve();
734
  box.innerHTML = '';
735
  var a = new Actor(box, '', heroT() * (name === 'fx-good' ? 1.3 : 1.15));
736
  return a.play(name, { fps: fps || 9 }).then(function () { box.innerHTML = ''; });
 
742
  var it = G.items && G.items[i]; if (!it) return;
743
  if (G.mode === 'story') { // 「你准备好了吗?」
744
  G.busy = true; B.buzz('light');
745
+ var g = G;
746
+ if (it.v === 'no') { say('女巫', '那就等你准备好再来,书我先放这儿。'); await wait(900); if (G === g) close(); return; }
747
+ await drinkAnim(i, who() + '-a2p2'); if (G !== g) return;
748
+ B.buzz('success'); hero(who() + '-a2p2-good', 6).then(function () { if (G === g) heroIdle(); });
749
+ await fx('fx-good', 10); if (G !== g) return;
750
  G.busy = false; G.appeared = true; start();
751
  return;
752
  }
 
754
  }
755
  async function drink(v, i) {
756
  if (!G || G.busy || G.mode !== 'play') return;
757
+ var g = G;
758
  G.busy = true; stopTimer();
759
  var q = G.q, ok = v === q.a, timeout = v < 0;
760
  $$('.w2-opt', L.el).forEach(function (b, k) { var it = G.items[k]; b.disabled = true; b.classList.add(it.v === q.a ? 'is-right' : it.v === v ? 'is-wrong' : 'is-dim'); });
761
+ // 先结算并存档,再播动画:中途退出也照样算数
762
  var sn = S.seen[q.qid] || (S.seen[q.qid] = [0, 0, 0]); sn[0]++; if (ok) sn[1]++; sn[2] = Date.now();
763
  var ak = actKey();
764
+ var before = { hero: heroKey(), ms: moneyStage(), ag: ageGroup(age()) }, delta = ok ? q.lv : -2 * q.lv, what = '', bmp = null;
765
+ if (ok) { S.today.right++; S.total.right++; S.combo++; }
766
+ else { S.today.wrong++; S.total.wrong++; S.wrong++; S.combo = 0; }
767
+ if (q.at === 'b') {
768
+ var r = Math.random(), sub = r < 0.4 ? 'y' : r < 0.7 ? 'phy' : 'look', a0 = age();
769
+ if (sub === 'y') { S.y = Math.max(Y_MIN, Math.min(SUB, S.y + delta)); var da = age() - a0; what = da < -0.05 ? '年轻了 ' + (-da).toFixed(1) + ' 岁' : da > 0.05 ? '老了 ' + da.toFixed(1) + ' 岁' : '年龄 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['age', delta]; }
770
+ else if (sub === 'phy') { S.phy = Math.max(S_MIN, Math.min(SUB, S.phy + delta)); what = '身材 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['phy', delta]; }
771
+ else { S.look = Math.max(S_MIN, Math.min(SUB, S.look + delta)); what = '颜值 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['look', delta]; }
772
+ } else { S.money = Math.max(0, Math.min(TOP, S.money + delta)); S.peak.m = Math.max(S.peak.m, S.money); what = '财富 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['money', delta]; }
773
+ if (age() >= AGE_MAX - 0.01) { S.dead = true; S.total.deaths++; S.ach.dead = S.ach.dead || Date.now(); }
774
+ save(true);
775
  if (!timeout) await drinkAnim(i, ak); else { B.buzz('medium'); await hero(ak + '-drink', 6); }
776
+ if (G !== g) { checkAch(); save(true); return; }
777
  if (ok) {
778
  B.buzz('success'); sfx('right'); flash();
779
+ clearTimeout(G.wIdleT); G.witch.play('witch-nod', { fps: 5 }).then(function () { if (G === g) witchIdle(); });
780
  hero(ak + '-good', 6);
781
  await fx('fx-good', 10);
 
782
  } else {
783
+ B.buzz('error'); sfx('wrong'); setTimeout(function () { if (G === g) sfx('laugh'); }, 350); shake();
784
+ clearTimeout(G.wIdleT); G.witch.play('witch-laugh', { fps: 5 }).then(function () { if (G === g) witchIdle(); });
785
  hero(ak + '-bad', 6);
786
  await fx('fx-bad', 9);
 
787
  }
788
+ if (G !== g) { checkAch(); save(true); return; }
 
 
 
 
 
789
  var change = '';
790
  if (heroKey() !== before.hero || moneyStage() !== before.ms) change = await transform(before);
791
+ if (G !== g) { checkAch(); save(true); return; }
792
  checkAch();
793
+ save(); refreshHud(); if (bmp) bump(bmp[0], bmp[1]);
 
794
  if (gAll() !== G.lastAll) { if (G.lastAll !== undefined) { B.buzz(gAll() > G.lastAll ? 'success' : 'heavy'); sfx(gAll() > G.lastAll ? 'level' : 'death'); B.toast('综合等级' + (gAll() > G.lastAll ? '提升' : '下降') + ':' + GRADE[gAll()][0] + '色头像框'); } G.lastAll = gAll(); }
795
  if (!S.dead) heroIdle();
796
  var over = !S.dead && S.wrong >= cap();
 
815
  }
816
  async function transform(before) {
817
  if (!alive()) return '';
818
+ var g = G;
819
+ clearTimeout(G.wIdleT); G.witch.play('witch-wand', { fps: 7 }).then(function () { if (G === g) witchIdle(); });
820
  await wait(450);
821
+ if (G !== g) return '';
822
  sfx('magic');
823
  var p = fx('fx-change', 8), lines = [];
824
  await wait(4 * 125); // 旋涡第 5 帧白光:换形象 / 换房子
825
+ if (G !== g) return '';
826
  if (heroKey() !== before.hero) {
827
  heroIdle();
828
  var ag = ageGroup(age());
 
834
  lines.push((ms > before.ms ? '发财了!' : '变穷了……') + '现在住' + MONEY[ms].house + ',开' + MONEY[ms].car);
835
  }
836
  await p;
837
+ if (G !== g) return '';
838
  vibrateLong();
839
  return lines.join('<br>');
840
  }
 
842
  /* ---------------- 喝错满 10 杯 ---------------- */
843
  function capPopup() {
844
  if (!alive()) return;
845
+ rollDay(); if (S.dead) { death(); return; } if (S.wrong < cap()) { G.busy = false; lobby(); return; }
846
  stopTimer(); G.mode = 'cap'; G.busy = true;
847
  showWitch(true); tray([]);
848
  sfx('stop');
 
865
  vibrateLong(); sfx('death'); tray([]);
866
  $('#w2-hero', L.el).className = 'wt-actor hero dead';
867
  G.hero.stop(); G.hero.frame(heroKey() + '-idle', 0);
868
+ say('女巫', '魔药喝错太多,你已经 ' + ageTxt() + ' 岁,寿终正寝了……', '<button class="w2-btn" type="button" data-act="wt-death">晒账单复活</button>');
869
  var mini = B.mini(), canComment = !!(mini && typeof mini.interactionOpenApi === 'function');
870
  popup('寿终正寝……', '<p>晒一下你的人生账单,女巫会把你变回 22 岁(金钱保留),不限次数。</p>' + shareRows('revive', canComment) +
871
  '<button class="w2-btn ghost wide" type="button" data-act="wt-forget">喝下「遗忘之药水」,重新投胎</button>');
 
879
  } else { S.unlock++; S.ach.unlock = S.ach.unlock || Date.now(); B.toast('女巫又给你备好了 10 杯魔药'); }
880
  save(true); B.buzz('success');
881
  closePopup();
882
+ if (alive()) { G.lastAll = gAll(); G.busy = false; refreshHud(); lobby(); }
883
  }
884
 
885
  /* ---------------- 弹窗(游戏风格;点空白处关闭) ---------------- */
886
+ function pauseTimer() {
887
+ if (G && G.mode === 'play' && !G.busy && !G.paused) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); G.paused = true; }
888
+ }
889
+ function resumeTimer() {
890
+ if (G && G.paused) { G.paused = false; if (G.mode === 'play' && !G.busy && alive()) startTimerResume(); }
891
+ }
892
  function popup(title, body, cls) {
893
+ closePopup(); pauseTimer();
894
  var p = document.createElement('div'); p.className = 'w2-pop' + (cls ? ' ' + cls : ''); p.id = 'w2-pop';
895
  var x = SPR['ui-close'] ? '<i style="' + bg('ui-close') + '"></i>' : '✕';
896
  p.innerHTML = '<div class="w2-pop-box rise">' + DECO + (title ? '<div class="w2-title">' + title + '</div>' : '') + '<div class="w2-pop-body">' + body + '</div><button class="w2-pop-x" type="button" data-act="wt-popclose" aria-label="关闭">' + x + '</button></div>';
 
903
  L.el.appendChild(t); clearTimeout(G.tipT);
904
  G.tipT = setTimeout(function () { t.classList.add('out'); setTimeout(function () { t.parentNode && t.parentNode.removeChild(t); }, 300); }, 2000);
905
  }
906
+ function closePopup() { var p = L && $('#w2-pop', L.el); if (p) { p.parentNode.removeChild(p); sfx('close'); } if (G && G.panelA) { G.panelA.stop(); G.panelA = null; } resumeTimer(); }
907
  function badge(a, got) {
908
  var art = SPR['badge-' + a[0]] ? '<i style="' + bg('badge-' + a[0]) + '"></i>' : '<i class="t">' + a[1].slice(0, 1) + '</i>';
909
  return '<button class="w2-badge' + (got ? ' got' : '') + '" type="button" data-act="wt-badge" data-id="' + a[0] + '">' + art + '<span>' + a[1] + '</span></button>';
 
919
  '<h4>每天的限制</h4><p>每天最多喝错 10 杯。超过后,晒一下人生账单(发图文、做成图集或发评论)可以再喝 10 杯,不限次数;也可以第二天再来。</p>' +
920
  '<h4>寿终</h4><p>晒人生账单可以复活:回到 22 岁,身材、颜值回到普通,财富保留。也可以喝下遗忘之药水,全部清零重来。</p></div>';
921
  function toolTap(k) {
922
+ if (k === 'exit') { B.buzz('light'); sfx('tap'); exitHome(); return; }
923
+ if (G && G.busy && (G.mode === 'play' || G.mode === 'choose')) return;
924
  B.buzz('light'); sfx('tap');
 
925
  if (k === 'share') { share('note', ''); return; }
926
  if (k === 'ach') {
927
  var n = 0; ACH.forEach(function (a) { if (S.ach[a[0]]) n++; });
 
1057
  case 'wt-cup': cupPicked(Number(el.getAttribute('data-i'))); break;
1058
  case 'wt-start': start(); break;
1059
  case 'wt-skip': if (G) { $('#w2-book', L.el).className = 'w2-book'; $('#w2-hero', L.el).className = 'wt-actor hero'; G.busy = false; lobby(); } break;
1060
+ case 'wt-next': if (G) { rollDay(); if (S.wrong >= cap()) { capPopup(); break; } G.busy = false; ask(); } break;
1061
  case 'wt-cap': capPopup(); break;
1062
  case 'wt-death': death(); break;
1063
  case 'wt-share': share(el.getAttribute('data-k'), el.getAttribute('data-why') || ''); break;
 
1071
  B.buzz('light'); sfx('tap');
1072
  break;
1073
  case 'wt-friend': S.ach.bill = S.ach.bill || Date.now(); afterShare('unlock'); break;
1074
+ case 'wt-replay': if (!G || G.busy && G.mode === 'play') break; closePopup(); G.appeared = false; story(0); break;
1075
  case 'wt-badge':
1076
  var aa = ACH.filter(function (x) { return x[0] === el.getAttribute('data-id'); })[0];
1077
  if (aa) { var gt = S.ach[aa[0]]; centerTip('<b>' + aa[1] + '</b><br>' + aa[2] + '<br><small>' + (gt ? new Date(gt).toLocaleDateString() + ' 获得' : '未获得') + '</small>'); B.buzz('light'); }
 
1080
  case 'wt-orig': B.openDetail(el.getAttribute('data-id')); break;
1081
  case 'wt-popclose': closePopup(); if (el.getAttribute('data-then') === 'lobby') lobby(); break;
1082
  case 'wt-forget':
1083
+ if (G && G.busy && G.mode === 'play') break;
1084
  if (Date.now() - forgetAt < 2500) {
1085
  var keep = S.intro, keepSnd = S.snd; S = blank(); S.intro = keep; S.snd = keepSnd; loaded = true; rollDay(); save(true); forgetAt = 0;
1086
  B.toast('喝下遗忘之药水:一切从 22 岁重新开始,重新选择你的角色');
1087
+ if (alive()) { G.lastAll = gAll(); G.appeared = false; closePopup(); $('#w2-hero', L.el).className = 'wt-actor hero'; setBg(0, true); refreshHud(); chooseGender(function () { lobby(); }); }
1088
  } else { forgetAt = Date.now(); B.toast('再点一次,喝下遗忘之药水(年龄、身材、颜值、金钱、成就全部清零)'); }
1089
  break;
1090
  }
 
1102
  // 「女巫的魔药」版:冒险页与「去喝魔药」入口
1103
  if (STANDALONE) {
1104
  window.__HTLB_CH__ = { show: function () { landing(); if (!L) open(); }, act: function (a, el) {
1105
+ if (a === 'ch-item') { var l = (BY_ADV[el.getAttribute('data-id')] || []).slice(); if (L) teardown(); var tp; while ((tp = B.top())) B.close(tp); open(l); }
1106
  }, bankSize: function () { return ALL.length; } };
1107
  }
1108
  })();
htlb/miniapp/tool/app.js CHANGED
The diff for this file is too large to render. See raw diff
 
htlb/miniapp/tool/style.css CHANGED
@@ -251,7 +251,7 @@
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
- .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
@@ -371,7 +371,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
- .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
@@ -460,7 +460,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
- .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
@@ -471,7 +471,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
- .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
@@ -520,7 +520,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
- .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
@@ -562,7 +562,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
- .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
@@ -683,7 +683,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
- .w2-dialog{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
@@ -717,7 +717,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
- .w2-dlg{position:absolute;left:8px;right:8px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
@@ -739,7 +739,7 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
- .w2-dlg{bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
@@ -760,3 +760,24 @@ html.game-on img{-webkit-user-drag:none;pointer-events:none}
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  .spr{position:absolute;left:0;background-repeat:no-repeat;pointer-events:none}
252
  /* 战斗页 */
253
  .gm-sheet{background:var(--paper)}
254
+ .gm-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
255
  .gm-stage{position:relative;flex-shrink:0;height:38vh;min-height:220px;max-height:320px;margin:0 10px;border-radius:18px;overflow:hidden;box-shadow:var(--lift)}
256
  .gm-actor{position:absolute;bottom:22%;width:0;height:0;transition:transform .22s var(--ease),opacity .3s}
257
  .gm-actor.hero{left:27%}
 
371
  .hub-back{display:inline-flex;align-items:center;font-size:13px;font-weight:800;color:var(--muted);min-height:36px;margin-top:4px}
372
  /* 女巫的魔药:全屏层 */
373
  .wt-sheet{background:#1d1626;color:var(--white)}
374
+ .wt-top{flex-shrink:0;padding:8px 10px 6px;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);background:#1d1626}
375
  .wt-hud{display:flex;align-items:stretch}
376
  .wt-stat{flex:1;min-width:0;background:rgba(255,255,255,.08);border-radius:12px;padding:6px 8px;margin-right:6px}
377
  .wt-k{display:inline-block;font-size:10.5px;font-weight:900;background:#12B886;color:#fff;border-radius:4px;padding:0 5px;margin-right:4px}
 
460
  .wt-ach b{display:block;font-size:14.5px;font-weight:900}
461
  .wt-ach small{display:block;font-size:11.5px;color:var(--muted)}
462
  /* 开场 */
463
+ .wt-intro{position:absolute;left:0;top:0;right:0;bottom:0;z-index:10;display:flex;flex-direction:column;background:#140e1a;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px)}
464
  .wt-intro-stage{position:relative;flex:1;margin:0 10px;border-radius:18px;overflow:hidden;background-size:cover;background-position:center bottom}
465
  .wt-intro-stage .wt-actor{bottom:18%}
466
  .wt-intro-car{position:absolute;right:6%;bottom:16%;width:38%;height:26%;background-size:contain;background-repeat:no-repeat;background-position:center bottom}
 
471
  .wt-intro-vs span{font-size:15px;font-weight:900;border-radius:10px;padding:3px 12px}
472
  .wt-intro-vs .g{background:#12B886}
473
  .wt-intro-vs .b{background:#7a4a8a}
474
+ .wt-intro-card{flex-shrink:0;margin:10px;background:#F6F1E7;color:var(--ink);border-radius:18px;padding:14px 16px;padding-bottom:14px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 14px)}
475
  .wt-dots{display:flex;justify-content:center;margin-bottom:8px}
476
  .wt-dots i{width:7px;height:7px;border-radius:4px;background:rgba(23,23,27,.18);margin:0 3px}
477
  .wt-dots i.on{width:18px;background:#5B2A86}
 
520
  .w2-cup:nth-of-type(2) i{-webkit-animation-delay:.3s;animation-delay:.3s}
521
  .w2-cup:nth-of-type(3) i{-webkit-animation-delay:.6s;animation-delay:.6s}
522
  .w2-cup:nth-of-type(4) i{-webkit-animation-delay:.9s;animation-delay:.9s}
523
+ .w2-hud{position:absolute;left:8px;right:8px;top:0;padding-top:56px;padding-top:calc(env(safe-area-inset-top,0px) + 56px);display:flex;align-items:flex-start;z-index:5;pointer-events:none}
524
  .w2-hud button{pointer-events:auto}
525
  .w2-me{flex-shrink:0;width:72px;text-align:center}
526
  .w2-face{position:relative;display:block;width:66px;height:66px;margin:0 auto;border-radius:50%;background-size:86% 86%;background-position:center;background-repeat:no-repeat;background-color:#f3d7c0}
 
562
  .w2-acts .w2-btn:last-child{margin-right:0}
563
  .w2-acts .w2-btn.ghost{flex:0 0 32%}
564
  .w2-change{font-size:13.5px;font-weight:900;line-height:1.6;background:rgba(155,89,182,.14);border-radius:10px;padding:6px 10px;margin-top:6px;color:#5B2A86}
565
+ .w2-tools{position:absolute;left:0;right:0;bottom:0;z-index:8;display:flex;justify-content:space-around;padding:6px 4px;padding-bottom:6px;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 6px);background:linear-gradient(180deg,rgba(29,22,38,.7),rgba(29,22,38,.95))}
566
  .w2-tool{display:flex;flex-direction:column;align-items:center;min-width:52px;color:#FFE58A;font-size:10.5px;font-weight:900}
567
  .w2-tool .w2-ic{width:38px;height:38px}
568
  .w2-tool:active{-webkit-transform:scale(.9);transform:scale(.9)}
 
683
  .w2-pcar{height:0;padding-bottom:34.6%;bottom:6%}
684
  .w2-badge i{background-color:transparent}
685
  /* 布局(与外观分开,外观见 2.3 版纯 CSS 规则) */
686
+ .w2-dialog{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7;max-height:50%;overflow-y:auto;-webkit-overflow-scrolling:touch;color:#2b1d12;min-height:96px}
687
  .w2-pop-box{position:relative;width:100%;max-width:360px;max-height:80%;overflow-y:auto;color:#2b1d12}
688
  .w2-btn{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px;font-weight:900;transition:transform .12s}
689
  .w2-opt{display:flex;align-items:center;justify-content:center;text-align:center;font-size:14px;font-weight:900;line-height:1.35;transition:transform .12s}
 
717
  .w2-setbtns .w2-btn .w2-ic{width:26px;height:26px;margin-right:6px}
718
  .w2-hud .w2-me{margin-top:30px}
719
  /* ===== 女巫的魔药 第 2.5 版:素材 7 角花 / 饰件 / 按钮宝石 ===== */
720
+ .w2-dlg{position:absolute;left:8px;right:8px;bottom:70px;bottom:calc(env(safe-area-inset-bottom,0px) + 70px);z-index:7}
721
  .w2-dlg .w2-dialog{position:relative;left:auto;right:auto;bottom:auto;z-index:auto;max-height:48vh}
722
  .w2-dialog::after,.w2-pop-box::after{content:none!important}
723
  .w2-c{position:absolute;width:32px;height:32px;background:url(./witch/ui-corner.webp) 0 0/100% 100% no-repeat;pointer-events:none;z-index:3}
 
739
  .w2-opt span{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.35;word-break:break-word;overflow-wrap:anywhere}
740
  .w2-opts.n4 .w2-opt{min-height:60px}
741
  .w2-opts.n4 .w2-opt i{width:46px!important;height:46px!important}
742
+ .w2-dlg{bottom:92px!important;bottom:calc(env(safe-area-inset-bottom,0px) + 92px)!important}
743
  /* 隐藏滚动条(仍可上下滚动) */
744
  .w2-pop-body,.w2-dialog,.w2-sheet *{scrollbar-width:none;-ms-overflow-style:none}
745
  .w2-pop-body::-webkit-scrollbar,.w2-dialog::-webkit-scrollbar,.w2-sheet ::-webkit-scrollbar{width:0;height:0;display:none}
 
760
  .w2-cstage{position:relative;display:block;height:140px;border-radius:10px;background:radial-gradient(circle at 50% 70%,rgba(255,229,138,.35),rgba(255,229,138,0) 65%)}
761
  .w2-cstage .wt-actor{left:50%;bottom:8px}
762
  .wt-actor.hero.gone{opacity:0}
763
+ /* 托盘:更倾斜,像桌面上的一个平面;层级在两个角色之下 */
764
+ .w2-scene .w2-tray{z-index:auto}
765
+ .w2-scene .w2-tray-img{z-index:2}
766
+ .w2-scene .w2-cup{z-index:4}
767
+ .w2-scene .wt-actor{z-index:3;pointer-events:none}
768
+ .w2-scene .wt-fx{z-index:5}
769
+ .w2-tray-img{-webkit-transform-origin:50% 100%;transform-origin:50% 100%;-webkit-transform:perspective(520px) rotateX(52deg);transform:perspective(520px) rotateX(52deg)}
770
+ /* PDF:关注后提示 */
771
+ .pdf-tip{padding:6px 18px 18px}
772
+ .pt-author{display:flex;align-items:center;background:var(--white);border-radius:14px;padding:12px 14px;box-shadow:var(--sticker)}
773
+ .pt-av{width:46px;height:46px;border-radius:23px;flex-shrink:0;background:var(--red-d);color:#fff;font-size:20px;font-weight:900;line-height:46px;text-align:center;margin-right:12px;box-shadow:0 0 0 2.5px #fff,0 3px 8px rgba(23,23,27,.2)}
774
+ .pt-author div{flex:1;min-width:0}
775
+ .pt-author b{display:block;font-size:16px;font-weight:900;line-height:1.4}
776
+ .pt-author small{display:block;font-size:12px;color:var(--muted);font-weight:700}
777
+ .pt-ok{flex-shrink:0;height:30px;line-height:30px;padding:0 12px;border-radius:15px;background:rgba(23,23,27,.07);color:var(--muted);font-size:13px;font-weight:800}
778
+ .pdf-tip h2{font-size:18px;font-weight:900;margin:18px 2px 8px}
779
+ .pt-steps{margin:0;padding:0 0 0 1.3em}
780
+ .pt-steps li{font-size:14.5px;line-height:1.75;margin-bottom:6px}
781
+ .pt-steps b{color:var(--red-d)}
782
+ /* 矮屏:对话框不要太高,角色和托盘不被挡住 */
783
+ @media (max-height:700px){.w2-dlg .w2-dialog{max-height:40vh}.w2-opt{min-height:52px}}
htlb/miniapp/tool/witch.js CHANGED
@@ -92,7 +92,7 @@
92
  return { v: 2, y: 0, phy: 0, look: 0, money: 0, day: '', wrong: 0, unlock: 0, intro: false, combo: 0, seen: {}, ach: {},
93
  today: { right: 0, wrong: 0 }, total: { right: 0, wrong: 0, deaths: 0, revives: 0 }, peak: { m: 0, age: AGE0 }, dead: false, pendingRevive: '', snd: { sfx: true, bgm: true }, gender: '' };
94
  }
95
- var S = blank(), loaded = false, saveT = 0;
96
  function save(now) { clearTimeout(saveT); var go = function () { return B.save('witch2', S); }; if (now) return go(); saveT = setTimeout(go, 200); return Promise.resolve(true); }
97
  function rollDay() { var k = B.today().key; if (S.day !== k) { S.day = k; S.wrong = 0; S.unlock = 0; S.today = { right: 0, wrong: 0 }; save(); } }
98
  B.load('witch2').then(function (d) {
@@ -102,7 +102,8 @@
102
  S.pendingRevive = '';
103
  if (!S.gender && S.intro) S.gender = 'm'; // 老用户:默认男主角
104
  loaded = true; rollDay(); save();
105
- if (B.tab() === 'quiz' && !L) landing();
 
106
  });
107
  function cap() { return WRONG_CAP * (1 + S.unlock); }
108
  function age() { return ageOf(S.y); }
@@ -212,6 +213,7 @@
212
  if (!SND.ctx) return;
213
  try { if (document.hidden) SND.ctx.suspend(); else if (L) SND.ctx.resume(); } catch (e) {}
214
  });
 
215
 
216
  /* ---------------- 精灵 ---------------- */
217
  var pre = {};
@@ -287,7 +289,8 @@
287
  function open(queue) {
288
  whenReady(function () {
289
  if (L) return;
290
- rollDay(); gameMode(true); B.buzz('light'); actx(); musicOn();
 
291
  ['ui-divider', 'ui-tray', 'ui-close', 'cup-1', 'icons', 'frames', 'witch-idle2', 'witch-idle3', actKey() + '-idle2', actKey() + '-idle3', 'fx-good', 'fx-bad', 'fx-change', 'witch-idle', 'witch-appear', 'witch-nod', 'witch-laugh', 'witch-wand', 'witch-stop',
292
  'house-' + moneyStage(), 'car-' + moneyStage(), heroKey() + '-idle', actKey() + '-drink', actKey() + '-good', actKey() + '-bad', faceKey(), who() + '-ride'].forEach(img);
293
  L = B.sheet('w2', { label: '女巫的魔药', render: function (lay) {
@@ -320,20 +323,34 @@
320
  var el = L.el, W = el.offsetWidth || 390, H = el.offsetHeight || 844;
321
  var sc = Math.max(W / 720, H / 1280), ih = 1280 * sc, oy = (H - ih) / 2;
322
  G.W = W; G.H = H; G.ground = oy + ih * 0.62;
 
 
 
 
 
 
323
  var scene = $('#w2-scene', el); scene.style.height = G.ground + 'px';
324
  }
325
  function heroT() { return Math.min(G.H * 0.22, G.W * 0.48); }
326
  function alive() { return L && L.el.parentNode; }
327
  function exitHome() { close(); if (B.tab() !== 'today' && B.go) B.go('today'); window.scrollTo(0, 0); }
 
 
 
 
 
 
 
 
 
 
 
328
  function close() {
329
  if (!L) return;
330
- stopTimer(); if (G) { G.hero.stop(); G.witch.stop(); }
331
- var lay = L; L = null; G = null;
332
- musicOff();
333
- save(); B.close(lay); gameMode(false);
334
  if (B.tab() === 'quiz') (window.__HTLB_CH__ && !STANDALONE ? window.__HTLB_CH__.show() : landing());
335
  }
336
- setInterval(function () { if (L && !L.el.parentNode) { stopTimer(); L = null; G = null; gameMode(false); } }, 800);
337
  function setBg(ms, instant) {
338
  var a = $('#w2-bg', L.el), b = $('#w2-bg2', L.el), url = 'url(' + DIR + 'house-' + ms + '.webp)';
339
  if (instant) { a.style.backgroundImage = url; return; }
@@ -533,16 +550,20 @@
533
  if (k === 3) { B.buzz('medium'); we.classList.remove('pre-in'); we.classList.add('rise-in'); }
534
  if (k === 4) bk.className = 'w2-book';
535
  } });
 
536
  await done; box.innerHTML = '';
 
537
  we.classList.remove('rise-in');
538
  witchIdle();
539
  }
540
  async function bookTapped() {
541
- if (!G || G.mode !== 'story' || !STORY[G.storyK].book) return;
 
542
  B.buzz('medium'); sfx('book');
543
  say('', '……');
544
  await witchAppear();
545
- G.busy = false;
 
546
  story(G.storyK + 1);
547
  }
548
  function storyNext() {
@@ -562,13 +583,16 @@
562
  var tm = SPR['ui-tray'] || { w: 426, h: 219 }, w = Math.min(G.W * (items.length > 2 ? 0.66 : 0.5), 320), h = w * tm.h / tm.w, cw = Math.min(w * 0.8 / items.length, 66);
563
  t.style.display = 'block'; t.style.width = w + 'px'; t.style.height = h + 'px'; t.style.left = (G.W * 0.5 - w / 2) + 'px';
564
  // 矮屏:对话框会盖住托盘时,把托盘抬到对话框上方
565
- setTimeout(function () {
566
- if (!alive()) return;
567
- var d = $('#w2-dialog', L.el), rr = L.el.getBoundingClientRect(), dTop = d.getBoundingClientRect().top - rr.top;
568
- t.style.bottom = (G.ground - (dTop - 2)) + 'px';
569
- }, 60);
 
 
 
570
  t.innerHTML = '<i class="w2-tray-img" style="background-image:url(' + DIR + 'ui-tray.webp)"></i>' + items.map(function (it, i) {
571
- return '<button class="w2-cup" type="button" data-act="wt-cup" data-i="' + i + '" style="left:' + (10 + (i + 0.5) / items.length * 80) + '%;width:' + cw + 'px;height:' + cw + 'px;margin-left:' + (-cw / 2) + 'px;bottom:' + (h * 0.4) + 'px"><i class="smoke" style="' + cupBg(it.k) + '"></i></button>';
572
  }).join('');
573
  G.items = items;
574
  // 选项名牌放在对话框里,带同色小杯子
@@ -584,6 +608,7 @@
584
  stopTimer();
585
  G.mode = 'lobby'; G.busy = false;
586
  showWitch(false); tray([]); setCar(true);
 
587
  $('#w2-hero', L.el).className = 'wt-actor hero lobby';
588
  heroIdle(); refreshHud();
589
  var M = MONEY[moneyStage()], over = S.wrong >= cap();
@@ -618,8 +643,10 @@
618
  setCar(false);
619
  $('#w2-hero', L.el).className = 'wt-actor hero';
620
  if (!G.appeared) {
 
621
  G.appeared = true; tray([]); say('', '书页一闪,女巫飘了出来……');
622
  await witchAppear();
 
623
  }
624
  showWitch(true); witchIdle();
625
  ask();
@@ -638,10 +665,10 @@
638
  }
639
  function stopTimer() { if (G) cancelAnimationFrame(G.timer); }
640
  function startTimer() {
641
- stopTimer();
642
  G.left = ANSWER_SEC * 1000; G.deadline = Date.now() + G.left; G.warned = false;
643
  (function tick() {
644
- if (!alive() || G.busy || G.mode !== 'play') return;
645
  var left = Math.max(0, G.deadline - Date.now()), bar = $('#w2-timer-bar', L.el), num = $('#w2-timer-n', L.el);
646
  if (bar) { bar.style.width = (left / (ANSWER_SEC * 10)) + '%'; bar.className = left < 5000 ? 'low' : ''; }
647
  if (num) num.textContent = Math.ceil(left / 1000);
@@ -652,7 +679,7 @@
652
  })();
653
  }
654
  document.addEventListener('visibilitychange', function () {
655
- if (!G || G.busy || G.mode !== 'play') return;
656
  if (document.hidden) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); }
657
  else { G.deadline = Date.now() + (G.left || 0); startTimerResume(); }
658
  });
@@ -686,22 +713,24 @@
686
  f = document.createElement('i'); f.className = 'wt-fly smoke'; f.setAttribute('style', cupBtn.firstChild.getAttribute('style'));
687
  f.style.left = (from.left - rr.left) + 'px'; f.style.top = (from.top - rr.top) + 'px'; f.style.width = from.width + 'px'; f.style.height = from.height + 'px';
688
  L.el.appendChild(f); cupBtn.style.visibility = 'hidden'; void f.offsetWidth;
689
- var tx = hp.x - (from.left - rr.left + from.width / 2), ty = hp.y + sz * 0.72 - (from.top - rr.top + from.height / 2), sc = sz / from.width;
690
  base = 'translate(' + tx + 'px,' + ty + 'px) scale(' + sc + ')';
691
  f.style.webkitTransform = f.style.transform = base;
692
  B.buzz('light'); sfx('cup');
693
  }
 
694
  await wait(480);
 
695
  await hero(ak + '-drink', 6, false, function (k) {
696
  if (!f) return;
697
  if (k >= 3 && k <= 5) { f.style.webkitTransform = f.style.transform = base + ' rotate(' + (-25 - (k - 3) * 12) + 'deg)'; if (k === 4) { B.buzz('medium'); sfx('gulp'); } }
698
  if (k === 6) f.classList.add('gone');
699
  });
700
  if (f) setTimeout(function () { f.parentNode && f.parentNode.removeChild(f); }, 450);
701
- G.drinking = false;
702
  }
703
  function fx(name, fps) {
704
- var box = $('#w2-fx', L.el); if (!box) return Promise.resolve();
705
  box.innerHTML = '';
706
  var a = new Actor(box, '', heroT() * (name === 'fx-good' ? 1.3 : 1.15));
707
  return a.play(name, { fps: fps || 9 }).then(function () { box.innerHTML = ''; });
@@ -713,9 +742,11 @@
713
  var it = G.items && G.items[i]; if (!it) return;
714
  if (G.mode === 'story') { // 「你准备好了吗?」
715
  G.busy = true; B.buzz('light');
716
- if (it.v === 'no') { say('女巫', '那就等你准备好再来,书我先放这儿。'); await wait(900); close(); return; }
717
- await drinkAnim(i, who() + '-a2p2'); B.buzz('success'); hero(who() + '-a2p2-good', 6).then(heroIdle);
718
- await fx('fx-good', 10);
 
 
719
  G.busy = false; G.appeared = true; start();
720
  return;
721
  }
@@ -723,37 +754,43 @@
723
  }
724
  async function drink(v, i) {
725
  if (!G || G.busy || G.mode !== 'play') return;
 
726
  G.busy = true; stopTimer();
727
  var q = G.q, ok = v === q.a, timeout = v < 0;
728
  $$('.w2-opt', L.el).forEach(function (b, k) { var it = G.items[k]; b.disabled = true; b.classList.add(it.v === q.a ? 'is-right' : it.v === v ? 'is-wrong' : 'is-dim'); });
 
729
  var sn = S.seen[q.qid] || (S.seen[q.qid] = [0, 0, 0]); sn[0]++; if (ok) sn[1]++; sn[2] = Date.now();
730
  var ak = actKey();
 
 
 
 
 
 
 
 
 
 
 
731
  if (!timeout) await drinkAnim(i, ak); else { B.buzz('medium'); await hero(ak + '-drink', 6); }
732
- var before = { hero: heroKey(), ms: moneyStage(), ag: ageGroup(age()) }, delta = ok ? q.lv : -2 * q.lv, what = '';
733
  if (ok) {
734
  B.buzz('success'); sfx('right'); flash();
735
- clearTimeout(G.wIdleT); G.witch.play('witch-nod', { fps: 5 }).then(function () { if (alive()) witchIdle(); });
736
  hero(ak + '-good', 6);
737
  await fx('fx-good', 10);
738
- S.today.right++; S.total.right++; S.combo++;
739
  } else {
740
- B.buzz('error'); sfx('wrong'); setTimeout(function () { sfx('laugh'); }, 350); shake();
741
- clearTimeout(G.wIdleT); G.witch.play('witch-laugh', { fps: 5 }).then(function () { if (alive()) witchIdle(); });
742
  hero(ak + '-bad', 6);
743
  await fx('fx-bad', 9);
744
- S.today.wrong++; S.total.wrong++; S.wrong++; S.combo = 0;
745
  }
746
- if (q.at === 'b') {
747
- var r = Math.random(), sub = r < 0.4 ? 'y' : r < 0.7 ? 'phy' : 'look', a0 = age();
748
- if (sub === 'y') { S.y = Math.max(Y_MIN, Math.min(SUB, S.y + delta)); var da = age() - a0; what = (da < 0 ? '年轻了 ' + (-da).toFixed(1) + ' 岁' : '老了 ' + da.toFixed(1) + ' 岁'); G.bump = ['age', delta]; }
749
- else if (sub === 'phy') { S.phy = Math.max(S_MIN, Math.min(SUB, S.phy + delta)); what = '身材 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['phy', delta]; }
750
- else { S.look = Math.max(S_MIN, Math.min(SUB, S.look + delta)); what = '颜值 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['look', delta]; }
751
- } else { S.money = Math.max(0, Math.min(TOP, S.money + delta)); S.peak.m = Math.max(S.peak.m, S.money); what = '财富 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); G.bump = ['money', delta]; }
752
  var change = '';
753
  if (heroKey() !== before.hero || moneyStage() !== before.ms) change = await transform(before);
 
754
  checkAch();
755
- if (age() >= AGE_MAX - 0.01) { S.dead = true; S.total.deaths++; S.ach.dead = S.ach.dead || Date.now(); }
756
- save(); refreshHud(); if (G.bump) { bump(G.bump[0], G.bump[1]); G.bump = null; }
757
  if (gAll() !== G.lastAll) { if (G.lastAll !== undefined) { B.buzz(gAll() > G.lastAll ? 'success' : 'heavy'); sfx(gAll() > G.lastAll ? 'level' : 'death'); B.toast('综合等级' + (gAll() > G.lastAll ? '提升' : '下降') + ':' + GRADE[gAll()][0] + '色头像框'); } G.lastAll = gAll(); }
758
  if (!S.dead) heroIdle();
759
  var over = !S.dead && S.wrong >= cap();
@@ -778,11 +815,14 @@
778
  }
779
  async function transform(before) {
780
  if (!alive()) return '';
781
- clearTimeout(G.wIdleT); G.witch.play('witch-wand', { fps: 7 }).then(function () { if (alive()) witchIdle(); });
 
782
  await wait(450);
 
783
  sfx('magic');
784
  var p = fx('fx-change', 8), lines = [];
785
  await wait(4 * 125); // 旋涡第 5 帧白光:换形象 / 换房子
 
786
  if (heroKey() !== before.hero) {
787
  heroIdle();
788
  var ag = ageGroup(age());
@@ -794,6 +834,7 @@
794
  lines.push((ms > before.ms ? '发财了!' : '变穷了……') + '现在住' + MONEY[ms].house + ',开' + MONEY[ms].car);
795
  }
796
  await p;
 
797
  vibrateLong();
798
  return lines.join('<br>');
799
  }
@@ -801,6 +842,7 @@
801
  /* ---------------- 喝错满 10 杯 ---------------- */
802
  function capPopup() {
803
  if (!alive()) return;
 
804
  stopTimer(); G.mode = 'cap'; G.busy = true;
805
  showWitch(true); tray([]);
806
  sfx('stop');
@@ -823,7 +865,7 @@
823
  vibrateLong(); sfx('death'); tray([]);
824
  $('#w2-hero', L.el).className = 'wt-actor hero dead';
825
  G.hero.stop(); G.hero.frame(heroKey() + '-idle', 0);
826
- say('女巫', '魔药喝错太多,你已经 ' + ageTxt() + ' 岁,寿终正寝了……', '');
827
  var mini = B.mini(), canComment = !!(mini && typeof mini.interactionOpenApi === 'function');
828
  popup('寿终正寝……', '<p>晒一下你的人生账单,女巫会把你变回 22 岁(金钱保留),不限次数。</p>' + shareRows('revive', canComment) +
829
  '<button class="w2-btn ghost wide" type="button" data-act="wt-forget">喝下「遗忘之药水」,重新投胎</button>');
@@ -837,12 +879,18 @@
837
  } else { S.unlock++; S.ach.unlock = S.ach.unlock || Date.now(); B.toast('女巫又给你备好了 10 杯魔药'); }
838
  save(true); B.buzz('success');
839
  closePopup();
840
- if (alive()) { refreshHud(); lobby(); }
841
  }
842
 
843
  /* ---------------- 弹窗(游戏风格;点空白处关闭) ---------------- */
 
 
 
 
 
 
844
  function popup(title, body, cls) {
845
- closePopup();
846
  var p = document.createElement('div'); p.className = 'w2-pop' + (cls ? ' ' + cls : ''); p.id = 'w2-pop';
847
  var x = SPR['ui-close'] ? '<i style="' + bg('ui-close') + '"></i>' : '✕';
848
  p.innerHTML = '<div class="w2-pop-box rise">' + DECO + (title ? '<div class="w2-title">' + title + '</div>' : '') + '<div class="w2-pop-body">' + body + '</div><button class="w2-pop-x" type="button" data-act="wt-popclose" aria-label="关闭">' + x + '</button></div>';
@@ -855,7 +903,7 @@
855
  L.el.appendChild(t); clearTimeout(G.tipT);
856
  G.tipT = setTimeout(function () { t.classList.add('out'); setTimeout(function () { t.parentNode && t.parentNode.removeChild(t); }, 300); }, 2000);
857
  }
858
- function closePopup() { var p = L && $('#w2-pop', L.el); if (p) { p.parentNode.removeChild(p); sfx('close'); } if (G && G.panelA) { G.panelA.stop(); G.panelA = null; } }
859
  function badge(a, got) {
860
  var art = SPR['badge-' + a[0]] ? '<i style="' + bg('badge-' + a[0]) + '"></i>' : '<i class="t">' + a[1].slice(0, 1) + '</i>';
861
  return '<button class="w2-badge' + (got ? ' got' : '') + '" type="button" data-act="wt-badge" data-id="' + a[0] + '">' + art + '<span>' + a[1] + '</span></button>';
@@ -871,8 +919,9 @@
871
  '<h4>每天的限制</h4><p>每天最多喝错 10 杯。超过后,晒一下人生账单(发图文、做成图集或发评论)可以再喝 10 杯,不限次数;也可以第二天再来。</p>' +
872
  '<h4>寿终</h4><p>晒人生账单可以复活:回到 22 岁,身材、颜值回到普通,财富保留。也可以喝下遗忘之药水,全部清零重来。</p></div>';
873
  function toolTap(k) {
 
 
874
  B.buzz('light'); sfx('tap');
875
- if (k === 'exit') { exitHome(); return; }
876
  if (k === 'share') { share('note', ''); return; }
877
  if (k === 'ach') {
878
  var n = 0; ACH.forEach(function (a) { if (S.ach[a[0]]) n++; });
@@ -1008,7 +1057,7 @@
1008
  case 'wt-cup': cupPicked(Number(el.getAttribute('data-i'))); break;
1009
  case 'wt-start': start(); break;
1010
  case 'wt-skip': if (G) { $('#w2-book', L.el).className = 'w2-book'; $('#w2-hero', L.el).className = 'wt-actor hero'; G.busy = false; lobby(); } break;
1011
- case 'wt-next': if (G) { G.busy = false; ask(); } break;
1012
  case 'wt-cap': capPopup(); break;
1013
  case 'wt-death': death(); break;
1014
  case 'wt-share': share(el.getAttribute('data-k'), el.getAttribute('data-why') || ''); break;
@@ -1022,7 +1071,7 @@
1022
  B.buzz('light'); sfx('tap');
1023
  break;
1024
  case 'wt-friend': S.ach.bill = S.ach.bill || Date.now(); afterShare('unlock'); break;
1025
- case 'wt-replay': closePopup(); G.appeared = false; story(0); break;
1026
  case 'wt-badge':
1027
  var aa = ACH.filter(function (x) { return x[0] === el.getAttribute('data-id'); })[0];
1028
  if (aa) { var gt = S.ach[aa[0]]; centerTip('<b>' + aa[1] + '</b><br>' + aa[2] + '<br><small>' + (gt ? new Date(gt).toLocaleDateString() + ' 获得' : '未获得') + '</small>'); B.buzz('light'); }
@@ -1031,10 +1080,11 @@
1031
  case 'wt-orig': B.openDetail(el.getAttribute('data-id')); break;
1032
  case 'wt-popclose': closePopup(); if (el.getAttribute('data-then') === 'lobby') lobby(); break;
1033
  case 'wt-forget':
 
1034
  if (Date.now() - forgetAt < 2500) {
1035
  var keep = S.intro, keepSnd = S.snd; S = blank(); S.intro = keep; S.snd = keepSnd; loaded = true; rollDay(); save(true); forgetAt = 0;
1036
  B.toast('喝下遗忘之药水:一切从 22 岁重新开始,重新选择你的角色');
1037
- if (alive()) { closePopup(); $('#w2-hero', L.el).className = 'wt-actor hero'; setBg(0, true); refreshHud(); chooseGender(function () { lobby(); }); }
1038
  } else { forgetAt = Date.now(); B.toast('再点一次,喝下遗忘之药水(年龄、身材、颜值、金钱、成就全部清零)'); }
1039
  break;
1040
  }
@@ -1052,7 +1102,7 @@
1052
  // 「女巫的魔药」版:冒险页与「去喝魔药」入口
1053
  if (STANDALONE) {
1054
  window.__HTLB_CH__ = { show: function () { landing(); if (!L) open(); }, act: function (a, el) {
1055
- if (a === 'ch-item') { var l = (BY_ADV[el.getAttribute('data-id')] || []).slice(); var tp; while ((tp = B.top())) B.close(tp); open(l); }
1056
  }, bankSize: function () { return ALL.length; } };
1057
  }
1058
  })();
 
92
  return { v: 2, y: 0, phy: 0, look: 0, money: 0, day: '', wrong: 0, unlock: 0, intro: false, combo: 0, seen: {}, ach: {},
93
  today: { right: 0, wrong: 0 }, total: { right: 0, wrong: 0, deaths: 0, revives: 0 }, peak: { m: 0, age: AGE0 }, dead: false, pendingRevive: '', snd: { sfx: true, bgm: true }, gender: '' };
94
  }
95
+ var S = blank(), loaded = false, saveT = 0, loadWait = [];
96
  function save(now) { clearTimeout(saveT); var go = function () { return B.save('witch2', S); }; if (now) return go(); saveT = setTimeout(go, 200); return Promise.resolve(true); }
97
  function rollDay() { var k = B.today().key; if (S.day !== k) { S.day = k; S.wrong = 0; S.unlock = 0; S.today = { right: 0, wrong: 0 }; save(); } }
98
  B.load('witch2').then(function (d) {
 
102
  S.pendingRevive = '';
103
  if (!S.gender && S.intro) S.gender = 'm'; // 老用户:默认男主角
104
  loaded = true; rollDay(); save();
105
+ var lw = loadWait; loadWait = []; lw.forEach(function (f) { try { f(); } catch (e) {} });
106
+ if (B.tab() === 'quiz' && !L && !lw.length) landing();
107
  });
108
  function cap() { return WRONG_CAP * (1 + S.unlock); }
109
  function age() { return ageOf(S.y); }
 
213
  if (!SND.ctx) return;
214
  try { if (document.hidden) SND.ctx.suspend(); else if (L) SND.ctx.resume(); } catch (e) {}
215
  });
216
+ document.addEventListener('visibilitychange', function () { if (document.hidden && loaded) save(true); });
217
 
218
  /* ---------------- 精灵 ---------------- */
219
  var pre = {};
 
289
  function open(queue) {
290
  whenReady(function () {
291
  if (L) return;
292
+ if (!loaded) { if (!loadWait.length) loadWait.push(function () { open(queue); }); return; }
293
+ rollDay(); gameMode(true); B.buzz('light'); var ac = actx(); try { if (ac && ac.state === 'suspended') ac.resume(); } catch (e) {} musicOn();
294
  ['ui-divider', 'ui-tray', 'ui-close', 'cup-1', 'icons', 'frames', 'witch-idle2', 'witch-idle3', actKey() + '-idle2', actKey() + '-idle3', 'fx-good', 'fx-bad', 'fx-change', 'witch-idle', 'witch-appear', 'witch-nod', 'witch-laugh', 'witch-wand', 'witch-stop',
295
  'house-' + moneyStage(), 'car-' + moneyStage(), heroKey() + '-idle', actKey() + '-drink', actKey() + '-good', actKey() + '-bad', faceKey(), who() + '-ride'].forEach(img);
296
  L = B.sheet('w2', { label: '女巫的魔药', render: function (lay) {
 
323
  var el = L.el, W = el.offsetWidth || 390, H = el.offsetHeight || 844;
324
  var sc = Math.max(W / 720, H / 1280), ih = 1280 * sc, oy = (H - ih) / 2;
325
  G.W = W; G.H = H; G.ground = oy + ih * 0.62;
326
+ var lim = H - 92 - 228, bgs = [$('#w2-bg', el), $('#w2-bg2', el)];
327
+ if (lim < G.ground) { // 矮屏:对话框会挡住脚,整幅画面(背景 + 角色)一起上移
328
+ var ih2 = Math.max(ih, (H - lim) / 0.38), oy2 = lim - ih2 * 0.62;
329
+ G.ground = lim;
330
+ bgs.forEach(function (b) { if (b) { b.style.backgroundSize = (720 * ih2 / 1280) + 'px ' + ih2 + 'px'; b.style.backgroundPosition = '50% ' + oy2 + 'px'; } });
331
+ } else bgs.forEach(function (b) { if (b) { b.style.backgroundSize = ''; b.style.backgroundPosition = ''; } });
332
  var scene = $('#w2-scene', el); scene.style.height = G.ground + 'px';
333
  }
334
  function heroT() { return Math.min(G.H * 0.22, G.W * 0.48); }
335
  function alive() { return L && L.el.parentNode; }
336
  function exitHome() { close(); if (B.tab() !== 'today' && B.go) B.go('today'); window.scrollTo(0, 0); }
337
+ function teardown() {
338
+ stopTimer();
339
+ if (G) {
340
+ G.hero.stop(); G.witch.stop(); if (G.panelA) G.panelA.stop();
341
+ (G.chooseA || []).forEach(function (a) { a.stop(); });
342
+ clearInterval(G.typer); clearTimeout(G.hIdleT); clearTimeout(G.wIdleT); clearTimeout(G.tipT);
343
+ }
344
+ L = null; G = null;
345
+ musicOff(); save(true); gameMode(false);
346
+ setTimeout(function () { try { if (!L && SND.ctx && SND.ctx.state === 'running') SND.ctx.suspend(); } catch (e) {} }, 700);
347
+ }
348
  function close() {
349
  if (!L) return;
350
+ var lay = L; teardown(); B.close(lay);
 
 
 
351
  if (B.tab() === 'quiz') (window.__HTLB_CH__ && !STANDALONE ? window.__HTLB_CH__.show() : landing());
352
  }
353
+ setInterval(function () { if (L && !L.el.parentNode) teardown(); }, 800);
354
  function setBg(ms, instant) {
355
  var a = $('#w2-bg', L.el), b = $('#w2-bg2', L.el), url = 'url(' + DIR + 'house-' + ms + '.webp)';
356
  if (instant) { a.style.backgroundImage = url; return; }
 
550
  if (k === 3) { B.buzz('medium'); we.classList.remove('pre-in'); we.classList.add('rise-in'); }
551
  if (k === 4) bk.className = 'w2-book';
552
  } });
553
+ var g = G;
554
  await done; box.innerHTML = '';
555
+ if (G !== g) return;
556
  we.classList.remove('rise-in');
557
  witchIdle();
558
  }
559
  async function bookTapped() {
560
+ if (!G || G.mode !== 'story' || !STORY[G.storyK].book || G.bookBusy) return;
561
+ var g = G; g.bookBusy = true;
562
  B.buzz('medium'); sfx('book');
563
  say('', '……');
564
  await witchAppear();
565
+ if (G !== g) return;
566
+ g.bookBusy = false; G.busy = false;
567
  story(G.storyK + 1);
568
  }
569
  function storyNext() {
 
583
  var tm = SPR['ui-tray'] || { w: 426, h: 219 }, w = Math.min(G.W * (items.length > 2 ? 0.66 : 0.5), 320), h = w * tm.h / tm.w, cw = Math.min(w * 0.8 / items.length, 66);
584
  t.style.display = 'block'; t.style.width = w + 'px'; t.style.height = h + 'px'; t.style.left = (G.W * 0.5 - w / 2) + 'px';
585
  // 矮屏:对话框会盖住托盘时,把托盘抬到对话框上方
586
+ // 对话框打字时会长高,多量几次,托盘始终贴在对话框上沿
587
+ [60, 400, 900, 1600].forEach(function (ms) {
588
+ setTimeout(function () {
589
+ if (!alive() || !G || t.style.display === 'none') return;
590
+ var d = $('#w2-dialog', L.el), rr = L.el.getBoundingClientRect(), dTop = d.getBoundingClientRect().top - rr.top;
591
+ t.style.bottom = (G.ground - (dTop - 4)) + 'px';
592
+ }, ms);
593
+ });
594
  t.innerHTML = '<i class="w2-tray-img" style="background-image:url(' + DIR + 'ui-tray.webp)"></i>' + items.map(function (it, i) {
595
+ return '<button class="w2-cup" type="button" data-act="wt-cup" data-i="' + i + '" style="left:' + (10 + (i + 0.5) / items.length * 80) + '%;width:' + cw + 'px;height:' + cw + 'px;margin-left:' + (-cw / 2) + 'px;bottom:' + (h * 0.2) + 'px"><i class="smoke" style="' + cupBg(it.k) + '"></i></button>';
596
  }).join('');
597
  G.items = items;
598
  // 选项名牌放在对话框里,带同色小杯子
 
608
  stopTimer();
609
  G.mode = 'lobby'; G.busy = false;
610
  showWitch(false); tray([]); setCar(true);
611
+ rollDay();
612
  $('#w2-hero', L.el).className = 'wt-actor hero lobby';
613
  heroIdle(); refreshHud();
614
  var M = MONEY[moneyStage()], over = S.wrong >= cap();
 
643
  setCar(false);
644
  $('#w2-hero', L.el).className = 'wt-actor hero';
645
  if (!G.appeared) {
646
+ var g = G;
647
  G.appeared = true; tray([]); say('', '书页一闪,女巫飘了出来……');
648
  await witchAppear();
649
+ if (G !== g) return;
650
  }
651
  showWitch(true); witchIdle();
652
  ask();
 
665
  }
666
  function stopTimer() { if (G) cancelAnimationFrame(G.timer); }
667
  function startTimer() {
668
+ stopTimer(); G.paused = false;
669
  G.left = ANSWER_SEC * 1000; G.deadline = Date.now() + G.left; G.warned = false;
670
  (function tick() {
671
+ if (!alive() || G.busy || G.paused || G.mode !== 'play') return;
672
  var left = Math.max(0, G.deadline - Date.now()), bar = $('#w2-timer-bar', L.el), num = $('#w2-timer-n', L.el);
673
  if (bar) { bar.style.width = (left / (ANSWER_SEC * 10)) + '%'; bar.className = left < 5000 ? 'low' : ''; }
674
  if (num) num.textContent = Math.ceil(left / 1000);
 
679
  })();
680
  }
681
  document.addEventListener('visibilitychange', function () {
682
+ if (!G || G.busy || G.paused || G.mode !== 'play') return;
683
  if (document.hidden) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); }
684
  else { G.deadline = Date.now() + (G.left || 0); startTimerResume(); }
685
  });
 
713
  f = document.createElement('i'); f.className = 'wt-fly smoke'; f.setAttribute('style', cupBtn.firstChild.getAttribute('style'));
714
  f.style.left = (from.left - rr.left) + 'px'; f.style.top = (from.top - rr.top) + 'px'; f.style.width = from.width + 'px'; f.style.height = from.height + 'px';
715
  L.el.appendChild(f); cupBtn.style.visibility = 'hidden'; void f.offsetWidth;
716
+ var tx = hp.x - (from.left - rr.left + from.width / 2), ty = hp.y + sz * 0.55 - (from.top - rr.top + from.height / 2), sc = sz / from.width;
717
  base = 'translate(' + tx + 'px,' + ty + 'px) scale(' + sc + ')';
718
  f.style.webkitTransform = f.style.transform = base;
719
  B.buzz('light'); sfx('cup');
720
  }
721
+ var g = G;
722
  await wait(480);
723
+ if (G !== g) return;
724
  await hero(ak + '-drink', 6, false, function (k) {
725
  if (!f) return;
726
  if (k >= 3 && k <= 5) { f.style.webkitTransform = f.style.transform = base + ' rotate(' + (-25 - (k - 3) * 12) + 'deg)'; if (k === 4) { B.buzz('medium'); sfx('gulp'); } }
727
  if (k === 6) f.classList.add('gone');
728
  });
729
  if (f) setTimeout(function () { f.parentNode && f.parentNode.removeChild(f); }, 450);
730
+ if (G === g) G.drinking = false;
731
  }
732
  function fx(name, fps) {
733
+ var box = alive() && $('#w2-fx', L.el); if (!box) return Promise.resolve();
734
  box.innerHTML = '';
735
  var a = new Actor(box, '', heroT() * (name === 'fx-good' ? 1.3 : 1.15));
736
  return a.play(name, { fps: fps || 9 }).then(function () { box.innerHTML = ''; });
 
742
  var it = G.items && G.items[i]; if (!it) return;
743
  if (G.mode === 'story') { // 「你准备好了吗?」
744
  G.busy = true; B.buzz('light');
745
+ var g = G;
746
+ if (it.v === 'no') { say('女巫', '那就等你准备好再来,书我先放这儿。'); await wait(900); if (G === g) close(); return; }
747
+ await drinkAnim(i, who() + '-a2p2'); if (G !== g) return;
748
+ B.buzz('success'); hero(who() + '-a2p2-good', 6).then(function () { if (G === g) heroIdle(); });
749
+ await fx('fx-good', 10); if (G !== g) return;
750
  G.busy = false; G.appeared = true; start();
751
  return;
752
  }
 
754
  }
755
  async function drink(v, i) {
756
  if (!G || G.busy || G.mode !== 'play') return;
757
+ var g = G;
758
  G.busy = true; stopTimer();
759
  var q = G.q, ok = v === q.a, timeout = v < 0;
760
  $$('.w2-opt', L.el).forEach(function (b, k) { var it = G.items[k]; b.disabled = true; b.classList.add(it.v === q.a ? 'is-right' : it.v === v ? 'is-wrong' : 'is-dim'); });
761
+ // 先结算并存档,再播动画:中途退出也照样算数
762
  var sn = S.seen[q.qid] || (S.seen[q.qid] = [0, 0, 0]); sn[0]++; if (ok) sn[1]++; sn[2] = Date.now();
763
  var ak = actKey();
764
+ var before = { hero: heroKey(), ms: moneyStage(), ag: ageGroup(age()) }, delta = ok ? q.lv : -2 * q.lv, what = '', bmp = null;
765
+ if (ok) { S.today.right++; S.total.right++; S.combo++; }
766
+ else { S.today.wrong++; S.total.wrong++; S.wrong++; S.combo = 0; }
767
+ if (q.at === 'b') {
768
+ var r = Math.random(), sub = r < 0.4 ? 'y' : r < 0.7 ? 'phy' : 'look', a0 = age();
769
+ if (sub === 'y') { S.y = Math.max(Y_MIN, Math.min(SUB, S.y + delta)); var da = age() - a0; what = da < -0.05 ? '年轻了 ' + (-da).toFixed(1) + ' 岁' : da > 0.05 ? '老了 ' + da.toFixed(1) + ' 岁' : '年龄 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['age', delta]; }
770
+ else if (sub === 'phy') { S.phy = Math.max(S_MIN, Math.min(SUB, S.phy + delta)); what = '身材 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['phy', delta]; }
771
+ else { S.look = Math.max(S_MIN, Math.min(SUB, S.look + delta)); what = '颜值 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['look', delta]; }
772
+ } else { S.money = Math.max(0, Math.min(TOP, S.money + delta)); S.peak.m = Math.max(S.peak.m, S.money); what = '财富 ' + (delta > 0 ? '+' : '−') + Math.abs(delta); bmp = ['money', delta]; }
773
+ if (age() >= AGE_MAX - 0.01) { S.dead = true; S.total.deaths++; S.ach.dead = S.ach.dead || Date.now(); }
774
+ save(true);
775
  if (!timeout) await drinkAnim(i, ak); else { B.buzz('medium'); await hero(ak + '-drink', 6); }
776
+ if (G !== g) { checkAch(); save(true); return; }
777
  if (ok) {
778
  B.buzz('success'); sfx('right'); flash();
779
+ clearTimeout(G.wIdleT); G.witch.play('witch-nod', { fps: 5 }).then(function () { if (G === g) witchIdle(); });
780
  hero(ak + '-good', 6);
781
  await fx('fx-good', 10);
 
782
  } else {
783
+ B.buzz('error'); sfx('wrong'); setTimeout(function () { if (G === g) sfx('laugh'); }, 350); shake();
784
+ clearTimeout(G.wIdleT); G.witch.play('witch-laugh', { fps: 5 }).then(function () { if (G === g) witchIdle(); });
785
  hero(ak + '-bad', 6);
786
  await fx('fx-bad', 9);
 
787
  }
788
+ if (G !== g) { checkAch(); save(true); return; }
 
 
 
 
 
789
  var change = '';
790
  if (heroKey() !== before.hero || moneyStage() !== before.ms) change = await transform(before);
791
+ if (G !== g) { checkAch(); save(true); return; }
792
  checkAch();
793
+ save(); refreshHud(); if (bmp) bump(bmp[0], bmp[1]);
 
794
  if (gAll() !== G.lastAll) { if (G.lastAll !== undefined) { B.buzz(gAll() > G.lastAll ? 'success' : 'heavy'); sfx(gAll() > G.lastAll ? 'level' : 'death'); B.toast('综合等级' + (gAll() > G.lastAll ? '提升' : '下降') + ':' + GRADE[gAll()][0] + '色头像框'); } G.lastAll = gAll(); }
795
  if (!S.dead) heroIdle();
796
  var over = !S.dead && S.wrong >= cap();
 
815
  }
816
  async function transform(before) {
817
  if (!alive()) return '';
818
+ var g = G;
819
+ clearTimeout(G.wIdleT); G.witch.play('witch-wand', { fps: 7 }).then(function () { if (G === g) witchIdle(); });
820
  await wait(450);
821
+ if (G !== g) return '';
822
  sfx('magic');
823
  var p = fx('fx-change', 8), lines = [];
824
  await wait(4 * 125); // 旋涡第 5 帧白光:换形象 / 换房子
825
+ if (G !== g) return '';
826
  if (heroKey() !== before.hero) {
827
  heroIdle();
828
  var ag = ageGroup(age());
 
834
  lines.push((ms > before.ms ? '发财了!' : '变穷了……') + '现在住' + MONEY[ms].house + ',开' + MONEY[ms].car);
835
  }
836
  await p;
837
+ if (G !== g) return '';
838
  vibrateLong();
839
  return lines.join('<br>');
840
  }
 
842
  /* ---------------- 喝错满 10 杯 ---------------- */
843
  function capPopup() {
844
  if (!alive()) return;
845
+ rollDay(); if (S.dead) { death(); return; } if (S.wrong < cap()) { G.busy = false; lobby(); return; }
846
  stopTimer(); G.mode = 'cap'; G.busy = true;
847
  showWitch(true); tray([]);
848
  sfx('stop');
 
865
  vibrateLong(); sfx('death'); tray([]);
866
  $('#w2-hero', L.el).className = 'wt-actor hero dead';
867
  G.hero.stop(); G.hero.frame(heroKey() + '-idle', 0);
868
+ say('女巫', '魔药喝错太多,你已经 ' + ageTxt() + ' 岁,寿终正寝了……', '<button class="w2-btn" type="button" data-act="wt-death">晒账单复活</button>');
869
  var mini = B.mini(), canComment = !!(mini && typeof mini.interactionOpenApi === 'function');
870
  popup('寿终正寝……', '<p>晒一下你的人生账单,女巫会把你变回 22 岁(金钱保留),不限次数。</p>' + shareRows('revive', canComment) +
871
  '<button class="w2-btn ghost wide" type="button" data-act="wt-forget">喝下「遗忘之药水」,重新投胎</button>');
 
879
  } else { S.unlock++; S.ach.unlock = S.ach.unlock || Date.now(); B.toast('女巫又给你备好了 10 杯魔药'); }
880
  save(true); B.buzz('success');
881
  closePopup();
882
+ if (alive()) { G.lastAll = gAll(); G.busy = false; refreshHud(); lobby(); }
883
  }
884
 
885
  /* ---------------- 弹窗(游戏风格;点空白处关闭) ---------------- */
886
+ function pauseTimer() {
887
+ if (G && G.mode === 'play' && !G.busy && !G.paused) { G.left = Math.max(0, G.deadline - Date.now()); cancelAnimationFrame(G.timer); G.paused = true; }
888
+ }
889
+ function resumeTimer() {
890
+ if (G && G.paused) { G.paused = false; if (G.mode === 'play' && !G.busy && alive()) startTimerResume(); }
891
+ }
892
  function popup(title, body, cls) {
893
+ closePopup(); pauseTimer();
894
  var p = document.createElement('div'); p.className = 'w2-pop' + (cls ? ' ' + cls : ''); p.id = 'w2-pop';
895
  var x = SPR['ui-close'] ? '<i style="' + bg('ui-close') + '"></i>' : '✕';
896
  p.innerHTML = '<div class="w2-pop-box rise">' + DECO + (title ? '<div class="w2-title">' + title + '</div>' : '') + '<div class="w2-pop-body">' + body + '</div><button class="w2-pop-x" type="button" data-act="wt-popclose" aria-label="关闭">' + x + '</button></div>';
 
903
  L.el.appendChild(t); clearTimeout(G.tipT);
904
  G.tipT = setTimeout(function () { t.classList.add('out'); setTimeout(function () { t.parentNode && t.parentNode.removeChild(t); }, 300); }, 2000);
905
  }
906
+ function closePopup() { var p = L && $('#w2-pop', L.el); if (p) { p.parentNode.removeChild(p); sfx('close'); } if (G && G.panelA) { G.panelA.stop(); G.panelA = null; } resumeTimer(); }
907
  function badge(a, got) {
908
  var art = SPR['badge-' + a[0]] ? '<i style="' + bg('badge-' + a[0]) + '"></i>' : '<i class="t">' + a[1].slice(0, 1) + '</i>';
909
  return '<button class="w2-badge' + (got ? ' got' : '') + '" type="button" data-act="wt-badge" data-id="' + a[0] + '">' + art + '<span>' + a[1] + '</span></button>';
 
919
  '<h4>每天的限制</h4><p>每天最多喝错 10 杯。超过后,晒一下人生账单(发图文、做成图集或发评论)可以再喝 10 杯,不限次数;也可以第二天再来。</p>' +
920
  '<h4>寿终</h4><p>晒人生账单可以复活:回到 22 岁,身材、颜值回到普通,财富保留。也可以喝下遗忘之药水,全部清零重来。</p></div>';
921
  function toolTap(k) {
922
+ if (k === 'exit') { B.buzz('light'); sfx('tap'); exitHome(); return; }
923
+ if (G && G.busy && (G.mode === 'play' || G.mode === 'choose')) return;
924
  B.buzz('light'); sfx('tap');
 
925
  if (k === 'share') { share('note', ''); return; }
926
  if (k === 'ach') {
927
  var n = 0; ACH.forEach(function (a) { if (S.ach[a[0]]) n++; });
 
1057
  case 'wt-cup': cupPicked(Number(el.getAttribute('data-i'))); break;
1058
  case 'wt-start': start(); break;
1059
  case 'wt-skip': if (G) { $('#w2-book', L.el).className = 'w2-book'; $('#w2-hero', L.el).className = 'wt-actor hero'; G.busy = false; lobby(); } break;
1060
+ case 'wt-next': if (G) { rollDay(); if (S.wrong >= cap()) { capPopup(); break; } G.busy = false; ask(); } break;
1061
  case 'wt-cap': capPopup(); break;
1062
  case 'wt-death': death(); break;
1063
  case 'wt-share': share(el.getAttribute('data-k'), el.getAttribute('data-why') || ''); break;
 
1071
  B.buzz('light'); sfx('tap');
1072
  break;
1073
  case 'wt-friend': S.ach.bill = S.ach.bill || Date.now(); afterShare('unlock'); break;
1074
+ case 'wt-replay': if (!G || G.busy && G.mode === 'play') break; closePopup(); G.appeared = false; story(0); break;
1075
  case 'wt-badge':
1076
  var aa = ACH.filter(function (x) { return x[0] === el.getAttribute('data-id'); })[0];
1077
  if (aa) { var gt = S.ach[aa[0]]; centerTip('<b>' + aa[1] + '</b><br>' + aa[2] + '<br><small>' + (gt ? new Date(gt).toLocaleDateString() + ' 获得' : '未获得') + '</small>'); B.buzz('light'); }
 
1080
  case 'wt-orig': B.openDetail(el.getAttribute('data-id')); break;
1081
  case 'wt-popclose': closePopup(); if (el.getAttribute('data-then') === 'lobby') lobby(); break;
1082
  case 'wt-forget':
1083
+ if (G && G.busy && G.mode === 'play') break;
1084
  if (Date.now() - forgetAt < 2500) {
1085
  var keep = S.intro, keepSnd = S.snd; S = blank(); S.intro = keep; S.snd = keepSnd; loaded = true; rollDay(); save(true); forgetAt = 0;
1086
  B.toast('喝下遗忘之药水:一切从 22 岁重新开始,重新选择你的角色');
1087
+ if (alive()) { G.lastAll = gAll(); G.appeared = false; closePopup(); $('#w2-hero', L.el).className = 'wt-actor hero'; setBg(0, true); refreshHud(); chooseGender(function () { lobby(); }); }
1088
  } else { forgetAt = Date.now(); B.toast('再点一次,喝下遗忘之药水(年龄、身材、颜值、金钱、成就全部清零)'); }
1089
  break;
1090
  }
 
1102
  // 「女巫的魔药」版:冒险页与「去喝魔药」入口
1103
  if (STANDALONE) {
1104
  window.__HTLB_CH__ = { show: function () { landing(); if (!L) open(); }, act: function (a, el) {
1105
+ if (a === 'ch-item') { var l = (BY_ADV[el.getAttribute('data-id')] || []).slice(); if (L) teardown(); var tp; while ((tp = B.top())) B.close(tp); open(l); }
1106
  }, bankSize: function () { return ALL.length; } };
1107
  }
1108
  })();
htlb/miniapp/高性价比人生-女巫的魔药版.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:02a66021792fcbae3d5f3aae13a7cbacab2175dc42e9897d148cd6c1549f06b3
3
- size 9059265
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90ab7f190b8b00036b6a526fbb7adc8a273132417cd29226e71812a7cf5e5997
3
+ size 9060854
htlb/miniapp/高性价比人生-红薯冒险版.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:365552c376efb70129cc21e036eeccf2487b57eda35d9ad7640aeb82b6f9a236
3
- size 3850612
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90e0b0f1dab966c25aa9b0c18746b853288cfe37d6826b990e12313678cbb426
3
+ size 3851384