Commit 12102999 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/ui/overlay' into 'main'

Feat/ui/overlay

See merge request !129
parents fff94394 aa85d993
...@@ -167,3 +167,32 @@ export const Race2StringCodeMap: Map<number, number> = new Map([ ...@@ -167,3 +167,32 @@ export const Race2StringCodeMap: Map<number, number> = new Map([
[RACE_WYRM, 1043], [RACE_WYRM, 1043],
[RACE_CYBERSE, 1044], [RACE_CYBERSE, 1044],
]); ]);
// const REASON_DESTROY = 0x1; //
// const REASON_RELEASE = 0x2; //
// const REASON_TEMPORARY = 0x4; //
export const REASON_MATERIAL = 0x8; //
// const REASON_SUMMON = 0x10; //
// const REASON_BATTLE = 0x20; //
// const REASON_EFFECT = 0x40; //
// const REASON_COST = 0x80; //
// const REASON_ADJUST = 0x100; //
// const REASON_LOST_TARGET = 0x200; //
// const REASON_RULE = 0x400; //
// const REASON_SPSUMMON = 0x800; //
// const REASON_DISSUMMON = 0x1000; //
// const REASON_FLIP = 0x2000; //
// const REASON_DISCARD = 0x4000; //
// const REASON_RDAMAGE = 0x8000; //
// const REASON_RRECOVER = 0x10000; //
// const REASON_RETURN = 0x20000; //
// const REASON_FUSION = 0x40000; //
// const REASON_SYNCHRO = 0x80000; //
// const REASON_RITUAL = 0x100000; //
// const REASON_XYZ = 0x200000; //
// const REASON_REPLACE = 0x1000000; //
// const REASON_DRAW = 0x2000000; //
// const REASON_REDIRECT = 0x4000000; //
// const REASON_REVEAL = 0x8000000; //
// const REASON_LINK = 0x10000000; //
// const REASON_LOST_OVERLAY = 0x20000000; //
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 setCardListModalIsOpenImpl: CaseReducer< export const setCardListModalIsOpenImpl: CaseReducer<
...@@ -15,9 +16,7 @@ export const setCardListModalInfoImpl: CaseReducer< ...@@ -15,9 +16,7 @@ export const setCardListModalInfoImpl: CaseReducer<
DuelState, DuelState,
PayloadAction< PayloadAction<
{ {
name?: string; meta?: CardMeta;
desc?: string;
imgUrl?: string;
interactivies: { desc: string; response: number }[]; interactivies: { desc: string; response: number }[];
}[] }[]
> >
......
...@@ -12,9 +12,7 @@ export interface ModalState { ...@@ -12,9 +12,7 @@ export interface ModalState {
cardListModal: { cardListModal: {
isOpen: boolean; isOpen: boolean;
list: { list: {
name?: string; meta?: CardMeta;
desc?: string;
imgUrl?: string;
interactivies: { desc: string; response: number }[]; interactivies: { desc: string; response: number }[];
}[]; }[];
}; };
......
...@@ -19,6 +19,7 @@ import { fetchCemeteryMeta } from "../../reducers/duel/cemeretySlice"; ...@@ -19,6 +19,7 @@ import { fetchCemeteryMeta } from "../../reducers/duel/cemeretySlice";
import { insertHandMeta } from "../../reducers/duel/handsSlice"; import { insertHandMeta } from "../../reducers/duel/handsSlice";
import { fetchExclusionMeta } from "../../reducers/duel/exclusionSlice"; import { fetchExclusionMeta } from "../../reducers/duel/exclusionSlice";
import { fetchExtraDeckMeta } from "../../reducers/duel/extraDeckSlice"; import { fetchExtraDeckMeta } from "../../reducers/duel/extraDeckSlice";
import { REASON_MATERIAL } from "../../common";
const OVERLAY_STACK: { code: number; sequence: number }[] = []; const OVERLAY_STACK: { code: number; sequence: number }[] = [];
...@@ -26,7 +27,7 @@ export default (move: MsgMove, dispatch: AppDispatch) => { ...@@ -26,7 +27,7 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
const code = move.code; const code = move.code;
const from = move.from; const from = move.from;
const to = move.to; const to = move.to;
// TODO: reason const reason = move.reason;
switch (from.location) { switch (from.location) {
case ygopro.CardZone.HAND: { case ygopro.CardZone.HAND: {
...@@ -165,8 +166,8 @@ export default (move: MsgMove, dispatch: AppDispatch) => { ...@@ -165,8 +166,8 @@ export default (move: MsgMove, dispatch: AppDispatch) => {
break; break;
} }
case ygopro.CardZone.OVERLAY: { case ygopro.CardZone.OVERLAY: {
if (to.sequence > 6) { if (reason == REASON_MATERIAL) {
// 超量素材在进行超量召唤时,若玩家未选择超量怪兽的位置,会“沉到决斗盘下面”,这时候素材们的sequence会暂时大于6 // 超量素材在进行超量召唤时,若玩家未选择超量怪兽的位置,会“沉到决斗盘下面”,`reason`字段值是`REASON_MATERIAL`
// 这时候将它们放到一个栈中,待超量怪兽的Move消息到来时从栈中获取超量素材补充到状态中 // 这时候将它们放到一个栈中,待超量怪兽的Move消息到来时从栈中获取超量素材补充到状态中
OVERLAY_STACK.push({ code, sequence: to.overlay_sequence }); OVERLAY_STACK.push({ code, sequence: to.overlay_sequence });
} else { } else {
......
...@@ -9,8 +9,9 @@ import { ...@@ -9,8 +9,9 @@ import {
clearAllIdleInteractivities, clearAllIdleInteractivities,
setCardListModalIsOpen, setCardListModalIsOpen,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { Modal, List, Button } from "antd"; import { Drawer, List, Button } from "antd";
import { sendSelectIdleCmdResponse } from "../../api/ocgcore/ocgHelper"; import { sendSelectIdleCmdResponse } from "../../api/ocgcore/ocgHelper";
import NeosConfig from "../../../neos.config.json";
const CARD_WIDTH = 100; const CARD_WIDTH = 100;
...@@ -24,7 +25,7 @@ const CardListModal = () => { ...@@ -24,7 +25,7 @@ const CardListModal = () => {
}; };
return ( return (
<Modal open={isOpen} onOk={handleOkOrCancel} onCancel={handleOkOrCancel}> <Drawer open={isOpen} onClose={handleOkOrCancel}>
<List <List
itemLayout="horizontal" itemLayout="horizontal"
dataSource={list} dataSource={list}
...@@ -45,17 +46,20 @@ const CardListModal = () => { ...@@ -45,17 +46,20 @@ const CardListModal = () => {
))} ))}
extra={ extra={
<img <img
alt={item.name} alt={item.meta?.text.name}
src={item.imgUrl} src={`${NeosConfig.cardImgUrl}/${item.meta?.id}.jpg`}
style={{ width: CARD_WIDTH }} style={{ width: CARD_WIDTH }}
/> />
} }
> >
<List.Item.Meta title={item.name} description={item.desc} /> <List.Item.Meta
title={item.meta?.text.name}
description={item.meta?.text.desc}
/>
</List.Item> </List.Item>
)} )}
></List> ></List>
</Modal> </Drawer>
); );
}; };
......
...@@ -6,6 +6,8 @@ import { useClick } from "./hook"; ...@@ -6,6 +6,8 @@ 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 {
setCardListModalInfo,
setCardListModalIsOpen,
setCardModalInteractivies, setCardModalInteractivies,
setCardModalIsOpen, setCardModalIsOpen,
setCardModalMeta, setCardModalMeta,
...@@ -54,6 +56,7 @@ const FixedSlot = (props: { ...@@ -54,6 +56,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(setCardModalMeta(props.state.occupant)); dispatch(setCardModalMeta(props.state.occupant));
dispatch( dispatch(
setCardModalInteractivies( setCardModalInteractivies(
...@@ -66,6 +69,24 @@ const FixedSlot = (props: { ...@@ -66,6 +69,24 @@ const FixedSlot = (props: {
) )
); );
dispatch(setCardModalIsOpen(true)); dispatch(setCardModalIsOpen(true));
// 侧边栏展示超量素材信息
if (
props.state.overlay_materials &&
props.state.overlay_materials.length > 0
) {
dispatch(
setCardListModalInfo(
props.state.overlay_materials?.map((overlay) => {
return {
meta: overlay,
interactivies: [],
};
}) || []
)
);
dispatch(setCardListModalIsOpen(true));
}
} }
}, },
planeRef, planeRef,
......
...@@ -73,14 +73,14 @@ const NeosDuel = () => { ...@@ -73,14 +73,14 @@ const NeosDuel = () => {
}; };
const NeosSider = () => ( const NeosSider = () => (
<div> <>
<Row> <Row>
<DuelTimeLine /> <DuelTimeLine />
</Row> </Row>
<Row> <Row>
<SendBox /> <SendBox />
</Row> </Row>
</div> </>
); );
const NeosCanvas = () => ( const NeosCanvas = () => (
......
...@@ -38,9 +38,7 @@ const SingleSlot = (props: { ...@@ -38,9 +38,7 @@ const SingleSlot = (props: {
) )
.map((item) => { .map((item) => {
return { return {
name: item.occupant?.text.name, meta: item.occupant,
desc: item.occupant?.text.desc,
imgUrl: `${NeosConfig.cardImgUrl}/${item.occupant?.id}.jpg`,
interactivies: item.idleInteractivities.map((interactivy) => { interactivies: item.idleInteractivities.map((interactivy) => {
return { return {
desc: interactTypeToString(interactivy.interactType), desc: interactTypeToString(interactivy.interactType),
......
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