Commit 2c3bb256 authored by chechunchi's avatar chechunchi

optimize HistoryItem

parent 7c742594
Pipeline #28954 passed with stages
in 18 minutes and 1 second
import { proxy } from "valtio"; import { proxy } from "valtio";
import { fetchCard, ygopro } from "@/api"; import { ygopro } from "@/api";
import { Context } from "@/container"; import { Context } from "@/container";
import { NeosStore } from "./shared"; import { NeosStore } from "./shared";
...@@ -17,7 +17,7 @@ export enum HistoryOp { ...@@ -17,7 +17,7 @@ export enum HistoryOp {
} }
export interface History { export interface History {
card?: string; card: number;
opponent: boolean; opponent: boolean;
currentLocation?: ygopro.CardLocation; currentLocation?: ygopro.CardLocation;
operation: HistoryOp; operation: HistoryOp;
...@@ -35,7 +35,7 @@ export class HistoryStore implements NeosStore { ...@@ -35,7 +35,7 @@ export class HistoryStore implements NeosStore {
) { ) {
// TODO: Refinement // TODO: Refinement
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(from.controller), opponent: !context.matStore.isMe(from.controller),
currentLocation: from, currentLocation: from,
operation: HistoryOp.MOVE, operation: HistoryOp.MOVE,
...@@ -45,7 +45,7 @@ export class HistoryStore implements NeosStore { ...@@ -45,7 +45,7 @@ export class HistoryStore implements NeosStore {
putEffect(context: Context, card: number, location: ygopro.CardLocation) { putEffect(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
currentLocation: location, currentLocation: location,
operation: HistoryOp.EFFECT, operation: HistoryOp.EFFECT,
...@@ -54,7 +54,7 @@ export class HistoryStore implements NeosStore { ...@@ -54,7 +54,7 @@ export class HistoryStore implements NeosStore {
putTargeted(context: Context, card: number, location: ygopro.CardLocation) { putTargeted(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
currentLocation: location, currentLocation: location,
operation: HistoryOp.TARGETED, operation: HistoryOp.TARGETED,
...@@ -63,7 +63,7 @@ export class HistoryStore implements NeosStore { ...@@ -63,7 +63,7 @@ export class HistoryStore implements NeosStore {
putConfirmed(context: Context, card: number, location: ygopro.CardLocation) { putConfirmed(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
currentLocation: location, currentLocation: location,
operation: HistoryOp.CONFIRMED, operation: HistoryOp.CONFIRMED,
...@@ -72,7 +72,7 @@ export class HistoryStore implements NeosStore { ...@@ -72,7 +72,7 @@ export class HistoryStore implements NeosStore {
putSummon(context: Context, card: number, location: ygopro.CardLocation) { putSummon(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
operation: HistoryOp.SUMMON, operation: HistoryOp.SUMMON,
}); });
...@@ -80,7 +80,7 @@ export class HistoryStore implements NeosStore { ...@@ -80,7 +80,7 @@ export class HistoryStore implements NeosStore {
putSpSummon(context: Context, card: number, location: ygopro.CardLocation) { putSpSummon(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
operation: HistoryOp.SP_SUMMON, operation: HistoryOp.SP_SUMMON,
}); });
...@@ -88,7 +88,7 @@ export class HistoryStore implements NeosStore { ...@@ -88,7 +88,7 @@ export class HistoryStore implements NeosStore {
putFlipSummon(context: Context, card: number, location: ygopro.CardLocation) { putFlipSummon(context: Context, card: number, location: ygopro.CardLocation) {
this.historys.push({ this.historys.push({
card: fetchCard(card).text.name, card,
opponent: !context.matStore.isMe(location.controller), opponent: !context.matStore.isMe(location.controller),
operation: HistoryOp.FLIP_SUMMON, operation: HistoryOp.FLIP_SUMMON,
}); });
......
...@@ -35,22 +35,50 @@ ...@@ -35,22 +35,50 @@
.timeline { .timeline {
margin-top: 1rem; margin-top: 1rem;
p {
.history {
display: flex;
font-family: var(--theme-font); font-family: var(--theme-font);
font-size: 1rem;
.card { .card-container {
color: #48faf0; display: flex;
} flex-direction: row;
.current-location { align-items: flex-start;
color: #8484ff;
.card {
width: 4rem;
height: auto;
}
.location {
margin-top: 3rem;
margin-left: 1rem;
font-size: 1.2rem;
}
} }
.op {
color: yellow; .op-container {
display: flex;
flex-direction: column;
align-items: center;
margin: 0 0.8rem;
.op {
font-size: 1.2rem; font-size: 1.2rem;
}
.arrow {
display: flex;
width: 4rem;
height: 2rem;
}
} }
.target { .target {
color: #f16b3f; margin-top: 3rem;
font-size: 1.2rem;
color: #f16b3f;
} }
} }
} }
......
...@@ -5,7 +5,7 @@ import { proxy, useSnapshot } from "valtio"; ...@@ -5,7 +5,7 @@ import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region, ygopro } from "@/api"; import { fetchStrings, Region, ygopro } from "@/api";
import { History, HistoryOp, historyStore } from "@/stores"; import { History, HistoryOp, historyStore } from "@/stores";
import { ScrollableArea } from "@/ui/Shared"; import { ScrollableArea, YgoCard } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
...@@ -48,22 +48,26 @@ const HistoryItem: React.FC<History> = ({ ...@@ -48,22 +48,26 @@ const HistoryItem: React.FC<History> = ({
operation, operation,
target, target,
}) => ( }) => (
<p> <div className={styles.history}>
<span className={styles.card}>{card ?? "未知卡片"}</span> <div className={styles["card-container"]}>
{currentLocation && ( <YgoCard className={styles.card} code={card} />
<span className={styles["current-location"]}>{` [${zone2Text( {currentLocation && (
currentLocation.zone, <div className={styles.location}>{`${zone2Text(
)}]`}</span> currentLocation.zone,
)} )}`}</div>
<span>{" "}</span> )}
<span className={styles.op}>{Op2Text(operation)}</span> </div>
{target && ( <div className={styles["op-container"]}>
<> <div className={styles.op}>{Op2Text(operation)}</div>
<span>{" "}</span> <img
<span className={styles.target}>{`[${zone2Text(target)}]`}</span> src={
</> "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTOrl9DtS0_aFlpp1cYH1wVdoNSTesfK2VvbQ&s"
)} }
</p> className={styles.arrow}
/>
</div>
{target && <div className={styles.target}>{`${zone2Text(target)}`}</div>}
</div>
); );
function zone2Text(zone: ygopro.CardZone): string { function zone2Text(zone: ygopro.CardZone): string {
......
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