@nonz250/ai-rotom 1.3.6 → 1.4.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.mjs +238 -405
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2,38 +2,46 @@
|
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { Field, Generations, Move, Pokemon, calculate } from "@smogon/calc";
|
|
5
|
+
import { Field, Generations, Move, Pokemon, calculate, toID } from "@smogon/calc";
|
|
6
6
|
import { randomBytes } from "node:crypto";
|
|
7
7
|
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import { parse } from "@pokesol/pokesol-text-parser-ts";
|
|
11
11
|
// ../../shared/src/utils/name-resolver.ts
|
|
12
|
+
/**
|
|
13
|
+
* データ上の日本語名は全角英数字 (10まんボルト) と半角英数字 (メガリザードンX) が混在しており、
|
|
14
|
+
* 入力側も半角で書かれることが多いため、照合は NFKC で正規化した表記で行う。
|
|
15
|
+
*/
|
|
16
|
+
function normalizeJapaneseName(name) {
|
|
17
|
+
return name.normalize("NFKC");
|
|
18
|
+
}
|
|
12
19
|
var NameResolver = class {
|
|
13
20
|
jaToEn;
|
|
14
21
|
enToJa;
|
|
15
22
|
jaNames;
|
|
16
23
|
constructor(entries) {
|
|
17
|
-
this.jaToEn = new Map(entries.map((e) => [e.ja, e.en]));
|
|
24
|
+
this.jaToEn = new Map(entries.map((e) => [normalizeJapaneseName(e.ja), e.en]));
|
|
18
25
|
this.enToJa = new Map(entries.map((e) => [e.en, e.ja]));
|
|
19
26
|
this.jaNames = entries.map((e) => e.ja);
|
|
20
27
|
}
|
|
21
28
|
toEnglish(jaName) {
|
|
22
|
-
return this.jaToEn.get(jaName);
|
|
29
|
+
return this.jaToEn.get(normalizeJapaneseName(jaName));
|
|
23
30
|
}
|
|
24
31
|
toJapanese(enName) {
|
|
25
32
|
return this.enToJa.get(enName);
|
|
26
33
|
}
|
|
27
34
|
hasJapaneseName(jaName) {
|
|
28
|
-
return this.jaToEn.has(jaName);
|
|
35
|
+
return this.jaToEn.has(normalizeJapaneseName(jaName));
|
|
29
36
|
}
|
|
30
37
|
hasEnglishName(enName) {
|
|
31
38
|
return this.enToJa.has(enName);
|
|
32
39
|
}
|
|
33
40
|
suggestSimilar(jaName, maxResults = 3) {
|
|
34
41
|
const candidates = [];
|
|
42
|
+
const normalizedInput = normalizeJapaneseName(jaName);
|
|
35
43
|
for (const name of this.jaNames) {
|
|
36
|
-
const distance = levenshteinDistance(
|
|
44
|
+
const distance = levenshteinDistance(normalizedInput, normalizeJapaneseName(name));
|
|
37
45
|
candidates.push({
|
|
38
46
|
name,
|
|
39
47
|
distance
|
|
@@ -307,7 +315,7 @@ const NORMAL_TYPE = "Normal";
|
|
|
307
315
|
* mcp-server 側の MoveCategory と同じ文字列だが、shared は mcp-server に
|
|
308
316
|
* 依存できないためここで独立に定義する。
|
|
309
317
|
*/
|
|
310
|
-
const STATUS_CATEGORY$
|
|
318
|
+
const STATUS_CATEGORY$3 = "Status";
|
|
311
319
|
/** 文字列を ID 相当(英数字のみ・小文字)に正規化する */
|
|
312
320
|
function toId(value) {
|
|
313
321
|
return value.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
@@ -341,7 +349,7 @@ const OFFENSIVE_TYPE_OVERRIDES = /* @__PURE__ */ new Map([
|
|
|
341
349
|
function applyOffensiveTypeOverride(originalMoveType, moveCategory, ability) {
|
|
342
350
|
if (ability === void 0) return originalMoveType;
|
|
343
351
|
if (originalMoveType !== NORMAL_TYPE) return originalMoveType;
|
|
344
|
-
if (moveCategory === STATUS_CATEGORY$
|
|
352
|
+
if (moveCategory === STATUS_CATEGORY$3) return originalMoveType;
|
|
345
353
|
const abilityId = toId(ability);
|
|
346
354
|
const overrideType = OFFENSIVE_TYPE_OVERRIDES.get(abilityId);
|
|
347
355
|
if (overrideType === void 0) return originalMoveType;
|
|
@@ -379,25 +387,6 @@ const boostsSchema = z.object({
|
|
|
379
387
|
spd: boostValueSchema.optional(),
|
|
380
388
|
spe: boostValueSchema.optional()
|
|
381
389
|
});
|
|
382
|
-
// ../../shared/src/schemas/pokemon-input.ts
|
|
383
|
-
const pokemonSchema = z.object({
|
|
384
|
-
name: z.string().describe("ポケモン名(日本語 or 英語)"),
|
|
385
|
-
nature: z.string().optional().describe("性格名(省略時: まじめ)"),
|
|
386
|
-
evs: evsSchema.optional().describe("能力ポイント(SP)。各ステ 0-32、合計 0-66。省略時は全 0 (無振り)。"),
|
|
387
|
-
ability: z.string().optional().describe("特性名"),
|
|
388
|
-
item: z.string().optional().describe("持ち物名"),
|
|
389
|
-
boosts: boostsSchema.optional().describe("ランク補正 (-6〜+6 の整数)。省略時は全 0。いかく・ちからをつける等の変動を表現する。"),
|
|
390
|
-
status: z.string().optional().describe("状態異常")
|
|
391
|
-
});
|
|
392
|
-
const conditionsSchema = z.object({
|
|
393
|
-
weather: z.string().optional().describe("天候(Sun, Rain, Sand, Hail, Snow)"),
|
|
394
|
-
terrain: z.string().optional().describe("フィールド(Electric, Grassy, Misty, Psychic)"),
|
|
395
|
-
battleFormat: z.enum(["singles", "doubles"]).optional().describe("対戦形式(シングル: singles / ダブル: doubles)。省略時は singles。doubles 指定時は全体攻撃技 (じしん/ねっぷう等) の威力が ×0.75 され、壁系の軽減率が約 0.667 倍に変わる。"),
|
|
396
|
-
isReflect: z.boolean().optional().describe("リフレクター"),
|
|
397
|
-
isLightScreen: z.boolean().optional().describe("ひかりのかべ"),
|
|
398
|
-
isAuroraVeil: z.boolean().optional().describe("オーロラベール"),
|
|
399
|
-
isCriticalHit: z.boolean().optional().describe("急所")
|
|
400
|
-
});
|
|
401
390
|
/** メモの最大文字数。 */
|
|
402
391
|
const MAX_PARTY_MEMO_LENGTH = 4e3;
|
|
403
392
|
const nameField$1 = z.string().min(1, { message: "名前は 1 文字以上で指定してください。" }).max(100, { message: `名前は 100 文字以下で指定してください。` });
|
|
@@ -431,6 +420,37 @@ const partiesFileSchema = z.object({
|
|
|
431
420
|
schemaVersion: z.number().int().positive().describe("パーティファイルの schemaVersion。"),
|
|
432
421
|
parties: z.array(partySchema).describe("登録済みパーティの一覧。")
|
|
433
422
|
});
|
|
423
|
+
// ../../shared/src/schemas/pokemon-input.ts
|
|
424
|
+
const pokemonFields = {
|
|
425
|
+
name: z.string().describe("ポケモン名(日本語 or 英語)"),
|
|
426
|
+
nature: z.string().optional().describe("性格名(省略時: まじめ)"),
|
|
427
|
+
evs: evsSchema.optional().describe("能力ポイント(SP)。各ステ 0-32、合計 0-66。省略時は全 0 (無振り)。"),
|
|
428
|
+
ability: z.string().optional().describe("特性名"),
|
|
429
|
+
item: z.string().optional().describe("持ち物名"),
|
|
430
|
+
boosts: boostsSchema.optional().describe("ランク補正 (-6〜+6 の整数)。省略時は全 0。いかく・ちからをつける等の変動を表現する。"),
|
|
431
|
+
status: z.string().optional().describe("状態異常")
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* 技構成を使わないツール向けのポケモン入力スキーマ。
|
|
435
|
+
* moves を受け付けると AI が指定を反映されたものと誤解するため、項目自体を持たない。
|
|
436
|
+
*/
|
|
437
|
+
const pokemonSchema = z.object(pokemonFields);
|
|
438
|
+
/**
|
|
439
|
+
* 攻撃側として全技ダメ計を行うツール向けのポケモン入力スキーマ。
|
|
440
|
+
*/
|
|
441
|
+
const pokemonWithMovesSchema = z.object({
|
|
442
|
+
...pokemonFields,
|
|
443
|
+
moves: z.array(z.string().min(1).max(100)).max(4, { message: `技は 4 個までです。` }).optional().describe("技構成(日本語 or 英語、最大 4)。攻撃側として全技計算するときは指定した技だけを計算する。省略時は習得技すべてで計算する。")
|
|
444
|
+
});
|
|
445
|
+
const conditionsSchema = z.object({
|
|
446
|
+
weather: z.string().optional().describe("天候(Sun, Rain, Sand, Hail, Snow)"),
|
|
447
|
+
terrain: z.string().optional().describe("フィールド(Electric, Grassy, Misty, Psychic)"),
|
|
448
|
+
battleFormat: z.enum(["singles", "doubles"]).optional().describe("対戦形式(シングル: singles / ダブル: doubles)。省略時は singles。doubles 指定時は全体攻撃技 (じしん/ねっぷう等) の威力が ×0.75 され、壁系の軽減率が約 0.667 倍に変わる。"),
|
|
449
|
+
isReflect: z.boolean().optional().describe("リフレクター"),
|
|
450
|
+
isLightScreen: z.boolean().optional().describe("ひかりのかべ"),
|
|
451
|
+
isAuroraVeil: z.boolean().optional().describe("オーロラベール"),
|
|
452
|
+
isCriticalHit: z.boolean().optional().describe("急所")
|
|
453
|
+
});
|
|
434
454
|
// ../../shared/src/calc/resolvers/resolve-name.ts
|
|
435
455
|
/**
|
|
436
456
|
* 日本語名または英語名を受け取り、対応する英語名に変換する。
|
|
@@ -551,7 +571,7 @@ function toPercent(value, maxHP) {
|
|
|
551
571
|
return Math.round(value / maxHP * 100 * 10) / 10;
|
|
552
572
|
}
|
|
553
573
|
// ../../shared/src/calc/damage-calculator.ts
|
|
554
|
-
const CHAMPIONS_GEN_NUM$
|
|
574
|
+
const CHAMPIONS_GEN_NUM$9 = 0;
|
|
555
575
|
const DEFAULT_NATURE_EN$2 = "Serious";
|
|
556
576
|
function buildTypeMetrics(gen, move, attacker, defender) {
|
|
557
577
|
const moveType = move.type;
|
|
@@ -580,9 +600,11 @@ function buildTypeMetrics(gen, move, attacker, defender) {
|
|
|
580
600
|
var DamageCalculatorAdapter = class {
|
|
581
601
|
resolvers;
|
|
582
602
|
entryProvider;
|
|
583
|
-
|
|
603
|
+
learnsetProvider;
|
|
604
|
+
constructor(resolvers, entryProvider, learnsetProvider) {
|
|
584
605
|
this.resolvers = resolvers;
|
|
585
606
|
this.entryProvider = entryProvider;
|
|
607
|
+
this.learnsetProvider = learnsetProvider;
|
|
586
608
|
}
|
|
587
609
|
calculate(input) {
|
|
588
610
|
const gen = this.getGen();
|
|
@@ -635,34 +657,32 @@ var DamageCalculatorAdapter = class {
|
|
|
635
657
|
const defender = new Pokemon(gen, defenderName, buildPokemonOptions(input.defender, defenderNature, defenderAbility, defenderItem, this.entryProvider.getByName(defenderName)));
|
|
636
658
|
const field = buildField(input.conditions);
|
|
637
659
|
const defenderMaxHP = defender.maxHP();
|
|
660
|
+
const candidateMoveNames = this.resolveCandidateMoveNames(gen, attackerName, input.attacker.moves);
|
|
638
661
|
const results = [];
|
|
639
|
-
for (const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
});
|
|
664
|
-
} catch {}
|
|
665
|
-
}
|
|
662
|
+
for (const moveName of candidateMoveNames) try {
|
|
663
|
+
const move = new Move(gen, moveName, { isCrit: input.conditions?.isCriticalHit });
|
|
664
|
+
const result = calculate(gen, attacker, defender, move, field);
|
|
665
|
+
const [min, max] = result.range();
|
|
666
|
+
if (max <= 0) continue;
|
|
667
|
+
const minPercent = toPercent(min, defenderMaxHP);
|
|
668
|
+
const maxPercent = toPercent(max, defenderMaxHP);
|
|
669
|
+
const koResult = result.kochance();
|
|
670
|
+
const damageArray = flattenDamage(result.damage);
|
|
671
|
+
const typeMetrics = buildTypeMetrics(gen, result.move, result.attacker, result.defender);
|
|
672
|
+
results.push({
|
|
673
|
+
attacker: attackerName,
|
|
674
|
+
defender: defenderName,
|
|
675
|
+
move: moveName,
|
|
676
|
+
damage: damageArray,
|
|
677
|
+
min,
|
|
678
|
+
max,
|
|
679
|
+
minPercent,
|
|
680
|
+
maxPercent,
|
|
681
|
+
koChance: koResult.text,
|
|
682
|
+
description: result.fullDesc(),
|
|
683
|
+
...typeMetrics
|
|
684
|
+
});
|
|
685
|
+
} catch {}
|
|
666
686
|
results.sort((a, b) => b.max - a.max);
|
|
667
687
|
return results;
|
|
668
688
|
}
|
|
@@ -677,8 +697,23 @@ var DamageCalculatorAdapter = class {
|
|
|
677
697
|
resolvedName
|
|
678
698
|
};
|
|
679
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* 技名 (日本語 or 英語) を英語名に解決し、重複を取り除く。
|
|
702
|
+
* 解決できない技名があれば類似候補を添えて例外を投げる。
|
|
703
|
+
* マスターデータにはあっても計算エンジンが持たない技は、計算すると結果から
|
|
704
|
+
* 黙って消えてしまうため、ここで例外にする。
|
|
705
|
+
*/
|
|
706
|
+
resolveMoveNames(moves) {
|
|
707
|
+
const gen = this.getGen();
|
|
708
|
+
const resolved = moves.map((name) => {
|
|
709
|
+
const englishName = resolveNameWithFallback(this.resolvers.move, name, "技");
|
|
710
|
+
if (gen.moves.get(toID(englishName)) === void 0) throw new Error(`技「${name}」は計算エンジンが未対応のため計算できません。技構成から外して呼び出してください。`);
|
|
711
|
+
return englishName;
|
|
712
|
+
});
|
|
713
|
+
return [...new Set(resolved)];
|
|
714
|
+
}
|
|
680
715
|
getGen() {
|
|
681
|
-
return Generations.get(CHAMPIONS_GEN_NUM$
|
|
716
|
+
return Generations.get(CHAMPIONS_GEN_NUM$9);
|
|
682
717
|
}
|
|
683
718
|
get pokemonResolver() {
|
|
684
719
|
return this.resolvers.pokemon;
|
|
@@ -689,27 +724,44 @@ var DamageCalculatorAdapter = class {
|
|
|
689
724
|
get natureResolver() {
|
|
690
725
|
return this.resolvers.nature;
|
|
691
726
|
}
|
|
727
|
+
resolveCandidateMoveNames(gen, attackerName, moves) {
|
|
728
|
+
if (moves !== void 0 && moves.length > 0) return this.resolveMoveNames(moves);
|
|
729
|
+
const learnableMoveIds = this.learnsetProvider.getMoveIds(attackerName);
|
|
730
|
+
const names = [];
|
|
731
|
+
for (const moveData of gen.moves) {
|
|
732
|
+
if (!moveData.basePower || moveData.basePower <= 0) continue;
|
|
733
|
+
if (learnableMoveIds.size > 0 && !learnableMoveIds.has(moveData.id)) continue;
|
|
734
|
+
names.push(moveData.name);
|
|
735
|
+
}
|
|
736
|
+
return names;
|
|
737
|
+
}
|
|
692
738
|
resolveNature(nature) {
|
|
693
739
|
if (nature === void 0) return DEFAULT_NATURE_EN$2;
|
|
694
740
|
return resolveNameWithFallback(this.resolvers.nature, nature, "性格");
|
|
695
741
|
}
|
|
696
742
|
};
|
|
697
|
-
// ../../shared/src/calc/
|
|
743
|
+
// ../../shared/src/calc/formatters/move-damage-summary.ts
|
|
698
744
|
/**
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* 呼び出し側で learnset フィルタを適用するための純関数。
|
|
703
|
-
*
|
|
704
|
-
* learnsetMoveIds が空集合の場合は、learnset データが無い(不明)とみなして
|
|
705
|
-
* フィルタせず元の配列をそのまま返す(現行挙動踏襲)。
|
|
706
|
-
*
|
|
707
|
-
* 呼び出し側は `results[i].move` と `learnsetMoveIds` を同じ正規化形式で
|
|
708
|
-
* 揃える責務を持つ。正規化ロジックは `normalize` 引数で注入する。
|
|
745
|
+
* ダメージ降順に並んだ計算結果を要約する。
|
|
746
|
+
* 特性や持ち物の補正はどの技にも同じように掛かるため、反映されたかの確認には
|
|
747
|
+
* 最大打点の技の説明文があれば足りる。全技に付けると出力が膨らむので先頭にだけ残す。
|
|
709
748
|
*/
|
|
710
|
-
function
|
|
711
|
-
|
|
712
|
-
|
|
749
|
+
function summarizeMoveDamages(results, toJapanese) {
|
|
750
|
+
return results.map((result, index) => {
|
|
751
|
+
const summary = {
|
|
752
|
+
move: result.move,
|
|
753
|
+
moveJa: toJapanese(result.move) ?? result.move,
|
|
754
|
+
moveType: result.moveType,
|
|
755
|
+
isStab: result.isStab,
|
|
756
|
+
typeMultiplier: result.typeMultiplier,
|
|
757
|
+
effectivePowerMultiplier: result.effectivePowerMultiplier,
|
|
758
|
+
minPercent: result.minPercent,
|
|
759
|
+
maxPercent: result.maxPercent,
|
|
760
|
+
koChance: result.koChance
|
|
761
|
+
};
|
|
762
|
+
if (index === 0) summary.description = result.description;
|
|
763
|
+
return summary;
|
|
764
|
+
});
|
|
713
765
|
}
|
|
714
766
|
// src/instructions.ts
|
|
715
767
|
const SERVER_INSTRUCTIONS = `
|
|
@@ -776,8 +828,6 @@ AI クライアントは目的駆動で刻む振り方を提案すること。
|
|
|
776
828
|
- 本サーバーのツールは「判断の根拠となる正確なデータを返す」ことに責務を限定しています。
|
|
777
829
|
「この選出が最適」「この構築が正解」といった最終判断は返しません。
|
|
778
830
|
- 選出・構築・対策の結論は、ツールが返したデータ (タイプ相性・ダメ計・素早さ比較・対面マトリクス等) を元に AI が総合的に導いてください。
|
|
779
|
-
- 一部ツール (find_counters 等) はスコア付きの候補リストを返しますが、これは候補抽出のための目安であり、
|
|
780
|
-
最終的な採用判断はダメ計・素早さ・対面状況を踏まえて AI が行うものです。
|
|
781
831
|
|
|
782
832
|
## ツール利用方針(必須)
|
|
783
833
|
|
|
@@ -805,6 +855,12 @@ AI クライアントは目的駆動で刻む振り方を提案すること。
|
|
|
805
855
|
- 素早さライン一覧・スカーフ込み比較 → list_speed_tiers
|
|
806
856
|
- 対面での先後判定 (素早さ比較込み) → analyze_matchup
|
|
807
857
|
|
|
858
|
+
### 対策候補 (「○○の対策は?」「○○に勝てるポケモンは?」等)
|
|
859
|
+
- 相手の弱点タイプを get_pokemon_summary の defenses で確認する
|
|
860
|
+
- 弱点タイプの攻撃技を覚えるポケモンを search_pokemon_by_type_effectiveness で検索する。タイプは 1 回に 1 つしか指定できないので、弱点が複数あればタイプごとに呼ぶ。相手の主力技のタイプを半減以下で受けるポケモンも同じツールで探せる
|
|
861
|
+
- 候補ごとに analyze_matchup を呼び、双方向のダメ計・素早さ・先制技を取得する。相手の技構成がわかっていれば moves を指定する
|
|
862
|
+
- どの候補を検討するか、受けて倒すのか上から倒すのかといった判断は AI が行う
|
|
863
|
+
|
|
808
864
|
### その他の事実確認 (「○○の特性効果は?」「○○の効果は?」「ねっぷう撃たれたら?」等)
|
|
809
865
|
- 特性効果 → get_ability_info
|
|
810
866
|
- 持ち物効果 → get_item_info
|
|
@@ -814,7 +870,7 @@ AI クライアントは目的駆動で刻む振り方を提案すること。
|
|
|
814
870
|
|
|
815
871
|
## 計算・分析系ツールでの ability / item 指定
|
|
816
872
|
|
|
817
|
-
- 計算・対面分析系ツール (calculate_damage_single / calculate_damage_all_moves / calculate_damage_party_matchup / analyze_damage_range / analyze_matchup / analyze_selection
|
|
873
|
+
- 計算・対面分析系ツール (calculate_damage_single / calculate_damage_all_moves / calculate_damage_party_matchup / analyze_damage_range / analyze_matchup / analyze_selection) を呼ぶ前に、攻撃側・防御側の ability / item を確認してから指定すること。
|
|
818
874
|
- 省略時の挙動: ability は通常特性 (pokemon.json の abilities[0]) が自動設定され、item は持ち物なし扱いとなる。そのためメガシンカ・こだわり系・半減きのみ・ちからのハチマキ 等が反映されず、実戦想定の build と乖離した結果になる。
|
|
819
875
|
- 正確な計算のためには ability / item を明示的に指定することを強く推奨する。
|
|
820
876
|
- 一方で、育成データ (evs・nature) が不明な場合は省略してよい (デフォルト値で計算)。
|
|
@@ -38043,9 +38099,25 @@ function toDataId(name) {
|
|
|
38043
38099
|
* 英語名から pokemonById Map を引いて PokemonEntry を返す。
|
|
38044
38100
|
*/
|
|
38045
38101
|
const pokemonEntryProvider = { getByName: (name) => pokemonById.get(toDataId(name)) };
|
|
38102
|
+
/** メガシンカ後のフォルム名の末尾 (例: "-Mega", "-Mega-X")。 */
|
|
38103
|
+
const MEGA_FORME_SUFFIX = /-Mega(-[XYZ])?$/;
|
|
38104
|
+
/**
|
|
38105
|
+
* shared/calc モジュールに渡すための LearnsetProvider 実装。
|
|
38106
|
+
* 英語名を ID に変換して learnset を引く。
|
|
38107
|
+
*/
|
|
38108
|
+
const learnsetProvider = { getMoveIds: (pokemonName) => {
|
|
38109
|
+
const id = toDataId(pokemonName);
|
|
38110
|
+
const own = getLearnsetMoveIdSet(id);
|
|
38111
|
+
if (own.size > 0) return own;
|
|
38112
|
+
const preMega = getLearnsetMoveIdSet(toDataId(pokemonName.replace(MEGA_FORME_SUFFIX, "")));
|
|
38113
|
+
if (preMega.size > 0) return preMega;
|
|
38114
|
+
const baseSpecies = pokemonById.get(id)?.baseSpecies;
|
|
38115
|
+
if (baseSpecies === null || baseSpecies === void 0) return own;
|
|
38116
|
+
return getLearnsetMoveIdSet(toDataId(baseSpecies));
|
|
38117
|
+
} };
|
|
38046
38118
|
/**
|
|
38047
38119
|
* 指定ポケモンの learnset に含まれる技 ID セットを取得する。
|
|
38048
|
-
* 未登録のポケモンは空 Set を返す(
|
|
38120
|
+
* 未登録のポケモンは空 Set を返す(DamageCalculatorAdapter.calculateAllMoves では
|
|
38049
38121
|
* 空 Set を「learnset データが無い」フォールバックとして扱う)。
|
|
38050
38122
|
* learnset JSON の ID は既に Showdown toID 形式だが、呼び出し側の
|
|
38051
38123
|
* 正規化関数({@link toDataId})との対称性を保つため念のため通している。
|
|
@@ -38117,9 +38189,9 @@ function toErrorResponse(error) {
|
|
|
38117
38189
|
};
|
|
38118
38190
|
}
|
|
38119
38191
|
// src/tools/info/ability-info.ts
|
|
38120
|
-
const TOOL_NAME$
|
|
38121
|
-
const TOOL_DESCRIPTION$
|
|
38122
|
-
const inputSchema$
|
|
38192
|
+
const TOOL_NAME$19 = "get_ability_info";
|
|
38193
|
+
const TOOL_DESCRIPTION$19 = "ポケモンの特性の詳細情報(効果説明)を取得する。ポケモンチャンピオンズで使える特性のみ返す。対戦でポケモンの特性を理解したいときに使用する。";
|
|
38194
|
+
const inputSchema$16 = { name: z.string().describe("特性名(日本語 or 英語)") };
|
|
38123
38195
|
/**
|
|
38124
38196
|
* 特性名を英語に解決する。日本語名・英語名どちらでも受け付ける。
|
|
38125
38197
|
*/
|
|
@@ -38132,7 +38204,7 @@ function resolveAbilityNameEn$1(input) {
|
|
|
38132
38204
|
throw new Error(`特性「${input}」が見つかりません。${suggestionMessage}`);
|
|
38133
38205
|
}
|
|
38134
38206
|
function registerAbilityInfoTool(server) {
|
|
38135
|
-
server.tool(TOOL_NAME$
|
|
38207
|
+
server.tool(TOOL_NAME$19, TOOL_DESCRIPTION$19, inputSchema$16, async (args) => {
|
|
38136
38208
|
try {
|
|
38137
38209
|
const abilityId = toDataId(resolveAbilityNameEn$1(args.name));
|
|
38138
38210
|
const entry = abilitiesById.get(abilityId);
|
|
@@ -38160,7 +38232,7 @@ function registerAbilityInfoTool(server) {
|
|
|
38160
38232
|
});
|
|
38161
38233
|
}
|
|
38162
38234
|
// src/tools/analysis/party-coverage.ts
|
|
38163
|
-
const CHAMPIONS_GEN_NUM$
|
|
38235
|
+
const CHAMPIONS_GEN_NUM$8 = 0;
|
|
38164
38236
|
/** 複合タイプを構成するタイプ数 */
|
|
38165
38237
|
const DUAL_TYPE_COUNT = 2;
|
|
38166
38238
|
/** 複合タイプ集合キーのセパレータ(タイプ名に現れない文字) */
|
|
@@ -38168,10 +38240,10 @@ const DUAL_TYPE_KEY_SEPARATOR = "/";
|
|
|
38168
38240
|
/** `dualTypeCoverage` の `examplePokemon` に収める最大件数 */
|
|
38169
38241
|
const MAX_EXAMPLE_POKEMON = 3;
|
|
38170
38242
|
/** ステータス技(攻撃タイプから除外するため) */
|
|
38171
|
-
const STATUS_CATEGORY$
|
|
38172
|
-
const TOOL_NAME$
|
|
38173
|
-
const TOOL_DESCRIPTION$
|
|
38174
|
-
const inputSchema$
|
|
38243
|
+
const STATUS_CATEGORY$2 = "Status";
|
|
38244
|
+
const TOOL_NAME$18 = "analyze_party_coverage";
|
|
38245
|
+
const TOOL_DESCRIPTION$18 = "パーティの攻撃カバレッジを分析する。各防御タイプ(18種)に対して、パーティのどの技が最も効果的かを算出し、抜群を取れないタイプを洗い出す。 `uncoveredTypes` は『抜群(>1 倍)を取れる技が 1 つも無い防御タイプ』を列挙する(等倍 1 倍も含む)。抜群倍率の内訳は `coverage[].maxMultiplier` を参照。 実在する複合タイプ(データ内に 1 匹以上存在する 2 タイプ組合せ)に対するカバレッジは `dualTypeCoverage` を参照。抜群を取れない複合タイプ数は `dualTypeUncoveredCount`。 攻撃側のタイプ変換系特性(Pixilate 等)は単一/複合カバレッジ双方に反映される。 ポケモンチャンピオンズ対応。";
|
|
38246
|
+
const inputSchema$15 = {
|
|
38175
38247
|
myParty: z.array(pokemonSchema).describe("自分のパーティ(moves 未指定時は learnset 内の全攻撃技を候補にする)"),
|
|
38176
38248
|
moves: z.record(z.string(), z.array(z.string())).optional().describe("ポケモン名(日本語 or 英語)をキーに技名配列を値とする map。省略時は learnset から全攻撃技を候補にする。")
|
|
38177
38249
|
};
|
|
@@ -38201,7 +38273,7 @@ function resolveAttackingMoveIds(pokemonEntry, explicitMoves) {
|
|
|
38201
38273
|
for (const moveName of explicitMoves) {
|
|
38202
38274
|
const moveId = toDataId(resolveMoveEnglishName(moveName));
|
|
38203
38275
|
const move = movesById.get(moveId);
|
|
38204
|
-
if (move !== void 0 && move.category !== STATUS_CATEGORY$
|
|
38276
|
+
if (move !== void 0 && move.category !== STATUS_CATEGORY$2) result.push(move);
|
|
38205
38277
|
}
|
|
38206
38278
|
return result;
|
|
38207
38279
|
}
|
|
@@ -38210,7 +38282,7 @@ function resolveAttackingMoveIds(pokemonEntry, explicitMoves) {
|
|
|
38210
38282
|
const moves = [];
|
|
38211
38283
|
for (const moveId of learnset) {
|
|
38212
38284
|
const move = movesById.get(moveId);
|
|
38213
|
-
if (move !== void 0 && move.category !== STATUS_CATEGORY$
|
|
38285
|
+
if (move !== void 0 && move.category !== STATUS_CATEGORY$2) moves.push(move);
|
|
38214
38286
|
}
|
|
38215
38287
|
return moves;
|
|
38216
38288
|
}
|
|
@@ -38231,7 +38303,7 @@ function resolveOptionalName$1(resolver, name) {
|
|
|
38231
38303
|
/**
|
|
38232
38304
|
* ポケモン名を pokemon.json のエントリに解決する。
|
|
38233
38305
|
*/
|
|
38234
|
-
function resolvePokemonEntry$
|
|
38306
|
+
function resolvePokemonEntry$3(name) {
|
|
38235
38307
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
38236
38308
|
if (englishName === null) {
|
|
38237
38309
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
@@ -38249,7 +38321,7 @@ function normalizeMovesMap(moves) {
|
|
|
38249
38321
|
const result = /* @__PURE__ */ new Map();
|
|
38250
38322
|
if (moves === void 0) return result;
|
|
38251
38323
|
for (const [pokemonName, moveList] of Object.entries(moves)) {
|
|
38252
|
-
const entry = resolvePokemonEntry$
|
|
38324
|
+
const entry = resolvePokemonEntry$3(pokemonName);
|
|
38253
38325
|
result.set(entry.id, moveList);
|
|
38254
38326
|
}
|
|
38255
38327
|
return result;
|
|
@@ -38329,12 +38401,12 @@ function updateBestAttackers(currentMax, bestAttackers, candidate) {
|
|
|
38329
38401
|
* MCP tool handler からも直接テストからも呼び出せる。
|
|
38330
38402
|
*/
|
|
38331
38403
|
function analyzePartyCoverage(args) {
|
|
38332
|
-
const gen = Generations.get(CHAMPIONS_GEN_NUM$
|
|
38404
|
+
const gen = Generations.get(CHAMPIONS_GEN_NUM$8);
|
|
38333
38405
|
const movesMap = normalizeMovesMap(args.moves);
|
|
38334
38406
|
const members = [];
|
|
38335
38407
|
const attackingTypesSet = /* @__PURE__ */ new Set();
|
|
38336
38408
|
for (const member of args.myParty) {
|
|
38337
|
-
const entry = resolvePokemonEntry$
|
|
38409
|
+
const entry = resolvePokemonEntry$3(member.name);
|
|
38338
38410
|
const rawAttackingMoves = resolveAttackingMoveIds(entry, movesMap.get(entry.id));
|
|
38339
38411
|
const ability = resolveOptionalName$1(abilityNameResolver, member.ability);
|
|
38340
38412
|
const attackingMoves = [];
|
|
@@ -38423,7 +38495,7 @@ function analyzePartyCoverage(args) {
|
|
|
38423
38495
|
};
|
|
38424
38496
|
}
|
|
38425
38497
|
function registerPartyCoverageTool(server) {
|
|
38426
|
-
server.tool(TOOL_NAME$
|
|
38498
|
+
server.tool(TOOL_NAME$18, TOOL_DESCRIPTION$18, inputSchema$15, async (args) => {
|
|
38427
38499
|
try {
|
|
38428
38500
|
const output = analyzePartyCoverage(args);
|
|
38429
38501
|
return withHint({
|
|
@@ -38443,18 +38515,18 @@ function registerPartyCoverageTool(server) {
|
|
|
38443
38515
|
});
|
|
38444
38516
|
}
|
|
38445
38517
|
// src/tools/analysis/compare-parties.ts
|
|
38446
|
-
const CHAMPIONS_GEN_NUM$
|
|
38518
|
+
const CHAMPIONS_GEN_NUM$7 = 0;
|
|
38447
38519
|
/** 対戦に組めるパーティメンバーの上限 (ポケモンチャンピオンズ仕様) */
|
|
38448
38520
|
const MAX_PARTY_SIZE = 6;
|
|
38449
38521
|
/** 性格未指定時の既定 (無補正性格) */
|
|
38450
38522
|
const DEFAULT_NATURE_EN$1 = "Serious";
|
|
38451
|
-
const TOOL_NAME$
|
|
38452
|
-
const TOOL_DESCRIPTION$
|
|
38523
|
+
const TOOL_NAME$17 = "compare_parties";
|
|
38524
|
+
const TOOL_DESCRIPTION$17 = "2 つのパーティ (A / B) の統計差分を比較する。メンバー差分・タイプ分布・弱点/耐性/カバレッジ集合・素早さ分布・種族値合計の構造化データを 1 コールで返す。 パーティ改修案の比較や入れ替え検討に使用する。優劣判定は行わず、差分データのみを返す (解釈は AI 側の責務)。 moves は指定できないため、カバレッジ差分は learnset 全攻撃技ベースで評価される。ポケモンチャンピオンズ対応。";
|
|
38453
38525
|
const labelsSchema = z.object({
|
|
38454
38526
|
partyA: z.string().optional(),
|
|
38455
38527
|
partyB: z.string().optional()
|
|
38456
38528
|
}).optional().describe("表示用ラベル (例: { partyA: '現行', partyB: '改修案' })");
|
|
38457
|
-
const inputSchema$
|
|
38529
|
+
const inputSchema$14 = {
|
|
38458
38530
|
partyA: z.array(pokemonSchema).min(1).max(MAX_PARTY_SIZE).describe("比較対象のパーティ A"),
|
|
38459
38531
|
partyB: z.array(pokemonSchema).min(1).max(MAX_PARTY_SIZE).describe("比較対象のパーティ B"),
|
|
38460
38532
|
labels: labelsSchema
|
|
@@ -38463,7 +38535,7 @@ const inputSchema$15 = {
|
|
|
38463
38535
|
* ポケモン名を pokemon.json のエントリに解決する。
|
|
38464
38536
|
* 未登録名は類似候補付きエラーを投げる。
|
|
38465
38537
|
*/
|
|
38466
|
-
function resolvePokemonEntry$
|
|
38538
|
+
function resolvePokemonEntry$2(name) {
|
|
38467
38539
|
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
38468
38540
|
if (englishName === null) {
|
|
38469
38541
|
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
@@ -38517,7 +38589,7 @@ function toMemberRef(entry) {
|
|
|
38517
38589
|
}
|
|
38518
38590
|
function resolveMembers(party) {
|
|
38519
38591
|
return party.map((input) => {
|
|
38520
|
-
const entry = resolvePokemonEntry$
|
|
38592
|
+
const entry = resolvePokemonEntry$2(input.name);
|
|
38521
38593
|
return {
|
|
38522
38594
|
input,
|
|
38523
38595
|
entry,
|
|
@@ -38619,7 +38691,7 @@ function computeCoverageDiff(partyA, partyB) {
|
|
|
38619
38691
|
* パーティ比較の純関数。MCP ツールハンドラとテストから共通で利用する。
|
|
38620
38692
|
*/
|
|
38621
38693
|
function comparePartiesAnalysis(args) {
|
|
38622
|
-
const gen = Generations.get(CHAMPIONS_GEN_NUM$
|
|
38694
|
+
const gen = Generations.get(CHAMPIONS_GEN_NUM$7);
|
|
38623
38695
|
const membersA = resolveMembers(args.partyA);
|
|
38624
38696
|
const membersB = resolveMembers(args.partyB);
|
|
38625
38697
|
const partyASummary = buildPartySummary(membersA, args.labels?.partyA, gen);
|
|
@@ -38652,7 +38724,7 @@ function comparePartiesAnalysis(args) {
|
|
|
38652
38724
|
};
|
|
38653
38725
|
}
|
|
38654
38726
|
function registerComparePartiesTool(server) {
|
|
38655
|
-
server.tool(TOOL_NAME$
|
|
38727
|
+
server.tool(TOOL_NAME$17, TOOL_DESCRIPTION$17, inputSchema$14, async (args) => {
|
|
38656
38728
|
try {
|
|
38657
38729
|
const output = comparePartiesAnalysis(args);
|
|
38658
38730
|
return withHint({
|
|
@@ -38672,15 +38744,15 @@ function registerComparePartiesTool(server) {
|
|
|
38672
38744
|
});
|
|
38673
38745
|
}
|
|
38674
38746
|
// src/tools/info/condition-info.ts
|
|
38675
|
-
const TOOL_NAME$
|
|
38676
|
-
const TOOL_DESCRIPTION$
|
|
38747
|
+
const TOOL_NAME$16 = "get_condition_info";
|
|
38748
|
+
const TOOL_DESCRIPTION$16 = "バトル条件(天候・フィールド・状態異常・サイド効果)の情報を取得する。category と name で絞り込める。省略時は全カテゴリ・全件を返す。ポケモンチャンピオンズ対応。";
|
|
38677
38749
|
const CATEGORY_VALUES = [
|
|
38678
38750
|
"weather",
|
|
38679
38751
|
"terrain",
|
|
38680
38752
|
"status",
|
|
38681
38753
|
"sideCondition"
|
|
38682
38754
|
];
|
|
38683
|
-
const inputSchema$
|
|
38755
|
+
const inputSchema$13 = {
|
|
38684
38756
|
category: z.enum(CATEGORY_VALUES).optional().describe("絞り込むカテゴリ(weather: 天候 / terrain: フィールド / status: 状態異常 / sideCondition: サイド効果)。省略時は全カテゴリ。"),
|
|
38685
38757
|
name: z.string().optional().describe("絞り込む条件名(日本語 or 英語)。省略時は全件。")
|
|
38686
38758
|
};
|
|
@@ -38701,7 +38773,7 @@ function resolveCategoryEntries(category, name) {
|
|
|
38701
38773
|
return filterByName(entries, name);
|
|
38702
38774
|
}
|
|
38703
38775
|
function registerConditionInfoTool(server) {
|
|
38704
|
-
server.tool(TOOL_NAME$
|
|
38776
|
+
server.tool(TOOL_NAME$16, TOOL_DESCRIPTION$16, inputSchema$13, async (args) => {
|
|
38705
38777
|
try {
|
|
38706
38778
|
const output = {};
|
|
38707
38779
|
const targetCategories = args.category !== void 0 ? [args.category] : CATEGORY_VALUES;
|
|
@@ -38729,7 +38801,7 @@ const damageCalculator = new DamageCalculatorAdapter({
|
|
|
38729
38801
|
ability: abilityNameResolver,
|
|
38730
38802
|
item: itemNameResolver,
|
|
38731
38803
|
nature: natureNameResolver
|
|
38732
|
-
}, pokemonEntryProvider);
|
|
38804
|
+
}, pokemonEntryProvider, learnsetProvider);
|
|
38733
38805
|
// src/tools/calc/damage-calculation.ts
|
|
38734
38806
|
const damageCalcInputSchema = {
|
|
38735
38807
|
attacker: pokemonSchema.describe("攻撃側ポケモン"),
|
|
@@ -38740,22 +38812,32 @@ const damageCalcInputSchema = {
|
|
|
38740
38812
|
const SINGLE_TOOL_NAME = "calculate_damage_single";
|
|
38741
38813
|
const SINGLE_TOOL_DESCRIPTION = "ポケモンのダメージ計算を行うツール。攻撃側ポケモンの指定した1技が防御側ポケモンに与えるダメージを計算する。ポケモンチャンピオンズ (Pokemon Champions) の対戦仕様に対応。重要: 能力ポイント(evs) は各ステ 0-32・合計 0-66 で指定すること (従来の努力値 252/510 上限ではない)。レベル 50・個体値 31 固定。育成データは省略可能で、省略時はデフォルト値で計算される。正確な計算のため攻撃側・防御側の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
38742
38814
|
const ALL_MOVES_TOOL_NAME = "calculate_damage_all_moves";
|
|
38743
|
-
const ALL_MOVES_TOOL_DESCRIPTION = "
|
|
38815
|
+
const ALL_MOVES_TOOL_DESCRIPTION = "ポケモン対戦で攻撃側ポケモンの全攻撃技のダメージを一括計算する。どの技が最も有効かを比較するときに使用する。技ごとの結果はタイプ・相性・ダメージ割合・確定数の要約で、乱数の内訳は含まない。計算条件の説明文は最大打点の技にだけ付く。1 技の詳しい結果は calculate_damage_single で確認する。ポケモンチャンピオンズ対応。正確な計算のため攻撃側・防御側の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
38744
38816
|
const allMovesInputSchema = {
|
|
38745
|
-
attacker:
|
|
38817
|
+
attacker: pokemonWithMovesSchema.describe("攻撃側ポケモン"),
|
|
38746
38818
|
defender: pokemonSchema.describe("防御側ポケモン"),
|
|
38747
38819
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
38748
38820
|
};
|
|
38749
38821
|
const PARTY_MATCHUP_TOOL_NAME = "calculate_damage_party_matchup";
|
|
38750
38822
|
const PARTY_MATCHUP_TOOL_DESCRIPTION = "パーティ対パーティの全組み合わせダメージ計算を行う。6vs6の全対面での火力関係を一覧する。ポケモン対戦の選出判断やパーティ構築の検討に使用する。正確な計算のため各ポケモンの ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
38751
38823
|
const partyMatchupInputSchema = {
|
|
38752
|
-
myParty: z.array(
|
|
38824
|
+
myParty: z.array(pokemonWithMovesSchema).describe("自分のパーティ"),
|
|
38753
38825
|
opponentParty: z.array(pokemonSchema).describe("相手のパーティ"),
|
|
38754
38826
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
38755
38827
|
};
|
|
38828
|
+
/** ダメージを与えられる技がない対面の最大ダメージ割合。 */
|
|
38829
|
+
const NO_DAMAGE_PERCENT = 0;
|
|
38756
38830
|
function extractBestMove(results, defenderNameEn, moveResolver) {
|
|
38757
|
-
const best = results[0];
|
|
38758
38831
|
const defenderNameJa = pokemonNameResolver.toJapanese(defenderNameEn) ?? defenderNameEn;
|
|
38832
|
+
if (results.length === 0) return {
|
|
38833
|
+
defender: defenderNameEn,
|
|
38834
|
+
defenderNameJa,
|
|
38835
|
+
bestMove: null,
|
|
38836
|
+
bestMoveJa: null,
|
|
38837
|
+
maxDamagePercent: NO_DAMAGE_PERCENT,
|
|
38838
|
+
koChance: null
|
|
38839
|
+
};
|
|
38840
|
+
const best = results[0];
|
|
38759
38841
|
const bestMoveJa = moveResolver.toJapanese(best.move) ?? best.move;
|
|
38760
38842
|
return {
|
|
38761
38843
|
defender: defenderNameEn,
|
|
@@ -38795,7 +38877,7 @@ function registerDamageCalculationTools(server) {
|
|
|
38795
38877
|
const output = {
|
|
38796
38878
|
attacker: results.length > 0 ? results[0].attacker : attackerNameEn,
|
|
38797
38879
|
defender: results.length > 0 ? results[0].defender : defenderNameEn,
|
|
38798
|
-
results
|
|
38880
|
+
results: summarizeMoveDamages(results, (en) => moveNameResolver.toJapanese(en))
|
|
38799
38881
|
};
|
|
38800
38882
|
return withHint({
|
|
38801
38883
|
type: "text",
|
|
@@ -38832,10 +38914,8 @@ function registerDamageCalculationTools(server) {
|
|
|
38832
38914
|
defender,
|
|
38833
38915
|
conditions: args.conditions
|
|
38834
38916
|
});
|
|
38835
|
-
|
|
38836
|
-
|
|
38837
|
-
attackerEntry.results.push(extractBestMove(results, defenderNameEn, moveNameResolver));
|
|
38838
|
-
}
|
|
38917
|
+
const { resolvedName: defenderNameEn } = damageCalculator.createPokemonObject(defender);
|
|
38918
|
+
attackerEntry.results.push(extractBestMove(results, defenderNameEn, moveNameResolver));
|
|
38839
38919
|
}
|
|
38840
38920
|
output.matchups.push(attackerEntry);
|
|
38841
38921
|
}
|
|
@@ -38852,9 +38932,9 @@ function registerDamageCalculationTools(server) {
|
|
|
38852
38932
|
/** 探索に使う SP 候補ステップ(細かさ)。4 きざみで枝刈り → hit したら 1 きざみで微調整 */
|
|
38853
38933
|
const SP_COARSE_STEP = 4;
|
|
38854
38934
|
const SP_FINE_STEP = 1;
|
|
38855
|
-
const TOOL_NAME$
|
|
38856
|
-
const TOOL_DESCRIPTION$
|
|
38857
|
-
const inputSchema$
|
|
38935
|
+
const TOOL_NAME$15 = "analyze_damage_range";
|
|
38936
|
+
const TOOL_DESCRIPTION$15 = "ダメージ計算を逆引きして、防御側を耐えさせるために必要な最小 SP 配分を探索する。`damage` には min/max ダメージと % を、`nHitKo` には確定 X 発の数を、`survivalSpConfig` には確定耐えに必要な最小 SP 配分を返す。ポケモンチャンピオンズ仕様(SP 各 0-32 / 合計 0-66)で計算。正確な計算のため攻撃側・防御側の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
38937
|
+
const inputSchema$12 = {
|
|
38858
38938
|
attacker: pokemonSchema.describe("攻撃側ポケモン"),
|
|
38859
38939
|
defender: pokemonSchema.describe("防御側ポケモン"),
|
|
38860
38940
|
moveName: z.string().describe("技名(日本語 or 英語)"),
|
|
@@ -38986,7 +39066,7 @@ function findMinimalSurvivalSp(damageCalculator, attacker, defender, moveName, c
|
|
|
38986
39066
|
};
|
|
38987
39067
|
}
|
|
38988
39068
|
function registerDamageRangeTool(server) {
|
|
38989
|
-
server.tool(TOOL_NAME$
|
|
39069
|
+
server.tool(TOOL_NAME$15, TOOL_DESCRIPTION$15, inputSchema$12, async (args) => {
|
|
38990
39070
|
try {
|
|
38991
39071
|
const moveEn = moveNameResolver.toEnglish(args.moveName) ?? (moveNameResolver.hasEnglishName(args.moveName) ? args.moveName : null);
|
|
38992
39072
|
if (moveEn === null) {
|
|
@@ -39055,263 +39135,6 @@ function registerDamageRangeTool(server) {
|
|
|
39055
39135
|
}
|
|
39056
39136
|
});
|
|
39057
39137
|
}
|
|
39058
|
-
// src/tools/analysis/find-counters.ts
|
|
39059
|
-
const CHAMPIONS_GEN_NUM$7 = 0;
|
|
39060
|
-
/** 弱点タイプ判定のしきい値(候補プール抽出で使用) */
|
|
39061
|
-
const SUPER_EFFECTIVE_MIN = 2;
|
|
39062
|
-
/** Status 技 */
|
|
39063
|
-
const STATUS_CATEGORY$2 = "Status";
|
|
39064
|
-
const TOOL_NAME$15 = "find_counters";
|
|
39065
|
-
const TOOL_DESCRIPTION$15 = "target の弱点タイプ攻撃技を持つポケモンを候補プールとして抽出し、各候補の双方向ダメ計・素早さ・タイプ相性を返す。`candidatePool` は文字列(名前のみ)と PokemonInput オブジェクト(ability / item / nature / evs 指定)を混在可能で、同一ポケモンの build 違い比較にも対応する。正確な計算のため target 側の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。判断(受け型か速度勝ち型か等)は AI が行う前提。ポケモンチャンピオンズ対応。";
|
|
39066
|
-
const battleFormatValues = ["singles", "doubles"];
|
|
39067
|
-
const candidatePoolItemSchema = z.union([z.string(), pokemonSchema]);
|
|
39068
|
-
const inputSchema$12 = {
|
|
39069
|
-
target: pokemonSchema.describe("対策したい相手ポケモン"),
|
|
39070
|
-
candidatePool: z.array(candidatePoolItemSchema).optional().describe("候補プール。各要素は「ポケモン名の文字列(簡易指定、デフォルト build で評価)」または「PokemonInput オブジェクト(name に加え ability / item / nature / evs / boosts / status を指定可能)」。同じポケモン名でも build 違いを並列で比較できる。未指定時は target の弱点タイプ攻撃技を覚える Champions 全ポケモンから自動選定(デフォルト build 評価)。"),
|
|
39071
|
-
battleFormat: z.enum(battleFormatValues).optional().describe("対戦形式(省略時: singles)")
|
|
39072
|
-
};
|
|
39073
|
-
/**
|
|
39074
|
-
* extractPriorityMoves 用の move 解決。learnset ID から MoveEntry を引く。
|
|
39075
|
-
*/
|
|
39076
|
-
function resolveMoveForPriority$1(id) {
|
|
39077
|
-
return movesById.get(id);
|
|
39078
|
-
}
|
|
39079
|
-
/**
|
|
39080
|
-
* extractPriorityMoves 用の日本語名解決。
|
|
39081
|
-
*/
|
|
39082
|
-
function moveToJapanese$1(en) {
|
|
39083
|
-
return moveNameResolver.toJapanese(en);
|
|
39084
|
-
}
|
|
39085
|
-
/**
|
|
39086
|
-
* 指定ポケモン ID の learnset から先制技のみを抽出する。
|
|
39087
|
-
* learnset データが無い場合は空配列を返す。
|
|
39088
|
-
*/
|
|
39089
|
-
function buildPriorityMoves(pokemonId) {
|
|
39090
|
-
return extractPriorityMoves({
|
|
39091
|
-
learnsetMoveIds: championsLearnsets[pokemonId] ?? [],
|
|
39092
|
-
resolveMove: resolveMoveForPriority$1,
|
|
39093
|
-
toJapanese: moveToJapanese$1
|
|
39094
|
-
});
|
|
39095
|
-
}
|
|
39096
|
-
/**
|
|
39097
|
-
* ポケモン名を pokemon.json のエントリに解決する。
|
|
39098
|
-
*/
|
|
39099
|
-
function resolvePokemonEntry$2(name) {
|
|
39100
|
-
const englishName = pokemonNameResolver.toEnglish(name) ?? (pokemonNameResolver.hasEnglishName(name) ? name : null);
|
|
39101
|
-
if (englishName === null) {
|
|
39102
|
-
const suggestions = pokemonNameResolver.suggestSimilar(name);
|
|
39103
|
-
const suggestionMessage = suggestions.length > 0 ? ` もしかして: ${suggestions.join(", ")}` : "";
|
|
39104
|
-
throw new Error(`ポケモン「${name}」が見つかりません。${suggestionMessage}`);
|
|
39105
|
-
}
|
|
39106
|
-
const entry = pokemonById.get(toDataId(englishName));
|
|
39107
|
-
if (entry === void 0) throw new Error(`ポケモン「${name}」のデータが見つかりません。`);
|
|
39108
|
-
return entry;
|
|
39109
|
-
}
|
|
39110
|
-
/**
|
|
39111
|
-
* 攻撃タイプから防御タイプ配列への複合倍率を算出する。
|
|
39112
|
-
*/
|
|
39113
|
-
function calcMultiplier(attackTypeName, defenderTypes, gen) {
|
|
39114
|
-
return calculateTypeEffectiveness(gen, attackTypeName, defenderTypes);
|
|
39115
|
-
}
|
|
39116
|
-
/**
|
|
39117
|
-
* target のタイプに対して 2 倍以上の弱点タイプを洗い出す。
|
|
39118
|
-
*/
|
|
39119
|
-
function findTypeWeaknesses(defenderTypes, gen) {
|
|
39120
|
-
const typeJaMap = new Map(championsTypes.map((t) => [t.name, t.nameJa]));
|
|
39121
|
-
const weaknesses = [];
|
|
39122
|
-
for (const attackerType of championsTypes) {
|
|
39123
|
-
const m = calcMultiplier(attackerType.name, defenderTypes, gen);
|
|
39124
|
-
if (m >= SUPER_EFFECTIVE_MIN) weaknesses.push({
|
|
39125
|
-
type: attackerType.name,
|
|
39126
|
-
nameJa: typeJaMap.get(attackerType.name) ?? attackerType.name,
|
|
39127
|
-
multiplier: m
|
|
39128
|
-
});
|
|
39129
|
-
}
|
|
39130
|
-
weaknesses.sort((a, b) => {
|
|
39131
|
-
if (a.multiplier !== b.multiplier) return b.multiplier - a.multiplier;
|
|
39132
|
-
return a.type.localeCompare(b.type);
|
|
39133
|
-
});
|
|
39134
|
-
return weaknesses;
|
|
39135
|
-
}
|
|
39136
|
-
/**
|
|
39137
|
-
* ポケモンが指定タイプ集合のいずれかに属する攻撃技を覚えるかを判定する。
|
|
39138
|
-
* 前フィルタとして使用。
|
|
39139
|
-
*/
|
|
39140
|
-
function hasAttackingMoveOfAnyType(pokemonId, weaknessTypes) {
|
|
39141
|
-
const learnset = championsLearnsets[pokemonId];
|
|
39142
|
-
if (learnset === void 0) return false;
|
|
39143
|
-
for (const moveId of learnset) {
|
|
39144
|
-
const move = movesById.get(moveId);
|
|
39145
|
-
if (move === void 0) continue;
|
|
39146
|
-
if (move.category === STATUS_CATEGORY$2) continue;
|
|
39147
|
-
if (weaknessTypes.has(move.type)) return true;
|
|
39148
|
-
}
|
|
39149
|
-
return false;
|
|
39150
|
-
}
|
|
39151
|
-
/**
|
|
39152
|
-
* ターゲットのタイプに対して弱点となるタイプ集合を算出する。
|
|
39153
|
-
*/
|
|
39154
|
-
function buildWeaknessTypeSet(targetTypes, gen) {
|
|
39155
|
-
const set = /* @__PURE__ */ new Set();
|
|
39156
|
-
for (const attackerType of championsTypes) if (calcMultiplier(attackerType.name, targetTypes, gen) >= SUPER_EFFECTIVE_MIN) set.add(attackerType.name);
|
|
39157
|
-
return set;
|
|
39158
|
-
}
|
|
39159
|
-
/**
|
|
39160
|
-
* PokemonInput から build 部分(name 以外)を抽出する。
|
|
39161
|
-
* 省略されたフィールドは含めない。
|
|
39162
|
-
*/
|
|
39163
|
-
function extractBuildInfo(input) {
|
|
39164
|
-
const build = {};
|
|
39165
|
-
if (input.ability !== void 0) build.ability = input.ability;
|
|
39166
|
-
if (input.item !== void 0) build.item = input.item;
|
|
39167
|
-
if (input.nature !== void 0) build.nature = input.nature;
|
|
39168
|
-
if (input.evs !== void 0) build.evs = input.evs;
|
|
39169
|
-
if (input.boosts !== void 0) build.boosts = input.boosts;
|
|
39170
|
-
if (input.status !== void 0) build.status = input.status;
|
|
39171
|
-
return build;
|
|
39172
|
-
}
|
|
39173
|
-
/**
|
|
39174
|
-
* 候補のソート用 tiebreaker として使う安定的な署名を生成する。
|
|
39175
|
-
* 同名ポケモンの build 違いを区別する。build 未指定(string or 自動選定)は "default" 扱い。
|
|
39176
|
-
*/
|
|
39177
|
-
function buildSignature(candidate) {
|
|
39178
|
-
if (!candidate.hasExplicitBuild) return "default";
|
|
39179
|
-
return JSON.stringify(extractBuildInfo(candidate.input));
|
|
39180
|
-
}
|
|
39181
|
-
/**
|
|
39182
|
-
* 候補プールを決定する。
|
|
39183
|
-
* - candidatePool 指定時: 各要素(string or PokemonInput)を正規化して CandidateBuild 配列で返す。
|
|
39184
|
-
* - 未指定時: target のタイプ弱点を攻撃技として持つ全 Champions ポケモンに絞る(デフォルト build)。
|
|
39185
|
-
*/
|
|
39186
|
-
function buildCandidateEntries(candidatePool, target, gen) {
|
|
39187
|
-
if (candidatePool !== void 0) {
|
|
39188
|
-
const candidates = [];
|
|
39189
|
-
for (const item of candidatePool) if (typeof item === "string") {
|
|
39190
|
-
const entry = resolvePokemonEntry$2(item);
|
|
39191
|
-
candidates.push({
|
|
39192
|
-
entry,
|
|
39193
|
-
input: { name: entry.name },
|
|
39194
|
-
hasExplicitBuild: false
|
|
39195
|
-
});
|
|
39196
|
-
} else {
|
|
39197
|
-
const entry = resolvePokemonEntry$2(item.name);
|
|
39198
|
-
candidates.push({
|
|
39199
|
-
entry,
|
|
39200
|
-
input: {
|
|
39201
|
-
...item,
|
|
39202
|
-
name: entry.name
|
|
39203
|
-
},
|
|
39204
|
-
hasExplicitBuild: true
|
|
39205
|
-
});
|
|
39206
|
-
}
|
|
39207
|
-
return candidates;
|
|
39208
|
-
}
|
|
39209
|
-
const weaknessTypes = buildWeaknessTypeSet(target.types, gen);
|
|
39210
|
-
return (weaknessTypes.size === 0 ? [...championsPokemon].filter((p) => p.id !== target.id) : championsPokemon.filter((p) => p.id !== target.id && hasAttackingMoveOfAnyType(p.id, weaknessTypes))).map((entry) => ({
|
|
39211
|
-
entry,
|
|
39212
|
-
input: { name: entry.name },
|
|
39213
|
-
hasExplicitBuild: false
|
|
39214
|
-
}));
|
|
39215
|
-
}
|
|
39216
|
-
function registerFindCountersTool(server) {
|
|
39217
|
-
server.tool(TOOL_NAME$15, TOOL_DESCRIPTION$15, inputSchema$12, async (args) => {
|
|
39218
|
-
try {
|
|
39219
|
-
const gen = Generations.get(CHAMPIONS_GEN_NUM$7);
|
|
39220
|
-
const damageConditions = { battleFormat: args.battleFormat };
|
|
39221
|
-
const targetEntry = resolvePokemonEntry$2(args.target.name);
|
|
39222
|
-
const { pokemon: targetObj, resolvedName: targetName } = damageCalculator.createPokemonObject(args.target);
|
|
39223
|
-
const targetNameJa = pokemonNameResolver.toJapanese(targetName) ?? targetName;
|
|
39224
|
-
const typeWeaknesses = findTypeWeaknesses(targetEntry.types, gen);
|
|
39225
|
-
const targetStats = {
|
|
39226
|
-
hp: targetObj.stats.hp,
|
|
39227
|
-
atk: targetObj.stats.atk,
|
|
39228
|
-
def: targetObj.stats.def,
|
|
39229
|
-
spa: targetObj.stats.spa,
|
|
39230
|
-
spd: targetObj.stats.spd,
|
|
39231
|
-
spe: targetObj.stats.spe
|
|
39232
|
-
};
|
|
39233
|
-
const candidateBuilds = buildCandidateEntries(args.candidatePool, targetEntry, gen);
|
|
39234
|
-
const counterEntries = [];
|
|
39235
|
-
for (const candidate of candidateBuilds) {
|
|
39236
|
-
const candidateEntry = candidate.entry;
|
|
39237
|
-
const candidateInput = candidate.input;
|
|
39238
|
-
let candidateObj;
|
|
39239
|
-
try {
|
|
39240
|
-
candidateObj = damageCalculator.createPokemonObject(candidateInput).pokemon;
|
|
39241
|
-
} catch {
|
|
39242
|
-
continue;
|
|
39243
|
-
}
|
|
39244
|
-
let outgoing = [];
|
|
39245
|
-
let incoming = [];
|
|
39246
|
-
try {
|
|
39247
|
-
outgoing = filterResultsByLearnset(damageCalculator.calculateAllMoves({
|
|
39248
|
-
attacker: candidateInput,
|
|
39249
|
-
defender: args.target,
|
|
39250
|
-
conditions: damageConditions
|
|
39251
|
-
}), getLearnsetMoveIdSet(candidateEntry.id), toDataId);
|
|
39252
|
-
} catch {
|
|
39253
|
-
outgoing = [];
|
|
39254
|
-
}
|
|
39255
|
-
try {
|
|
39256
|
-
incoming = filterResultsByLearnset(damageCalculator.calculateAllMoves({
|
|
39257
|
-
attacker: args.target,
|
|
39258
|
-
defender: candidateInput,
|
|
39259
|
-
conditions: damageConditions
|
|
39260
|
-
}), getLearnsetMoveIdSet(targetEntry.id), toDataId);
|
|
39261
|
-
} catch {
|
|
39262
|
-
incoming = [];
|
|
39263
|
-
}
|
|
39264
|
-
const speedCompare = compareSpeed(candidateObj.stats.spe, targetObj.stats.spe);
|
|
39265
|
-
const nameJa = candidateEntry.nameJa ?? candidateEntry.name;
|
|
39266
|
-
const pokemonProfile = {
|
|
39267
|
-
id: candidateEntry.id,
|
|
39268
|
-
name: candidateEntry.name,
|
|
39269
|
-
nameJa,
|
|
39270
|
-
types: [...candidateEntry.types],
|
|
39271
|
-
baseStats: { ...candidateEntry.baseStats },
|
|
39272
|
-
abilities: [...candidateEntry.abilities]
|
|
39273
|
-
};
|
|
39274
|
-
if (candidate.hasExplicitBuild) pokemonProfile.build = extractBuildInfo(candidateInput);
|
|
39275
|
-
counterEntries.push({
|
|
39276
|
-
pokemon: pokemonProfile,
|
|
39277
|
-
speedCompare,
|
|
39278
|
-
outgoing,
|
|
39279
|
-
incoming,
|
|
39280
|
-
priorityMoves: buildPriorityMoves(candidateEntry.id),
|
|
39281
|
-
sortKey: buildSignature(candidate)
|
|
39282
|
-
});
|
|
39283
|
-
}
|
|
39284
|
-
counterEntries.sort((a, b) => {
|
|
39285
|
-
const nameOrder = a.pokemon.name.localeCompare(b.pokemon.name);
|
|
39286
|
-
if (nameOrder !== 0) return nameOrder;
|
|
39287
|
-
return a.sortKey.localeCompare(b.sortKey);
|
|
39288
|
-
});
|
|
39289
|
-
const output = {
|
|
39290
|
-
target: {
|
|
39291
|
-
name: targetName,
|
|
39292
|
-
nameJa: targetNameJa,
|
|
39293
|
-
stats: targetStats,
|
|
39294
|
-
typeWeaknesses,
|
|
39295
|
-
priorityMoves: buildPriorityMoves(targetEntry.id)
|
|
39296
|
-
},
|
|
39297
|
-
counters: counterEntries.map(({ sortKey: _sortKey, ...rest }) => rest)
|
|
39298
|
-
};
|
|
39299
|
-
return withHint({
|
|
39300
|
-
type: "text",
|
|
39301
|
-
text: JSON.stringify(output)
|
|
39302
|
-
});
|
|
39303
|
-
} catch (error) {
|
|
39304
|
-
const message = error instanceof Error ? error.message : "不明なエラーが発生しました";
|
|
39305
|
-
return {
|
|
39306
|
-
content: [{
|
|
39307
|
-
type: "text",
|
|
39308
|
-
text: JSON.stringify({ error: message })
|
|
39309
|
-
}],
|
|
39310
|
-
isError: true
|
|
39311
|
-
};
|
|
39312
|
-
}
|
|
39313
|
-
});
|
|
39314
|
-
}
|
|
39315
39138
|
// src/party-store.ts
|
|
39316
39139
|
/** ai-rotom の永続化用ディレクトリ名 (ホーム直下)。 */
|
|
39317
39140
|
const AI_ROTOM_DIR_NAME = ".ai-rotom";
|
|
@@ -39687,12 +39510,21 @@ function registerLearnsetTool(server) {
|
|
|
39687
39510
|
}
|
|
39688
39511
|
});
|
|
39689
39512
|
}
|
|
39513
|
+
// src/calc/candidate-moves.ts
|
|
39514
|
+
/**
|
|
39515
|
+
* ポケモンが使う候補技の ID 一覧を返す。
|
|
39516
|
+
* 技構成の指定があればその技、なければ習得技すべて。
|
|
39517
|
+
*/
|
|
39518
|
+
function candidateMoveIds(resolvedName, moves) {
|
|
39519
|
+
if (moves !== void 0 && moves.length > 0) return damageCalculator.resolveMoveNames(moves).map(toDataId);
|
|
39520
|
+
return [...learnsetProvider.getMoveIds(resolvedName)];
|
|
39521
|
+
}
|
|
39690
39522
|
// src/tools/analysis/matchup.ts
|
|
39691
39523
|
const TOOL_NAME$11 = "analyze_matchup";
|
|
39692
|
-
const TOOL_DESCRIPTION$11 = "ポケモン2
|
|
39524
|
+
const TOOL_DESCRIPTION$11 = "ポケモン2体の対面を分析する。双方向のダメージ計算と素早さ比較を行い、どちらが有利かを判断するためのデータを提供する。ポケモン対戦の対面判断に使用する。技ごとの結果はタイプ・相性・ダメージ割合・確定数の要約で、乱数の内訳は含まない。計算条件の説明文は最大打点の技にだけ付く。1 技の詳しい結果は calculate_damage_single で確認する。pokemon1Faster は静的な素早さ実数値のみの比較のため、素早さ負けでも先制技で逆転できる判断は pokemon{1,2}PriorityMoves を併用すること。正確な計算のため双方の ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
39693
39525
|
const matchupInputSchema = {
|
|
39694
|
-
pokemon1:
|
|
39695
|
-
pokemon2:
|
|
39526
|
+
pokemon1: pokemonWithMovesSchema.describe("ポケモン1"),
|
|
39527
|
+
pokemon2: pokemonWithMovesSchema.describe("ポケモン2"),
|
|
39696
39528
|
conditions: conditionsSchema.optional().describe("バトル条件")
|
|
39697
39529
|
};
|
|
39698
39530
|
function resolveMoveForPriority(id) {
|
|
@@ -39701,9 +39533,9 @@ function resolveMoveForPriority(id) {
|
|
|
39701
39533
|
function moveToJapanese(en) {
|
|
39702
39534
|
return moveNameResolver.toJapanese(en);
|
|
39703
39535
|
}
|
|
39704
|
-
function priorityMovesFor(resolvedName) {
|
|
39536
|
+
function priorityMovesFor(resolvedName, moves) {
|
|
39705
39537
|
return extractPriorityMoves({
|
|
39706
|
-
learnsetMoveIds:
|
|
39538
|
+
learnsetMoveIds: candidateMoveIds(resolvedName, moves),
|
|
39707
39539
|
resolveMove: resolveMoveForPriority,
|
|
39708
39540
|
toJapanese: moveToJapanese
|
|
39709
39541
|
});
|
|
@@ -39729,16 +39561,16 @@ function registerMatchupTool(server) {
|
|
|
39729
39561
|
const { pokemon: p2, resolvedName: name2 } = damageCalculator.createPokemonObject(args.pokemon2);
|
|
39730
39562
|
const nameJa1 = pokemonNameResolver.toJapanese(name1) ?? name1;
|
|
39731
39563
|
const nameJa2 = pokemonNameResolver.toJapanese(name2) ?? name2;
|
|
39732
|
-
const pokemon1Attacks =
|
|
39564
|
+
const pokemon1Attacks = damageCalculator.calculateAllMoves({
|
|
39733
39565
|
attacker: args.pokemon1,
|
|
39734
39566
|
defender: args.pokemon2,
|
|
39735
39567
|
conditions: args.conditions
|
|
39736
|
-
})
|
|
39737
|
-
const pokemon2Attacks =
|
|
39568
|
+
});
|
|
39569
|
+
const pokemon2Attacks = damageCalculator.calculateAllMoves({
|
|
39738
39570
|
attacker: args.pokemon2,
|
|
39739
39571
|
defender: args.pokemon1,
|
|
39740
39572
|
conditions: args.conditions
|
|
39741
|
-
})
|
|
39573
|
+
});
|
|
39742
39574
|
const gen = damageCalculator.getGen();
|
|
39743
39575
|
const typeSummary = {
|
|
39744
39576
|
p1ToP2MaxByPokemonType: maxTypeMultiplier$1(p1.types, p2.types, gen),
|
|
@@ -39756,10 +39588,10 @@ function registerMatchupTool(server) {
|
|
|
39756
39588
|
speed: p2.stats.spe
|
|
39757
39589
|
},
|
|
39758
39590
|
pokemon1Faster: compareSpeed(p1.stats.spe, p2.stats.spe) === "faster",
|
|
39759
|
-
pokemon1Attacks,
|
|
39760
|
-
pokemon2Attacks,
|
|
39761
|
-
pokemon1PriorityMoves: priorityMovesFor(name1),
|
|
39762
|
-
pokemon2PriorityMoves: priorityMovesFor(name2),
|
|
39591
|
+
pokemon1Attacks: summarizeMoveDamages(pokemon1Attacks, moveToJapanese),
|
|
39592
|
+
pokemon2Attacks: summarizeMoveDamages(pokemon2Attacks, moveToJapanese),
|
|
39593
|
+
pokemon1PriorityMoves: priorityMovesFor(name1, args.pokemon1.moves),
|
|
39594
|
+
pokemon2PriorityMoves: priorityMovesFor(name2, args.pokemon2.moves),
|
|
39763
39595
|
typeSummary
|
|
39764
39596
|
};
|
|
39765
39597
|
return withHint({
|
|
@@ -40708,10 +40540,10 @@ const CHAMPIONS_GEN_NUM$3 = 0;
|
|
|
40708
40540
|
const TOOL_NAME$3 = "analyze_selection";
|
|
40709
40541
|
const TOOL_DESCRIPTION$3 = "6v6 パーティ間の全対面(最大 36 エントリ)について、タイプ相性・素早さ比較・最大ダメージ見積もりをマトリクスで返す。選出判断は本ツールが返すデータを元に AI が総合的に行う前提で、ツール側では推奨やスコアリングは行わない。ポケモンチャンピオンズ対応。正確な計算のため各ポケモンの ability / item の指定を推奨(省略時は通常特性・持ち物なし扱い)。";
|
|
40710
40542
|
const inputSchema$2 = {
|
|
40711
|
-
myParty: z.array(
|
|
40543
|
+
myParty: z.array(pokemonWithMovesSchema).describe("自分のパーティ"),
|
|
40712
40544
|
opponentParty: z.array(pokemonSchema).describe("相手のパーティ"),
|
|
40713
40545
|
battleFormat: z.enum(["singles", "doubles"]).describe("対戦形式(シングル: singles / ダブル: doubles)"),
|
|
40714
|
-
moves: z.record(z.string(), z.array(z.string())).optional().describe("ポケモン名(日本語 or
|
|
40546
|
+
moves: z.record(z.string(), z.array(z.string())).optional().describe("ポケモン名(日本語 or 英語)ごとに候補技を指定する。指定がなければ myParty 各メンバーの moves、それもなければ習得技すべてで計算する。")
|
|
40715
40547
|
};
|
|
40716
40548
|
/**
|
|
40717
40549
|
* 2つのポケモンタイプ配列から、攻撃側→防御側の最大抜群倍率を算出する。
|
|
@@ -40756,22 +40588,25 @@ function resolveMovesMap(moves) {
|
|
|
40756
40588
|
if (moves === void 0) return result;
|
|
40757
40589
|
for (const [pokemonName, moveList] of Object.entries(moves)) {
|
|
40758
40590
|
const englishName = pokemonNameResolver.toEnglish(pokemonName) ?? (pokemonNameResolver.hasEnglishName(pokemonName) ? pokemonName : null);
|
|
40759
|
-
if (englishName === null)
|
|
40591
|
+
if (englishName === null) throw new Error(`moves に指定したポケモン「${pokemonName}」が見つかりません。`);
|
|
40760
40592
|
const id = toDataId(englishName);
|
|
40761
|
-
result.set(id, moveList);
|
|
40593
|
+
result.set(id, damageCalculator.resolveMoveNames(moveList));
|
|
40762
40594
|
}
|
|
40763
40595
|
return result;
|
|
40764
40596
|
}
|
|
40597
|
+
function explicitMovesFor(pokemonId, movesMap) {
|
|
40598
|
+
const moves = movesMap.get(pokemonId);
|
|
40599
|
+
return moves !== void 0 && moves.length > 0 ? moves : void 0;
|
|
40600
|
+
}
|
|
40765
40601
|
/**
|
|
40766
40602
|
* attacker vs defender の候補技でダメージを計算する。
|
|
40767
|
-
* movesMap
|
|
40768
|
-
* movesMap 未指定経路では attacker の learnset でフィルタし、覚えない技での過大評価を避ける。
|
|
40603
|
+
* movesMap に指定があればそれを、無ければ attacker.moves、それも無ければ習得技すべてで計算する。
|
|
40769
40604
|
* 明示指定経路は learnset フィルタを掛けない(ユーザーの明示選択を尊重する既存仕様を維持)。
|
|
40770
40605
|
* conditions (battleFormat 等) を damageCalculator に伝える。
|
|
40771
40606
|
*/
|
|
40772
|
-
function calculateDamageForMatchup(damageCalculator, attacker, defender, attackerId,
|
|
40773
|
-
const explicitMoves =
|
|
40774
|
-
if (explicitMoves !== void 0
|
|
40607
|
+
function calculateDamageForMatchup(damageCalculator, attacker, defender, attackerId, movesMap, conditions) {
|
|
40608
|
+
const explicitMoves = explicitMovesFor(attackerId, movesMap);
|
|
40609
|
+
if (explicitMoves !== void 0) {
|
|
40775
40610
|
const results = [];
|
|
40776
40611
|
for (const moveName of explicitMoves) try {
|
|
40777
40612
|
results.push(damageCalculator.calculate({
|
|
@@ -40784,11 +40619,11 @@ function calculateDamageForMatchup(damageCalculator, attacker, defender, attacke
|
|
|
40784
40619
|
results.sort((a, b) => b.max - a.max);
|
|
40785
40620
|
return results;
|
|
40786
40621
|
}
|
|
40787
|
-
return
|
|
40622
|
+
return damageCalculator.calculateAllMoves({
|
|
40788
40623
|
attacker,
|
|
40789
40624
|
defender,
|
|
40790
40625
|
conditions
|
|
40791
|
-
})
|
|
40626
|
+
});
|
|
40792
40627
|
}
|
|
40793
40628
|
function registerSelectionAnalysisTool(server) {
|
|
40794
40629
|
server.tool(TOOL_NAME$3, TOOL_DESCRIPTION$3, inputSchema$2, async (args) => {
|
|
@@ -40796,14 +40631,15 @@ function registerSelectionAnalysisTool(server) {
|
|
|
40796
40631
|
const gen = Generations.get(CHAMPIONS_GEN_NUM$3);
|
|
40797
40632
|
const movesMap = resolveMovesMap(args.moves);
|
|
40798
40633
|
const damageConditions = { battleFormat: args.battleFormat };
|
|
40799
|
-
function buildMemberContext(input) {
|
|
40634
|
+
function buildMemberContext(input, partyMoves) {
|
|
40635
|
+
damageCalculator.resolveMoveNames(input.moves ?? []);
|
|
40800
40636
|
const { pokemon, resolvedName } = damageCalculator.createPokemonObject(input);
|
|
40801
40637
|
const entryId = toDataId(resolvedName);
|
|
40802
40638
|
const entry = pokemonById.get(entryId);
|
|
40803
40639
|
const nameJa = pokemonNameResolver.toJapanese(resolvedName) ?? resolvedName;
|
|
40804
40640
|
const types = entry !== void 0 ? [...entry.types] : [...pokemon.types];
|
|
40805
40641
|
const priorityMoves = extractPriorityMoves({
|
|
40806
|
-
learnsetMoveIds:
|
|
40642
|
+
learnsetMoveIds: candidateMoveIds(resolvedName, explicitMovesFor(entryId, partyMoves) ?? input.moves),
|
|
40807
40643
|
resolveMove: (id) => movesById.get(id),
|
|
40808
40644
|
toJapanese: (enName) => moveNameResolver.toJapanese(enName)
|
|
40809
40645
|
});
|
|
@@ -40826,10 +40662,8 @@ function registerSelectionAnalysisTool(server) {
|
|
|
40826
40662
|
entryId
|
|
40827
40663
|
};
|
|
40828
40664
|
}
|
|
40829
|
-
const myMembers = args.myParty.map(buildMemberContext);
|
|
40830
|
-
const oppMembers = args.opponentParty.map(buildMemberContext);
|
|
40831
|
-
const myLearnsetIds = /* @__PURE__ */ new Map();
|
|
40832
|
-
for (const mine of myMembers) myLearnsetIds.set(mine.entryId, getLearnsetMoveIdSet(mine.entryId));
|
|
40665
|
+
const myMembers = args.myParty.map((input) => buildMemberContext(input, movesMap));
|
|
40666
|
+
const oppMembers = args.opponentParty.map((input) => buildMemberContext(input, /* @__PURE__ */ new Map()));
|
|
40833
40667
|
const matrix = [];
|
|
40834
40668
|
for (const mine of myMembers) for (const opp of oppMembers) {
|
|
40835
40669
|
const myToOpp = maxTypeMultiplier(mine.profile.types, opp.profile.types, gen);
|
|
@@ -40837,7 +40671,7 @@ function registerSelectionAnalysisTool(server) {
|
|
|
40837
40671
|
const speedCompare = compareSpeed(mine.profile.actualStats.spe, opp.profile.actualStats.spe);
|
|
40838
40672
|
let damageEstimate = null;
|
|
40839
40673
|
try {
|
|
40840
|
-
damageEstimate = bestDamageEstimate(calculateDamageForMatchup(damageCalculator, mine.input, opp.input, mine.entryId,
|
|
40674
|
+
damageEstimate = bestDamageEstimate(calculateDamageForMatchup(damageCalculator, mine.input, opp.input, mine.entryId, movesMap, damageConditions), (enName) => moveNameResolver.toJapanese(enName));
|
|
40841
40675
|
} catch {
|
|
40842
40676
|
damageEstimate = null;
|
|
40843
40677
|
}
|
|
@@ -41145,7 +40979,6 @@ function createServer() {
|
|
|
41145
40979
|
registerConditionInfoTool(server);
|
|
41146
40980
|
registerDamageCalculationTools(server);
|
|
41147
40981
|
registerDamageRangeTool(server);
|
|
41148
|
-
registerFindCountersTool(server);
|
|
41149
40982
|
registerImportPartyFromTextTool(server);
|
|
41150
40983
|
registerItemInfoTool(server);
|
|
41151
40984
|
registerLearnsetTool(server);
|