Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit c1363bd

Browse files
koki-developclaude
andcommitted
feat: Add random thinking time for more natural cat responses
- Implement random delay between 300-1300ms instead of fixed 500ms - Fix character encoding inconsistencies in tests (half-width tilde) - Improve realistic interaction timing for cat responses 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 17e488b commit c1363bd

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/lib/cat.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe("Cat", () => {
1616

1717
test("should respond with affection sounds for affection messages", async () => {
1818
const affectionMessages = ["可愛いね", "好きだよ", "撫でて"];
19-
const affectionSounds = ["ニャオン", "ミャオ", "ニャンニャン"];
19+
const affectionSounds = ["ニャオ~ン", "ミャオ~", "ニャンニャン"];
2020

2121
for (const message of affectionMessages) {
2222
const response = await cat.response(message);
@@ -26,7 +26,7 @@ describe("Cat", () => {
2626

2727
test("should respond with satisfaction sounds for satisfaction messages", async () => {
2828
const satisfactionMessages = ["ありがとう", "嬉しい", "素晴らしい"];
29-
const satisfactionSounds = ["ゴロゴロ", "ニャ"];
29+
const satisfactionSounds = ["ゴロゴロ", "ニャ~"];
3030

3131
for (const message of satisfactionMessages) {
3232
const response = await cat.response(message);
@@ -56,7 +56,7 @@ describe("Cat", () => {
5656

5757
test("should respond with sleepy sounds for sleepy messages", async () => {
5858
const sleepyMessages = ["眠い", "疲れた", "おやすみ"];
59-
const sleepySounds = ["ニャ…", "フニャ", "ニャン"];
59+
const sleepySounds = ["ニャ…", "フニャ~", "ニャ~ン"];
6060

6161
for (const message of sleepyMessages) {
6262
const response = await cat.response(message);

src/lib/cat.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ export class Cat {
8888
return responses[index] as string;
8989
}
9090

91+
private getRandomThinkingTime(): number {
92+
return Math.floor(Math.random() * 1000) + 300; // 300-1300ms
93+
}
94+
9195
async response(message: string): Promise<string> {
92-
await new Promise((resolve) => setTimeout(resolve, 500));
96+
const thinkingTime = this.getRandomThinkingTime();
97+
await new Promise((resolve) => setTimeout(resolve, thinkingTime));
9398

9499
const emotion = this.detectEmotion(message);
95100
return this.getRandomResponse(emotion);

0 commit comments

Comments
 (0)