Commit f89dedac authored by Chunchi Che's avatar Chunchi Che

fix chainEnd

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