Commit e0e5c7a6 authored by Chunchi Che's avatar Chunchi Che

fix package-lock.json and format code

parent 85196568
Pipeline #28219 passed with stages
in 10 minutes and 39 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -30,7 +30,7 @@ export async function predictDuel( ...@@ -30,7 +30,7 @@ export async function predictDuel(
): Promise<PredictResp | undefined> { ): Promise<PredictResp | undefined> {
const headers = { const headers = {
...agentHeader(), ...agentHeader(),
'Content-Type': 'application/json', "Content-Type": "application/json",
}; };
const resp = await fetch(`${agentServer}/${apiPath(duelId)}`, { const resp = await fetch(`${agentServer}/${apiPath(duelId)}`, {
......
This diff is collapsed.
import { import {
PredictReq, PredictReq,
ygopro, sendSelectBattleCmdResponse,
sendSelectEffectYnResponse,
sendSelectIdleCmdResponse, sendSelectIdleCmdResponse,
sendSelectPlaceResponse,
sendSelectMultiResponse, sendSelectMultiResponse,
sendSelectSingleResponse,
sendSelectEffectYnResponse,
sendSelectPositionResponse,
sendSelectOptionResponse, sendSelectOptionResponse,
sendSelectBattleCmdResponse, sendSelectPlaceResponse,
sendSortCardResponse, sendSelectPositionResponse,
sendSelectSingleResponse,
ygopro,
} from "@/api"; } from "@/api";
import { cardStore, matStore } from "@/stores"; import { predictDuel } from "@/api/ygoAgent/predict";
import { import {
Global, convertPhase, convertCard, convertDeckCard, convertActionMsg,
parsePlayerFromMsg, convertActionMsg, Input, MultiSelectMsg, MsgSelectSum convertCard,
convertDeckCard,
convertPhase,
Global,
Input,
MsgSelectSum,
MultiSelectMsg,
parsePlayerFromMsg,
} from "@/api/ygoAgent/schema"; } from "@/api/ygoAgent/schema";
import { predictDuel } from "@/api/ygoAgent/predict"; import { cardStore, matStore } from "@/stores";
function computeSetDifference(a1: number[], a2: number[]): number[] { function computeSetDifference(a1: number[], a2: number[]): number[] {
const freq1 = new Map<number, number>(); const freq1 = new Map<number, number>();
...@@ -44,7 +50,6 @@ function computeSetDifference(a1: number[], a2: number[]): number[] { ...@@ -44,7 +50,6 @@ function computeSetDifference(a1: number[], a2: number[]): number[] {
return difference; return difference;
} }
export function genInput(msg: ygopro.StocGameMessage): Input { export function genInput(msg: ygopro.StocGameMessage): Input {
// 全局信息可以从 `matStore` 里面拿 // 全局信息可以从 `matStore` 里面拿
const mat = matStore; const mat = matStore;
...@@ -66,23 +71,29 @@ export function genInput(msg: ygopro.StocGameMessage): Input { ...@@ -66,23 +71,29 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
const opponent = 1 - player; const opponent = 1 - player;
const cards = cardStore.inner const cards = cardStore.inner
.filter((card) => .filter(
zones.includes(card.location.zone) && (card) =>
!(card.location.zone === ygopro.CardZone.DECK zones.includes(card.location.zone) &&
&& card.location.controller === player !(
) card.location.zone === ygopro.CardZone.DECK &&
card.location.controller === player
),
) )
.map((card) => convertCard(card, player)); .map((card) => convertCard(card, player));
const cardCodesMe = cardStore.inner const cardCodesMe = cardStore.inner
.filter((card) => .filter(
zones.includes(card.location.zone) && card.location.controller === player (card) =>
zones.includes(card.location.zone) &&
card.location.controller === player,
) )
.map((card) => card.code); .map((card) => card.code);
const cardCodesMeDeck = computeSetDifference(mat.mainDeck, cardCodesMe); const cardCodesMeDeck = computeSetDifference(mat.mainDeck, cardCodesMe);
const mainDeckCardMeta = mat.mainDeckCardMeta; const mainDeckCardMeta = mat.mainDeckCardMeta;
// TODO (ygo-agent): 临时方案,有很多边界情况未考虑 // TODO (ygo-agent): 临时方案,有很多边界情况未考虑
const deckCardsMe = cardCodesMeDeck.map((code) => convertDeckCard(mainDeckCardMeta.get(code)!)); const deckCardsMe = cardCodesMeDeck.map((code) =>
convertDeckCard(mainDeckCardMeta.get(code)!),
);
const turnPlayer = mat.currentPlayer; const turnPlayer = mat.currentPlayer;
const global: Global = { const global: Global = {
...@@ -92,7 +103,7 @@ export function genInput(msg: ygopro.StocGameMessage): Input { ...@@ -92,7 +103,7 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
op_lp: mat.initInfo.of(opponent).life, op_lp: mat.initInfo.of(opponent).life,
phase: convertPhase(mat.phase.currentPhase), phase: convertPhase(mat.phase.currentPhase),
turn: mat.turnCount, turn: mat.turnCount,
} };
const actionMsg = convertActionMsg(msg); const actionMsg = convertActionMsg(msg);
...@@ -100,10 +111,9 @@ export function genInput(msg: ygopro.StocGameMessage): Input { ...@@ -100,10 +111,9 @@ export function genInput(msg: ygopro.StocGameMessage): Input {
global: global, global: global,
cards: deckCardsMe.concat(cards), cards: deckCardsMe.concat(cards),
action_msg: actionMsg, action_msg: actionMsg,
} };
} }
async function sendRequest(req: PredictReq) { async function sendRequest(req: PredictReq) {
console.log("Sending predict request:", req); console.log("Sending predict request:", req);
const duelId = matStore.duelId; const duelId = matStore.duelId;
...@@ -111,8 +121,7 @@ async function sendRequest(req: PredictReq) { ...@@ -111,8 +121,7 @@ async function sendRequest(req: PredictReq) {
console.log("Got predict response:", resp); console.log("Got predict response:", resp);
if (resp !== undefined) { if (resp !== undefined) {
matStore.agentIndex = resp.index; matStore.agentIndex = resp.index;
} } else {
else {
throw new Error("Failed to get predict response"); throw new Error("Failed to get predict response");
} }
...@@ -143,11 +152,11 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -143,11 +152,11 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx: matStore.prevActionIndex, prev_action_idx: matStore.prevActionIndex,
}; };
const response = (await sendRequest(req)).response; const response = (await sendRequest(req)).response;
if (response != -1) { if (response !== -1) {
selected.push(matStore.prevActionIndex); selected.push(matStore.prevActionIndex);
responses.push(response); responses.push(response);
} }
if (response == -1 || selected.length == msg_.max) { if (response === -1 || selected.length === msg_.max) {
sendSelectMultiResponse(responses); sendSelectMultiResponse(responses);
break; break;
} }
...@@ -169,7 +178,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -169,7 +178,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
prev_action_idx: matStore.prevActionIndex, prev_action_idx: matStore.prevActionIndex,
}; };
const pred = await sendRequest(req); const pred = await sendRequest(req);
const idx = matStore.prevActionIndex const idx = matStore.prevActionIndex;
selected.push(idx); selected.push(idx);
responses.push(pred.response); responses.push(pred.response);
if (pred.can_finish) { if (pred.can_finish) {
...@@ -189,7 +198,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -189,7 +198,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
switch (msgName) { switch (msgName) {
case "announce_attrib": case "announce_attrib":
case "announce_number": case "announce_number":
sendSelectOptionResponse(response); sendSelectOptionResponse(response);
break; break;
case "select_battlecmd": case "select_battlecmd":
sendSelectBattleCmdResponse(response); sendSelectBattleCmdResponse(response);
...@@ -211,7 +220,8 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -211,7 +220,8 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
sendSelectPositionResponse(convertPositionResponse(response)); sendSelectPositionResponse(convertPositionResponse(response));
break; break;
case "select_place": { case "select_place": {
const place = (msg as unknown as ygopro.StocGameMessage.MsgSelectPlace).places[response]; const place = (msg as unknown as ygopro.StocGameMessage.MsgSelectPlace)
.places[response];
sendSelectPlaceResponse({ sendSelectPlaceResponse({
controller: place.controller, controller: place.controller,
zone: place.zone, zone: place.zone,
...@@ -220,7 +230,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -220,7 +230,7 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
break; break;
} }
case "select_unselect_card": { case "select_unselect_card": {
if (response == -1) { if (response === -1) {
sendSelectSingleResponse(-1); sendSelectSingleResponse(-1);
} else { } else {
sendSelectMultiResponse([response]); sendSelectMultiResponse([response]);
...@@ -231,7 +241,6 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) { ...@@ -231,7 +241,6 @@ export async function sendAIPredictAsResponse(msg: ygopro.StocGameMessage) {
} }
} }
function argmax<T>(arr: T[], getValue: (item: T) => number): number { function argmax<T>(arr: T[], getValue: (item: T) => number): number {
if (arr.length === 0) { if (arr.length === 0) {
throw new Error("Array is empty"); throw new Error("Array is empty");
...@@ -251,14 +260,17 @@ function argmax<T>(arr: T[], getValue: (item: T) => number): number { ...@@ -251,14 +260,17 @@ function argmax<T>(arr: T[], getValue: (item: T) => number): number {
return maxIndex; return maxIndex;
} }
function convertPositionResponse(response: number): ygopro.CardPosition { function convertPositionResponse(response: number): ygopro.CardPosition {
switch (response) { switch (response) {
case 0x1: return ygopro.CardPosition.FACEUP_ATTACK; case 0x1:
case 0x2: return ygopro.CardPosition.FACEDOWN_ATTACK; return ygopro.CardPosition.FACEUP_ATTACK;
case 0x4: return ygopro.CardPosition.FACEUP_DEFENSE; case 0x2:
case 0x8: return ygopro.CardPosition.FACEDOWN_DEFENSE; return ygopro.CardPosition.FACEDOWN_ATTACK;
case 0x4:
return ygopro.CardPosition.FACEUP_DEFENSE;
case 0x8:
return ygopro.CardPosition.FACEDOWN_DEFENSE;
default: default:
throw new Error(`Invalid position response: ${response}`); throw new Error(`Invalid position response: ${response}`);
} }
} }
\ No newline at end of file
import { fetchStrings, Region, ygopro } from "@/api"; import { fetchStrings, Region, ygopro } from "@/api";
import { displayOptionModal } from "@/ui/Duel/Message"; import { displayOptionModal } from "@/ui/Duel/Message";
import MsgAnnounce = ygopro.StocGameMessage.MsgAnnounce; import MsgAnnounce = ygopro.StocGameMessage.MsgAnnounce;
import { displayAnnounceModal } from "@/ui/Duel/Message/AnnounceModal";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displayAnnounceModal } from "@/ui/Duel/Message/AnnounceModal";
export default async (announce: MsgAnnounce) => { export default async (announce: MsgAnnounce) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept announce"); console.log("intercept announce");
await sendAIPredictAsResponse(announce as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
return; announce as unknown as ygopro.StocGameMessage,
);
return;
} }
const type_ = announce.announce_type; const type_ = announce.announce_type;
......
...@@ -20,7 +20,9 @@ export default async (selectBattleCmd: MsgSelectBattleCmd) => { ...@@ -20,7 +20,9 @@ export default async (selectBattleCmd: MsgSelectBattleCmd) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectBattleCmd"); console.log("intercept selectBattleCmd");
await sendAIPredictAsResponse(selectBattleCmd as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectBattleCmd as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { sendSelectMultiResponse, ygopro } from "@/api"; import { sendSelectMultiResponse, ygopro } from "@/api";
import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard; import MsgSelectCard = ygopro.StocGameMessage.MsgSelectCard;
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores";
import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal"; import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal";
import { fetchCheckCardMeta } from "../utils"; import { fetchCheckCardMeta } from "../utils";
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores";
export default async (selectCard: MsgSelectCard) => { export default async (selectCard: MsgSelectCard) => {
const { cancelable, min, max, cards } = selectCard; const { cancelable, min, max, cards } = selectCard;
// TODO: handle release_param // TODO: handle release_param
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectCard"); console.log("intercept selectCard");
await sendAIPredictAsResponse(selectCard as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectCard as unknown as ygopro.StocGameMessage,
);
return; return;
} }
...@@ -26,7 +26,6 @@ export default async (selectCard: MsgSelectCard) => { ...@@ -26,7 +26,6 @@ export default async (selectCard: MsgSelectCard) => {
return; return;
} }
const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta( const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta(
cards, cards,
); );
......
import { sendSelectSingleResponse, ygopro } from "@/api"; import { sendSelectSingleResponse, ygopro } from "@/api";
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { ChainSetting, fetchSelectHintMeta, matStore } from "@/stores"; import { ChainSetting, fetchSelectHintMeta, matStore } from "@/stores";
import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal"; import { displaySelectActionsModal } from "@/ui/Duel/Message/SelectActionsModal";
import { fetchCheckCardMeta } from "../utils"; import { fetchCheckCardMeta } from "../utils";
import { sendAIPredictAsResponse } from "@/service/duel/agent";
type MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain; type MsgSelectChain = ygopro.StocGameMessage.MsgSelectChain;
export default async (selectChain: MsgSelectChain) => { export default async (selectChain: MsgSelectChain) => {
...@@ -69,10 +69,12 @@ export default async (selectChain: MsgSelectChain) => { ...@@ -69,10 +69,12 @@ export default async (selectChain: MsgSelectChain) => {
case 3: { case 3: {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectChain"); console.log("intercept selectChain");
await sendAIPredictAsResponse(selectChain as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectChain as unknown as ygopro.StocGameMessage,
);
return; return;
} }
// 处理强制发动的卡 // 处理强制发动的卡
fetchSelectHintMeta({ fetchSelectHintMeta({
selectHintData: 203, selectHintData: 203,
......
import { fetchStrings, Region, type ygopro } from "@/api"; import { fetchStrings, Region, type ygopro } from "@/api";
import { CardMeta, fetchCard } from "@/api/cards"; import { CardMeta, fetchCard } from "@/api/cards";
import { displayYesNoModal } from "@/ui/Duel/Message";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displayYesNoModal } from "@/ui/Duel/Message";
type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn; type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
...@@ -10,7 +10,9 @@ type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn; ...@@ -10,7 +10,9 @@ type MsgSelectEffectYn = ygopro.StocGameMessage.MsgSelectEffectYn;
export default async (selectEffectYn: MsgSelectEffectYn) => { export default async (selectEffectYn: MsgSelectEffectYn) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectEffectYn"); console.log("intercept selectEffectYn");
await sendAIPredictAsResponse(selectEffectYn as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectEffectYn as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { import {
cardStore, cardStore,
type Interactivity, type Interactivity,
InteractType, InteractType,
matStore, matStore,
} from "@/stores"; } from "@/stores";
import { sendAIPredictAsResponse } from "@/service/duel/agent";
import MsgSelectIdleCmd = ygopro.StocGameMessage.MsgSelectIdleCmd; import MsgSelectIdleCmd = ygopro.StocGameMessage.MsgSelectIdleCmd;
...@@ -20,10 +20,12 @@ export default async (selectIdleCmd: MsgSelectIdleCmd) => { ...@@ -20,10 +20,12 @@ export default async (selectIdleCmd: MsgSelectIdleCmd) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectIdleCmd"); console.log("intercept selectIdleCmd");
await sendAIPredictAsResponse(selectIdleCmd as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectIdleCmd as unknown as ygopro.StocGameMessage,
);
return; return;
} }
cmds.forEach((cmd) => { cmds.forEach((cmd) => {
const interactType = idleTypeToInteractType(cmd.idle_type); const interactType = idleTypeToInteractType(cmd.idle_type);
......
...@@ -5,9 +5,9 @@ import { ...@@ -5,9 +5,9 @@ import {
sendSelectOptionResponse, sendSelectOptionResponse,
type ygopro, type ygopro,
} from "@/api"; } from "@/api";
import { displayOptionModal } from "@/ui/Duel/Message";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displayOptionModal } from "@/ui/Duel/Message";
export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => { export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
const options = selectOption.options; const options = selectOption.options;
...@@ -18,7 +18,9 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => { ...@@ -18,7 +18,9 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectOption"); console.log("intercept selectOption");
await sendAIPredictAsResponse(selectOption as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectOption as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { sendSelectPlaceResponse, ygopro } from "@/api"; import { sendSelectPlaceResponse, ygopro } from "@/api";
import { InteractType, placeStore, matStore } from "@/stores";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { InteractType, matStore, placeStore } from "@/stores";
type MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace; type MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
...@@ -12,7 +12,9 @@ export default async (selectPlace: MsgSelectPlace) => { ...@@ -12,7 +12,9 @@ export default async (selectPlace: MsgSelectPlace) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectPlace"); console.log("intercept selectPlace");
await sendAIPredictAsResponse(selectPlace as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectPlace as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { displayPositionModal } from "@/ui/Duel/Message";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displayPositionModal } from "@/ui/Duel/Message";
type MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition; type MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition;
export default async (selectPosition: MsgSelectPosition) => { export default async (selectPosition: MsgSelectPosition) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectPosition"); console.log("intercept selectPosition");
await sendAIPredictAsResponse(selectPosition as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectPosition as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
...@@ -10,7 +10,9 @@ import { matStore } from "@/stores"; ...@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export default async (selectSum: MsgSelectSum) => { export default async (selectSum: MsgSelectSum) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectSum"); console.log("intercept selectSum");
await sendAIPredictAsResponse(selectSum as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectSum as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
...@@ -10,7 +10,9 @@ import { matStore } from "@/stores"; ...@@ -10,7 +10,9 @@ import { matStore } from "@/stores";
export default async (selectTribute: MsgSelectTribute) => { export default async (selectTribute: MsgSelectTribute) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectTribute"); console.log("intercept selectTribute");
await sendAIPredictAsResponse(selectTribute as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectTribute as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
...@@ -11,7 +11,9 @@ import { sendAIPredictAsResponse } from "@/service/duel/agent"; ...@@ -11,7 +11,9 @@ import { sendAIPredictAsResponse } from "@/service/duel/agent";
export default async (selectUnselectCards: MsgSelectUnselectCard) => { export default async (selectUnselectCards: MsgSelectUnselectCard) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectUnselectCards"); console.log("intercept selectUnselectCards");
await sendAIPredictAsResponse(selectUnselectCards as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectUnselectCards as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { getStrings, ygopro } from "@/api"; import { getStrings, ygopro } from "@/api";
import { displayYesNoModal } from "@/ui/Duel/Message";
import { sendAIPredictAsResponse } from "@/service/duel/agent"; import { sendAIPredictAsResponse } from "@/service/duel/agent";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displayYesNoModal } from "@/ui/Duel/Message";
type MsgSelectYesNo = ygopro.StocGameMessage.MsgSelectYesNo; type MsgSelectYesNo = ygopro.StocGameMessage.MsgSelectYesNo;
export default async (selectYesNo: MsgSelectYesNo) => { export default async (selectYesNo: MsgSelectYesNo) => {
if (matStore.autoSelect) { if (matStore.autoSelect) {
console.log("intercept selectYesNo"); console.log("intercept selectYesNo");
await sendAIPredictAsResponse(selectYesNo as unknown as ygopro.StocGameMessage); await sendAIPredictAsResponse(
selectYesNo as unknown as ygopro.StocGameMessage,
);
return; return;
} }
......
import { fetchCard, ygopro } from "@/api"; import { fetchCard, ygopro } from "@/api";
import { displaySortCardModal } from "@/ui/Duel/Message";
import { matStore } from "@/stores"; import { matStore } from "@/stores";
import { displaySortCardModal } from "@/ui/Duel/Message";
type MsgSortCard = ygopro.StocGameMessage.MsgSortCard; type MsgSortCard = ygopro.StocGameMessage.MsgSortCard;
......
import { flatten } from "lodash-es"; import { flatten } from "lodash-es";
import { v4 as v4uuid } from "uuid"; import { v4 as v4uuid } from "uuid";
import { createDuel, ygopro, fetchCard } from "@/api"; import { createDuel, fetchCard, ygopro } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { sleep } from "@/infra"; import { sleep } from "@/infra";
import { import {
...@@ -92,13 +92,12 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -92,13 +92,12 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
const { duelId, index } = (await createDuel())!; const { duelId, index } = (await createDuel())!;
matStore.duelId = duelId; matStore.duelId = duelId;
matStore.agentIndex = index; matStore.agentIndex = index;
matStore.mainDeckCardMeta = matStore.mainDeck matStore.mainDeckCardMeta = matStore.mainDeck.reduce((map, item) => {
.reduce((map, item) => { if (!map.has(item)) {
if (!map.has(item)) { map.set(item, fetchCard(item));
map.set(item, fetchCard(item)); }
} return map;
return map; }, new Map());
}, new Map());
if (replayStore.isReplay) { if (replayStore.isReplay) {
replayStart(); replayStart();
......
...@@ -50,7 +50,7 @@ export interface MatState { ...@@ -50,7 +50,7 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */ /** 根据自己的先后手判断是否是自己 */
isMe: (player: number) => boolean; isMe: (player: number) => boolean;
turnCount: number, turnCount: number;
duelId: string; duelId: string;
agentIndex: number; agentIndex: number;
prevActionIndex: number; prevActionIndex: number;
......
...@@ -3,9 +3,9 @@ import { ...@@ -3,9 +3,9 @@ import {
CheckOutlined, CheckOutlined,
CloseCircleFilled, CloseCircleFilled,
MessageFilled, MessageFilled,
StepForwardFilled,
RobotFilled, RobotFilled,
RobotOutlined, RobotOutlined,
StepForwardFilled,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { import {
Button, Button,
......
...@@ -27,12 +27,12 @@ import { ...@@ -27,12 +27,12 @@ import {
accountStore, accountStore,
deckStore, deckStore,
IDeck, IDeck,
matStore,
Player, Player,
resetUniverse, resetUniverse,
RoomStage, RoomStage,
roomStore, roomStore,
sideStore, sideStore,
matStore,
} from "@/stores"; } from "@/stores";
import { Background, IconFont, Select, SpecialButton } from "@/ui/Shared"; import { Background, IconFont, Select, SpecialButton } from "@/ui/Shared";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment