Commit e503eea3 authored by Chunchi Che's avatar Chunchi Che

修复一些指示器相关的问题

parent 3d7dd366
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
height: 100%; height: 100%;
} }
.atkLine { .atkLine,
.counterLine
{
.title, .title,
.number { .number {
font-family: var(--theme-font); font-family: var(--theme-font);
...@@ -46,5 +48,5 @@ ...@@ -46,5 +48,5 @@
.info { .info {
justify-content: space-between; justify-content: space-between;
position: relative; position: relative;
height: 204px; // TODO - fix this height: 230px; // TODO - fix this
} }
...@@ -41,7 +41,7 @@ const store = proxy(defaultStore); ...@@ -41,7 +41,7 @@ const store = proxy(defaultStore);
export const CardModal = () => { export const CardModal = () => {
const snap = useSnapshot(store); const snap = useSnapshot(store);
const { isOpen, meta, counters: _counters } = snap; const { isOpen, meta, counters } = snap;
const name = meta?.text.name; const name = meta?.text.name;
const types = extraCardTypes(meta?.data.type ?? 0); const types = extraCardTypes(meta?.data.type ?? 0);
...@@ -80,10 +80,10 @@ export const CardModal = () => { ...@@ -80,10 +80,10 @@ export const CardModal = () => {
atk={atk} atk={atk}
def={types.includes(TYPE_LINK) ? undefined : def} def={types.includes(TYPE_LINK) ? undefined : def}
/> />
<CounterLine counters={counters} />
<AttLine types={types} race={race} attribute={attribute} /> <AttLine types={types} race={race} attribute={attribute} />
{/* TODO: 只有怪兽卡需要展示攻击防御 */} {/* TODO: 只有怪兽卡需要展示攻击防御 */}
{/* TODO: 展示星级/LINK数 */} {/* TODO: 展示星级/LINK数 */}
{/* <CounterLine counters={counters} /> */}
</Space> </Space>
</Space> </Space>
<Divider style={{ margin: "14px 0" }}></Divider> <Divider style={{ margin: "14px 0" }}></Divider>
...@@ -132,23 +132,24 @@ const AtkLine = (props: { atk?: number; def?: number }) => ( ...@@ -132,23 +132,24 @@ const AtkLine = (props: { atk?: number; def?: number }) => (
</Space> </Space>
); );
// TODO: 未完成,研究一下怎么展示这个信息 const CounterLine = (props: { counters: { [type: number]: number } }) => {
const _CounterLine = (props: { counters: { [type: number]: number } }) => {
const counters = [];
for (const counterType in props.counters) {
const count = props.counters[counterType];
if (count > 0) {
const counterStr = fetchStrings(Region.Counter, `0x${counterType}`);
counters.push(`${counterStr}: ${count}`);
}
}
return ( return (
<> <Space size={10} className={styles.counterLine} direction="vertical">
{counters.map((counter) => ( {Object.entries(props.counters).map(
<div>{counter}</div> ([counterType, count], idx) =>
))} count > 0 && (
</> <div key={idx}>
<div className={styles.title}>
{fetchStrings(
Region.Counter,
`0x${Number(counterType).toString(16)}`,
)}
</div>
<div className={styles.number}>{count}</div>
</div>
),
)}
</Space>
); );
}; };
......
// 指示器选择弹窗 // 指示器选择弹窗
import { Omit } from "@react-spring/web"; import { Omit } from "@react-spring/web";
import { Button, Card, Col, InputNumber, Row } from "antd"; import { Button, Card, Col, InputNumber, Row } from "antd";
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region, sendSelectCounterResponse } from "@/api"; import { fetchStrings, Region, sendSelectCounterResponse } from "@/api";
...@@ -41,6 +41,10 @@ export const CheckCounterModal = () => { ...@@ -41,6 +41,10 @@ export const CheckCounterModal = () => {
const sum = selected.reduce((sum, current) => sum + current, 0); const sum = selected.reduce((sum, current) => sum + current, 0);
const finishable = sum === min; const finishable = sum === min;
useEffect(() => {
setSelected(new Array(options.length));
}, [options]);
const onFinish = () => { const onFinish = () => {
sendSelectCounterResponse(selected); sendSelectCounterResponse(selected);
rs(); rs();
...@@ -75,10 +79,11 @@ export const CheckCounterModal = () => { ...@@ -75,10 +79,11 @@ export const CheckCounterModal = () => {
max={option.max} max={option.max}
defaultValue={0} defaultValue={0}
onChange={(value) => { onChange={(value) => {
let newSelected = [...selected]; setSelected((prevSelected) => {
newSelected[idx] = value || 0; let newSelected = [...prevSelected];
newSelected[idx] = value ?? 0;
setSelected(newSelected); return newSelected;
});
}} }}
/> />
</Card> </Card>
......
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