Commit 0cdb6898 authored by Chunchi Che's avatar Chunchi Che

update

parent 5d36736c
......@@ -4,6 +4,7 @@
* */
import { adaptStoc } from "@/api/ocgcore/ocgAdapter/adapter";
import { YgoProPacket } from "@/api/ocgcore/ocgAdapter/packet";
import { matStore, replayStore } from "@/stores";
import handleGameMsg from "./duel/gameMsg";
import handleTimeLimit from "./duel/timeLimit";
......@@ -87,6 +88,11 @@ export default async function handleSocketMessage(e: MessageEvent) {
case "stoc_game_msg": {
await handleGameMsg(pb);
if (!matStore.isReplay) {
// 如果不是回放模式,则记录回放数据
replayStore.record(packet);
}
break;
}
case "stoc_time_limit": {
......
......@@ -4,7 +4,6 @@ import { YgoProPacket } from "@/api/ocgcore/ocgAdapter/packet";
// 对局中每一次状态改变的记录
interface ReplaySpot {
msg: string; // 人类能理解的语音,后续考虑用来在对局中展示
packet: ReplayPacket; // 将会保存在回放文件中的数据
}
......@@ -14,11 +13,11 @@ interface ReplayPacket {
extraData: ArrayBuffer;
}
// 保存对局回放数据的`Store`
class ReplayStore {
inner: ReplaySpot[] = [];
record(ygoPacket: YgoProPacket, msg?: string) {
record(ygoPacket: YgoProPacket) {
this.inner.push({
msg: msg ?? "",
packet: ygoPacket2replayPacket(ygoPacket),
});
}
......
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