koishi-plugin-smmcat-selfhelp 0.2.1 → 0.2.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/lib/index.js +178 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -145,7 +145,19 @@ function apply(ctx, config) {
145
145
  child: [
146
146
  {
147
147
  name: "1.睡一觉",
148
- child: "一辆马车把你撞战败后,你回到了现实世界..."
148
+ child: [
149
+ {
150
+ name: "1.返回 序章",
151
+ child: [],
152
+ title: "%jumpBranch|5%"
153
+ },
154
+ {
155
+ name: "2.复活",
156
+ child: [],
157
+ title: "%jumpByLostProp|金币*11?5-2-3-2-1-1%"
158
+ }
159
+ ],
160
+ title: "熟睡中饿死了,需要20金币复活,你选择..."
149
161
  },
150
162
  {
151
163
  name: "2.冒险去",
@@ -169,12 +181,82 @@ function apply(ctx, config) {
169
181
  }
170
182
  ],
171
183
  title: "她们把你打了一顿,抢劫跑人"
184
+ },
185
+ {
186
+ name: "3.一看是怪物 通知卫兵",
187
+ child: [
188
+ {
189
+ name: "1.蕉个朋友 给你了",
190
+ child: [
191
+ {
192
+ name: "1.我有 你康康",
193
+ child: [
194
+ {
195
+ name: "1.继续",
196
+ child: [
197
+ {
198
+ name: "1.返回序章",
199
+ child: "%jumpBranch|5%"
200
+ }
201
+ ],
202
+ title: "因为太饿,吃太多撑死了。结束人生..."
203
+ }
204
+ ],
205
+ title: "%jumpByCheckProp|金币?5-2-3-1-1-1%"
206
+ },
207
+ {
208
+ name: "2.没有 可以白给我吗",
209
+ child: [
210
+ {
211
+ name: "1.返回序章",
212
+ child: "%jumpBranch|5%"
213
+ }
214
+ ],
215
+ title: "你被打了一顿,然后饿死街头"
216
+ }
217
+ ],
218
+ title: "你游荡在街上,没钱什么也做不了。也没实际的身份证明...\r\n\r\n走了一会,你实在饿得不行。去了一家看起来 是餐厅的地方,老板要确认你是否有钱。你现在:"
219
+ },
220
+ {
221
+ name: "2.请给我打钱 谢谢",
222
+ child: [
223
+ {
224
+ name: "1.去买房",
225
+ child: [
226
+ {
227
+ name: "1.继续",
228
+ child: [
229
+ {
230
+ name: "1.返回序章",
231
+ child: "%jumpBranch|5%"
232
+ }
233
+ ],
234
+ title: "你在 %getTime% 成为了有钱人,在城市中活得滋润。"
235
+ }
236
+ ],
237
+ title: "%jumpByLostProp|金币*11?5-2-3-2-1-1%"
238
+ },
239
+ {
240
+ name: "2.去找工作",
241
+ child: [
242
+ {
243
+ name: "1.返回序章",
244
+ child: "%jumpBranch|5%"
245
+ }
246
+ ],
247
+ title: "最后你成为了异世界的打工人"
248
+ }
249
+ ],
250
+ title: "%getProp|金币*10%\r\n拿到金币后,卫兵看你衣着特殊,以为你是外地人。推荐你去找份工作看看。你决定:"
251
+ }
252
+ ],
253
+ title: "你发现这个阵容的冒险小队不对劲。马上告知了巡逻的卫兵。她们仓皇逃窜走了...\r\n...经过一番追赶虽然跑了一个,但是女哥布林 Shigma 被抓住了\r\n\r\n“你真走运,”卫兵说,“她们是悬赏的罪犯。一人奖金就有 10 金币呢!”\r\n“是吗?太好了” 你似乎有点期待..."
172
254
  }
173
255
  ],
