Commit 485fdcc8 authored by timel's avatar timel

style: add comments and rename

parent fdecfd97
......@@ -58,7 +58,8 @@ const initInfo: PlayMatState["initInfo"] = proxy({
});
/**
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法
* 在决斗盘仓库之中,
* 给 `{me: [...], op: [...]}` 这种类型的对象添加一些方法
*/
const wrap = <T extends DuelFieldState>(
entity: BothSide<T>,
......@@ -100,21 +101,27 @@ const wrap = <T extends DuelFieldState>(
return res;
};
/**
* 🔥 决斗盘状态仓库,本文件核心,
* 具体介绍可以点进`PlayMatState`去看
*/
export const playMat = proxy<PlayMatState>({
magics: wrap(genBlock(ygopro.CardZone.SZONE), ygopro.CardZone.SZONE),
monsters: wrap(genBlock(ygopro.CardZone.MZONE), ygopro.CardZone.MZONE),
graveyard: wrap({ me: [], op: [] }, ygopro.CardZone.GRAVE),
banishedZone: wrap({ me: [], op: [] }, ygopro.CardZone.REMOVED),
graveyards: wrap({ me: [], op: [] }, ygopro.CardZone.GRAVE),
banishedZones: wrap({ me: [], op: [] }, ygopro.CardZone.REMOVED),
hands: wrap({ me: [], op: [] }, ygopro.CardZone.HAND),
deck: wrap({ me: [], op: [] }, ygopro.CardZone.DECK),
extraDeck: wrap({ me: [], op: [] }, ygopro.CardZone.EXTRA),
decks: wrap({ me: [], op: [] }, ygopro.CardZone.DECK),
extraDecks: wrap({ me: [], op: [] }, ygopro.CardZone.EXTRA),
initInfo,
timeLimit: {
timeLimits: {
// 时间限制
me: 0,
op: 0,
},
initInfo,
selfType: ygopro.StocTypeChange.SelfType.UNKNOWN,
hint: {
code: -1,
......@@ -131,6 +138,9 @@ export const playMat = proxy<PlayMatState>({
unimplemented: 0,
});
/**
* 根据controller判断是自己还是对方
*/
const getWhom = (controller: number) =>
judgeSelf(controller, playMat.selfType) ? "me" : "op";
......
......@@ -27,15 +27,15 @@ export interface PlayMatState {
magics: CardsBothSide<MagicState>; // 双方的魔法区状态
graveyard: CardsBothSide<GraveyardState>; // 双方的墓地状态
graveyards: CardsBothSide<GraveyardState>; // 双方的墓地状态
banishedZone: CardsBothSide<BanishedZoneState>; // 双方的除外区状态
banishedZones: CardsBothSide<BanishedZoneState>; // 双方的除外区状态
deck: CardsBothSide<DeckState>; // 双方的卡组状态
decks: CardsBothSide<DeckState>; // 双方的卡组状态
extraDeck: CardsBothSide<ExtraDeckState>; // 双方的额外卡组状态
extraDecks: CardsBothSide<ExtraDeckState>; // 双方的额外卡组状态
timeLimit: BothSide<number>; // 双方的时间限制
timeLimits: BothSide<number>; // 双方的时间限制
hint: HintState;
......
import { ygopro } from "@/api/ocgcore/idl/ocgcore";
/**
* 生成一个指定长度的卡片数组
*/
function genBlock(location: ygopro.CardZone, n: number = 5) {
return {
me: Array(n)
.fill(null)
.map((_) => ({
location: {
location,
},
idleInteractivities: [],
counters: {},
})),
op: Array(n)
.fill(null)
.map((_) => ({
location: {
location,
},
idleInteractivities: [],
counters: {},
})),
};
}
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