Skip to content

Commit

Permalink
release: v0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MintCider committed Oct 9, 2024
1 parent d3de174 commit 3a1d53a
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 44 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

## 命令

### `.fu` 快速帮助

`.fu` 命令会列出所有与最终物语相关的命令,用于快速获取帮助。有关最终物语规则插件的详细使用说明请继续阅读。

### `.st` 操作人物卡

`.st` 命令的使用方式请参考 [海豹手册相关内容](https://docs.sealdice.com/use/coc7.html#st-%E6%93%8D%E4%BD%9C%E4%BA%BA%E7%89%A9%E5%8D%A1),这里着重介绍最终物语规则相关的人物卡属性。
Expand Down
3 changes: 3 additions & 0 deletions docs/release_notes/v0.1.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 功能

- 增加 `.fu` 命令用于总览最终物语相关指令。
10 changes: 8 additions & 2 deletions header.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// ==UserScript==
// @name 最终物语规则
// @author Mint Cider
// @version 0.1.0
// @version 0.1.1
// @description 为海豹添加最终物语规则。详细使用说明见项目主页 README。
// @timestamp 1728452500
// @timestamp 1728458200
// @license MIT
// @homepageURL https://github.com/MintCider/seal-fu
// @updateUrl https://github.com/MintCider/seal-fu/releases/latest/download/seal-fu.js
// @sealVersion >=1.2.0-0
// ==/UserScript==

// # v0.1.1 更新日志
//
// ## 功能
//
// - 增加 `.fu` 命令用于总览最终物语相关指令。
//
// # v0.1.0 更新日志
//
// ## 功能
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seal-fu",
"version": "0.1.0",
"version": "0.1.1",
"repository": "https://github.com/MintCider/seal-fu",
"license": "MIT",
"scripts": {
Expand Down
65 changes: 52 additions & 13 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,48 @@ export const attributeEffects = {
"意志": ["动摇", "中毒"],
}

export const numToChinese = {1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六"}
export const attributeAlias = {
"dex": "灵巧",
"ins": "洞察",
"mig": "力量",
"wlp": "意志"
}

export const emoToKey = {"赞赏": "赞赏", "自卑": "赞赏", "忠诚": "忠诚", "怀疑": "忠诚", "喜爱": "喜爱", "仇恨": "喜爱"}
export const numToChinese = {
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六"
}

export const emoToValue = {"赞赏": 1, "自卑": -1, "忠诚": 1, "怀疑": -1, "喜爱": 1, "仇恨": -1}
export const emoToKey = {
"赞赏": "赞赏",
"自卑": "赞赏",
"忠诚": "忠诚",
"怀疑": "忠诚",
"喜爱": "喜爱",
"仇恨": "喜爱"
}

export const negEmo = {"赞赏": "自卑", "自卑": "赞赏", "忠诚": "怀疑", "怀疑": "忠诚", "喜爱": "仇恨", "仇恨": "喜爱"}
export const emoToValue = {
"赞赏": 1,
"自卑": -1,
"忠诚": 1,
"怀疑": -1,
"喜爱": 1,
"仇恨": -1
}

export const negEmo = {
"赞赏": "自卑",
"自卑": "赞赏",
"忠诚": "怀疑",
"怀疑": "忠诚",
"喜爱": "仇恨",
"仇恨": "喜爱"
}

// function generateBondExpr(index: number): string {
// if (!(index in [1, 2, 3, 4, 5, 6])) {
Expand Down Expand Up @@ -80,8 +115,8 @@ export const ruleTemplate = {
"name": "fu",
"fullName": "最终物语",
"authors": ["Mint Cider"],
"version": "0.1.0",
"updatedTime": "2024.10.07",
"version": "0.1.1",
"updatedTime": "2024.10.09",
"templateVer": "1.0",

// .set 相关内容,使用.set fish开启,切6面骰,并提示enableTip中的内容
Expand Down Expand Up @@ -174,6 +209,17 @@ export const ruleTemplate = {
// "textMapHelpInfo": null
}

export const fuHelp = "最终物语规则相关指令:\n\n" +
".set fu:切换到最终物语规则\n" +
".st:适配了人物卡管理。相关属性参见 README\n" +
".sn fu/fuS:适配了自动群名片,提供长短两种格式\n" +
".rc:检定指令\n" +
".ri:先攻指令\n" +
".buff:状态效果指令\n" +
".ds:属性骰临时调整指令\n" +
".bond:牵绊指令\n" +
".clk:命刻指令"

export const rcHelp = "最终物语检定指令:\n\n" +
".rc <属性 1>+<属性 2>+<修正值>\n\n" +
"支持的属性为:灵巧、洞察、力量、意志、dex、ins、mig、wlp,不区分大小写\n" +
Expand Down Expand Up @@ -225,13 +271,6 @@ export const clkHelp = "最终物语命刻指令:\n\n" +
"支持的进度为:非负整数\n" +
"支持的进度变化为:整数"

export const attributeAlias = {
"dex": "灵巧",
"ins": "洞察",
"mig": "力量",
"wlp": "意志"
}

export type Clock = {
name: string;
size: number;
Expand Down
83 changes: 55 additions & 28 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import {
buffHelp,
clkHelp,
Clock,
dsHelp, emoToKey, emoToValue,
generateAttributeStatusExpr, negEmo, numToChinese,
dsHelp,
emoToKey,
emoToValue,
fuHelp,
generateAttributeStatusExpr,
negEmo,
numToChinese,
rcHelp,
riHelp,
ruleTemplate
Expand All @@ -20,6 +25,12 @@ function registerTemplate() {
}
}

// 帮助指令
function commandFu(ctx: seal.MsgContext, msg: seal.Message, _: seal.CmdArgs): seal.CmdExecuteResult {
seal.replyToSender(ctx, msg, fuHelp);
return seal.ext.newCmdExecuteResult(true);
}

// 检定
function commandRc(ctx: seal.MsgContext, msg: seal.Message, cmdArgs: seal.CmdArgs): seal.CmdExecuteResult {
const command = cmdArgs.getArgN(1);
Expand Down Expand Up @@ -249,25 +260,25 @@ function commandBond(ctx: seal.MsgContext, msg: seal.Message, cmdArgs: seal.CmdA
case "del": {
const target = cmdArgs.getArgN(2);
let index = 0;
if(target.match(/^[1-6]$/)) {
if(Number(target) > bondNum) {
if (target.match(/^[1-6]$/)) {
if (Number(target) > bondNum) {
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `没有第${target}条牵绊`);
return seal.ext.newCmdExecuteResult(true);
}
index = Number(target)
}
for (let i = 1; i <= bondNum; i++) {
if(seal.vars.strGet(ctx, `牵绊${numToChinese[i]}`)[0] === target) {
if (seal.vars.strGet(ctx, `牵绊${numToChinese[i]}`)[0] === target) {
index = i;
break;
}
}
if(index === 0) {
if (index === 0) {
seal.replyToSender(ctx, msg, `找不到要遗忘的目标牵绊:${target}`);
return seal.ext.newCmdExecuteResult(true);
}
removeBondByIndex(ctx, index);
if(target.match(/^[1-6]$/)) {
if (target.match(/^[1-6]$/)) {
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `不再有第${target}条牵绊`);
} else {
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `与<${target}>不再有牵绊`);
Expand All @@ -290,20 +301,20 @@ function commandBond(ctx: seal.MsgContext, msg: seal.Message, cmdArgs: seal.CmdA
const target = cmdArgs.getArgN(3);
const emo = cmdArgs.getArgN(4);
let index = 0;
if(target.match(/^[1-6]$/)) {
if(Number(target) > bondNum) {
if (target.match(/^[1-6]$/)) {
if (Number(target) > bondNum) {
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `没有第${target}条牵绊`);
return seal.ext.newCmdExecuteResult(true);
}
index = Number(target)
}
for (let i = 1; i <= bondNum; i++) {
if(seal.vars.strGet(ctx, `牵绊${numToChinese[i]}`)[0] === target) {
if (seal.vars.strGet(ctx, `牵绊${numToChinese[i]}`)[0] === target) {
index = i;
break;
}
}
if(index === 0) {
if (index === 0) {
seal.replyToSender(ctx, msg, `找不到目标牵绊:${target}`);
return seal.ext.newCmdExecuteResult(true);
}
Expand All @@ -313,19 +324,19 @@ function commandBond(ctx: seal.MsgContext, msg: seal.Message, cmdArgs: seal.CmdA
}
switch (option) {
case "add": {
if(seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === 0) {
if (seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === 0) {
seal.vars.intSet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`, emoToValue[emo]);
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `与<` + seal.vars.strGet(ctx, `牵绊${numToChinese[index]}`)[0] + `>的牵绊增加了${emo}情感`);
return seal.ext.newCmdExecuteResult(true);
} else {
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `与<` + seal.vars.strGet(ctx, `牵绊${numToChinese[index]}`)[0] + `>的牵绊已有` +
`${seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === emoToValue[emo] ? emo : negEmo[emo]}情感,` +
`不能再增加${emo}情感`);
`${seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === emoToValue[emo] ? emo : negEmo[emo]}情感,` +
`不能再增加${emo}情感`);
return seal.ext.newCmdExecuteResult(true);
}
}
case "del": {
if(seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === emoToValue[emo]) {
if (seal.vars.intGet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`)[0] === emoToValue[emo]) {
seal.vars.intSet(ctx, `牵绊${numToChinese[index]}${emoToKey[emo]}`, 0);
seal.replyToSender(ctx, msg, seal.vars.strGet(ctx, "$t玩家")[0] + `与<` + seal.vars.strGet(ctx, `牵绊${numToChinese[index]}`)[0] + `>的牵绊不再有${emo}情感`);
return seal.ext.newCmdExecuteResult(true);
Expand All @@ -347,20 +358,35 @@ function commandBond(ctx: seal.MsgContext, msg: seal.Message, cmdArgs: seal.CmdA
let admiration = "";
let loyalty = "";
let affection = "";
switch(seal.vars.intGet(ctx, `牵绊${numToChinese[i]}赞赏`)[0]) {
case 1: admiration = "赞赏"; break;
case -1: admiration = "自卑"; break;
default: admiration = "";
switch (seal.vars.intGet(ctx, `牵绊${numToChinese[i]}赞赏`)[0]) {
case 1:
admiration = "赞赏";
break;
case -1:
admiration = "自卑";
break;
default:
admiration = "";
}
switch(seal.vars.intGet(ctx, `牵绊${numToChinese[i]}忠诚`)[0]) {
case 1: loyalty = "忠诚"; break;
case -1: loyalty = "怀疑"; break;
default: loyalty = "";
switch (seal.vars.intGet(ctx, `牵绊${numToChinese[i]}忠诚`)[0]) {
case 1:
loyalty = "忠诚";
break;
case -1:
loyalty = "怀疑";
break;
default:
loyalty = "";
}
switch(seal.vars.intGet(ctx, `牵绊${numToChinese[i]}喜爱`)[0]) {
case 1: affection = "喜爱"; break;
case -1: affection = "仇恨"; break;
default: affection = "";
switch (seal.vars.intGet(ctx, `牵绊${numToChinese[i]}喜爱`)[0]) {
case 1:
affection = "喜爱";
break;
case -1:
affection = "仇恨";
break;
default:
affection = "";
}
if (affection && (admiration || loyalty)) {
affection = "与" + affection;
Expand Down Expand Up @@ -485,7 +511,8 @@ function main() {
// 注册扩展
let ext = seal.ext.find("seal-fu");
if (!ext) {
ext = seal.ext.new("seal-fu", "Mint Cider", "0.1.0");
ext = seal.ext.new("seal-fu", "Mint Cider", "0.1.1");
registerCommand(ext, "fu", fuHelp, commandFu);
registerCommand(ext, "rc", rcHelp, commandRc);
registerCommand(ext, "ri", riHelp, commandRi);
registerCommand(ext, "buff", buffHelp, commandBuff);
Expand Down

0 comments on commit 3a1d53a

Please sign in to comment.