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