Commit 32e81ece authored by Chunchi Che's avatar Chunchi Che

show counter in CardModal

parent e2ade0f6
Pipeline #23476 passed with stages
in 13 minutes and 54 seconds
...@@ -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>
); );
}; };
......
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