Commit d38980b4 authored by chechunchi's avatar chechunchi Committed by Chunchi Che

udpate move.ts

parent 28b2cafe
Pipeline #21743 passed with stages
in 15 minutes and 42 seconds
......@@ -22,6 +22,7 @@ export default async (move: MsgMove) => {
// FIXME: 考虑超量素材的情况
let uuid;
let chainIndex;
switch (from.location) {
case ygopro.CardZone.MZONE:
case ygopro.CardZone.SZONE: {
......@@ -32,6 +33,7 @@ export default async (move: MsgMove) => {
target.occupant = undefined;
target.overlay_materials = [];
uuid = target.uuid;
chainIndex = target.chainIndex;
// 需要重新分配UUID
target.uuid = v4uuid();
break;
......@@ -47,6 +49,7 @@ export default async (move: MsgMove) => {
.of(from.controler)
.remove(from.sequence);
uuid = removed.uuid;
chainIndex = removed.chainIndex;
break;
}
......@@ -77,8 +80,12 @@ export default async (move: MsgMove) => {
.of(to.controler)
.setOccupant(to.sequence, code, to.position, true);
if (uuid) {
// 设置UUID
matStore.in(to.location).of(to.controler)[to.sequence].uuid = uuid;
}
// 设置连锁序号
matStore.in(to.location).of(to.controler)[to.sequence].chainIndex =
chainIndex;
await sleep(NeosConfig.ui.moveDelay);
matStore.in(to.location).of(to.controler)[to.sequence].focus = false;
......@@ -92,7 +99,7 @@ export default async (move: MsgMove) => {
matStore
.in(to.location)
.of(to.controler)
.insert(uuid, code, to.sequence, to.position);
.insert(uuid, code, to.sequence, to.position, false, chainIndex);
}
break;
}
......@@ -106,7 +113,8 @@ export default async (move: MsgMove) => {
code,
to.sequence,
ygopro.CardPosition.FACEUP_ATTACK,
true
true,
chainIndex
);
await sleep(NeosConfig.ui.moveDelay);
......
......@@ -31,7 +31,8 @@ class CardArray extends Array<CardState> implements ArrayCardState {
controller: number,
id: number,
position?: ygopro.CardPosition,
focus?: boolean
focus?: boolean,
chainIndex?: number
) => ({
uuid,
occupant: await fetchCard(id, true),
......@@ -56,14 +57,16 @@ class CardArray extends Array<CardState> implements ArrayCardState {
id: number,
sequence: number,
position?: ygopro.CardPosition,
focus?: boolean
focus?: boolean,
chainIndex?: number
) {
const card = await this.genCard(
uuid,
this.getController(),
id,
position,
focus
focus,
chainIndex
);
this.splice(sequence, 0, card);
}
......
......@@ -21,7 +21,8 @@ export interface DuelFieldState extends Array<CardState> {
id: number,
sequence: number,
position?: ygopro.CardPosition,
focus?: boolean
focus?: boolean,
chainIndex?: number
) => Promise<void>;
/** 在末尾添加卡片 */
add: (
......
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