Commit f8b621eb authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/magic/place' into 'main'

fix FixedSlot.tsx

See merge request !77
parents e6e7bab4 be7cdb4d
Pipeline #19536 passed with stages
in 5 minutes and 58 seconds
......@@ -38,5 +38,17 @@ export const initFieldImpl: CaseReducer<DuelState, PayloadAction<number>> = (
}
};
export const clearFieldPlaceInteractivitiesImpl: CaseReducer<
DuelState,
PayloadAction<number>
> = (state, action) => {
const player = action.payload;
const field = judgeSelf(player, state) ? state.meField : state.opField;
if (field && field.inner) {
field.inner.placeInteractivities = undefined;
}
};
export const selectMeField = (state: RootState) => state.duel.meField;
export const selectOpField = (state: RootState) => state.duel.opField;
......@@ -64,7 +64,11 @@ import {
exclusionCase,
} from "./exclusionSlice";
import { DeckState, initDeckImpl } from "./deckSlice";
import { FieldState, initFieldImpl } from "./fieldSlice";
import {
FieldState,
initFieldImpl,
clearFieldPlaceInteractivitiesImpl,
} from "./fieldSlice";
export interface DuelState {
selfType?: number;
......@@ -156,6 +160,7 @@ const duelSlice = createSlice({
// 场地区相关`Reducer`
initField: initFieldImpl,
clearFieldPlaceInteractivities: clearFieldPlaceInteractivitiesImpl,
// UI相关`Reducer`
setCardModalIsOpen: setCardModalIsOpenImpl,
......@@ -229,6 +234,7 @@ export const {
initDeck,
initExclusion,
initField,
clearFieldPlaceInteractivities,
} = duelSlice.actions;
export const selectDuelHsStart = (state: RootState) => {
return state.duel.meInitInfo != null;
......
......@@ -2,6 +2,7 @@ import * as BABYLON from "@babylonjs/core";
import * as CONFIG from "../../config/ui";
import { useAppSelector } from "../../hook";
import { selectMeField, selectOpField } from "../../reducers/duel/fieldSlice";
import { clearFieldPlaceInteractivities } from "../../reducers/duel/mod";
import FixedSlot from "./fixedSlot";
import { Depth } from "./singleSlot";
......@@ -17,6 +18,7 @@ const Field = () => {
sequence={0}
position={fieldPosition(0)}
rotation={CONFIG.CardSlotRotation(false)}
clearPlaceInteractivitiesAction={clearFieldPlaceInteractivities}
/>
) : (
<></>
......@@ -27,6 +29,7 @@ const Field = () => {
sequence={0}
position={fieldPosition(1)}
rotation={CONFIG.CardSlotRotation(true)}
clearPlaceInteractivitiesAction={clearFieldPlaceInteractivities}
/>
) : (
<></>
......
......@@ -7,12 +7,12 @@ import { useClick } from "./hook";
import { sendSelectPlaceResponse } from "../../api/ocgcore/ocgHelper";
import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import {
clearMonsterPlaceInteractivities,
setCardModalImgUrl,
setCardModalInteractivies,
setCardModalIsOpen,
setCardModalText,
} from "../../reducers/duel/mod";
import { ActionCreatorWithPayload } from "@reduxjs/toolkit";
const shape = CONFIG.CardSlotShape();
......@@ -22,6 +22,7 @@ const FixedSlot = (props: {
position: BABYLON.Vector3;
rotation: BABYLON.Vector3;
deffenseRotation?: BABYLON.Vector3;
clearPlaceInteractivitiesAction: ActionCreatorWithPayload<number, string>;
}) => {
const planeRef = useRef(null);
......@@ -44,8 +45,8 @@ const FixedSlot = (props: {
(_event) => {
if (props.state.placeInteractivities) {
sendSelectPlaceResponse(props.state.placeInteractivities.response);
dispatch(clearMonsterPlaceInteractivities(0));
dispatch(clearMonsterPlaceInteractivities(1));
dispatch(props.clearPlaceInteractivitiesAction(0));
dispatch(props.clearPlaceInteractivitiesAction(1));
} else if (props.state.occupant) {
dispatch(
setCardModalText([
......
......@@ -5,6 +5,7 @@ import { CardState } from "../../reducers/duel/generic";
import { useAppSelector } from "../../hook";
import { zip } from "./util";
import FixedSlot from "./fixedSlot";
import { clearMagicPlaceInteractivities } from "../../reducers/duel/mod";
// TODO: use config
const left = -2.15;
......@@ -27,6 +28,7 @@ const Magics = () => {
sequence={sequence}
position={position}
rotation={CONFIG.CardSlotRotation(false)}
clearPlaceInteractivitiesAction={clearMagicPlaceInteractivities}
/>
);
})}
......@@ -38,6 +40,7 @@ const Magics = () => {
sequence={sequence}
position={position}
rotation={CONFIG.CardSlotRotation(true)}
clearPlaceInteractivitiesAction={clearMagicPlaceInteractivities}
/>
);
})}
......
......@@ -9,6 +9,7 @@ import {
} from "../../reducers/duel/monstersSlice";
import { zip } from "./util";
import FixedSlot from "./fixedSlot";
import { clearMonsterPlaceInteractivities } from "../../reducers/duel/mod";
const shape = CONFIG.CardSlotShape();
const left = -2.15; // TODO: config
......@@ -32,6 +33,7 @@ const Monsters = () => {
position={position}
rotation={CONFIG.CardSlotRotation(false)}
deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/>
);
}
......@@ -46,6 +48,7 @@ const Monsters = () => {
position={position}
rotation={CONFIG.CardSlotRotation(true)}
deffenseRotation={CONFIG.CardSlotDefenceRotation()}
clearPlaceInteractivitiesAction={clearMonsterPlaceInteractivities}
/>
);
}
......
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