Commit 7ecd0dca authored by Chunchi Che's avatar Chunchi Che

update handsCase

parent de2c697f
...@@ -38,12 +38,17 @@ export const fetchHandsMeta = createAsyncThunk( ...@@ -38,12 +38,17 @@ export const fetchHandsMeta = createAsyncThunk(
); );
export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => { export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
builder.addCase(fetchHandsMeta.fulfilled, (state, action) => { builder.addCase(fetchHandsMeta.pending, (state, action) => {
const player = action.payload[0]; // Meta结果没返回之前先更新手牌`ID`
const hands = action.payload[1]; const player = action.meta.arg[0];
const ids = action.meta.arg[1];
const cards = hands.map((meta) => {
return { meta, transform: {}, interactivities: [] }; const cards = ids.map((id) => {
return {
meta: { id, data: {}, text: {} },
transform: {},
interactivities: [],
};
}); });
if (judgeSelf(player, state)) { if (judgeSelf(player, state)) {
if (state.meHands) { if (state.meHands) {
...@@ -60,6 +65,22 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => { ...@@ -60,6 +65,22 @@ export const handsCase = (builder: ActionReducerMapBuilder<DuelState>) => {
} }
} }
}); });
builder.addCase(fetchHandsMeta.fulfilled, (state, action) => {
// `Meta`结果回来后更新手牌的`Meta`结果
const player = action.payload[0];
const metas = action.payload[1];
const hands = judgeSelf(player, state) ? state.meHands : state.opHands;
if (hands) {
for (let hand of hands.cards) {
for (let meta of metas) {
if (hand.meta.id === meta.id) {
hand.meta = meta;
}
}
}
}
});
}; };
// 更新手牌的位置和旋转信息 // 更新手牌的位置和旋转信息
......
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