Commit 20689467 authored by Chunchi Che's avatar Chunchi Che

fix

parent 86e4e7f3
Pipeline #20807 failed with stages
in 7 minutes and 2 seconds
...@@ -6,6 +6,9 @@ import { ...@@ -6,6 +6,9 @@ import {
updateCardData, updateCardData,
} from "./generic"; } from "./generic";
import { judgeSelf } from "./util"; import { judgeSelf } from "./util";
type MsgUpdateData = ReturnType<
typeof ygopro.StocGameMessage.MsgUpdateData.prototype.toObject
>;
export const clearAllIdleInteractivitiesImpl: DuelReducer<number> = ( export const clearAllIdleInteractivitiesImpl: DuelReducer<number> = (
state, state,
...@@ -59,13 +62,15 @@ export const clearAllPlaceInteractivitiesImpl: DuelReducer<number> = ( ...@@ -59,13 +62,15 @@ export const clearAllPlaceInteractivitiesImpl: DuelReducer<number> = (
states.forEach((item) => clearPlaceInteractivities(item)); states.forEach((item) => clearPlaceInteractivities(item));
}; };
export const updateFieldDataImpl: DuelReducer< export const updateFieldDataImpl: DuelReducer<MsgUpdateData> = (
ygopro.StocGameMessage.MsgUpdateData state,
> = (state, action) => { action
) => {
const player = action.payload.player; const player = action.payload.player;
const zone = action.payload.zone; const zone = action.payload.zone;
const actions = action.payload.actions; const actions = action.payload.actions;
if (player && zone && actions) {
switch (zone) { switch (zone) {
case ygopro.CardZone.HAND: { case ygopro.CardZone.HAND: {
const hand = judgeSelf(player, state) ? state.meHands : state.opHands; const hand = judgeSelf(player, state) ? state.meHands : state.opHands;
...@@ -90,7 +95,9 @@ export const updateFieldDataImpl: DuelReducer< ...@@ -90,7 +95,9 @@ export const updateFieldDataImpl: DuelReducer<
break; break;
} }
case ygopro.CardZone.SZONE: { case ygopro.CardZone.SZONE: {
const magics = judgeSelf(player, state) ? state.meMagics : state.opMagics; const magics = judgeSelf(player, state)
? state.meMagics
: state.opMagics;
updateCardData(magics, actions); updateCardData(magics, actions);
break; break;
...@@ -115,4 +122,5 @@ export const updateFieldDataImpl: DuelReducer< ...@@ -115,4 +122,5 @@ export const updateFieldDataImpl: DuelReducer<
break; break;
} }
} }
}
}; };
...@@ -8,7 +8,9 @@ import { CardMeta } from "../../api/cards"; ...@@ -8,7 +8,9 @@ import { CardMeta } from "../../api/cards";
import { ygopro } from "../../api/ocgcore/idl/ocgcore"; import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { fetchCard } from "../../api/cards"; import { fetchCard } from "../../api/cards";
import { DuelState } from "./mod"; import { DuelState } from "./mod";
import UpdateDataAction = ygopro.StocGameMessage.MsgUpdateData.Action; type UpdateDataAction = ReturnType<
typeof ygopro.StocGameMessage.MsgUpdateData.Action.prototype.toObject
>;
export type DuelReducer<T> = CaseReducer<DuelState, PayloadAction<T>>; export type DuelReducer<T> = CaseReducer<DuelState, PayloadAction<T>>;
...@@ -289,8 +291,7 @@ export function updateCardData<T extends DuelFieldState>( ...@@ -289,8 +291,7 @@ export function updateCardData<T extends DuelFieldState>(
state: T | undefined, state: T | undefined,
actions: UpdateDataAction[] actions: UpdateDataAction[]
) { ) {
for (const action of actions) { for (const payload of actions) {
const payload = action.toObject();
const sequence = payload.location?.sequence; const sequence = payload.location?.sequence;
if (typeof sequence !== "undefined") { if (typeof sequence !== "undefined") {
const target = state?.inner.find((_, idx) => idx == sequence); const target = state?.inner.find((_, idx) => idx == sequence);
......
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