Commit f89dedac authored by Chunchi Che's avatar Chunchi Che

fix chainEnd

parent 16aaeaa3
import { ygopro } from "@/api";
import { matStore } from "@/stores";
import { cardStore, matStore } from "@/stores";
export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
while (true) {
......@@ -8,6 +8,11 @@ export default (_chainEnd: ygopro.StocGameMessage.MsgChainEnd) => {
break;
}
matStore.setChained(chain, undefined);
const target = cardStore.find(chain);
if (target) {
target.chainIndex = undefined;
} else {
console.warn(`<ChainEnd>target is null`);
}
}
};
......@@ -41,21 +41,30 @@ export interface CardType {
class CardStore {
inner: CardType[] = [];
at(zone: ygopro.CardZone, controller: number): CardType[];
at(zone: ygopro.CardZone, controller: number, sequence?: number): CardType;
at(
zone: ygopro.CardZone,
controller: number,
sequence?: number
): CardType | undefined;
at(zone: ygopro.CardZone, controller: number, sequence?: number) {
if (sequence !== undefined) {
return this.inner.filter(
(card) =>
card.zone === zone &&
card.controller === controller &&
card.sequence === sequence
)[0];
return this.inner
.filter(
(card) =>
card.zone === zone &&
card.controller === controller &&
card.sequence === sequence
)
.at(0);
} else {
return this.inner.filter(
(card) => card.zone === zone && card.controller === controller
);
}
}
find(location: ygopro.CardLocation): CardType | undefined {
return this.at(location.location, location.controler, location.sequence);
}
}
export const cardStore = proxy(new CardStore());
......
......@@ -69,7 +69,7 @@ export const fetchEsHintMeta = async ({
location.controler,
location.sequence
);
if (fieldMeta.text.name) {
if (fieldMeta?.text.name) {
esHint = esHint.replace("[?]", fieldMeta.text.name);
}
}
......
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