Commit 5bbb6526 authored by Chunchi Che's avatar Chunchi Che

add attack spring

parent 803137c9
Pipeline #22177 failed with stages
in 13 minutes and 18 seconds
......@@ -6,6 +6,7 @@ const eventEmitter = new EventEmitter();
export enum Task {
Move = "move",
Focus = "focus",
Attack = "attack",
}
const getEnd = (task: Task) => `${task}-end`;
......
import { ygopro } from "@/api";
import { eventbus, Task } from "@/infra";
import { cardStore, fetchEsHintMeta } from "@/stores";
export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
......@@ -15,7 +16,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
if (attacker) {
if (attack.direct_attack) {
// TODO: 实现直接攻击的动画
await eventbus.call(Task.Attack, attacker.uuid, true);
} else {
const target = cardStore.at(
attack.target_location.zone,
......@@ -23,11 +24,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
attack.target_location.sequence
);
if (target) {
// TODO: 实现攻击`target`的动画
} else {
console.warn(`<Attack>target from ${attack.target_location} is null`);
}
await eventbus.call(Task.Attack, attacker.uuid, false, target);
}
} else {
console.warn(`<Attack>attacker from ${attack.attacker_location} is null`);
......
......@@ -12,6 +12,7 @@ import { cardStore, CardType, messageStore } from "@/stores";
import { interactTypeToString } from "../../utils";
import {
attack,
focus,
moveToDeck,
moveToGround,
......@@ -90,6 +91,19 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
await addToAnimation(() => focus({ card: state, api }));
}
});
eventbus.register(
Task.Attack,
async (
uuid: string,
directAttack: boolean,
target?: ygopro.CardLocation
) => {
if (uuid === state.uuid) {
await attack({ card: state, api, target, directAttack });
}
}
);
// <<< 动画 <<<
useEffect(() => {
......
import { ygopro } from "@/api";
import { CardType } from "@/stores";
import { SpringApi } from "./types";
export const attack = async (props: {
card: CardType;
api: SpringApi;
target?: ygopro.CardLocation;
directAttack: boolean;
}) => {
// TODO
};
export * from "./attack";
export * from "./focus";
export * from "./moveToDeck";
export * from "./moveToGround";
......
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