Commit 6501b7de authored by chechunchi's avatar chechunchi

fix extendState

parent f96af3a5
......@@ -54,15 +54,14 @@ export const banishedZoneCase = (
location: {
controler,
location: ygopro.CardZone.REMOVED,
sequence,
},
idleInteractivities: [],
counters: {},
};
if (judgeSelf(controler, state)) {
extendState(state.meBanishedZone, newExclusion);
extendState(state.meBanishedZone, newExclusion, sequence);
} else {
extendState(state.opBanishedZone, newExclusion);
extendState(state.opBanishedZone, newExclusion, sequence);
}
});
builder.addCase(fetchBanishedZoneMeta.fulfilled, (state, action) => {
......
......@@ -52,15 +52,14 @@ export const graveyardCase = (builder: ActionReducerMapBuilder<DuelState>) => {
location: {
controler,
location: ygopro.CardZone.GRAVE,
sequence,
},
idleInteractivities: [],
counters: {},
};
if (judgeSelf(controler, state)) {
extendState(state.meGraveyard, newGraveyard);
extendState(state.meGraveyard, newGraveyard, sequence);
} else {
extendState(state.opGraveyard, newGraveyard);
extendState(state.opGraveyard, newGraveyard, sequence);
}
});
builder.addCase(fetchGraveyardMeta.fulfilled, (state, action) => {
......
......@@ -64,7 +64,6 @@ export const extraDeckCase = (builder: ActionReducerMapBuilder<DuelState>) => {
location: {
controler,
location: ygopro.CardZone.EXTRA,
sequence,
},
idleInteractivities: [],
counters: {},
......@@ -72,7 +71,7 @@ export const extraDeckCase = (builder: ActionReducerMapBuilder<DuelState>) => {
const extraDeck = judgeSelf(controler, state)
? state.meExtraDeck
: state.opExtraDeck;
extendState(extraDeck, newExtraDeck);
extendState(extraDeck, newExtraDeck, sequence);
});
builder.addCase(fetchExtraDeckMeta.fulfilled, (state, action) => {
const controler = action.payload.controler;
......
......@@ -129,12 +129,22 @@ export function createAsyncRepeatedMetaThunk(
);
}
/*
* 扩充决斗区域卡片内容
*
* @param state - 需要扩充的区域,比如`MonsterState`
* @param newState - 新增加的`CardState`
* @sequence - 新增加的卡片的序列号,可选,如果为空则补充到列表末尾
*
* */
export function extendState<T extends DuelFieldState>(
state: T | undefined,
newState: CardState
newState: CardState,
sequence?: number
) {
if (state) {
state.inner.push(newState);
let index = sequence !== undefined ? sequence : state.inner.length;
state.inner.splice(index, 0, newState);
}
}
......
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