dsh-blackjack 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/client.js +10 -2
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -1,4 +1,9 @@
1
- import{useCallback as p,useEffect as T,useState as k}from"react";import{jsx as t,jsxs as r}from"react/jsx-runtime";var v={S:"\u2660",H:"\u2665",D:"\u2666",C:"\u2663"},j=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"},h=`
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-blackjack",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";var b=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var h=(e,n)=>{for(var a in n)b(e,a,{get:n[a],enumerable:!0})},S=(e,n,a,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of j(n))!x.call(e,o)&&o!==a&&b(e,o,{get:()=>n[o],enumerable:!(i=v(n,o))||i.enumerable});return e};var w=e=>S(b({},"__esModule",{value:!0}),e);var $={};h($,{apply:()=>P,inject:()=>I});module.exports=w($);var s=require("react");var t=require("react/jsx-runtime"),y={S:"\u2660",H:"\u2665",D:"\u2666",C:"\u2663"},C=new Set(["H","D"]),d=e=>e.toLocaleString("en-US"),N={hit:"\u8981\u724C",stand:"\u505C\u724C",double:"\u53CC\u500D",split:"\u5206\u724C",insure:"\u4E70\u4FDD\u9669",decline:"\u4E0D\u4E70\u4FDD\u9669"},E=`
2
7
  .bj-table { --bj-felt: #0f3d2e; --bj-line: rgba(255,255,255,.18); font-size: 14px; }
3
8
  .bj-hand { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
4
9
  .bj-card {
@@ -23,4 +28,7 @@ import{useCallback as p,useEffect as T,useState as k}from"react";import{jsx as t
23
28
  color: #c0392b; border: 1px solid rgba(192,57,43,.4); border-radius: 6px;
24
29
  padding: 4px 8px; margin-bottom: 8px;
25
30
  }
26
- `;function u({card:e}){if("hidden"in e)return t("div",{className:"bj-card bj-card-back","aria-label":"\u6697\u724C"});let n=v[e.suit]??e.suit,a=j.has(e.suit)?"bj-card-red":"bj-card-black";return t("div",{className:`bj-card ${a}`,children:`${e.rank}${n}`})}function S({hand:e,label:n}){let a=e.soft?"\u8F6F":"";return r("div",{children:[r("div",{className:"bj-meta",children:[n,"\uFF08",a,e.total,"\uFF09",e.doubled?" [\u53CC\u500D]":""]}),t("div",{className:"bj-hand",children:e.cards.map((s,o)=>t(u,{card:s},o))})]})}function w({dealer:e}){return r("div",{children:[r("div",{className:"bj-meta",children:["\u5E84\u5BB6",e.total!==void 0?`\uFF08${e.total}\uFF09`:""]}),t("div",{className:"bj-hand",children:e.cards.map((n,a)=>t(u,{card:n},a))})]})}function y(){return t("div",{className:"bj-table",children:r("p",{children:["\u8BF7\u5148\u5728\u547D\u4EE4\u884C\u8F93\u5165 ",t("code",{children:"/blackjack agree"}),"\uFF0C\u9605\u8BFB\u5E76\u540C\u610F\u89C4\u5219\u540E\u624D\u80FD\u5F00\u59CB\u3002"]})})}function C({me:e}){return r("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.poolEmpty?"\uFF08\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u73B0\u5728\u8D62\u724C\u5C06\u53D1\u653E\u79EF\u5206\uFF09":"",e.sponsorText?t("div",{children:e.sponsorText}):null]})}function N({round:e}){if(e.phase!=="settled")return null;let n=e.payoutChips??0;return r("div",{className:"bj-meta",children:[n>0?`\u672C\u624B\u8D62\u5F97 ${d(n)} CHIP\u3002`:"\u672C\u624B\u6CA1\u6709\u6536\u83B7\uFF0C\u660E\u5929\u518D\u6765\u3002",e.pointsGranted?r("div",{children:["\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u6539\u4E3A\u53D1\u653E ",d(e.pointsGranted)," \u79EF\u5206\u3002"]}):null]})}function E({round:e,onAction:n}){return e.actions.length===0?null:t("div",{className:"bj-actions",children:e.actions.map(a=>t("button",{type:"button",onClick:()=>n(a),children:x[a]??a},a))})}function A({me:e,onDeal:n}){return r("div",{children:[t("div",{className:"bj-meta",children:"\u5F53\u524D\u6CA1\u6709\u8FDB\u884C\u4E2D\u7684\u724C\u5C40\u3002"}),r("div",{className:"bj-actions",children:[t("button",{type:"button",onClick:()=>n(),children:"\u5F00\u59CB\u4E00\u5C40\uFF08\u9650\u514D\uFF09"}),e?r("button",{type:"button",onClick:()=>n(e.baseBetChips),children:["\u5F00\u59CB\u4E00\u5C40\uFF08",d(e.baseBetChips)," CHIP\uFF09"]}):null]})]})}function m({state:e,onAction:n,onDeal:a,error:s}){if(!e.consented)return t(y,{});let{me:o,round:i}=e;return r("div",{className:"bj-table",children:[t("style",{children:h}),s?t("div",{className:"bj-error",children:s}):null,o?t(C,{me:o}):null,i?r("div",{children:[i.hands.map((b,l)=>t(S,{hand:b,label:i.hands.length>1?`\u4F60\u7684\u7B2C ${l+1} \u624B`:"\u4F60\u7684\u724C"},l)),t(w,{dealer:i.dealer}),t(N,{round:i}),t(E,{round:i,onAction:n})]}):t(A,{me:o,onDeal:a})]})}import{jsx as J}from"react/jsx-runtime";var D=["slots"];async function f(e,n){let a=await fetch(e,n),s=await a.text(),o=s.length>0?JSON.parse(s):{};if(!a.ok){let i=typeof o?.error=="string"?o.error:`${a.status}`;throw new Error(i)}return o}var B="\u4E0A\u4E00\u6B21\u64CD\u4F5C\u6CA1\u6709\u6210\u529F\uFF0C\u5DF2\u4E3A\u4F60\u5237\u65B0\u5230\u6700\u65B0\u72B6\u6001\u3002";function R(){let[e,n]=k(null),[a,s]=k(null),o=p(()=>{f("/blackjack/api/state").then(n).catch(()=>n({consented:!1}))},[]);T(()=>{o()},[o]);let i=p((c,g)=>{f(c,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)}).then(()=>{s(null),o()}).catch(()=>{s(B),o()})},[o]),b=p(c=>i("/blackjack/api/deal",c===void 0?{}:{betChips:c}),[i]),l=p(c=>i("/blackjack/api/action",{action:c}),[i]);return e===null?null:J(m,{state:e,onAction:l,onDeal:b,error:a??void 0})}function P(e){e.slots.inject("conversation.chat.commandview",()=>e.slots.register({name:"conversation.chat.commandview",key:"blackjack",inject:()=>({})},R))}export{P as apply,D as inject};
31
+ `;function u({card:e}){if("hidden"in e)return(0,t.jsx)("div",{className:"bj-card bj-card-back","aria-label":"\u6697\u724C"});let n=y[e.suit]??e.suit,a=C.has(e.suit)?"bj-card-red":"bj-card-black";return(0,t.jsx)("div",{className:`bj-card ${a}`,children:`${e.rank}${n}`})}function A({hand:e,label:n}){let a=e.soft?"\u8F6F":"";return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"bj-meta",children:[n,"\uFF08",a,e.total,"\uFF09",e.doubled?" [\u53CC\u500D]":""]}),(0,t.jsx)("div",{className:"bj-hand",children:e.cards.map((i,o)=>(0,t.jsx)(u,{card:i},o))})]})}function T({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,a)=>(0,t.jsx)(u,{card:n},a))})]})}function B(){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 R({me:e}){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.poolEmpty?"\uFF08\u672C\u671F\u5956\u6C60\u5DF2\u53D1\u5B8C\uFF0C\u73B0\u5728\u8D62\u724C\u5C06\u53D1\u653E\u79EF\u5206\uFF09":"",e.sponsorText?(0,t.jsx)("div",{children:e.sponsorText}):null]})}function J({round:e}){if(e.phase!=="settled")return null;let n=e.payoutChips??0;return(0,t.jsxs)("div",{className:"bj-meta",children:[n>0?`\u672C\u624B\u8D62\u5F97 ${d(n)} CHIP\u3002`:"\u672C\u624B\u6CA1\u6709\u6536\u83B7\uFF0C\u660E\u5929\u518D\u6765\u3002",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 H({round:e,onAction:n}){return e.actions.length===0?null:(0,t.jsx)("div",{className:"bj-actions",children:e.actions.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>n(a),children:N[a]??a},a))})}function V({me:e,onDeal:n}){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-actions",children:[(0,t.jsx)("button",{type:"button",onClick:()=>n(),children:"\u5F00\u59CB\u4E00\u5C40\uFF08\u9650\u514D\uFF09"}),e?(0,t.jsxs)("button",{type:"button",onClick:()=>n(e.baseBetChips),children:["\u5F00\u59CB\u4E00\u5C40\uFF08",d(e.baseBetChips)," CHIP\uFF09"]}):null]})]})}function m({state:e,onAction:n,onDeal:a,error:i}){if(!e.consented)return(0,t.jsx)(B,{});let{me:o,round:r}=e;return(0,t.jsxs)("div",{className:"bj-table",children:[(0,t.jsx)("style",{children:E}),i?(0,t.jsx)("div",{className:"bj-error",children:i}):null,o?(0,t.jsx)(R,{me:o}):null,r?(0,t.jsxs)("div",{children:[r.hands.map((p,l)=>(0,t.jsx)(A,{hand:p,label:r.hands.length>1?`\u4F60\u7684\u7B2C ${l+1} \u624B`:"\u4F60\u7684\u724C"},l)),(0,t.jsx)(T,{dealer:r.dealer}),(0,t.jsx)(J,{round:r}),(0,t.jsx)(H,{round:r,onAction:n})]}):(0,t.jsx)(V,{me:o,onDeal:a})]})}var f=require("react/jsx-runtime"),I=["slots"];async function k(e,n){let a=await fetch(e,n),i=await a.text(),o=i.length>0?JSON.parse(i):{};if(!a.ok){let r=typeof o?.error=="string"?o.error:`${a.status}`;throw new Error(r)}return o}var X="\u4E0A\u4E00\u6B21\u64CD\u4F5C\u6CA1\u6709\u6210\u529F\uFF0C\u5DF2\u4E3A\u4F60\u5237\u65B0\u5230\u6700\u65B0\u72B6\u6001\u3002";function D(){let[e,n]=(0,s.useState)(null),[a,i]=(0,s.useState)(null),o=(0,s.useCallback)(()=>{k("/blackjack/api/state").then(n).catch(()=>n({consented:!1}))},[]);(0,s.useEffect)(()=>{o()},[o]);let r=(0,s.useCallback)((c,g)=>{k(c,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)}).then(()=>{i(null),o()}).catch(()=>{i(X),o()})},[o]),p=(0,s.useCallback)(c=>r("/blackjack/api/deal",c===void 0?{}:{betChips:c}),[r]),l=(0,s.useCallback)(c=>r("/blackjack/api/action",{action:c}),[r]);return e===null?null:(0,f.jsx)(m,{state:e,onAction:l,onDeal:p,error:a??void 0})}function P(e){e.slots.inject("conversation.chat.commandview",()=>e.slots.register({name:"conversation.chat.commandview",key:"blackjack",inject:()=>({})},D))}
32
+ return module.exports;
33
+ }
34
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-blackjack",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "社区福利小游戏插件:在 dsh 里玩 21 点赢取可消费的模型额度",
5
5
  "license": "MIT",
6
6
  "keywords": [