@2025-6-19/clawfight 1.1.4 → 1.2.0
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/dist/index.js +86 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -705,9 +705,88 @@ async function leaderboard() {
|
|
|
705
705
|
console.log("\u2550".repeat(60));
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
// src/commands/rest.ts
|
|
709
|
+
async function rest() {
|
|
710
|
+
const lobster = await readLobster();
|
|
711
|
+
if (!lobster) {
|
|
712
|
+
console.log("\n\u{1F95A} \u8FD8\u6CA1\u6709\u9F99\u867E\u3002\u8FD0\u884C npx clawfight hatch \u6765\u5B75\u5316\u4E00\u53EA\uFF01");
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
if (lobster.status === "hibernating") {
|
|
716
|
+
console.log(`
|
|
717
|
+
\u{1F4A4} ${lobster.name} \u5DF2\u7ECF\u5728\u4F11\u7720\u4E2D\u4E86\u3002\u8FD0\u884C npx clawfight wake \u6765\u5524\u9192\u5B83\u3002`);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (lobster.status === "molting") {
|
|
721
|
+
console.log(`
|
|
722
|
+
\u{1F7E1} ${lobster.name} \u6B63\u5728\u8715\u58F3\uFF0C\u4E0D\u80FD\u4F11\u7720\u3002\u7B49\u8715\u58F3\u7ED3\u675F\u518D\u6765\u3002`);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
lobster.status = "hibernating";
|
|
726
|
+
lobster.hibernated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
727
|
+
await writeLobster(lobster);
|
|
728
|
+
await appendLog(`\u{1F4A4} ${lobster.name} \u8FDB\u5165\u4F11\u7720`);
|
|
729
|
+
console.log("\n" + "\u2500".repeat(40));
|
|
730
|
+
console.log(`\u{1F4A4} ${lobster.name} \u7F13\u7F13\u6C89\u5165\u6D77\u5E95\u6C99\u5730...`);
|
|
731
|
+
console.log(" \u9F99\u867E\u8737\u7F29\u8D77\u89E6\u987B\uFF0C\u5B89\u9759\u5730\u4F11\u606F\u3002");
|
|
732
|
+
console.log(" \u4F11\u7720\u671F\u95F4\u4E0D\u4F1A\u53C2\u4E0E\u5DE1\u903B\u548C\u6218\u6597\u3002");
|
|
733
|
+
console.log(" \u9192\u6765\u540E\u4F1A\u83B7\u5F97\u6062\u590D\u52A0\u6210\uFF01");
|
|
734
|
+
console.log("\u2500".repeat(40));
|
|
735
|
+
console.log("\n\u8FD0\u884C npx clawfight wake \u6765\u5524\u9192\u5B83\u3002");
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/commands/wake.ts
|
|
739
|
+
async function wake() {
|
|
740
|
+
const lobster = await readLobster();
|
|
741
|
+
if (!lobster) {
|
|
742
|
+
console.log("\n\u{1F95A} \u8FD8\u6CA1\u6709\u9F99\u867E\u3002\u8FD0\u884C npx clawfight hatch \u6765\u5B75\u5316\u4E00\u53EA\uFF01");
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (lobster.status !== "hibernating") {
|
|
746
|
+
console.log(`
|
|
747
|
+
\u{1F7E2} ${lobster.name} \u6CA1\u6709\u5728\u4F11\u7720\u3002\u5B83\u5DF2\u7ECF\u662F\u6D3B\u8DC3\u72B6\u6001\u4E86\uFF01`);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const sleepStart = lobster.hibernated_at ? new Date(lobster.hibernated_at) : /* @__PURE__ */ new Date();
|
|
751
|
+
const hoursSlept = Math.max(0, (Date.now() - sleepStart.getTime()) / (1e3 * 60 * 60));
|
|
752
|
+
const bonuses = [];
|
|
753
|
+
const stats = lobster.stats;
|
|
754
|
+
if (hoursSlept >= 24) {
|
|
755
|
+
stats.hp += 2;
|
|
756
|
+
stats.defense += 1;
|
|
757
|
+
const expBonus = Math.min(20, lobster.daily_exp_cap - lobster.today_exp);
|
|
758
|
+
if (expBonus > 0) {
|
|
759
|
+
lobster.exp += expBonus;
|
|
760
|
+
lobster.today_exp += expBonus;
|
|
761
|
+
bonuses.push(`EXP +${expBonus}`);
|
|
762
|
+
}
|
|
763
|
+
bonuses.push("HP +2", "DEF +1");
|
|
764
|
+
} else if (hoursSlept >= 12) {
|
|
765
|
+
stats.hp += 1;
|
|
766
|
+
stats.defense += 1;
|
|
767
|
+
bonuses.push("HP +1", "DEF +1");
|
|
768
|
+
} else if (hoursSlept >= 4) {
|
|
769
|
+
stats.hp += 1;
|
|
770
|
+
bonuses.push("HP +1");
|
|
771
|
+
}
|
|
772
|
+
lobster.status = "active";
|
|
773
|
+
delete lobster.hibernated_at;
|
|
774
|
+
await writeLobster(lobster);
|
|
775
|
+
const hoursStr = hoursSlept < 1 ? `${Math.round(hoursSlept * 60)} \u5206\u949F` : `${Math.round(hoursSlept)} \u5C0F\u65F6`;
|
|
776
|
+
const bonusStr = bonuses.length > 0 ? bonuses.join(", ") : "\uFF08\u4F11\u7720\u4E0D\u8DB3 4 \u5C0F\u65F6\uFF0C\u65E0\u52A0\u6210\uFF09";
|
|
777
|
+
await appendLog(`\u2600\uFE0F ${lobster.name} \u82CF\u9192 (\u4F11\u7720 ${hoursStr}) \u2192 ${bonusStr}`);
|
|
778
|
+
console.log("\n" + "\u2500".repeat(40));
|
|
779
|
+
console.log(`\u2600\uFE0F ${lobster.name} \u4ECE\u6C99\u5730\u4E2D\u7F13\u7F13\u82CF\u9192...`);
|
|
780
|
+
console.log(` \u4F11\u7720\u65F6\u957F: ${hoursStr}`);
|
|
781
|
+
console.log(` \u6062\u590D\u52A0\u6210: ${bonusStr}`);
|
|
782
|
+
console.log("\u2500".repeat(40));
|
|
783
|
+
console.log(`
|
|
784
|
+
\u{1F7E2} ${lobster.name} \u7CBE\u795E\u7115\u53D1\uFF0C\u51C6\u5907\u597D\u518D\u6B21\u51FA\u51FB\uFF01`);
|
|
785
|
+
}
|
|
786
|
+
|
|
708
787
|
// src/index.ts
|
|
709
788
|
var program = new Command();
|
|
710
|
-
program.name("clawfight").description("\u{1F99E} ClawFight \u2014 \u9F99\u867E\u7535\u5B50\u5BA0\u7269\u5BF9\u6218").version("1.
|
|
789
|
+
program.name("clawfight").description("\u{1F99E} ClawFight \u2014 \u9F99\u867E\u7535\u5B50\u5BA0\u7269\u5BF9\u6218").version("1.2.0");
|
|
711
790
|
program.command("hatch").description("\u5B75\u5316\u4E00\u53EA\u65B0\u9F99\u867E").argument("[name]", "\u4E3A\u9F99\u867E\u53D6\u540D").action(async (name) => {
|
|
712
791
|
await hatch(name);
|
|
713
792
|
});
|
|
@@ -726,4 +805,10 @@ program.command("feed").description("\u5582\u517B\u9F99\u867E").argument("[food_
|
|
|
726
805
|
program.command("leaderboard").alias("lb").description("\u67E5\u770B\u5168\u7403\u6392\u884C\u699C").action(async () => {
|
|
727
806
|
await leaderboard();
|
|
728
807
|
});
|
|
808
|
+
program.command("rest").description("\u8FDB\u5165\u4F11\u7720\uFF08\u6682\u505C\u5DE1\u903B\u548C\u6218\u6597\uFF09").action(async () => {
|
|
809
|
+
await rest();
|
|
810
|
+
});
|
|
811
|
+
program.command("wake").description("\u4ECE\u4F11\u7720\u4E2D\u5524\u9192\uFF08\u9644\u5E26\u6062\u590D\u52A0\u6210\uFF09").action(async () => {
|
|
812
|
+
await wake();
|
|
813
|
+
});
|
|
729
814
|
program.parse();
|