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