Commit b68b030e authored by chechunchi's avatar chechunchi

fix something

parent 99af0d62
......@@ -5,51 +5,23 @@ import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
// 后端传过来的`from_locations`的列表是切洗前场上卡的location,它们在列表里面按照切洗后的顺序排列
export default async (shuffleSetCard: MsgShuffleSetCard) => {
const zone = shuffleSetCard.zone;
const from_locations = shuffleSetCard.from_locations;
if (from_locations.length == 0) {
console.error("<ShuffleSetCard>from_locations is empty");
return;
}
const controller = from_locations[0].controller;
// 获取到场上对应zone的卡
const cards = cardStore.at(zone, controller);
// 获取场上卡当前所有sequence,并按大小排列
const sequences = cards
.map((card) => card.location.sequence)
.sort((a, b) => a - b);
if (sequences.length != from_locations.length) {
console.error(
"<ShuffleSetCard>length of sequences and from_locations not matched"
);
return;
}
const count = from_locations.length;
for (let i = 0; i < count; i++) {
const from = from_locations[i];
const to_seq = sequences[i];
for (const from of from_locations) {
const target = cardStore.at(from.zone, from.controller, from.sequence);
if (target) {
// 更新位置
target.location.sequence = to_seq;
// 渲染动画
await eventbus.call(Task.Move, target.uuid);
// 设置code为0,洗切后的code会由`UpdateData`指定
target.code = 0;
target.meta.id = 0;
target.meta.text.id = 0;
} else {
console.warn(`<ShuffleSetCard>target from ${from} is null`);
}
// 同时更新超量素材的sequence(非overlay_sequence)
for (const overlay of cardStore.findOverlay(
from.zone,
from.controller,
from.sequence
)) {
overlay.location.sequence = to_seq;
await eventbus.call(Task.Move, overlay.uuid);
}
}
// TODO: 处理超量
};
import { ygopro } from "@/api";
import { fetchCard, ygopro } from "@/api";
import MsgUpdateData = ygopro.StocGameMessage.MsgUpdateData;
import { eventbus, Task } from "@/infra";
......@@ -15,12 +15,14 @@ export default async (updateData: MsgUpdateData) => {
.filter((card) => card.location.sequence == sequence)
.at(0);
if (target) {
const meta = target.meta;
// 目前只更新以下字段
if (action?.code >= 0) {
meta.id = action.code;
meta.text.id = action.code;
const newMeta = await fetchCard(action.code);
target.code = action.code;
target.meta = newMeta;
}
const meta = target.meta;
if (action.location !== undefined) {
if (target.location.position != action.location.position) {
// Currently only update position
......
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