174
256
  title: "你遇到了一个冒险小队。小队里的人物中一个是爆乳法师 42,一个是 女哥布林 Shigma。\r\n她们邀请你讨伐史莱姆。 你决定...\r\n(刚开始你还未了解这个世界,请谨慎选择...)"
175
257
  }
176
258
  ],
177
- title: import_koishi.h.image("https://forum.koishi.xyz/user_avatar/forum.koishi.xyz/lizard/96/2522_2.png") + "\r\n这是一个异世界,你果然...又被撞到异世界里了。依然到了异世界,那就拿出真本事吧!"
259
+ title: '<img src="https://forum.koishi.xyz/user_avatar/forum.koishi.xyz/lizard/96/2522_2.png" />\r\n你在 %getTime% 时候被车撞 s 了嗯...\r\n这是一个异世界,你果然...又被撞到异世界里了。依然到了异世界,那就拿出真本事吧!'
178
260
  }
179
261
  ];
180
262
  try {
@@ -183,6 +265,9 @@ function apply(ctx, config) {
183
265
  console.log(error);
184
266
  }
185
267
  }, "addTemplate");
268
+ const userBranch = {};
269
+ const onlyOneTemp = {};
270
+ const takeIng = {};
186
271
  const transferTool = {
187
272
  // 获取当前时间
188
273
  getTime: (session) => (/* @__PURE__ */ new Date()).toLocaleString().replaceAll("/", "-"),
@@ -194,9 +279,83 @@ function apply(ctx, config) {
194
279
  jumpBranch(session, params, ev) {
195
280
  userBranch[session.userId] = params?.split("-") || [];
196
281
  ev.change = true;
282
+ },
283
+ // 通过交出持有物跳转分支 xxx>4?1-1-1
284
+ jumpByLostProp(session, params, ev) {
285
+ const dict = params.split("?");
286
+ if (this.lostProp(session, dict[0], ev)) {
287
+ userBranch[session.userId] = dict[1]?.split("-") || [];
288
+ ev.change = true;
289
+ } else {
290
+ userBranch[session.userId].pop();
291
+ ev.change = true;
292
+ session.send("不满足要求,请重新选择");
293
+ }
294
+ },
295
+ // 通过查询是否存在持有物跳转分支 xxx>4?1-1-1
296
+ jumpByCheckProp(session, params, ev) {
297
+ const dict = params.split("?");
298
+ if (this.querymentProp(session, dict[0], ev)) {
299
+ userBranch[session.userId] = dict[1]?.split("-") || [];
300
+ ev.change = true;
301
+ } else {
302
+ userBranch[session.userId].pop();
303
+ ev.change = true;
304
+ session.send("不满足要求,请重新选择");
305
+ }
306
+ },
307
+ // 获得道具 |xxx>4
308
+ getProp(session, params, ev) {
309
+ const item = params.split("*");
310
+ const prop = item[0];
311
+ const num = isNaN(Number(item[1])) ? 1 : Number(item[1]);
312
+ if (!onlyOneTemp[session.userId]) {
313
+ onlyOneTemp[session.userId] = [];
314
+ }
315
+ if (!onlyOneTemp[session.userId].includes(userBranch[session.userId].join("-"))) {
316
+ if (!takeIng[session.userId]) {
317
+ takeIng[session.userId] = {};
318
+ }
319
+ onlyOneTemp[session.userId].push(userBranch[session.userId].join("-"));
320
+ if (takeIng[session.userId][prop] === void 0) {
321
+ takeIng[session.userId][prop] = num;
322
+ } else {
323
+ takeIng[session.userId][prop] += num;
324
+ }
325
+ session.send("你在事件中得到了" + (num || 1) + `个${prop}`);
326
+ }
327
+ },
328
+ // 失去某物 |xxx>1
329
+ lostProp(session, params, ev) {
330
+ const item = params.split("*");
331
+ const prop = item[0];
332
+ const num = isNaN(Number(item[1])) ? 1 : Number(item[1]);
333
+ if (!onlyOneTemp[session.userId].includes(userBranch[session.userId].join("-"))) {
334
+ if (!this.querymentProp(session, prop, num || 1))
335
+ return false;
336
+ takeIng[session.userId][prop] -= num;
337
+ if (!takeIng[session.userId][prop]) {
338
+ delete takeIng[session.userId][prop];
339
+ }
340
+ onlyOneTemp[session.userId].push(userBranch[session.userId].join("-"));
341
+ session.send("你在事件中失去了" + (num || 1) + `个${prop}`);
342
+ return true;
343
+ }
344
+ },
345
+ // 判断是否存在某物
346
+ querymentProp(session, prop, num = 1) {
347
+ if (!takeIng[session.userId]) {
348
+ takeIng[session.userId] = {};
349
+ }
350
+ if (takeIng[session.userId][prop] === void 0) {
351
+ return false;
352
+ }
353
+ if (takeIng[session.userId][prop] < Number(num)) {
354
+ return false;
355
+ }
356
+ return true;
197
357
  }
198
358
  };
199
- const userBranch = {};
200
359
  const selfhelpMap = {
201
360
  // 基地址
202
361
  upath: import_path2.default.join(ctx.baseDir, config.mapAddress),
@@ -354,6 +513,8 @@ ${goalItem.crumbs}
354
513
  userBranch[session.userId] = [];
355
514
  }
356
515
  while (true) {
516
+ config.debug && console.log("当前持有:" + takeIng[session.userId]);
517
+ config.debug && console.log("已获取/失去过道具的分支:" + onlyOneTemp[session.userId]);
357
518
  let data = selfhelpMap.markScreen(userBranch[session.userId].join("-"), session);
358
519
  if (data.err) {
359
520
  userBranch[session.userId].pop();
@@ -374,7 +535,7 @@ ${goalItem.crumbs}
374
535
  if (!config.scriptMode) {
375
536
  userBranch[session.userId].length = 0;
376
537
  }
377
- await session.send(!config.scriptMode ? "长时间未操作,退出自助服务" : "长时间未操作,退出剧本");
538
+ await session.send(!config.scriptMode ? "长时间未操作,退出自助服务" : "长时间未操作,退出剧本,记录保留");
378
539
  break;
379
540
  }
380
541
  if (!res.trim() || isNaN(Number(res)) && res.toLowerCase() !== "q" && res.toLowerCase() !== "p") {
@@ -385,7 +546,7 @@ ${goalItem.crumbs}
385
546
  if (!config.scriptMode) {
386
547
  userBranch[session.userId].length = 0;
387
548
  }
388
- res == "0" && await session.send(!config.scriptMode ? "已退出自助服务" : "已退出剧本");
549
+ res == "0" && await session.send(!config.scriptMode ? "已退出自助服务" : "已退出剧本,记录保留");
389
550
  break;
390
551
  }
391
552
  if (!config.scriptMode && res.toLowerCase() === "q") {
@@ -410,9 +571,21 @@ ${goalItem.crumbs}
410
571
  const res = await session.prompt(2e4);
411
572
  if (res === "是") {
412
573
  userBranch[session.userId] = [];
574
+ onlyOneTemp[session.userId] = [];
575
+ takeIng[session.userId] = {};
413
576
  await session.send("已重置当前进度");
414
577
  }
415
578
  });
579
+ ctx.command("当前持有").action(async ({ session }) => {
580
+ const temp = takeIng[session.userId];
581
+ if (!temp || !Object.keys(temp).length) {
582
+ await session.send("你当进度中前还没有任何道具持有...");
583
+ }
584
+ const msg = Object.keys(temp).map((item) => {
585
+ return `【${item}】单位:${temp[item]}`;
586
+ });
587
+ await session.send("你当前进度中持有:\n" + msg);
588
+ });
416
589
  }
417
590
  }
418
591
  __name(apply, "apply");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-smmcat-selfhelp",
3
3
  "description": "用户自助服务系统",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [