Commit b6e201c0 authored by Chunchi Che's avatar Chunchi Che

update cardModal

parent c13934a8
Pipeline #20571 passed with stages
in 6 minutes and 34 seconds
...@@ -27,8 +27,7 @@ import { HintState, hintCase } from "./hintSlice"; ...@@ -27,8 +27,7 @@ import { HintState, hintCase } from "./hintSlice";
import { import {
ModalState, ModalState,
setCardModalIsOpenImpl, setCardModalIsOpenImpl,
setCardModalTextImpl, setCardModalMetaImpl,
setCardModalImgUrlImpl,
setCardModalInteractiviesImpl, setCardModalInteractiviesImpl,
setCardListModalIsOpenImpl, setCardListModalIsOpenImpl,
setCardListModalInfoImpl, setCardListModalInfoImpl,
...@@ -227,8 +226,7 @@ const duelSlice = createSlice({ ...@@ -227,8 +226,7 @@ const duelSlice = createSlice({
// UI相关`Reducer` // UI相关`Reducer`
setCardModalIsOpen: setCardModalIsOpenImpl, setCardModalIsOpen: setCardModalIsOpenImpl,
setCardModalText: setCardModalTextImpl, setCardModalMeta: setCardModalMetaImpl,
setCardModalImgUrl: setCardModalImgUrlImpl,
setCardModalInteractivies: setCardModalInteractiviesImpl, setCardModalInteractivies: setCardModalInteractiviesImpl,
setCardListModalIsOpen: setCardListModalIsOpenImpl, setCardListModalIsOpen: setCardListModalIsOpenImpl,
setCardListModalInfo: setCardListModalInfoImpl, setCardListModalInfo: setCardListModalInfoImpl,
...@@ -288,8 +286,7 @@ export const { ...@@ -288,8 +286,7 @@ export const {
addHandsIdleInteractivity, addHandsIdleInteractivity,
updateTimeLimit, updateTimeLimit,
setCardModalIsOpen, setCardModalIsOpen,
setCardModalText, setCardModalMeta,
setCardModalImgUrl,
setCardModalInteractivies, setCardModalInteractivies,
initMonsters, initMonsters,
addMonsterPlaceInteractivities, addMonsterPlaceInteractivities,
......
import { PayloadAction, CaseReducer } from "@reduxjs/toolkit"; import { PayloadAction, CaseReducer } from "@reduxjs/toolkit";
import { DuelState } from "../mod"; import { DuelState } from "../mod";
import { RootState } from "../../../store"; import { RootState } from "../../../store";
import { CardMeta } from "../../../api/cards";
// 更新卡牌弹窗打开状态 // 更新卡牌弹窗打开状态
export const setCardModalIsOpenImpl: CaseReducer< export const setCardModalIsOpenImpl: CaseReducer<
...@@ -11,23 +12,11 @@ export const setCardModalIsOpenImpl: CaseReducer< ...@@ -11,23 +12,11 @@ export const setCardModalIsOpenImpl: CaseReducer<
}; };
// 更新卡牌弹窗文本 // 更新卡牌弹窗文本
export const setCardModalTextImpl: CaseReducer< export const setCardModalMetaImpl: CaseReducer<
DuelState, DuelState,
PayloadAction<[string?, string?]> PayloadAction<CardMeta>
> = (state, action) => { > = (state, action) => {
const name = action.payload[0]; state.modalState.cardModal.meta = action.payload;
const desc = action.payload[1];
state.modalState.cardModal.name = name;
state.modalState.cardModal.desc = desc;
};
// 更新卡牌弹窗图片Url
export const setCardModalImgUrlImpl: CaseReducer<
DuelState,
PayloadAction<string>
> = (state, action) => {
state.modalState.cardModal.imgUrl = action.payload;
}; };
// 更新卡牌弹窗互动选项 // 更新卡牌弹窗互动选项
...@@ -40,11 +29,7 @@ export const setCardModalInteractiviesImpl: CaseReducer< ...@@ -40,11 +29,7 @@ export const setCardModalInteractiviesImpl: CaseReducer<
export const selectCardModalIsOpen = (state: RootState) => export const selectCardModalIsOpen = (state: RootState) =>
state.duel.modalState.cardModal.isOpen; state.duel.modalState.cardModal.isOpen;
export const selectCardModalName = (state: RootState) => export const selectCardModalMeta = (state: RootState) =>
state.duel.modalState.cardModal.name; state.duel.modalState.cardModal.meta;
export const selectCardModalDesc = (state: RootState) =>
state.duel.modalState.cardModal.desc;
export const selectCardModalImgUrl = (state: RootState) =>
state.duel.modalState.cardModal.imgUrl;
export const selectCardModalInteractivies = (state: RootState) => export const selectCardModalInteractivies = (state: RootState) =>
state.duel.modalState.cardModal.interactivies; state.duel.modalState.cardModal.interactivies;
import { CardMeta } from "../../../api/cards";
import { ygopro } from "../../../api/ocgcore/idl/ocgcore"; import { ygopro } from "../../../api/ocgcore/idl/ocgcore";
export interface ModalState { export interface ModalState {
// 卡牌弹窗 // 卡牌弹窗
cardModal: { cardModal: {
isOpen: boolean; isOpen: boolean;
name?: string; meta?: CardMeta;
desc?: string;
imgUrl?: string;
interactivies: { desc: string; response: number }[]; interactivies: { desc: string; response: number }[];
}; };
// 卡牌列表弹窗 // 卡牌列表弹窗
......
...@@ -3,10 +3,8 @@ import { useAppSelector } from "../../hook"; ...@@ -3,10 +3,8 @@ import { useAppSelector } from "../../hook";
import { store } from "../../store"; import { store } from "../../store";
import { import {
selectCardModalIsOpen, selectCardModalIsOpen,
selectCardModalName,
selectCardModalDesc,
selectCardModalImgUrl,
selectCardModalInteractivies, selectCardModalInteractivies,
selectCardModalMeta,
} from "../../reducers/duel/modal/mod"; } from "../../reducers/duel/modal/mod";
import { import {
setCardModalIsOpen, setCardModalIsOpen,
...@@ -14,6 +12,7 @@ import { ...@@ -14,6 +12,7 @@ import {
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { Modal, Card, Button } from "antd"; import { Modal, Card, Button } from "antd";
import { sendSelectIdleCmdResponse } from "../../api/ocgcore/ocgHelper"; import { sendSelectIdleCmdResponse } from "../../api/ocgcore/ocgHelper";
import NeosConfig from "../../../neos.config.json";
const { Meta } = Card; const { Meta } = Card;
const CARD_WIDTH = 240; const CARD_WIDTH = 240;
...@@ -21,9 +20,12 @@ const CARD_WIDTH = 240; ...@@ -21,9 +20,12 @@ const CARD_WIDTH = 240;
const CardModal = () => { const CardModal = () => {
const dispatch = store.dispatch; const dispatch = store.dispatch;
const isOpen = useAppSelector(selectCardModalIsOpen); const isOpen = useAppSelector(selectCardModalIsOpen);
const name = useAppSelector(selectCardModalName); const meta = useAppSelector(selectCardModalMeta);
const desc = useAppSelector(selectCardModalDesc); const name = meta?.text.name;
const imgUrl = useAppSelector(selectCardModalImgUrl); const desc = meta?.text.desc;
const imgUrl = meta?.id
? `${NeosConfig.cardImgUrl}/${meta.id}.jpg`
: undefined;
const interactivies = useAppSelector(selectCardModalInteractivies); const interactivies = useAppSelector(selectCardModalInteractivies);
const handleOkOrCancel = () => { const handleOkOrCancel = () => {
......
...@@ -6,10 +6,9 @@ import { useClick } from "./hook"; ...@@ -6,10 +6,9 @@ import { useClick } from "./hook";
import { sendSelectPlaceResponse } from "../../api/ocgcore/ocgHelper"; import { sendSelectPlaceResponse } from "../../api/ocgcore/ocgHelper";
import { ygopro } from "../../api/ocgcore/idl/ocgcore"; import { ygopro } from "../../api/ocgcore/idl/ocgcore";
import { import {
setCardModalImgUrl,
setCardModalInteractivies, setCardModalInteractivies,
setCardModalIsOpen, setCardModalIsOpen,
setCardModalText, setCardModalMeta,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { ActionCreatorWithPayload } from "@reduxjs/toolkit"; import { ActionCreatorWithPayload } from "@reduxjs/toolkit";
import { interactTypeToString } from "./util"; import { interactTypeToString } from "./util";
...@@ -55,17 +54,7 @@ const FixedSlot = (props: { ...@@ -55,17 +54,7 @@ const FixedSlot = (props: {
dispatch(props.clearPlaceInteractivitiesAction(0)); dispatch(props.clearPlaceInteractivitiesAction(0));
dispatch(props.clearPlaceInteractivitiesAction(1)); dispatch(props.clearPlaceInteractivitiesAction(1));
} else if (props.state.occupant) { } else if (props.state.occupant) {
dispatch( dispatch(setCardModalMeta(props.state.occupant));
setCardModalText([
props.state.occupant.text.name,
props.state.occupant.text.desc,
])
);
dispatch(
setCardModalImgUrl(
`${NeosConfig.cardImgUrl}/${props.state.occupant.id}.jpg`
)
);
dispatch( dispatch(
setCardModalInteractivies( setCardModalInteractivies(
props.state.idleInteractivities.map((interactivity) => { props.state.idleInteractivities.map((interactivity) => {
......
...@@ -3,9 +3,8 @@ import { useAppSelector } from "../../hook"; ...@@ -3,9 +3,8 @@ import { useAppSelector } from "../../hook";
import { selectMeHands, selectOpHands } from "../../reducers/duel/handsSlice"; import { selectMeHands, selectOpHands } from "../../reducers/duel/handsSlice";
import { CardState } from "../../reducers/duel/generic"; import { CardState } from "../../reducers/duel/generic";
import { import {
setCardModalImgUrl,
setCardModalIsOpen, setCardModalIsOpen,
setCardModalText, setCardModalMeta,
setCardModalInteractivies, setCardModalInteractivies,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { store } from "../../store"; import { store } from "../../store";
...@@ -112,12 +111,9 @@ const CHand = (props: { ...@@ -112,12 +111,9 @@ const CHand = (props: {
useClick( useClick(
() => { () => {
dispatch( if (state.occupant) {
setCardModalText([state.occupant?.text.name, state.occupant?.text.desc]) dispatch(setCardModalMeta(state.occupant));
); }
dispatch(
setCardModalImgUrl(`${NeosConfig.cardImgUrl}/${state.occupant?.id}.jpg`)
);
dispatch( dispatch(
setCardModalInteractivies( setCardModalInteractivies(
state.idleInteractivities.map((interactive) => { state.idleInteractivities.map((interactive) => {
......
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