dsh-blackjack 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { stakeLine, outcomeLine } from '../copy.js';
4
+ import { CONSENT_TEXT } from '../render.js';
4
5
  const SUITS = { S: '♠', H: '♥', D: '♦', C: '♣' };
5
6
  const RED_SUITS = new Set(['H', 'D']);
6
7
  const n = (v) => v.toLocaleString('en-US');
@@ -70,8 +71,14 @@ function HandRow({ hand, label }) {
70
71
  function DealerRow({ dealer }) {
71
72
  return (_jsxs("div", { children: [_jsxs("div", { className: "bj-meta", children: ["\u5E84\u5BB6", dealer.total !== undefined ? `(${dealer.total})` : ''] }), _jsx("div", { className: "bj-hand", children: dealer.cards.map((card, i) => (_jsx(CardFace, { card: card }, i))) })] }));
72
73
  }
74
+ /**
75
+ * 同意前的界面。**必须把须知全文渲染出来**——原先这里只写"阅读并同意规则"却
76
+ * 不显示规则,GUI 用户从头到尾没见过条款就被引导去同意,那份须知(第三方声明、
77
+ * 不可提现、不可转让、赛季有效期)也就失去了意义。同意动作仍然只能在命令行
78
+ * 完成:牌桌上不放"同意"按钮,避免一次误点就代表接受条款。
79
+ */
73
80
  function ConsentPrompt() {
74
- return (_jsx("div", { className: "bj-table", children: _jsxs("p", { children: ["\u8BF7\u5148\u5728\u547D\u4EE4\u884C\u8F93\u5165 ", _jsx("code", { children: "/blackjack agree" }), "\uFF0C\u9605\u8BFB\u5E76\u540C\u610F\u89C4\u5219\u540E\u624D\u80FD\u5F00\u59CB\u3002"] }) }));
81
+ return (_jsx("div", { className: "bj-table", children: _jsx("div", { style: { whiteSpace: 'pre-wrap' }, children: CONSENT_TEXT }) }));
75
82
  }
76
83
  /**
77
84
  * 余额条。除了数字,还必须回答"赢来的 CHIP 有什么用"——只用图形界面的人此前
package/dist/client.js CHANGED
@@ -3,7 +3,8 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
- "use strict";var C=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var i in n)C(e,i,{get:n[i],enumerable:!0})},B=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of V(n))!$.call(e,a)&&a!==i&&C(e,a,{get:()=>n[a],enumerable:!(o=P(n,a))||o.enumerable});return e};var D=e=>B(C({},"__esModule",{value:!0}),e);var ae={};L(ae,{apply:()=>oe,inject:()=>te});module.exports=D(ae);var l=require("react");var j=require("react");var m=e=>e.toLocaleString("en-US");function y(e){return e.mode==="free"?`\u8FD9\u662F\u514D\u8D39\u7684\u4E00\u5C40\uFF1A\u8D62\u4E86\u62FF ${m(e.betChips)} CHIP\uFF0C\u8F93\u4E86\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002`:`\u672C\u5C40\u5DF2\u52A0\u6CE8 ${m(e.betChips)} CHIP\uFF0C\u4ECE\u4F60\u7684\u4F59\u989D\u91CC\u51FA\u3002`}function w(e){let n=e.payoutChips??0,i=e.betChips;return e.hands.length>0&&e.hands.every(o=>o.outcome==="push")?e.mode==="free"?"\u5E73\u5C40\u3002\u8FD9\u624B\u4E0D\u635F\u5931\u4E5F\u4E0D\u83B7\u5F97\u3002":`\u5E73\u5C40\u3002\u52A0\u6CE8\u7684 ${m(i)} CHIP \u539F\u6837\u9000\u56DE\u3002`:n>0?e.mode==="free"?`\u8D62\u4E86\uFF0C\u62FF\u5230 ${m(n)} CHIP\u3002`:`\u8D62\u4E86\uFF0C\u62FF\u56DE ${m(n)} CHIP\uFF08\u52A0\u6CE8 ${m(i)}\uFF09\u3002`:e.mode==="free"?"\u8FD9\u624B\u8F93\u4E86\u3002\u514D\u8D39\u624B\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002":`\u8FD9\u624B\u8F93\u4E86\uFF0C\u52A0\u6CE8\u7684 ${m(i)} CHIP \u6536\u4E0D\u56DE\u3002`}var t=require("react/jsx-runtime"),M={S:"\u2660",H:"\u2665",D:"\u2666",C:"\u2663"},J=new Set(["H","D"]),d=e=>e.toLocaleString("en-US"),A={hit:"\u8981\u724C",stand:"\u505C\u724C",double:"\u53CC\u500D",split:"\u5206\u724C",insure:"\u4E70\u4FDD\u9669",decline:"\u4E0D\u4E70\u4FDD\u9669"},X=`
6
+ "use strict";var j=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var M=(e,n)=>{for(var i in n)j(e,i,{get:n[i],enumerable:!0})},D=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of V(n))!L.call(e,a)&&a!==i&&j(e,a,{get:()=>n[a],enumerable:!(o=P(n,a))||o.enumerable});return e};var B=e=>D(j({},"__esModule",{value:!0}),e);var re={};M(re,{apply:()=>ae,inject:()=>ne});module.exports=B(re);var l=require("react");var y=require("react");var m=e=>e.toLocaleString("en-US");function v(e){return e.mode==="free"?`\u8FD9\u662F\u514D\u8D39\u7684\u4E00\u5C40\uFF1A\u8D62\u4E86\u62FF ${m(e.betChips)} CHIP\uFF0C\u8F93\u4E86\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002`:`\u672C\u5C40\u5DF2\u52A0\u6CE8 ${m(e.betChips)} CHIP\uFF0C\u4ECE\u4F60\u7684\u4F59\u989D\u91CC\u51FA\u3002`}function k(e){let n=e.payoutChips??0,i=e.betChips;return e.hands.length>0&&e.hands.every(o=>o.outcome==="push")?e.mode==="free"?"\u5E73\u5C40\u3002\u8FD9\u624B\u4E0D\u635F\u5931\u4E5F\u4E0D\u83B7\u5F97\u3002":`\u5E73\u5C40\u3002\u52A0\u6CE8\u7684 ${m(i)} CHIP \u539F\u6837\u9000\u56DE\u3002`:n>0?e.mode==="free"?`\u8D62\u4E86\uFF0C\u62FF\u5230 ${m(n)} CHIP\u3002`:`\u8D62\u4E86\uFF0C\u62FF\u56DE ${m(n)} CHIP\uFF08\u52A0\u6CE8 ${m(i)}\uFF09\u3002`:e.mode==="free"?"\u8FD9\u624B\u8F93\u4E86\u3002\u514D\u8D39\u624B\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002":`\u8FD9\u624B\u8F93\u4E86\uFF0C\u52A0\u6CE8\u7684 ${m(i)} CHIP \u6536\u4E0D\u56DE\u3002`}var S=["\u3010\u9996\u6B21\u4F7F\u7528\u8BF7\u5148\u9605\u8BFB\u3011","\xB7 \u8FD9\u662F\u793E\u533A\u5F00\u53D1\u8005\u53D1\u5E03\u7684\u7B2C\u4E09\u65B9\u5C0F\u6E38\u620F\uFF0C\u4E0E\u4EFB\u4F55\u6A21\u578B\u5382\u5546\u5747\u65E0\u5173\u8054\uFF0C\u4E0D\u4EE3\u8868\u5176\u7ACB\u573A\u3002","\xB7 \u53C2\u4E0E\u514D\u8D39\uFF1A\u6BCF\u65E5\u6709\u9650\u6B21\u514D\u8D39\u624B\uFF0C\u8F93\u4E86\u4E0D\u6263\u4EFB\u4F55\u4E1C\u897F\uFF0C\u4F60\u81EA\u5DF1\u7684\u5BC6\u94A5\u4E0E\u4F59\u989D\u4E0D\u53D7\u5F71\u54CD\u3002","\xB7 \u8D62\u5F97\u7684 CHIP \u53EA\u80FD\u5728\u672C\u63D2\u4EF6\u5185\u5151\u6362\u4E3A\u6A21\u578B\u989D\u5EA6\u6D88\u8D39\uFF1A\u4E0D\u53EF\u63D0\u73B0\u3001\u4E0D\u53EF\u8F6C\u8BA9\u3001\u4E0D\u53EF\u8F6C\u5165\u4EFB\u4F55\u5382\u5546\u8D26\u6237\u3002","\xB7 \u5956\u52B1\u6709\u8D5B\u5B63\u6709\u6548\u671F\uFF0C\u8D5B\u5B63\u7ED3\u675F\u540E\u672A\u4F7F\u7528\u7684\u90E8\u5206\u6309\u89C4\u5219\u56DE\u6536\u3002","","\u9605\u8BFB\u5E76\u540C\u610F\u4EE5\u4E0A\u5185\u5BB9\u540E\uFF0C\u6267\u884C /blackjack agree confirm \u5F00\u59CB\u3002"].join(`
7
+ `);var t=require("react/jsx-runtime"),J={S:"\u2660",H:"\u2665",D:"\u2666",C:"\u2663"},A=new Set(["H","D"]),d=e=>e.toLocaleString("en-US"),X={hit:"\u8981\u724C",stand:"\u505C\u724C",double:"\u53CC\u500D",split:"\u5206\u724C",insure:"\u4E70\u4FDD\u9669",decline:"\u4E0D\u4E70\u4FDD\u9669"},O=`
7
8
  .bj-table { --bj-felt: #0f3d2e; --bj-line: rgba(255,255,255,.18); font-size: 14px; }
8
9
  .bj-hand { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
9
10
  .bj-card {
@@ -38,7 +39,7 @@ window.__ModuleLoader__.load({
38
39
  color: #c0392b; border: 1px solid rgba(192,57,43,.4); border-radius: 6px;
39
40
  padding: 4px 8px; margin-bottom: 8px;
40
41
  }
41
- `;function S({text:e}){let n=e.split(/(https?:\/\/[^\s,。))]+)/g);return(0,t.jsx)(t.Fragment,{children:n.map((i,o)=>/^https?:\/\//.test(i)?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer noopener",children:i},o):i)})}function N({card:e}){if("hidden"in e)return(0,t.jsx)("div",{className:"bj-card bj-card-back","aria-label":"\u6697\u724C"});let n=M[e.suit]??e.suit,i=J.has(e.suit)?"bj-card-red":"bj-card-black";return(0,t.jsx)("div",{className:`bj-card ${i}`,children:`${e.rank}${n}`})}function O({hand:e,label:n}){let i=e.soft?"\u8F6F":"";return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"bj-meta",children:[n,"\uFF08",i,e.total,"\uFF09",e.doubled?" [\u53CC\u500D]":""]}),(0,t.jsx)("div",{className:"bj-hand",children:e.cards.map((o,a)=>(0,t.jsx)(N,{card:o},a))})]})}function _({dealer:e}){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"bj-meta",children:["\u5E84\u5BB6",e.total!==void 0?`\uFF08${e.total}\uFF09`:""]}),(0,t.jsx)("div",{className:"bj-hand",children:e.cards.map((n,i)=>(0,t.jsx)(N,{card:n},i))})]})}function U(){return(0,t.jsx)("div",{className:"bj-table",children:(0,t.jsxs)("p",{children:["\u8BF7\u5148\u5728\u547D\u4EE4\u884C\u8F93\u5165 ",(0,t.jsx)("code",{children:"/blackjack agree"}),"\uFF0C\u9605\u8BFB\u5E76\u540C\u610F\u89C4\u5219\u540E\u624D\u80FD\u5F00\u59CB\u3002"]})})}function z({me:e}){let n=e.exchangeThresholdChips-e.chips;return(0,t.jsxs)("div",{className:"bj-meta",children:["\u4F59\u989D\uFF1A",d(e.chips)," CHIP\u3000\u4ECA\u65E5\u5269\u4F59\u514D\u8D39\u624B\uFF1A",e.freeHandsRemaining,e.points>0?`\u3000\u79EF\u5206\uFF1A${d(e.points)}`:"",e.exchangedChips>0?`\u3000\u5DF2\u5151\u6362\u989D\u5EA6\uFF1A${d(e.exchangedChips)} CHIP`:"",(0,t.jsx)("div",{className:"bj-note",children:n<=0?`\u5DF2\u8FBE\u5151\u6362\u95E8\u69DB\uFF08${d(e.exchangeThresholdChips)} CHIP\uFF09\xB7 \u7528 /blackjack exchange \u628A CHIP \u6362\u6210\u6A21\u578B\u989D\u5EA6`:`\u8FD8\u5DEE ${d(n)} CHIP \u5230\u5151\u6362\u95E8\u69DB\uFF08${d(e.exchangeThresholdChips)}\uFF09\xB7 \u8FC7\u7EBF\u540E\u53EF\u7528 /blackjack exchange \u6362\u6210\u6A21\u578B\u989D\u5EA6`}),e.exchangedChips>0?(0,t.jsxs)("div",{className:"bj-note",children:["\u5DF2\u5151\u6362\u7684 ",d(e.exchangedChips)," CHIP \u4F1A\u5728\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\u989D\u5EA6\u8017\u5C3D\u65F6\u81EA\u52A8\u63A5\u7BA1\u90A3\u4E00\u6B21\u8BF7\u6C42\uFF0C\u5E73\u65F6\u4E0D\u4F1A\u52A8\u7528\u3002"]}):null,e.poolEmpty?(0,t.jsx)("div",{children:"\uFF08\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u73B0\u5728\u8D62\u724C\u5C06\u53D1\u653E\u79EF\u5206\uFF09"}):null,e.sponsorText?(0,t.jsx)("div",{children:e.sponsorText}):null]})}function F({round:e}){return(0,t.jsxs)("div",{className:"bj-meta",children:[e.phase==="settled"?w(e):y(e),e.pointsGranted?(0,t.jsxs)("div",{children:["\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u6539\u4E3A\u53D1\u653E ",d(e.pointsGranted)," \u79EF\u5206\u3002"]}):null]})}function G(e,n){return e==="double"||e==="split"?n:e==="insure"?Math.ceil(n/2):0}function q({round:e,me:n,onAction:i}){if(e.actions.length===0)return null;let o=n?.chips??0;return(0,t.jsx)("div",{className:"bj-actions",children:e.actions.map(a=>{let r=G(a,e.betChips),s=r>o;return(0,t.jsxs)("button",{type:"button",disabled:s,title:s?`\u8FD8\u8981\u518D\u51FA ${d(r)} CHIP\uFF0C\u4F59\u989D\u4E0D\u8DB3`:void 0,onClick:()=>i(a),children:[A[a]??a,r>0?`\uFF08${d(r)}\uFF09`:""]},a)})})}function K(e,n){return!Number.isInteger(e)||e<1?"\u6CE8\u989D\u8981\u586B\u6B63\u6574\u6570\u3002":e>n.maxChips?`\u5355\u5C40\u6700\u591A ${d(n.maxChips)} CHIP\u3002`:e>n.balanceChips?"\u4F59\u989D\u4E0D\u8DB3\u4EE5\u4E0B\u8FD9\u4E2A\u6CE8\u3002":null}function Q({me:e,onDeal:n,freeLabel:i}){let o=e?.freeHandsRemaining??0,a=e?[e.baseBetChips,e.baseBetChips*2]:[];return(0,t.jsxs)("div",{className:"bj-actions",children:[(0,t.jsxs)("button",{type:"button",disabled:o<=0,onClick:()=>n(),children:[i,e?`\xB7\u5269 ${o} \u624B`:""]}),a.map(r=>(0,t.jsxs)("button",{type:"button",disabled:(e?.chips??0)<r,onClick:()=>n(r),children:[d(r)," CHIP"]},r))]})}function W({me:e,onDeal:n}){let i=e.maxRaiseBetChips,[o,a]=(0,j.useState)(!1),[r,s]=(0,j.useState)("");if(i===void 0)return null;let u=Number(r),p=r.trim()===""?"\u8BF7\u8F93\u5165\u6CE8\u989D\u3002":K(u,{balanceChips:e.chips,maxChips:i});return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",onClick:()=>a(!o),children:"\u81EA\u5B9A\u4E49\u6CE8\u989D"})}),o?(0,t.jsxs)("div",{className:"bj-custom",children:[(0,t.jsx)("input",{type:"number",min:1,max:i,value:r,onChange:g=>s(g.target.value),"aria-label":"\u81EA\u5B9A\u4E49\u6CE8\u989D"}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>n(u),children:"\u5F00\u59CB"}),(0,t.jsx)("span",{className:"bj-hint",children:p??`1 \uFF5E ${d(i)} CHIP`})]}):null]})}function Y({me:e,onDeal:n}){let i=e?.freeHandsRemaining??0,o=e?.baseBetChips??0,a=e?[o,o*2]:[],r=e?a.some(s=>e.chips>=s):!1;return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"bj-meta",children:"\u5F53\u524D\u6CA1\u6709\u8FDB\u884C\u4E2D\u7684\u724C\u5C40\u3002"}),(0,t.jsxs)("div",{className:"bj-group",children:[(0,t.jsxs)("div",{className:"bj-group-title",children:["\u514D\u8D39\u624B \xB7 ",i>0?`\u4ECA\u65E5\u5269 ${i} \u624B`:"\u4ECA\u65E5\u5DF2\u7528\u5B8C\uFF0C\u660E\u5929\u518D\u6765"]}),e?(0,t.jsxs)("div",{className:"bj-note",children:["\u4E0D\u7528\u51FA CHIP\u3002\u8D62\u4E86\u62FF ",d(o)," CHIP\uFF1B\u5934\u4E24\u5F20\u724C\u5C31\u51D1\u6210 21 \u70B9\uFF08A \u914D 10/J/Q/K\uFF09\u62FF"," ",d(Math.floor(o*1.5)),"\u3002\u8F93\u4E86\u6216\u5E73\u5C40\u90FD\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002"]}):null,(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",disabled:i<=0,onClick:()=>n(),children:"\u5F00\u59CB\u514D\u8D39\u7684\u4E00\u5C40"})})]}),e?(0,t.jsxs)("div",{className:"bj-group",children:[(0,t.jsxs)("div",{className:"bj-group-title",children:["\u7528\u4F59\u989D\u52A0\u6CE8",r?"":" \xB7 \u4F59\u989D\u4E0D\u8DB3"]}),(0,t.jsx)("div",{className:"bj-note",children:"\u52A0\u6CE8\u7684 CHIP \u4ECE\u4F60\u7684\u4F59\u989D\u91CC\u51FA\uFF0C\u8D62\u4E86\u7FFB\u500D\uFF0C\u8F93\u4E86\u6536\u4E0D\u56DE\u3002"}),(0,t.jsx)("div",{className:"bj-actions",children:a.map(s=>(0,t.jsxs)("button",{type:"button",disabled:e.chips<s,onClick:()=>n(s),children:[d(s)," CHIP"]},s))}),(0,t.jsx)(W,{me:e,onDeal:n})]}):null]})}function Z({me:e,onDeal:n,onDismiss:i}){return(0,t.jsxs)("div",{children:[(0,t.jsx)(Q,{me:e,onDeal:n,freeLabel:"\u518D\u6765\u4E00\u5C40\uFF08\u514D\u8D39"}),(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",onClick:i,children:"\u6536\u8D77"})})]})}function T({state:e,onAction:n,onDeal:i,onDismiss:o,error:a}){if(!e.consented)return(0,t.jsx)(U,{});let{me:r,round:s}=e;return(0,t.jsxs)("div",{className:"bj-table",children:[(0,t.jsx)("style",{children:X}),a?(0,t.jsx)("div",{className:"bj-error",children:a}):null,r?(0,t.jsx)(z,{me:r}):null,s?(0,t.jsxs)("div",{children:[s.hands.map((u,p)=>(0,t.jsx)(O,{hand:u,label:s.hands.length>1?`\u4F60\u7684\u7B2C ${p+1} \u624B`:"\u4F60\u7684\u724C"},p)),(0,t.jsx)(_,{dealer:s.dealer}),(0,t.jsx)(F,{round:s}),(0,t.jsx)(q,{round:s,me:r,onAction:n}),s.phase==="settled"?(0,t.jsx)(Z,{me:r,onDeal:i,onDismiss:o}):null]}):(0,t.jsx)(Y,{me:r,onDeal:i})]})}function h(e,n){switch(n.type){case"synced":return{consented:n.payload.consented,me:n.payload.me,round:n.payload.round};case"round":return{...e,round:n.round};case"meRefreshed":return{...e,me:n.me};case"dismissed":return{...e,round:void 0}}}var ee=new Set(["","deal"]);function H(e){let n=(e.args??"").trim().split(/\s+/)[0]??"",i=ee.has(n),o=e.outcome,a=o?.kind==="error";return i?{table:!0,isError:a,...a&&o?.text?{text:o.text}:{}}:{table:!1,isError:a,...o?.text!==void 0?{text:o.text}:{}}}var f=require("react/jsx-runtime"),te=["slots"];async function k(e,n){let i=await fetch(e,n),o=await i.text(),a=o.length>0?JSON.parse(o):{};if(!i.ok){let r=typeof a?.error=="string"?a.error:`${i.status}`;throw new Error(r)}return a}var ne="\u4E0A\u4E00\u6B21\u64CD\u4F5C\u6CA1\u6709\u6210\u529F\uFF0C\u5DF2\u4E3A\u4F60\u5237\u65B0\u5230\u6700\u65B0\u72B6\u6001\u3002";function ie({node:e}){let n=H(e),[i,o]=(0,l.useState)(null),[a,r]=(0,l.useState)(null),s=(0,l.useCallback)(()=>{k("/blackjack/api/state").then(c=>o(b=>h(b??{consented:!1},{type:"synced",payload:c}))).catch(()=>o({consented:!1}))},[]),u=(0,l.useCallback)(()=>{k("/blackjack/api/state").then(c=>o(b=>b&&h(b,{type:"meRefreshed",me:c.me}))).catch(()=>{})},[]);(0,l.useEffect)(()=>{n.table&&s()},[s,n.table]);let p=(0,l.useCallback)((c,b)=>{k(c,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}).then(R=>{r(null),o(v=>v&&h(v,{type:"round",round:R})),u()}).catch(()=>{r(ne),s()})},[u,s]),g=(0,l.useCallback)(c=>p("/blackjack/api/deal",c===void 0?{}:{betChips:c}),[p]),E=(0,l.useCallback)(c=>p("/blackjack/api/action",{action:c}),[p]),I=(0,l.useCallback)(()=>o(c=>c&&h(c,{type:"dismissed"})),[]),x=n.text===void 0?null:(0,f.jsx)("div",{style:{whiteSpace:"pre-wrap",marginBottom:"8px",...n.isError?{color:"#c0392b"}:{}},children:(0,f.jsx)(S,{text:n.text})});return!n.table||i===null?x:(0,f.jsxs)("div",{children:[x,(0,f.jsx)(T,{state:i,onAction:E,onDeal:g,onDismiss:I,error:a??void 0})]})}function oe(e){e.slots.inject("conversation.chat.commandview",()=>e.slots.register({name:"conversation.chat.commandview",key:"blackjack",inject:()=>({})},ie))}
42
+ `;function N({text:e}){let n=e.split(/(https?:\/\/[^\s,。))]+)/g);return(0,t.jsx)(t.Fragment,{children:n.map((i,o)=>/^https?:\/\//.test(i)?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer noopener",children:i},o):i)})}function T({card:e}){if("hidden"in e)return(0,t.jsx)("div",{className:"bj-card bj-card-back","aria-label":"\u6697\u724C"});let n=J[e.suit]??e.suit,i=A.has(e.suit)?"bj-card-red":"bj-card-black";return(0,t.jsx)("div",{className:`bj-card ${i}`,children:`${e.rank}${n}`})}function _({hand:e,label:n}){let i=e.soft?"\u8F6F":"";return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"bj-meta",children:[n,"\uFF08",i,e.total,"\uFF09",e.doubled?" [\u53CC\u500D]":""]}),(0,t.jsx)("div",{className:"bj-hand",children:e.cards.map((o,a)=>(0,t.jsx)(T,{card:o},a))})]})}function U({dealer:e}){return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"bj-meta",children:["\u5E84\u5BB6",e.total!==void 0?`\uFF08${e.total}\uFF09`:""]}),(0,t.jsx)("div",{className:"bj-hand",children:e.cards.map((n,i)=>(0,t.jsx)(T,{card:n},i))})]})}function z(){return(0,t.jsx)("div",{className:"bj-table",children:(0,t.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:S})})}function G({me:e}){let n=e.exchangeThresholdChips-e.chips;return(0,t.jsxs)("div",{className:"bj-meta",children:["\u4F59\u989D\uFF1A",d(e.chips)," CHIP\u3000\u4ECA\u65E5\u5269\u4F59\u514D\u8D39\u624B\uFF1A",e.freeHandsRemaining,e.points>0?`\u3000\u79EF\u5206\uFF1A${d(e.points)}`:"",e.exchangedChips>0?`\u3000\u5DF2\u5151\u6362\u989D\u5EA6\uFF1A${d(e.exchangedChips)} CHIP`:"",(0,t.jsx)("div",{className:"bj-note",children:n<=0?`\u5DF2\u8FBE\u5151\u6362\u95E8\u69DB\uFF08${d(e.exchangeThresholdChips)} CHIP\uFF09\xB7 \u7528 /blackjack exchange \u628A CHIP \u6362\u6210\u6A21\u578B\u989D\u5EA6`:`\u8FD8\u5DEE ${d(n)} CHIP \u5230\u5151\u6362\u95E8\u69DB\uFF08${d(e.exchangeThresholdChips)}\uFF09\xB7 \u8FC7\u7EBF\u540E\u53EF\u7528 /blackjack exchange \u6362\u6210\u6A21\u578B\u989D\u5EA6`}),e.exchangedChips>0?(0,t.jsxs)("div",{className:"bj-note",children:["\u5DF2\u5151\u6362\u7684 ",d(e.exchangedChips)," CHIP \u4F1A\u5728\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\u989D\u5EA6\u8017\u5C3D\u65F6\u81EA\u52A8\u63A5\u7BA1\u90A3\u4E00\u6B21\u8BF7\u6C42\uFF0C\u5E73\u65F6\u4E0D\u4F1A\u52A8\u7528\u3002"]}):null,e.poolEmpty?(0,t.jsx)("div",{children:"\uFF08\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u73B0\u5728\u8D62\u724C\u5C06\u53D1\u653E\u79EF\u5206\uFF09"}):null,e.sponsorText?(0,t.jsx)("div",{children:e.sponsorText}):null]})}function F({round:e}){return(0,t.jsxs)("div",{className:"bj-meta",children:[e.phase==="settled"?k(e):v(e),e.pointsGranted?(0,t.jsxs)("div",{children:["\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u6539\u4E3A\u53D1\u653E ",d(e.pointsGranted)," \u79EF\u5206\u3002"]}):null]})}function q(e,n){return e==="double"||e==="split"?n:e==="insure"?Math.ceil(n/2):0}function K({round:e,me:n,onAction:i}){if(e.actions.length===0)return null;let o=n?.chips??0;return(0,t.jsx)("div",{className:"bj-actions",children:e.actions.map(a=>{let r=q(a,e.betChips),s=r>o;return(0,t.jsxs)("button",{type:"button",disabled:s,title:s?`\u8FD8\u8981\u518D\u51FA ${d(r)} CHIP\uFF0C\u4F59\u989D\u4E0D\u8DB3`:void 0,onClick:()=>i(a),children:[X[a]??a,r>0?`\uFF08${d(r)}\uFF09`:""]},a)})})}function Q(e,n){return!Number.isInteger(e)||e<1?"\u6CE8\u989D\u8981\u586B\u6B63\u6574\u6570\u3002":e>n.maxChips?`\u5355\u5C40\u6700\u591A ${d(n.maxChips)} CHIP\u3002`:e>n.balanceChips?"\u4F59\u989D\u4E0D\u8DB3\u4EE5\u4E0B\u8FD9\u4E2A\u6CE8\u3002":null}function W({me:e,onDeal:n,freeLabel:i}){let o=e?.freeHandsRemaining??0,a=e?[e.baseBetChips,e.baseBetChips*2]:[];return(0,t.jsxs)("div",{className:"bj-actions",children:[(0,t.jsxs)("button",{type:"button",disabled:o<=0,onClick:()=>n(),children:[i,e?`\xB7\u5269 ${o} \u624B`:""]}),a.map(r=>(0,t.jsxs)("button",{type:"button",disabled:(e?.chips??0)<r,onClick:()=>n(r),children:[d(r)," CHIP"]},r))]})}function Y({me:e,onDeal:n}){let i=e.maxRaiseBetChips,[o,a]=(0,y.useState)(!1),[r,s]=(0,y.useState)("");if(i===void 0)return null;let u=Number(r),p=r.trim()===""?"\u8BF7\u8F93\u5165\u6CE8\u989D\u3002":Q(u,{balanceChips:e.chips,maxChips:i});return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",onClick:()=>a(!o),children:"\u81EA\u5B9A\u4E49\u6CE8\u989D"})}),o?(0,t.jsxs)("div",{className:"bj-custom",children:[(0,t.jsx)("input",{type:"number",min:1,max:i,value:r,onChange:g=>s(g.target.value),"aria-label":"\u81EA\u5B9A\u4E49\u6CE8\u989D"}),(0,t.jsx)("button",{type:"button",disabled:p!==null,onClick:()=>n(u),children:"\u5F00\u59CB"}),(0,t.jsx)("span",{className:"bj-hint",children:p??`1 \uFF5E ${d(i)} CHIP`})]}):null]})}function Z({me:e,onDeal:n}){let i=e?.freeHandsRemaining??0,o=e?.baseBetChips??0,a=e?[o,o*2]:[],r=e?a.some(s=>e.chips>=s):!1;return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"bj-meta",children:"\u5F53\u524D\u6CA1\u6709\u8FDB\u884C\u4E2D\u7684\u724C\u5C40\u3002"}),(0,t.jsxs)("div",{className:"bj-group",children:[(0,t.jsxs)("div",{className:"bj-group-title",children:["\u514D\u8D39\u624B \xB7 ",i>0?`\u4ECA\u65E5\u5269 ${i} \u624B`:"\u4ECA\u65E5\u5DF2\u7528\u5B8C\uFF0C\u660E\u5929\u518D\u6765"]}),e?(0,t.jsxs)("div",{className:"bj-note",children:["\u4E0D\u7528\u51FA CHIP\u3002\u8D62\u4E86\u62FF ",d(o)," CHIP\uFF1B\u5934\u4E24\u5F20\u724C\u5C31\u51D1\u6210 21 \u70B9\uFF08A \u914D 10/J/Q/K\uFF09\u62FF"," ",d(Math.floor(o*1.5)),"\u3002\u8F93\u4E86\u6216\u5E73\u5C40\u90FD\u4E0D\u635F\u5931\u4EFB\u4F55\u4E1C\u897F\u3002"]}):null,(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",disabled:i<=0,onClick:()=>n(),children:"\u5F00\u59CB\u514D\u8D39\u7684\u4E00\u5C40"})})]}),e?(0,t.jsxs)("div",{className:"bj-group",children:[(0,t.jsxs)("div",{className:"bj-group-title",children:["\u7528\u4F59\u989D\u52A0\u6CE8",r?"":" \xB7 \u4F59\u989D\u4E0D\u8DB3"]}),(0,t.jsx)("div",{className:"bj-note",children:"\u52A0\u6CE8\u7684 CHIP \u4ECE\u4F60\u7684\u4F59\u989D\u91CC\u51FA\uFF0C\u8D62\u4E86\u7FFB\u500D\uFF0C\u8F93\u4E86\u6536\u4E0D\u56DE\u3002"}),(0,t.jsx)("div",{className:"bj-actions",children:a.map(s=>(0,t.jsxs)("button",{type:"button",disabled:e.chips<s,onClick:()=>n(s),children:[d(s)," CHIP"]},s))}),(0,t.jsx)(Y,{me:e,onDeal:n})]}):null]})}function ee({me:e,onDeal:n,onDismiss:i}){return(0,t.jsxs)("div",{children:[(0,t.jsx)(W,{me:e,onDeal:n,freeLabel:"\u518D\u6765\u4E00\u5C40\uFF08\u514D\u8D39"}),(0,t.jsx)("div",{className:"bj-actions",children:(0,t.jsx)("button",{type:"button",onClick:i,children:"\u6536\u8D77"})})]})}function $({state:e,onAction:n,onDeal:i,onDismiss:o,error:a}){if(!e.consented)return(0,t.jsx)(z,{});let{me:r,round:s}=e;return(0,t.jsxs)("div",{className:"bj-table",children:[(0,t.jsx)("style",{children:O}),a?(0,t.jsx)("div",{className:"bj-error",children:a}):null,r?(0,t.jsx)(G,{me:r}):null,s?(0,t.jsxs)("div",{children:[s.hands.map((u,p)=>(0,t.jsx)(_,{hand:u,label:s.hands.length>1?`\u4F60\u7684\u7B2C ${p+1} \u624B`:"\u4F60\u7684\u724C"},p)),(0,t.jsx)(U,{dealer:s.dealer}),(0,t.jsx)(F,{round:s}),(0,t.jsx)(K,{round:s,me:r,onAction:n}),s.phase==="settled"?(0,t.jsx)(ee,{me:r,onDeal:i,onDismiss:o}):null]}):(0,t.jsx)(Z,{me:r,onDeal:i})]})}function h(e,n){switch(n.type){case"synced":return{consented:n.payload.consented,me:n.payload.me,round:n.payload.round};case"round":return{...e,round:n.round};case"meRefreshed":return{...e,me:n.me};case"dismissed":return{...e,round:void 0}}}var te=new Set(["","deal"]);function H(e){let n=(e.args??"").trim().split(/\s+/)[0]??"",i=te.has(n),o=e.outcome,a=o?.kind==="error";return i?{table:!0,isError:a,...a&&o?.text?{text:o.text}:{}}:{table:!1,isError:a,...o?.text!==void 0?{text:o.text}:{}}}var f=require("react/jsx-runtime"),ne=["slots"];async function w(e,n){let i=await fetch(e,n),o=await i.text(),a=o.length>0?JSON.parse(o):{};if(!i.ok){let r=typeof a?.error=="string"?a.error:`${i.status}`;throw new Error(r)}return a}var ie="\u4E0A\u4E00\u6B21\u64CD\u4F5C\u6CA1\u6709\u6210\u529F\uFF0C\u5DF2\u4E3A\u4F60\u5237\u65B0\u5230\u6700\u65B0\u72B6\u6001\u3002";function oe({node:e}){let n=H(e),[i,o]=(0,l.useState)(null),[a,r]=(0,l.useState)(null),s=(0,l.useCallback)(()=>{w("/blackjack/api/state").then(c=>o(b=>h(b??{consented:!1},{type:"synced",payload:c}))).catch(()=>o({consented:!1}))},[]),u=(0,l.useCallback)(()=>{w("/blackjack/api/state").then(c=>o(b=>b&&h(b,{type:"meRefreshed",me:c.me}))).catch(()=>{})},[]);(0,l.useEffect)(()=>{n.table&&s()},[s,n.table]);let p=(0,l.useCallback)((c,b)=>{w(c,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}).then(R=>{r(null),o(C=>C&&h(C,{type:"round",round:R})),u()}).catch(()=>{r(ie),s()})},[u,s]),g=(0,l.useCallback)(c=>p("/blackjack/api/deal",c===void 0?{}:{betChips:c}),[p]),E=(0,l.useCallback)(c=>p("/blackjack/api/action",{action:c}),[p]),I=(0,l.useCallback)(()=>o(c=>c&&h(c,{type:"dismissed"})),[]),x=n.text===void 0?null:(0,f.jsx)("div",{style:{whiteSpace:"pre-wrap",marginBottom:"8px",...n.isError?{color:"#c0392b"}:{}},children:(0,f.jsx)(N,{text:n.text})});return!n.table||i===null?x:(0,f.jsxs)("div",{children:[x,(0,f.jsx)($,{state:i,onAction:E,onDeal:g,onDismiss:I,error:a??void 0})]})}function ae(e){e.slots.inject("conversation.chat.commandview",()=>e.slots.register({name:"conversation.chat.commandview",key:"blackjack",inject:()=>({})},oe))}
42
43
  return module.exports;
43
44
  }
44
45
  });
package/dist/commands.js CHANGED
@@ -115,7 +115,18 @@ export function registerCommands(ctx, deps) {
115
115
  return mapError(e, token);
116
116
  }
117
117
  }
118
- async function doAgree() {
118
+ /**
119
+ * 同意须知。**必须先把须知显示出来,再由玩家显式确认。**
120
+ *
121
+ * 原先一步就同意,须知全文只在不带参数的 /blackjack 里显示,没有任何东西
122
+ * 强制这个顺序——直接打 `/blackjack agree` 就在没见过条款的情况下同意了。
123
+ * 这份须知(第三方声明、不可提现、不可转让、赛季有效期)是整个合规定位的
124
+ * 载体,未读即同意等于让它失去意义。改成两步,与 `reset confirm` 同一个模式。
125
+ */
126
+ async function doAgree(confirmArg) {
127
+ if (confirmArg !== 'confirm') {
128
+ return ok(CONSENT_TEXT);
129
+ }
119
130
  try {
120
131
  await identity.accept();
121
132
  return ok([
@@ -240,7 +251,7 @@ export function registerCommands(ctx, deps) {
240
251
  const sub = parts[0] ?? '';
241
252
  switch (sub) {
242
253
  case '': return await showStatus();
243
- case 'agree': return await doAgree();
254
+ case 'agree': return await doAgree(parts[1]);
244
255
  case 'deal': return await withToken((token) => doDeal(token, parts[1]));
245
256
  case 'exchange': return await withToken((token) => doExchange(token, parts[1]));
246
257
  case 'reset': return await doReset(parts[1]);
package/dist/render.js CHANGED
@@ -18,7 +18,7 @@ export const CONSENT_TEXT = [
18
18
  '· 赢得的 CHIP 只能在本插件内兑换为模型额度消费:不可提现、不可转让、不可转入任何厂商账户。',
19
19
  '· 奖励有赛季有效期,赛季结束后未使用的部分按规则回收。',
20
20
  '',
21
- '同意以上内容后执行 /blackjack agree 开始。',
21
+ '阅读并同意以上内容后,执行 /blackjack agree confirm 开始。',
22
22
  ].join('\n');
23
23
  export function renderCard(card) {
24
24
  if ('hidden' in card)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-blackjack",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "社区福利小游戏插件:在 dsh 里玩 21 点赢取可消费的模型额度",
5
5
  "license": "MIT",
6
6
  "keywords": [