Commit 2bab3140 authored by Chunchi Che's avatar Chunchi Che

add genPredictReq but remain unimpl

parent 308c696a
Pipeline #27902 failed with stages
in 9 minutes
......@@ -11,7 +11,7 @@ interface CreateResp {
index: number;
}
export async function crateDuel(): Promise<CreateResp | undefined> {
export async function createDuel(): Promise<CreateResp | undefined> {
const headers = agentHeader();
const resp = await fetch(`${agentServer}/${API_PATH}`, {
......
......@@ -7,7 +7,7 @@ import { agentHeader } from "./util";
const { agentServer } = useConfig();
const apiPath = (duelId: string) => `${agentServer}/v0/duels/${duelId}/predict`;
interface PredictReq {
export interface PredictReq {
/**
* The index must be equal to the index from the previous response of the same duelId.
*/
......
import { PredictReq } from "@/api";
import { cardStore, matStore, placeStore } from "@/stores";
export function genPredictReq(): PredictReq {
// 全局信息可以从 `matStore` 里面拿
const mat = matStore;
// 卡片信息可以从 `cardStore` 里面拿
const cards = cardStore.inner;
// 选择场上位置的可选项可以从 `cardStore` 里面拿
// 也可以从 `selectPlace` msg 里面获取
const place = placeStore;
const duelId = mat.duelId;
const index = mat.agentIndex;
// TODO: impl
}
import { flatten } from "lodash-es";
import { v4 as v4uuid } from "uuid";
import { ygopro } from "@/api";
import { createDuel, ygopro } from "@/api";
import { useConfig } from "@/config";
import { sleep } from "@/infra";
import {
......@@ -89,6 +89,10 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
// note: 额外卡组的卡会在对局开始后通过`UpdateData` msg更新
const { duelId, index } = (await createDuel())!;
matStore.duelId = duelId;
matStore.agentIndex = index;
if (replayStore.isReplay) {
replayStart();
}
......
......@@ -93,6 +93,8 @@ const initialState: Omit<MatState, "reset"> = {
duelEnd: false,
// methods
isMe,
duelId: "",
agentIndex: 0
};
class MatStore implements MatState, NeosStore {
......@@ -109,6 +111,9 @@ class MatStore implements MatState, NeosStore {
tossResult = initialState.tossResult;
selectUnselectInfo = initialState.selectUnselectInfo;
duelEnd = initialState.duelEnd;
duelId = initialState.duelId;
agentIndex = initialState.agentIndex;
// methods
isMe = initialState.isMe;
reset(): void {
......
......@@ -49,6 +49,9 @@ export interface MatState {
/** 根据自己的先后手判断是否是自己 */
isMe: (player: number) => boolean;
duelId: string;
agentIndex: number;
}
export interface InitInfo {
......
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