koishi-plugin-ciyi 0.0.1 → 0.0.3

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.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface Ciyi {
20
20
  answer: string;
21
21
  lastStartTimestamp: Date;
22
22
  guessedWords: string[];
23
+ guessedHistoryInOneGame: string[];
23
24
  rankList: string[];
24
25
  history: History[];
25
26
  isOver: boolean;
package/lib/index.js CHANGED
@@ -50,6 +50,7 @@ function apply(ctx, cfg) {
50
50
  answer: "string",
51
51
  lastStartTimestamp: "timestamp",
52
52
  guessedWords: "list",
53
+ guessedHistoryInOneGame: "list",
53
54
  rankList: "list",
54
55
  history: { type: "json", initial: [] },
55
56
  isOver: "boolean"
@@ -46743,14 +46744,20 @@ ${formattedRanks}`;
46743
46744
  if (gameInfo[0].isOver) {
46744
46745
  return await sendMsg(session, "今日挑战已结束,请明日再来!");
46745
46746
  }
46747
+ if (gameInfo[0].guessedHistoryInOneGame.includes(guess)) {
46748
+ return await sendMsg(session, "你已经猜过这个词了!");
46749
+ }
46746
46750
  const rankList = gameInfo[0].rankList;
46747
46751
  const history = [...gameInfo[0].history, getHistory(guess, rankList)];
46748
46752
  await ctx.database.set("ciyi", { channelId: session.channelId }, {
46753
+ guessedHistoryInOneGame: [...gameInfo[0].guessedHistoryInOneGame, guess],
46749
46754
  history
46750
46755
  });
46751
46756
  if (guess === gameInfo[0].answer) {
46752
46757
  await ctx.database.set("ciyi", { channelId: session.channelId }, {
46753
- isOver: true
46758
+ isOver: true,
46759
+ history: [],
46760
+ guessedHistoryInOneGame: []
46754
46761
  });
46755
46762
  const msg = `恭喜你猜对了!
46756
46763
  正确答案:${gameInfo[0].answer}`;
@@ -46780,6 +46787,9 @@ ${formattedRanks}`;
46780
46787
  if (isSameDay(timestamp, gameInfo[0].lastStartTimestamp)) {
46781
46788
  return await sendMsg(session, "今日挑战已经开始,请明日再来!");
46782
46789
  }
46790
+ if (!gameInfo[0].isOver) {
46791
+ return await sendMsg(session, "还有未完成的挑战,请完成后再来!");
46792
+ }
46783
46793
  }
46784
46794
  let answer = random.pick(questionList);
46785
46795
  while (!isNone && gameInfo[0].guessedWords.includes(answer)) {
@@ -46794,7 +46804,8 @@ ${formattedRanks}`;
46794
46804
  guessedWords: [`${answer}`],
46795
46805
  rankList,
46796
46806
  history: [],
46797
- isOver: false
46807
+ isOver: false,
46808
+ guessedHistoryInOneGame: []
46798
46809
  });
46799
46810
  } else {
46800
46811
  await ctx.database.set("ciyi", { channelId: session.channelId }, {
@@ -46802,7 +46813,9 @@ ${formattedRanks}`;
46802
46813
  lastStartTimestamp: new Date(timestamp),
46803
46814
  guessedWords: [...gameInfo[0].guessedWords, `${answer}`],
46804
46815
  rankList,
46805
- isOver: false
46816
+ isOver: false,
46817
+ guessedHistoryInOneGame: [],
46818
+ history: []
46806
46819
  });
46807
46820
  }
46808
46821
  const msg = `词意每日挑战开始!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ciyi",
3
3
  "description": "Koishi 的词意(猜词小游戏)插件。根据词语的含义相似程度,猜测正确的词语。",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [