Commit 09fe150d authored by love_飞影's avatar love_飞影

refactor: use service implements effect

parent f2dd6118
Pipeline #26463 passed with stages
in 7 minutes and 58 seconds
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../idl/ocgcore";
import { StocAdapter, YgoProPacket } from "../packet";
......@@ -16,7 +14,6 @@ export default class ChatAdapter implements StocAdapter {
constructor(packet: YgoProPacket) {
this.packet = packet;
playEffect(AudioActionType.SOUND_CHAT);
}
upcast(): ygopro.YgoStocMsg {
......
import { BufferReader } from "rust-src";
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../idl/ocgcore";
import { StocAdapter, YgoProPacket } from "../packet";
......@@ -16,7 +14,6 @@ export default class ErrorMsg implements StocAdapter {
constructor(packet: YgoProPacket) {
this.packet = packet;
playEffect(AudioActionType.SOUND_INFO);
}
upcast(): ygopro.YgoStocMsg {
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
import { AudioActionType, playEffect } from "@/infra/audio";
/*
* Msg Add Counter
......@@ -10,7 +9,6 @@ import { AudioActionType, playEffect } from "@/infra/audio";
* @usage - TODO
* */
export default (data: Uint8Array) => {
playEffect(AudioActionType.SOUND_COUNTER_ADD);
const reader = new BufferReaderExt(data);
const counterType = reader.inner.readUint16();
......
......@@ -2,7 +2,6 @@ import { ygopro } from "@/api/ocgcore/idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgAttack = ygopro.StocGameMessage.MsgAttack;
import { AudioActionType, playEffect } from "@/infra/audio";
/*
* Msg Attack
......@@ -22,14 +21,12 @@ export default (data: Uint8Array) => {
target_location.zone === 0 &&
target_location.sequence === 0
) {
playEffect(AudioActionType.SOUND_DIRECT_ATTACK);
// 全零表示直接攻击玩家
return new MsgAttack({
attacker_location,
direct_attack: true,
});
} else {
playEffect(AudioActionType.SOUND_ATTACK);
return new MsgAttack({
attacker_location,
target_location,
......
import { BufferReader } from "rust-src";
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../../idl/ocgcore";
/*
......@@ -20,7 +18,6 @@ export default (data: Uint8Array) => {
let cards: number[] = [];
for (let i = 0; i < count; i++) {
cards.push(reader.readUint32());
playEffect(AudioActionType.SOUND_DRAW);
}
return new ygopro.StocGameMessage.MsgDraw({
......
import { BufferReader } from "rust-src";
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../../idl/ocgcore";
/*
......@@ -13,7 +11,6 @@ import { ygopro } from "../../../idl/ocgcore";
* */
export default (data: Uint8Array) => {
playEffect(AudioActionType.SOUND_PHASE);
const reader = new BufferReader(data);
const phase = reader.readUint16();
......
import { BufferReader } from "rust-src";
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../../idl/ocgcore";
/*
......@@ -13,7 +11,6 @@ import { ygopro } from "../../../idl/ocgcore";
* */
export default (data: Uint8Array) => {
playEffect(AudioActionType.SOUND_NEXT_TURN);
const reader = new BufferReader(data);
const player = reader.readUint8();
......
import { BufferReader } from "rust-src";
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../../idl/ocgcore";
/*
......@@ -11,7 +9,6 @@ import { ygopro } from "../../../idl/ocgcore";
* @param value - 回复的Hp数值
* */
export default (data: Uint8Array) => {
playEffect(AudioActionType.SOUND_RECOVER);
const reader = new BufferReader(data);
const player = reader.readUint8();
......
import { ygopro } from "../../../idl/ocgcore";
import { BufferReaderExt } from "../../bufferIO";
import MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
import { AudioActionType, playEffect } from "@/infra/audio";
/*
* Msg Remove Counter
......@@ -10,7 +9,6 @@ import { AudioActionType, playEffect } from "@/infra/audio";
* @usage - TODO
* */
export default (data: Uint8Array) => {
playEffect(AudioActionType.SOUND_COUNTER_REMOVE);
const reader = new BufferReaderExt(data);
const counterType = reader.inner.readUint16();
......
import { BufferReader } from "../../../../../../rust-src/pkg/rust_src";
import { ygopro } from "../../../idl/ocgcore";
import MsgToss = ygopro.StocGameMessage.MsgToss;
import { AudioActionType, playEffect } from "@/infra/audio";
/*
* Msg Toss
......@@ -10,7 +9,6 @@ import { AudioActionType, playEffect } from "@/infra/audio";
* @usage 骰子/硬币结果
* */
export default (data: Uint8Array, toss_type: MsgToss.TossType) => {
playEffect(AudioActionType.SOUND_DICE);
const reader = new BufferReader(data);
const player = reader.readUint8();
const count = reader.readUint8();
......
import { AudioActionType, playEffect } from "@/infra/audio";
import { ygopro } from "../../idl/ocgcore";
import { StocAdapter, YgoProPacket } from "../packet";
import { _cutoff_name, UTF16_BUFFER_MAX_LEN } from "../util";
......@@ -19,7 +17,6 @@ export default class HsPlayerEnterAdapter implements StocAdapter {
constructor(packet: YgoProPacket) {
this.packet = packet;
playEffect(AudioActionType.SOUND_PLAYER_ENTER);
}
upcast(): ygopro.YgoStocMsg {
......
import { ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { cardStore, fetchEsHintMeta } from "@/stores";
import { callCardAttack } from "@/ui/Duel/PlayMat/Card";
......@@ -16,10 +17,12 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
if (attacker) {
if (attack.direct_attack) {
playEffect(AudioActionType.SOUND_DIRECT_ATTACK);
await callCardAttack(attacker.uuid, {
directAttack: true,
});
} else {
playEffect(AudioActionType.SOUND_ATTACK);
await callCardAttack(attacker.uuid, {
directAttack: false,
target: attack.target_location,
......
import { fetchCard, ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { cardStore, fetchEsHintMeta } from "@/stores";
import { callCardMove } from "@/ui/Duel/PlayMat/Card";
......@@ -22,6 +23,7 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
card.meta = meta;
card.location.zone = ygopro.CardZone.HAND;
card.location.sequence = Number(idx) + handsLength;
playEffect(AudioActionType.SOUND_DRAW);
}
// 抽卡动画
......
import { ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { matStore } from "@/stores";
export default (newPhase: ygopro.StocGameMessage.MsgNewPhase) => {
playEffect(AudioActionType.SOUND_PHASE);
// ts本身还没有这么智能,所以需要手动指定类型
matStore.phase.currentPhase = newPhase.phase_type;
};
import { ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { matStore } from "@/stores";
export default (newTurn: ygopro.StocGameMessage.MsgNewTurn) => {
playEffect(AudioActionType.SOUND_NEXT_TURN);
const player = newTurn.player;
matStore.currentPlayer = player;
};
......@@ -2,6 +2,7 @@ import { fetchStrings, Region, ygopro } from "@/api";
import { sleep } from "@/infra";
import { matStore } from "@/stores";
import MsgToss = ygopro.StocGameMessage.MsgToss;
import { AudioActionType, playEffect } from "@/infra/audio";
export default async (toss: MsgToss) => {
const player = toss.player;
......@@ -11,8 +12,10 @@ export default async (toss: MsgToss) => {
for (const x of toss.res) {
if (tossType === MsgToss.TossType.DICE) {
playEffect(AudioActionType.SOUND_DICE);
matStore.tossResult = prefix + fetchStrings(Region.System, 1624) + x;
} else if (tossType === MsgToss.TossType.COIN) {
playEffect(AudioActionType.SOUND_COIN);
matStore.tossResult =
prefix +
fetchStrings(Region.System, 1623) +
......
import { ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { cardStore } from "@/stores";
type MsgUpdateCounter = ygopro.StocGameMessage.MsgUpdateCounter;
......@@ -12,8 +13,10 @@ export default (updateCounter: MsgUpdateCounter) => {
case ygopro.StocGameMessage.MsgUpdateCounter.ActionType.ADD: {
if (counterType in target.counters) {
target.counters[counterType] += count;
playEffect(AudioActionType.SOUND_COUNTER_ADD);
} else {
target.counters[counterType] = count;
playEffect(AudioActionType.SOUND_COUNTER_REMOVE);
}
break;
}
......
......@@ -2,13 +2,15 @@ import { ygopro } from "@/api";
import { fetchEsHintMeta, matStore } from "@/stores";
import MsgUpdateHp = ygopro.StocGameMessage.MsgUpdateHp;
import { AudioActionType, changeScene } from "@/infra/audio";
import { AudioActionType, changeScene, playEffect } from "@/infra/audio";
export default (msgUpdateHp: MsgUpdateHp) => {
if (msgUpdateHp.type_ === MsgUpdateHp.ActionType.DAMAGE) {
playEffect(AudioActionType.SOUND_DAMAGE);
fetchEsHintMeta({ originMsg: "玩家收到伤害时" }); // TODO: i18n
matStore.initInfo.of(msgUpdateHp.player).life -= msgUpdateHp.value;
} else if (msgUpdateHp.type_ === MsgUpdateHp.ActionType.RECOVER) {
playEffect(AudioActionType.SOUND_RECOVER);
fetchEsHintMeta({ originMsg: "玩家生命值回复时" }); // TODO: i18n
matStore.initInfo.of(msgUpdateHp.player).life += msgUpdateHp.value;
}
......
import { ygopro } from "@/api";
import { AudioActionType, playEffect } from "@/infra/audio";
import { roomStore } from "@/stores";
export default function handleHsPlayerEnter(pb: ygopro.YgoStocMsg) {
playEffect(AudioActionType.SOUND_PLAYER_ENTER);
const name = pb.stoc_hs_player_enter.name;
const pos = pb.stoc_hs_player_enter.pos;
......
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