Commit 6501b7de authored by chechunchi's avatar chechunchi

fix extendState

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