Commit 5c373e9f authored by timel's avatar timel

fix: chaining animation

parent 94d5f901
Pipeline #21971 passed with stages
in 14 minutes and 47 seconds
......@@ -23,6 +23,7 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
if (target) {
target.chainIndex = matStore.chains.length;
eventBus.emit(Report.Chaining, target.uuid);
console.color("blue")(`${target.meta.text.name} chaining`);
} else {
console.warn(`<Chaining>target from ${location} is null`);
}
......
......@@ -69,23 +69,32 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
const [highlight, setHighlight] = useState(false);
const [shadowOpacity, setShadowOpacity] = useState(0);
// >>> 动画 >>>
/** 动画序列的promise,当不是undefined,就说明现在这个卡有动画 */
let animation: Promise<void> | undefined = undefined;
let animation: Promise<void> | null = null;
const play = (p: () => Promise<void>) => {
if (animation) {
animation = animation.then(p).then(() => {
animation = null;
});
} else {
animation = p();
}
};
eventBus.on(Report.Move, (uuid: string) => {
if (uuid === state.uuid) {
const p = move(state.zone);
animation = animation ? animation.then(() => p) : p;
play(() => move(state.zone));
}
});
// TODO:测试和改bug
eventBus.on(Report.Chaining, (uuid: string) => {
if (uuid === state.uuid) {
// const p = chaining({ card: state, api });
// animation = animation ? animation.then(() => p) : p;
play(() => chaining({ card: state, api }));
}
});
// <<< 动画 <<<
useEffect(() => {
setHighlight(!!snap.idleInteractivities.length);
......
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