Commit 20776ae3 authored by chechunchi's avatar chechunchi

optimize card modal effect button

parent a47e1e93
...@@ -3,7 +3,6 @@ import MsgSelectOption = ygopro.StocGameMessage.MsgSelectOption; ...@@ -3,7 +3,6 @@ import MsgSelectOption = ygopro.StocGameMessage.MsgSelectOption;
import { messageStore } from "@/stores"; import { messageStore } from "@/stores";
export default async (selectOption: MsgSelectOption) => { export default async (selectOption: MsgSelectOption) => {
const player = selectOption.player;
const options = selectOption.options; const options = selectOption.options;
await Promise.all( await Promise.all(
......
...@@ -18,7 +18,7 @@ export interface ModalState { ...@@ -18,7 +18,7 @@ export interface ModalState {
cardModal: { cardModal: {
isOpen: boolean; isOpen: boolean;
meta?: CardMeta; meta?: CardMeta;
interactivies: { desc: string; response: number }[]; interactivies: { desc: string; response: number; effectCode?: number }[];
counters: { [type: number]: number }; counters: { [type: number]: number };
}; };
// 卡牌列表弹窗 // 卡牌列表弹窗
......
...@@ -4,7 +4,7 @@ import classnames from "classnames"; ...@@ -4,7 +4,7 @@ import classnames from "classnames";
import React from "react"; import React from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { fetchStrings, sendSelectIdleCmdResponse } from "@/api"; import { fetchStrings, getCardStr, sendSelectIdleCmdResponse } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { import {
clearAllIdleInteractivities as clearAllIdleInteractivities, clearAllIdleInteractivities as clearAllIdleInteractivities,
...@@ -40,7 +40,12 @@ export const CardModal = () => { ...@@ -40,7 +40,12 @@ export const CardModal = () => {
const imgUrl = meta?.id const imgUrl = meta?.id
? `${NeosConfig.cardImgUrl}/${meta.id}.jpg` ? `${NeosConfig.cardImgUrl}/${meta.id}.jpg`
: undefined; : undefined;
const interactivies = snap.interactivies; const nonEffectInteractivies = snap.interactivies.filter(
(item) => item.desc != "发动效果"
);
const effectInteractivies = snap.interactivies.filter(
(item) => item.desc == "发动效果"
);
return ( return (
<div <div
...@@ -63,7 +68,7 @@ export const CardModal = () => { ...@@ -63,7 +68,7 @@ export const CardModal = () => {
<AtkLine atk={atk} def={def} /> <AtkLine atk={atk} def={def} />
<CounterLine counters={counters} /> <CounterLine counters={counters} />
<div className="card-modal-effect">{desc}</div> <div className="card-modal-effect">{desc}</div>
{interactivies.map((interactive, idx) => { {nonEffectInteractivies.map((interactive, idx) => {
return ( return (
<button <button
key={idx} key={idx}
...@@ -79,6 +84,29 @@ export const CardModal = () => { ...@@ -79,6 +84,29 @@ export const CardModal = () => {
</button> </button>
); );
})} })}
{effectInteractivies.length > 0 ? (
<button
className="card-modal-btn"
onClick={() => {
for (const effect of effectInteractivies) {
const effectMsg =
meta && effect.effectCode
? getCardStr(meta, effect.effectCode & 0xf) ?? "[:?]"
: "[:?]";
messageStore.optionModal.options.push({
msg: effectMsg,
response: effect.response,
});
}
cardModal.isOpen = false;
messageStore.optionModal.isOpen = true;
}}
>
发动效果
</button>
) : (
<></>
)}
</div> </div>
</div> </div>
); );
......
...@@ -247,6 +247,7 @@ const onCardClick = (state: CardState) => () => { ...@@ -247,6 +247,7 @@ const onCardClick = (state: CardState) => () => {
messageStore.cardModal.interactivies = state.idleInteractivities.map( messageStore.cardModal.interactivies = state.idleInteractivities.map(
(interactivity) => ({ (interactivity) => ({
desc: interactTypeToString(interactivity.interactType), desc: interactTypeToString(interactivity.interactType),
effectCode: interactivity.activateIndex,
response: interactivity.response, response: interactivity.response,
}) })
); );
......
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