koishi-plugin-ciyi 1.2.4 → 1.2.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.
- package/lib/index.js +21 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -734,8 +734,15 @@ function renderWinCard(service, opts) {
|
|
|
734
734
|
__name(renderWinCard, "renderWinCard");
|
|
735
735
|
function renderRankCard(service, opts) {
|
|
736
736
|
const innerW = s(620);
|
|
737
|
-
const
|
|
738
|
-
const
|
|
737
|
+
const headerH = s(87);
|
|
738
|
+
const contentGap = s(20);
|
|
739
|
+
const rowH = s(52);
|
|
740
|
+
const emptyH = s(92);
|
|
741
|
+
const hiddenH = opts.hidden > 0 ? s(36) : 0;
|
|
742
|
+
const footerGap = s(20);
|
|
743
|
+
const footerH = s(60);
|
|
744
|
+
const contentH = opts.entries.length ? opts.entries.length * rowH + hiddenH : emptyH;
|
|
745
|
+
const innerH = headerH + contentGap + contentH + footerGap + footerH;
|
|
739
746
|
return toPng(service, innerW, innerH, (ctx, ix, iy, iw, ih) => {
|
|
740
747
|
let y = iy + drawHeader(ctx, ix, iy, iw, "每日挑战 · 累计猜中", {
|
|
741
748
|
big: String(opts.players),
|
|
@@ -743,11 +750,12 @@ function renderRankCard(service, opts) {
|
|
|
743
750
|
});
|
|
744
751
|
y += s(20);
|
|
745
752
|
if (!opts.entries.length) {
|
|
753
|
+
drawPanel(ctx, ix + s(22), y, iw - s(44), emptyH);
|
|
746
754
|
textCenter(
|
|
747
755
|
ctx,
|
|
748
756
|
"榜上无名。",
|
|
749
757
|
ix + iw / 2,
|
|
750
|
-
y + s(
|
|
758
|
+
y + s(31),
|
|
751
759
|
`${s(13.5)}px ${FONT_SERIF}`,
|
|
752
760
|
C.ink3
|
|
753
761
|
);
|
|
@@ -755,7 +763,7 @@ function renderRankCard(service, opts) {
|
|
|
755
763
|
ctx,
|
|
756
764
|
"今日第一个猜中的人,会写在这里。",
|
|
757
765
|
ix + iw / 2,
|
|
758
|
-
y + s(
|
|
766
|
+
y + s(61),
|
|
759
767
|
`${s(13.5)}px ${FONT_SERIF}`,
|
|
760
768
|
C.ink3
|
|
761
769
|
);
|
|
@@ -763,7 +771,6 @@ function renderRankCard(service, opts) {
|
|
|
763
771
|
let ry = y;
|
|
764
772
|
for (let i = 0; i < opts.entries.length; i++) {
|
|
765
773
|
const e = opts.entries[i];
|
|
766
|
-
const rowH = s(52);
|
|
767
774
|
const midY = ry + rowH / 2;
|
|
768
775
|
if (e.me) {
|
|
769
776
|
ctx.fillStyle = "rgba(178,58,46,0.055)";
|
|
@@ -793,9 +800,13 @@ function renderRankCard(service, opts) {
|
|
|
793
800
|
const name2 = e.username || "无名氏";
|
|
794
801
|
const nameX = px + posSize + s(14);
|
|
795
802
|
const nameFont = `${s(15)}px ${FONT_SERIF}`;
|
|
803
|
+
const score = String(e.score);
|
|
804
|
+
const scoreRight = ix + iw - s(38);
|
|
805
|
+
const scoreLeft = scoreRight - textWidth(score, s(19));
|
|
806
|
+
const meWidth = e.me ? textWidth("我", s(10.5)) + s(18) : 0;
|
|
796
807
|
const fittedName = ellipsize(
|
|
797
808
|
name2,
|
|
798
|
-
|
|
809
|
+
Math.max(0, scoreLeft - s(18) - nameX - meWidth),
|
|
799
810
|
s(15)
|
|
800
811
|
);
|
|
801
812
|
textLeft(ctx, fittedName, nameX, midY, nameFont, C.ink);
|
|
@@ -805,8 +816,8 @@ function renderRankCard(service, opts) {
|
|
|
805
816
|
}
|
|
806
817
|
textRight(
|
|
807
818
|
ctx,
|
|
808
|
-
|
|
809
|
-
|
|
819
|
+
score,
|
|
820
|
+
scoreRight,
|
|
810
821
|
midY,
|
|
811
822
|
`700 ${s(19)}px ${FONT_NUM}`,
|
|
812
823
|
C.ink
|
|
@@ -868,8 +879,8 @@ var usage = `# 词意
|
|
|
868
879
|
var inject = { required: ["database"], optional: ["canvas"] };
|
|
869
880
|
var Config = import_koishi.Schema.object({
|
|
870
881
|
atReply: import_koishi.Schema.boolean().default(false).description("响应时 @"),
|
|
871
|
-
quoteReply: import_koishi.Schema.boolean().default(
|
|
872
|
-
isEnableMiddleware: import_koishi.Schema.boolean().default(
|
|
882
|
+
quoteReply: import_koishi.Schema.boolean().default(false).description("响应时引用"),
|
|
883
|
+
isEnableMiddleware: import_koishi.Schema.boolean().default(true).description("是否启用中间件(若启用,猜测词语时可以不使用指令直接猜测)"),
|
|
873
884
|
renderImage: import_koishi.Schema.boolean().default(true).description("渲染图片(复用 Koishi Canvas 服务;不可用时使用等价文本)"),
|
|
874
885
|
maxHistory: import_koishi.Schema.number().default(10).min(0).description("猜测板最多列出的历史条数(最新一次猜测始终会列出)"),
|
|
875
886
|
maxRank: import_koishi.Schema.number().default(10).min(0).description("最大排行榜人数")
|