Commit 745e7944 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'fix/start' into 'main'

Fix/start

See merge request mycard/Neos!214
parents 6ef9a17f 667cb96c
Pipeline #22135 passed with stages
in 15 minutes and 14 seconds
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
"cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN", "cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL":false,
"streamInterval": 20, "streamInterval":20,
"startDelay":1000,
"ui":{ "ui":{
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 1 "maxCount":1
} }
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
......
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
"cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN", "cardImgUrl":"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb", "cardsDbUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb",
"stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf", "stringsUrl":"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf",
"chainALL": false, "chainALL":false,
"streamInterval": 20, "streamInterval":20,
"startDelay":1000,
"ui":{ "ui":{
"hint":{ "hint":{
"waitingDuration":1.5, "waitingDuration":1.5,
"maxCount": 1 "maxCount":1
} }
}, },
"unimplementedWhiteList":[ "unimplementedWhiteList":[
......
{ {
"50": { "50":{
"protoType": "move", "protoType":"move",
"fields": [ "fields":[
{ {
"fieldName": "code", "fieldName":"code",
"fieldType": "uint32" "fieldType":"uint32"
}, },
{ {
"fieldName": "from", "fieldName":"from",
"fieldType": "CardLocation" "fieldType":"CardLocation"
}, },
{ {
"fieldName": "to", "fieldName":"to",
"fieldType": "CardLocation" "fieldType":"CardLocation"
}, },
{ {
"fieldName": "reason", "fieldName":"reason",
"fieldType": "uint8" "fieldType":"uint8"
} }
] ]
}, },
"33": { "33":{
"protoType": "shuffle_hand", "protoType":"shuffle_hand",
"fields": [ "fields":[
{ {
"fieldName": "player", "fieldName":"player",
"fieldType": "uint8" "fieldType":"uint8"
}, },
{ {
"fieldName": "hands", "fieldName":"hands",
"fieldType": "repeated", "fieldType":"repeated",
"repeatedType": "uint32" "repeatedType":"uint32"
} }
] ]
}, },
"53": { "53":{
"protoType": "pos_change", "protoType":"pos_change",
"fields": [ "fields":[
{ {
"fieldName": "card_info", "fieldName":"card_info",
"fieldType": "CardInfo" "fieldType":"CardInfo"
}, },
{ {
"fieldName": "pre_position", "fieldName":"pre_position",
"fieldType": "CardPosition" "fieldType":"CardPosition"
}, },
{ {
"fieldName": "cur_position", "fieldName":"cur_position",
"fieldType": "CardPosition" "fieldType":"CardPosition"
} }
] ]
}, },
"13": { "13":{
"protoType": "select_yes_no", "protoType":"select_yes_no",
"fields": [ "fields":[
{ "fieldName": "player","fieldType": "uint8" }, {
{ "fieldName": "effect_description", "fieldType": "uint32" } "fieldName":"player",
] "fieldType":"uint8"
}, },
"54": { {
"protoType": "set", "fieldName":"effect_description",
"fields": [] "fieldType":"uint32"
}, }
"55": { ]
"protoType": "swap", },
"fields": [] "54":{
}, "protoType":"set",
"60": { "fields":[
"protoType": "summoning",
"fields": [ ]
{ "fieldName": "code", "fieldType": "uint32" }, },
{ "fieldName": "location", "fieldType": "CardLocation" } "55":{
] "protoType":"swap",
}, "fields":[
"61": {
"protoType": "summoned", ]
"fields": [] },
}, "60":{
"62": { "protoType":"summoning",
"protoType": "sp_summoning", "fields":[
"fields": [ {
{ "fieldName": "code", "fieldType": "uint32" }, "fieldName":"code",
{ "fieldName": "location", "fieldType": "CardLocation" } "fieldType":"uint32"
] },
}, {
"63": { "fieldName":"location",
"protoType": "sp_summoned", "fieldType":"CardLocation"
"fields": [] }
}, ]
"64": { },
"protoType": "flip_summoning", "61":{
"fields": [ "protoType":"summoned",
{ "fieldName": "code", "fieldType": "uint32" }, "fields":[
{ "fieldName": "location", "fieldType": "CardLocation" }
] ]
}, },
"65": { "62":{
"protoType": "flip_summoned", "protoType":"sp_summoning",
"fields": [] "fields":[
}, {
"70": { "fieldName":"code",
"protoType": "chaining", "fieldType":"uint32"
"fields": [ },
{ "fieldName": "code", "fieldType": "uint32" }, {
{ "fieldName": "location", "fieldType": "CardLocation" } "fieldName":"location",
] "fieldType":"CardLocation"
}, }
"112": { ]
"protoType": "attack_disable", },
"fields": [] "63":{
}, "protoType":"sp_summoned",
"73": { "fields":[
"protoType": "chain_solved",
"fields": [{ "fieldName": "solved_index", "fieldType": "uint8"}] ]
}, },
"74": { "64":{
"protoType": "chain_end", "protoType":"flip_summoning",
"fields": [] "fields":[
}, {
"75": { "fieldName":"code",
"protoType": "chain_solved", "fieldType":"uint32"
"fields": [{ "fieldName": "solved_index", "fieldType": "uint8"}] },
}, {
"76": { "fieldName":"location",
"protoType": "chain_solved", "fieldType":"CardLocation"
"fields": [{ "fieldName": "solved_index", "fieldType": "uint8"}] }
}, ]
"94": { },
"protoType": "lp_update", "65":{
"fields": [ "protoType":"flip_summoned",
{ "fieldName": "player", "fieldType": "uint8" }, "fields":[
{ "fieldName": "new_lp", "fieldType": "uint32" }
] ]
}, },
"30": { "70":{
"protoType": "confirm_cards", "protoType":"chaining",
"fields": [ "fields":[
{ {
"fieldName": "player", "fieldName":"code",
"fieldType": "uint8" "fieldType":"uint32"
}, },
{ {
"fieldName": "cards", "fieldName":"location",
"fieldType": "repeated", "fieldType":"CardLocation"
"repeatedType": "CardInfo" }
} ]
] },
}, "112":{
"31": { "protoType":"attack_disable",
"protoType": "confirm_cards", "fields":[
"fields": [
{ ]
"fieldName": "player", },
"fieldType": "uint8" "73":{
}, "protoType":"chain_solved",
{ "fields":[
"fieldName": "cards", {
"fieldType": "repeated", "fieldName":"solved_index",
"repeatedType": "CardInfo" "fieldType":"uint8"
} }
] ]
} },
"74":{
"protoType":"chain_end",
"fields":[
]
},
"75":{
"protoType":"chain_solved",
"fields":[
{
"fieldName":"solved_index",
"fieldType":"uint8"
}
]
},
"76":{
"protoType":"chain_solved",
"fields":[
{
"fieldName":"solved_index",
"fieldType":"uint8"
}
]
},
"94":{
"protoType":"lp_update",
"fields":[
{
"fieldName":"player",
"fieldType":"uint8"
},
{
"fieldName":"new_lp",
"fieldType":"uint32"
}
]
},
"30":{
"protoType":"confirm_cards",
"fields":[
{
"fieldName":"player",
"fieldType":"uint8"
},
{
"fieldName":"cards",
"fieldType":"repeated",
"repeatedType":"CardInfo"
}
]
},
"31":{
"protoType":"confirm_cards",
"fields":[
{
"fieldName":"player",
"fieldType":"uint8"
},
{
"fieldName":"cards",
"fieldType":"repeated",
"repeatedType":"CardInfo"
}
]
}
} }
import { ygopro } from "@/api"; import { ygopro } from "@/api";
import { cardStore, fetchEsHintMeta, matStore } from "@/stores"; import { cardStore, fetchEsHintMeta } from "@/stores";
export default async (attack: ygopro.StocGameMessage.MsgAttack) => { export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
fetchEsHintMeta({ fetchEsHintMeta({
...@@ -15,10 +15,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => { ...@@ -15,10 +15,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
if (attacker) { if (attacker) {
if (attack.direct_attack) { if (attack.direct_attack) {
attacker.directAttack = true; // TODO: 实现直接攻击的动画
// await sleep(500);
attacker.directAttack = false;
} else { } else {
const target = cardStore.at( const target = cardStore.at(
attack.target_location.zone, attack.target_location.zone,
...@@ -27,14 +24,12 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => { ...@@ -27,14 +24,12 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
); );
if (target) { if (target) {
attacker.attackTarget = { // TODO: 实现攻击`target`的动画
opponent: !matStore.isMe(attack.target_location.controller), } else {
...target, console.warn(`<Attack>target from ${attack.target_location} is null`);
};
// await sleep(500);
attacker.attackTarget = undefined;
} }
} }
} else {
console.warn(`<Attack>attacker from ${attack.attacker_location} is null`);
} }
}; };
...@@ -8,18 +8,17 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => { ...@@ -8,18 +8,17 @@ export default async (chaining: ygopro.StocGameMessage.MsgChaining) => {
cardID: chaining.code, cardID: chaining.code,
}); });
await cardStore.setChaining(chaining.location, chaining.code, true);
const location = chaining.location; const location = chaining.location;
// 恢复成非`chaining`状态
await cardStore.setChaining(location, chaining.code, false);
// 将`location`添加到连锁栈 // 将`location`添加到连锁栈
matStore.chains.push(location); matStore.chains.push(location);
// 设置被连锁状态
const target = cardStore.find(location); const target = cardStore.find(location);
if (target) { if (target) {
// 设置连锁序号
target.chainIndex = matStore.chains.length; target.chainIndex = matStore.chains.length;
// 发动效果动画
await eventbus.call(Task.Focus, target.uuid); await eventbus.call(Task.Focus, target.uuid);
console.color("blue")(`${target.meta.text.name} chaining`); console.color("blue")(`${target.meta.text.name} chaining`);
} else { } else {
......
...@@ -2,8 +2,6 @@ import { fetchCard, ygopro } from "@/api"; ...@@ -2,8 +2,6 @@ import { fetchCard, ygopro } from "@/api";
import { eventbus, Task } from "@/infra"; import { eventbus, Task } from "@/infra";
import { cardStore, fetchEsHintMeta } from "@/stores"; import { cardStore, fetchEsHintMeta } from "@/stores";
let cnt = 0;
export default async (draw: ygopro.StocGameMessage.MsgDraw) => { export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
fetchEsHintMeta({ originMsg: "玩家抽卡时" }); fetchEsHintMeta({ originMsg: "玩家抽卡时" });
...@@ -25,11 +23,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => { ...@@ -25,11 +23,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
card.location.sequence = Number(idx) + handsLength; card.location.sequence = Number(idx) + handsLength;
} }
if (cnt++ < 2) {
// FIXME 暂时性的解决方案,头两回抽卡(双方各自初始手卡)先屏蔽掉
// 不然会出现一些问题...
return;
}
// 抽卡动画 // 抽卡动画
await Promise.all( await Promise.all(
cardStore cardStore
......
...@@ -76,7 +76,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) { ...@@ -76,7 +76,7 @@ async function _handleGameMsg(pb: ygopro.YgoStocMsg) {
switch (msg.gameMsg) { switch (msg.gameMsg) {
case "start": { case "start": {
onMsgStart(msg.start); await onMsgStart(msg.start);
break; break;
} }
......
...@@ -4,11 +4,13 @@ import { proxy } from "valtio"; ...@@ -4,11 +4,13 @@ import { proxy } from "valtio";
import { subscribeKey } from "valtio/utils"; import { subscribeKey } from "valtio/utils";
import { fetchCard, ygopro } from "@/api"; import { fetchCard, ygopro } from "@/api";
import { useConfig } from "@/config";
import { sleep } from "@/infra";
import { cardStore, CardType, store } from "@/stores"; import { cardStore, CardType, store } from "@/stores";
const { matStore } = store; const { matStore } = store;
const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token const TOKEN_SIZE = 13; // 每人场上最多就只可能有13个token
export default (start: ygopro.StocGameMessage.MsgStart) => { export default async (start: ygopro.StocGameMessage.MsgStart) => {
// 先初始化`matStore` // 先初始化`matStore`
matStore.selfType = start.playerType; matStore.selfType = start.playerType;
const opponent = const opponent =
...@@ -61,8 +63,6 @@ export default (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -61,8 +63,6 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
text: {}, text: {},
}, },
isToken: !((i + 1) % 3), isToken: !((i + 1) % 3),
chaining: false,
directAttack: false,
}) })
) )
) )
...@@ -73,6 +73,10 @@ export default (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -73,6 +73,10 @@ export default (start: ygopro.StocGameMessage.MsgStart) => {
cardStore cardStore
.at(ygopro.CardZone.EXTRA, 1 - opponent) .at(ygopro.CardZone.EXTRA, 1 - opponent)
.forEach((card) => (card.code = myExtraDeckCodes.pop()!)); .forEach((card) => (card.code = myExtraDeckCodes.pop()!));
// 初始化完后,sleep 1s,让UI初始化完成,
// 否则在和AI对战时,由于后端给传给前端的`MSG`频率太高,会导致一些问题。
await sleep(useConfig().startDelay);
}; };
// 自动从code推断出occupant // 自动从code推断出occupant
......
import { proxy } from "valtio"; import { proxy } from "valtio";
import { CardMeta, fetchCard, ygopro } from "@/api"; import { CardMeta, ygopro } from "@/api";
import type { Interactivity } from "./matStore/types"; import type { Interactivity } from "./matStore/types";
...@@ -23,12 +23,8 @@ export interface CardType { ...@@ -23,12 +23,8 @@ export interface CardType {
reload?: boolean; // 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false reload?: boolean; // 这个字段会在收到MSG_RELOAD_FIELD的时候设置成true,在收到MSG_UPDATE_DATE的时候设置成false
isToken: boolean; // 是否是token isToken: boolean; // 是否是token
// 新的字段(从matstore之中搬过来的)
chaining: boolean; // 是否在连锁中
chainIndex?: number /*连锁的序号,如果为空表示不在连锁 chainIndex?: number /*连锁的序号,如果为空表示不在连锁
TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/; TODO: 目前是妥协的设计,因为其实一张卡是可以在同一个连锁链中被连锁多次的,这里为了避免太过复杂只保存最后的连锁序号*/;
directAttack: boolean; // 是否正在直接攻击为玩家
attackTarget?: CardType & { opponent: boolean }; // 攻击目标。(嵌套结构可行么?)
} }
class CardStore { class CardStore {
...@@ -95,30 +91,6 @@ class CardStore { ...@@ -95,30 +91,6 @@ class CardStore {
card.location.is_overlay card.location.is_overlay
); );
} }
async setChaining(
location: ygopro.CardLocation,
code: number,
isChaining: boolean
): Promise<void> {
const target = this.find(location);
if (target) {
target.chaining = isChaining;
if (isChaining) {
// 目前需要判断`isChaining`为ture才设置meta,因为有些手坑发效果后会move到墓地,
// 运行到这里的时候已经和原来的位置对不上了,这时候不设置meta
const meta = await fetchCard(code);
// 这里不能设置`code`,因为存在一个场景:
// 对方的`魔神仪-曼德拉护肤草`发动效果后,后端会发一次`MSG_SHUFFLE_HAND`,但传给前端的codes全是0,如果这里设置了`code`的话,在后面的`MSG_SHUFFLE_HAND`处理就会有问题。
// target.code = meta.id;
target.meta = meta;
}
if (target.location.zone == ygopro.CardZone.HAND) {
target.location.position = isChaining
? ygopro.CardPosition.FACEUP_ATTACK
: ygopro.CardPosition.FACEDOWN_ATTACK;
}
}
}
} }
export const cardStore = proxy(new CardStore()); export const cardStore = proxy(new CardStore());
......
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