Commit 6ef76a9e authored by Chunchi Che's avatar Chunchi Che

第N次修复娱乐匹配更换卡组问题

parent d9831588
...@@ -23,7 +23,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) { ...@@ -23,7 +23,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
} }
case ErrorType.DECKERROR: { case ErrorType.DECKERROR: {
const flag = error_code >> 28; const flag = error_code >> 28;
const code = error_code && 0xfffffff; const code = error_code & 0xfffffff;
const card = fetchCard(code); const card = fetchCard(code);
const baseMsg = `卡组非法,请检查:${card.text.name}`; const baseMsg = `卡组非法,请检查:${card.text.name}`;
switch (flag) { switch (flag) {
......
...@@ -53,6 +53,36 @@ export const Component: React.FC = () => { ...@@ -53,6 +53,36 @@ export const Component: React.FC = () => {
const op = room.getOpPlayer(); const op = room.getOpPlayer();
const navigate = useNavigate(); const navigate = useNavigate();
const updateDeck = (deck: IDeck) => {
sendUpdateDeck(deck);
// 设置side里面的卡组
sideStore.deck = deck;
};
const onDeckSelected = (deckName: string) => {
const newDeck = deckStore.get(deckName);
if (newDeck) {
sendHsNotReady();
updateDeck(newDeck);
setDeck(newDeck);
} else {
message.error(`Deck ${deckName} not found`);
}
};
const onReady = () => {
if (me?.state === PlayerState.NO_READY) {
if (deck) {
updateDeck(deck);
sendHsReady();
} else {
message.error("请先选择卡组");
}
} else {
sendHsNotReady();
}
};
useEffect(() => { useEffect(() => {
// 组件初始化时发一次更新卡组的包 // 组件初始化时发一次更新卡组的包
// //
...@@ -90,16 +120,7 @@ export const Component: React.FC = () => { ...@@ -90,16 +120,7 @@ export const Component: React.FC = () => {
switchCollapse={() => setCollapsed(!collapsed)} switchCollapse={() => setCollapsed(!collapsed)}
/> />
<div className={styles.wrap}> <div className={styles.wrap}>
<Controller <Controller onDeckChange={onDeckSelected} />
onDeckChange={(deckName: string) => {
const deck = deckStore.get(deckName);
if (deck) {
setDeck(deck);
} else {
message.error(`Deck ${deckName} not found`);
}
}}
/>
<div className={styles["both-side-container"]}> <div className={styles["both-side-container"]}>
<PlayerZone <PlayerZone
who={Who.Me} who={Who.Me}
...@@ -111,20 +132,7 @@ export const Component: React.FC = () => { ...@@ -111,20 +132,7 @@ export const Component: React.FC = () => {
<Button <Button
size="large" size="large"
className={styles["btn-join"]} className={styles["btn-join"]}
onClick={() => { onClick={onReady}
if (me?.state === PlayerState.NO_READY) {
if (deck) {
sendUpdateDeck(deck);
// 设置side里面的卡组
sideStore.deck = deck;
sendHsReady();
} else {
message.error("请先选择卡组");
}
} else {
sendHsNotReady();
}
}}
> >
{me?.state === PlayerState.NO_READY {me?.state === PlayerState.NO_READY
? "决斗准备" ? "决斗准备"
......
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