Commit f6414f4d authored by timel's avatar timel

Merge branch 'chore/dependencies' into 'main'

Chore/dependencies

See merge request mycard/Neos!262
parents 15167474 18400f60
Pipeline #23130 passed with stages
in 11 minutes and 55 seconds
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"extends": [ "extends": [
"plugin:prettier/recommended", "plugin:prettier/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:valtio/recommended" "plugin:valtio/recommended"
], ],
"plugins": [ "plugins": [
...@@ -11,17 +9,20 @@ ...@@ -11,17 +9,20 @@
"simple-import-sort" "simple-import-sort"
], ],
"rules": { "rules": {
"eqeqeq": 0, "simple-import-sort/imports": "warn",
"no-var": "error", "simple-import-sort/exports": "warn",
"eqeqeq": "warn",
"@typescript-eslint/consistent-type-definitions": [ "@typescript-eslint/consistent-type-definitions": [
"error", "error",
"interface" "interface"
], ],
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"no-unused-vars": "off", "no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } "error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
] ]
}, },
"settings": { "settings": {
...@@ -30,5 +31,7 @@ ...@@ -30,5 +31,7 @@
"typescript": true "typescript": true
} }
}, },
"ignorePatterns": ["src/api/ocgcore/idl/ocgcore.ts"] "ignorePatterns": [
"src/api/ocgcore/idl/ocgcore.ts"
]
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,19 +3,11 @@ ...@@ -3,19 +3,11 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@ant-design/pro-components": "^2.4.4", "@ant-design/pro-components": "^2.6.12",
"@dnd-kit/core": "^6.0.8", "@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2", "@dnd-kit/sortable": "^7.0.2",
"@react-spring/web": "^9.7.2", "@react-spring/web": "^9.7.3",
"@testing-library/jest-dom": "^5.16.5", "antd": "^5.8.3",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.23",
"@types/react": "^18.0.33",
"@types/react-dom": "^18.0.11",
"@types/sql.js": "^1.4.4",
"antd": "^5.4.0",
"classnames": "^2.3.2", "classnames": "^2.3.2",
"cookies-ts": "^1.0.5", "cookies-ts": "^1.0.5",
"eventemitter3": "^5.0.1", "eventemitter3": "^5.0.1",
...@@ -28,15 +20,12 @@ ...@@ -28,15 +20,12 @@
"react-dnd": "^16.0.1", "react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1", "react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-draggable": "^4.4.5", "react-router-dom": "^6.15.0",
"react-router-dom": "^6.10.0",
"react-scripts": "^2.1.3",
"sql.js": "^1.8.0", "sql.js": "^1.8.0",
"u-reset.css": "^2.0.1", "u-reset.css": "^2.0.1",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"valtio": "^1.10.4", "valtio": "^1.11.2",
"vite-plugin-svgr": "^2.4.0", "vite-plugin-svgr": "^3.2.0",
"web-vitals": "^2.1.4",
"ygopro-deck-encode": "^1.0.3" "ygopro-deck-encode": "^1.0.3"
}, },
"scripts": { "scripts": {
...@@ -46,14 +35,11 @@ ...@@ -46,14 +35,11 @@
"build:prod": "vite build --base=https://cdn02.moecube.com:444/neos/", "build:prod": "vite build --base=https://cdn02.moecube.com:444/neos/",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint --ext .ts --ext .tsx src", "lint": "eslint --ext .ts --ext .tsx src",
"fmt": "eslint --ext .ts --ext .tsx src --fix && cd rust-src && cargo fmt", "fmt": "eslint --ext .ts --ext .tsx src --fix && cd rust-src && cargo fmt"
"test": "react-scripts test",
"eject": "react-scripts eject"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
"react-app", "react-app"
"react-app/jest"
] ]
}, },
"browserslist": { "browserslist": {
...@@ -70,25 +56,28 @@ ...@@ -70,25 +56,28 @@
}, },
"devDependencies": { "devDependencies": {
"@types/google-protobuf": "^3.15.6", "@types/google-protobuf": "^3.15.6",
"@types/lodash-es": "^4.17.7", "@types/lodash-es": "^4.17.8",
"@types/uuid": "^9.0.1", "@types/node": "^20.5.0",
"@typescript-eslint/eslint-plugin": "^5.57.1", "@types/react": "^18.2.20",
"@typescript-eslint/parser": "^5.57.1", "@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^3.1.0", "@types/sql.js": "^1.4.4",
"eslint": "^8.38.0", "@types/uuid": "^9.0.2",
"eslint-config-prettier": "^8.8.0", "@typescript-eslint/eslint-plugin": "^6.3.0",
"eslint-import-resolver-typescript": "^3.5.5", "@typescript-eslint/parser": "^6.3.0",
"eslint-plugin-import": "^2.27.5", "@vitejs/plugin-react": "^4.0.4",
"eslint-plugin-prettier": "^4.2.1", "eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-valtio": "^0.6.2", "eslint-plugin-valtio": "^0.6.2",
"prettier": "^2.8.7", "prettier": "^3.0.1",
"sass": "^1.61.0", "sass": "^1.65.1",
"typescript": "^4.9.5", "typescript": "^5.1.6",
"vite": "^4.2.1", "vite": "^4.4.9",
"vite-plugin-sass-dts": "^1.3.8", "vite-plugin-sass-dts": "^1.3.9",
"vite-plugin-wasm-pack": "^0.1.12", "vite-plugin-wasm-pack": "^0.1.12",
"vite-tsconfig-paths": "^4.0.8", "vite-tsconfig-paths": "^4.2.0",
"vite-ydk-loader": "^0.0.2" "vite-ydk-loader": "^0.0.2"
} }
} }
...@@ -28,14 +28,14 @@ export async function initForbiddens(): Promise<void> { ...@@ -28,14 +28,14 @@ export async function initForbiddens(): Promise<void> {
// 获取禁限信息 // 获取禁限信息
export async function getForbiddenInfo( export async function getForbiddenInfo(
id: number id: number,
): Promise<number | undefined> { ): Promise<number | undefined> {
return await get(id, idb); return await get(id, idb);
} }
// 解析函数,提取卡片编号和限制张数 // 解析函数,提取卡片编号和限制张数
function parseCardInfo( function parseCardInfo(
input: string input: string,
): { cardId: number; limitCount: number } | null { ): { cardId: number; limitCount: number } | null {
const match = input.match(/^(\d+)\s+(\d+)\s+--/); const match = input.match(/^(\d+)\s+(\d+)\s+--/);
if (match) { if (match) {
......
...@@ -9,7 +9,7 @@ export interface MatchInfo { ...@@ -9,7 +9,7 @@ export interface MatchInfo {
export async function match( export async function match(
username: string, username: string,
extraId: number, extraId: number,
arena: string = "entertain" arena: string = "entertain",
): Promise<MatchInfo | undefined> { ): Promise<MatchInfo | undefined> {
const headers = { Authorization: "Basic " + btoa(username + ":" + extraId) }; const headers = { Authorization: "Basic " + btoa(username + ":" + extraId) };
let response: Response | undefined = undefined; let response: Response | undefined = undefined;
......
...@@ -68,7 +68,7 @@ export default class CtosResponsePacket extends YgoProPacket { ...@@ -68,7 +68,7 @@ export default class CtosResponsePacket extends YgoProPacket {
} }
case "select_counter_response": { case "select_counter_response": {
extraData = adaptSelectCounterResponse( extraData = adaptSelectCounterResponse(
response.select_counter_response response.select_counter_response,
); );
break; break;
......
...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src"; ...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src";
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
export default ( export default (
response: ygopro.CtosGameMsgResponse.SelectBattleCmdResponse response: ygopro.CtosGameMsgResponse.SelectBattleCmdResponse,
) => { ) => {
const writer = new BufferWriter(); const writer = new BufferWriter();
......
...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src"; ...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src";
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
export default ( export default (
response: ygopro.CtosGameMsgResponse.SelectEffectYnResponse response: ygopro.CtosGameMsgResponse.SelectEffectYnResponse,
) => { ) => {
const writer = new BufferWriter(); const writer = new BufferWriter();
......
...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src"; ...@@ -3,7 +3,7 @@ import { BufferWriter } from "rust-src";
import { ygopro } from "../../../idl/ocgcore"; import { ygopro } from "../../../idl/ocgcore";
export default ( export default (
response: ygopro.CtosGameMsgResponse.SelectPositionResponse response: ygopro.CtosGameMsgResponse.SelectPositionResponse,
) => { ) => {
const writer = new BufferWriter(); const writer = new BufferWriter();
......
...@@ -44,7 +44,7 @@ export class YgoProPacket { ...@@ -44,7 +44,7 @@ export class YgoProPacket {
try { try {
if (array.byteLength < PACKET_MIN_LEN) { if (array.byteLength < PACKET_MIN_LEN) {
throw new Error( throw new Error(
"Packet length too short, length = " + array.byteLength "Packet length too short, length = " + array.byteLength,
); );
} }
} catch (e) { } catch (e) {
......
...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => { ...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => {
new MsgAnnounce.Option({ new MsgAnnounce.Option({
code: i, code: i,
response: 1 << i, response: 1 << i,
}) }),
); );
} }
} }
......
...@@ -23,7 +23,7 @@ export default (data: Uint8Array) => { ...@@ -23,7 +23,7 @@ export default (data: Uint8Array) => {
new MsgAnnounce.Option({ new MsgAnnounce.Option({
code, code,
response: code, response: code,
}) }),
); );
} }
......
...@@ -23,7 +23,7 @@ export default (data: Uint8Array) => { ...@@ -23,7 +23,7 @@ export default (data: Uint8Array) => {
new MsgAnnounce.Option({ new MsgAnnounce.Option({
code: num, code: num,
response: i, response: i,
}) }),
); );
} }
......
...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => { ...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => {
new MsgAnnounce.Option({ new MsgAnnounce.Option({
code: i, code: i,
response: 1 << i, response: 1 << i,
}) }),
); );
} }
} }
......
...@@ -17,9 +17,9 @@ export default (data: Uint8Array) => { ...@@ -17,9 +17,9 @@ export default (data: Uint8Array) => {
const target_location = reader.readCardLocation(); const target_location = reader.readCardLocation();
if ( if (
target_location.controller == 0 && target_location.controller === 0 &&
target_location.zone == 0 && target_location.zone === 0 &&
target_location.sequence == 0 target_location.sequence === 0
) { ) {
// 全零表示直接攻击玩家 // 全零表示直接攻击玩家
return new MsgAttack({ return new MsgAttack({
......
...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => { ...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => {
zone: CardZone.MZONE, zone: CardZone.MZONE,
sequence: i, sequence: i,
disabled, disabled,
}) }),
); );
} }
...@@ -37,7 +37,7 @@ export default (data: Uint8Array) => { ...@@ -37,7 +37,7 @@ export default (data: Uint8Array) => {
zone: CardZone.SZONE, zone: CardZone.SZONE,
sequence: i, sequence: i,
disabled, disabled,
}) }),
); );
} }
...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => { ...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => {
zone: CardZone.MZONE, zone: CardZone.MZONE,
sequence: i, sequence: i,
disabled, disabled,
}) }),
); );
} }
...@@ -63,7 +63,7 @@ export default (data: Uint8Array) => { ...@@ -63,7 +63,7 @@ export default (data: Uint8Array) => {
zone: CardZone.SZONE, zone: CardZone.SZONE,
sequence: i, sequence: i,
disabled, disabled,
}) }),
); );
} }
......
...@@ -230,7 +230,7 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -230,7 +230,7 @@ export default class GameMsgAdapter implements StocAdapter {
case GAME_MSG.MSG_TOSS_COIN: { case GAME_MSG.MSG_TOSS_COIN: {
gameMsg.toss = MsgTossAdapter( gameMsg.toss = MsgTossAdapter(
gameData, gameData,
ygopro.StocGameMessage.MsgToss.TossType.COIN ygopro.StocGameMessage.MsgToss.TossType.COIN,
); );
break; break;
...@@ -238,7 +238,7 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -238,7 +238,7 @@ export default class GameMsgAdapter implements StocAdapter {
case GAME_MSG.MSG_TOSS_DICE: { case GAME_MSG.MSG_TOSS_DICE: {
gameMsg.toss = MsgTossAdapter( gameMsg.toss = MsgTossAdapter(
gameData, gameData,
ygopro.StocGameMessage.MsgToss.TossType.DICE ygopro.StocGameMessage.MsgToss.TossType.DICE,
); );
break; break;
...@@ -261,7 +261,7 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -261,7 +261,7 @@ export default class GameMsgAdapter implements StocAdapter {
case GAME_MSG.MSG_SHUFFLE_HAND: { case GAME_MSG.MSG_SHUFFLE_HAND: {
gameMsg.shuffle_hand_extra = MsgShuffleHandExtraAdapter( gameMsg.shuffle_hand_extra = MsgShuffleHandExtraAdapter(
gameData, gameData,
false false,
); );
break; break;
...@@ -269,7 +269,7 @@ export default class GameMsgAdapter implements StocAdapter { ...@@ -269,7 +269,7 @@ export default class GameMsgAdapter implements StocAdapter {
case GAME_MSG.MSG_SHUFFLE_EXTRA: { case GAME_MSG.MSG_SHUFFLE_EXTRA: {
gameMsg.shuffle_hand_extra = MsgShuffleHandExtraAdapter( gameMsg.shuffle_hand_extra = MsgShuffleHandExtraAdapter(
gameData, gameData,
true true,
); );
break; break;
......
...@@ -72,7 +72,7 @@ class PenetrateManager { ...@@ -72,7 +72,7 @@ class PenetrateManager {
private readRepeatedField( private readRepeatedField(
reader: BufferReaderExt, reader: BufferReaderExt,
repeatedType: string repeatedType: string,
): any { ): any {
const handler = this.readFieldHandlerMap.get(repeatedType); const handler = this.readFieldHandlerMap.get(repeatedType);
......
...@@ -26,7 +26,7 @@ export default (data: Uint8Array) => { ...@@ -26,7 +26,7 @@ export default (data: Uint8Array) => {
sequence, sequence,
position: numberToCardPosition(position), position: numberToCardPosition(position),
overlay_count, overlay_count,
}) }),
); );
} else { } else {
zone_actions.push( zone_actions.push(
...@@ -34,7 +34,7 @@ export default (data: Uint8Array) => { ...@@ -34,7 +34,7 @@ export default (data: Uint8Array) => {
zone: ygopro.CardZone.MZONE, zone: ygopro.CardZone.MZONE,
sequence, sequence,
position: ygopro.CardPosition.FACEDOWN, position: ygopro.CardPosition.FACEDOWN,
}) }),
); );
} }
} }
...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => { ...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => {
zone: ygopro.CardZone.SZONE, zone: ygopro.CardZone.SZONE,
sequence, sequence,
position: numberToCardPosition(position), position: numberToCardPosition(position),
}) }),
); );
} else { } else {
zone_actions.push( zone_actions.push(
...@@ -58,7 +58,7 @@ export default (data: Uint8Array) => { ...@@ -58,7 +58,7 @@ export default (data: Uint8Array) => {
zone: ygopro.CardZone.SZONE, zone: ygopro.CardZone.SZONE,
sequence, sequence,
position: ygopro.CardPosition.FACEDOWN, position: ygopro.CardPosition.FACEDOWN,
}) }),
); );
} }
} }
...@@ -70,7 +70,7 @@ export default (data: Uint8Array) => { ...@@ -70,7 +70,7 @@ export default (data: Uint8Array) => {
zone: ygopro.CardZone.DECK, zone: ygopro.CardZone.DECK,
sequence, sequence,
position: ygopro.CardPosition.FACEDOWN_ATTACK, position: ygopro.CardPosition.FACEDOWN_ATTACK,
}) }),
); );
} }
...@@ -80,7 +80,7 @@ export default (data: Uint8Array) => { ...@@ -80,7 +80,7 @@ export default (data: Uint8Array) => {
new MsgReloadField.ZoneAction({ new MsgReloadField.ZoneAction({
zone: ygopro.CardZone.HAND, zone: ygopro.CardZone.HAND,
sequence, sequence,
}) }),
); );
} }
...@@ -90,7 +90,7 @@ export default (data: Uint8Array) => { ...@@ -90,7 +90,7 @@ export default (data: Uint8Array) => {
new MsgReloadField.ZoneAction({ new MsgReloadField.ZoneAction({
zone: ygopro.CardZone.GRAVE, zone: ygopro.CardZone.GRAVE,
sequence, sequence,
}) }),
); );
} }
...@@ -100,7 +100,7 @@ export default (data: Uint8Array) => { ...@@ -100,7 +100,7 @@ export default (data: Uint8Array) => {
new MsgReloadField.ZoneAction({ new MsgReloadField.ZoneAction({
zone: ygopro.CardZone.REMOVED, zone: ygopro.CardZone.REMOVED,
sequence, sequence,
}) }),
); );
} }
...@@ -111,7 +111,7 @@ export default (data: Uint8Array) => { ...@@ -111,7 +111,7 @@ export default (data: Uint8Array) => {
zone: ygopro.CardZone.EXTRA, zone: ygopro.CardZone.EXTRA,
sequence, sequence,
position: ygopro.CardPosition.FACEDOWN_ATTACK, position: ygopro.CardPosition.FACEDOWN_ATTACK,
}) }),
); );
} }
...@@ -145,7 +145,7 @@ export default (data: Uint8Array) => { ...@@ -145,7 +145,7 @@ export default (data: Uint8Array) => {
lp, lp,
zone_actions, zone_actions,
// chain_actions, // chain_actions,
}) }),
); );
} }
......
...@@ -44,7 +44,7 @@ export default (data: Uint8Array) => { ...@@ -44,7 +44,7 @@ export default (data: Uint8Array) => {
const directAttackAble = reader.inner.readUint8(); const directAttackAble = reader.inner.readUint8();
const attackData = new MsgSelectBattleCmd.BattleCmd.BattleData({ const attackData = new MsgSelectBattleCmd.BattleCmd.BattleData({
card_info: cardInfo, card_info: cardInfo,
direct_attackable: directAttackAble == 1, direct_attackable: directAttackAble === 1,
response: (i << 16) + 1, response: (i << 16) + 1,
}); });
attackCmd.battle_datas.push(attackData); attackCmd.battle_datas.push(attackData);
...@@ -53,9 +53,9 @@ export default (data: Uint8Array) => { ...@@ -53,9 +53,9 @@ export default (data: Uint8Array) => {
msg.battle_cmds = [activateCmd, attackCmd]; msg.battle_cmds = [activateCmd, attackCmd];
// 是否可进入M2阶段 // 是否可进入M2阶段
msg.enable_m2 = reader.inner.readUint8() == 1; msg.enable_m2 = reader.inner.readUint8() === 1;
//时是否可结束回合 //时是否可结束回合
msg.enable_ep = reader.inner.readUint8() == 1; msg.enable_ep = reader.inner.readUint8() === 1;
return msg; return msg;
}; };
...@@ -13,7 +13,7 @@ export default (data: Uint8Array) => { ...@@ -13,7 +13,7 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data); const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8(); const player = reader.inner.readUint8();
const cancelable = reader.inner.readUint8() != 0; const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8(); const min = reader.inner.readUint8();
const max = reader.inner.readUint8(); const max = reader.inner.readUint8();
const count = reader.inner.readUint8(); const count = reader.inner.readUint8();
...@@ -25,7 +25,7 @@ export default (data: Uint8Array) => { ...@@ -25,7 +25,7 @@ export default (data: Uint8Array) => {
const location = reader.readCardLocation(); const location = reader.readCardLocation();
msg.cards.push( msg.cards.push(
new MsgSelectCard.SelectAbleCard({ code, location, response: i }) new MsgSelectCard.SelectAbleCard({ code, location, response: i }),
); );
} }
......
...@@ -17,7 +17,7 @@ export default (data: Uint8Array) => { ...@@ -17,7 +17,7 @@ export default (data: Uint8Array) => {
const player = reader.inner.readUint8(); const player = reader.inner.readUint8();
const count = reader.inner.readUint8(); const count = reader.inner.readUint8();
const spCount = reader.inner.readUint8(); const spCount = reader.inner.readUint8();
const forced = reader.inner.readUint8() != 0; const forced = reader.inner.readUint8() !== 0;
const hint0 = reader.inner.readUint32(); const hint0 = reader.inner.readUint32();
const hint1 = reader.inner.readUint32(); const hint1 = reader.inner.readUint32();
...@@ -43,7 +43,7 @@ export default (data: Uint8Array) => { ...@@ -43,7 +43,7 @@ export default (data: Uint8Array) => {
location, location,
effect_description: effect_desc, effect_description: effect_desc,
response: i, response: i,
}) }),
); );
} }
......
...@@ -33,7 +33,7 @@ export default (data: Uint8Array) => { ...@@ -33,7 +33,7 @@ export default (data: Uint8Array) => {
code, code,
location, location,
counter_count: counterCount, counter_count: counterCount,
}) }),
); );
} }
......
...@@ -19,7 +19,7 @@ export default (data: Uint8Array) => { ...@@ -19,7 +19,7 @@ export default (data: Uint8Array) => {
const _field = ~reader.readUint32(); const _field = ~reader.readUint32();
// TODO: 暂时和`ygopro2`一样不支持取消操作,后续需要再考虑加上 // TODO: 暂时和`ygopro2`一样不支持取消操作,后续需要再考虑加上
if (count == 0) { if (count === 0) {
count = 1; count = 1;
} }
...@@ -30,67 +30,67 @@ export default (data: Uint8Array) => { ...@@ -30,67 +30,67 @@ export default (data: Uint8Array) => {
}); });
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
const controller = i == 0 ? player : 1 - player; const controller = i === 0 ? player : 1 - player;
const field = i == 0 ? _field & 0xffff : _field >> 16; const field = i === 0 ? _field & 0xffff : _field >> 16;
if ((field & 0x7f) != 0) { if ((field & 0x7f) !== 0) {
// 怪兽区 // 怪兽区
const zone = ygopro.CardZone.MZONE; const zone = ygopro.CardZone.MZONE;
const filter = field & 0x7f; const filter = field & 0x7f;
for (let sequence = 0; sequence < 7; sequence++) { for (let sequence = 0; sequence < 7; sequence++) {
if ((filter & (1 << sequence)) != 0) { if ((filter & (1 << sequence)) !== 0) {
msg.places.push( msg.places.push(
new MsgSelectPlace.SelectAblePlace({ new MsgSelectPlace.SelectAblePlace({
controller, controller,
zone, zone,
sequence: sequence, sequence: sequence,
}) }),
); );
} }
} }
} }
if ((field & 0x1f00) != 0) { if ((field & 0x1f00) !== 0) {
// 魔法陷阱区 // 魔法陷阱区
const zone = ygopro.CardZone.SZONE; const zone = ygopro.CardZone.SZONE;
const filter = (field >> 8) & 0x1f; const filter = (field >> 8) & 0x1f;
for (let sequence = 0; sequence < 5; sequence++) { for (let sequence = 0; sequence < 5; sequence++) {
if ((filter & (1 << sequence)) != 0) { if ((filter & (1 << sequence)) !== 0) {
msg.places.push( msg.places.push(
new MsgSelectPlace.SelectAblePlace({ new MsgSelectPlace.SelectAblePlace({
controller, controller,
zone, zone,
sequence, sequence,
}) }),
); );
} }
} }
} }
if ((field & 0xc000) != 0) { if ((field & 0xc000) !== 0) {
// 灵摆区? // 灵摆区?
const zone = ygopro.CardZone.SZONE; const zone = ygopro.CardZone.SZONE;
const filter = (field >> 14) & 0x3; const filter = (field >> 14) & 0x3;
if ((filter & 0x1) != 0) { if ((filter & 0x1) !== 0) {
msg.places.push( msg.places.push(
new MsgSelectPlace.SelectAblePlace({ new MsgSelectPlace.SelectAblePlace({
controller, controller,
zone, zone,
sequence: 6, sequence: 6,
}) }),
); );
} }
if ((filter & 0x2) != 0) { if ((filter & 0x2) !== 0) {
msg.places.push( msg.places.push(
new MsgSelectPlace.SelectAblePlace({ new MsgSelectPlace.SelectAblePlace({
controller, controller,
zone, zone,
sequence: 7, sequence: 7,
}) }),
); );
} }
} }
......
...@@ -28,28 +28,28 @@ export default (data: Uint8Array) => { ...@@ -28,28 +28,28 @@ export default (data: Uint8Array) => {
msg.positions.push( msg.positions.push(
new MsgSelectPosition.SelectAblePosition({ new MsgSelectPosition.SelectAblePosition({
position: ygopro.CardPosition.FACEUP_ATTACK, position: ygopro.CardPosition.FACEUP_ATTACK,
}) }),
); );
} }
if ((positions & 0x2) > 0) { if ((positions & 0x2) > 0) {
msg.positions.push( msg.positions.push(
new MsgSelectPosition.SelectAblePosition({ new MsgSelectPosition.SelectAblePosition({
position: ygopro.CardPosition.FACEDOWN_ATTACK, position: ygopro.CardPosition.FACEDOWN_ATTACK,
}) }),
); );
} }
if ((positions & 0x4) > 0) { if ((positions & 0x4) > 0) {
msg.positions.push( msg.positions.push(
new MsgSelectPosition.SelectAblePosition({ new MsgSelectPosition.SelectAblePosition({
position: ygopro.CardPosition.FACEUP_DEFENSE, position: ygopro.CardPosition.FACEUP_DEFENSE,
}) }),
); );
} }
if ((positions & 0x8) > 0) { if ((positions & 0x8) > 0) {
msg.positions.push( msg.positions.push(
new MsgSelectPosition.SelectAblePosition({ new MsgSelectPosition.SelectAblePosition({
position: ygopro.CardPosition.FACEDOWN_DEFENSE, position: ygopro.CardPosition.FACEDOWN_DEFENSE,
}) }),
); );
} }
......
...@@ -41,7 +41,7 @@ export default (data: Uint8Array) => { ...@@ -41,7 +41,7 @@ export default (data: Uint8Array) => {
level1: para & 0xffff, level1: para & 0xffff,
level2: para >> 16, level2: para >> 16,
response: i, response: i,
}) }),
); );
} }
...@@ -60,7 +60,7 @@ export default (data: Uint8Array) => { ...@@ -60,7 +60,7 @@ export default (data: Uint8Array) => {
level1, level1,
level2, level2,
response: i, response: i,
}) }),
); );
} }
......
...@@ -13,7 +13,7 @@ export default (data: Uint8Array) => { ...@@ -13,7 +13,7 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data); const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8(); const player = reader.inner.readUint8();
const cancelable = reader.inner.readUint8() != 0; const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8(); const min = reader.inner.readUint8();
const max = reader.inner.readUint8(); const max = reader.inner.readUint8();
const count = reader.inner.readUint8(); const count = reader.inner.readUint8();
...@@ -37,7 +37,7 @@ export default (data: Uint8Array) => { ...@@ -37,7 +37,7 @@ export default (data: Uint8Array) => {
location, location,
level, level,
response: i, response: i,
}) }),
); );
} }
......
...@@ -13,8 +13,8 @@ export default (data: Uint8Array) => { ...@@ -13,8 +13,8 @@ export default (data: Uint8Array) => {
const reader = new BufferReaderExt(data); const reader = new BufferReaderExt(data);
const player = reader.inner.readUint8(); const player = reader.inner.readUint8();
const finishable = reader.inner.readUint8() != 0; const finishable = reader.inner.readUint8() !== 0;
const cancelable = reader.inner.readUint8() != 0; const cancelable = reader.inner.readUint8() !== 0;
const min = reader.inner.readUint8(); const min = reader.inner.readUint8();
const max = reader.inner.readUint8(); const max = reader.inner.readUint8();
...@@ -32,7 +32,7 @@ export default (data: Uint8Array) => { ...@@ -32,7 +32,7 @@ export default (data: Uint8Array) => {
const location = reader.readCardLocation(); const location = reader.readCardLocation();
msg.selectable_cards.push( msg.selectable_cards.push(
new MsgSelectUnselectCard.Info({ code, location, response: i }) new MsgSelectUnselectCard.Info({ code, location, response: i }),
); );
} }
...@@ -42,7 +42,7 @@ export default (data: Uint8Array) => { ...@@ -42,7 +42,7 @@ export default (data: Uint8Array) => {
const location = reader.readCardLocation(); const location = reader.readCardLocation();
msg.selected_cards.push( msg.selected_cards.push(
new MsgSelectUnselectCard.Info({ code, location, response: i }) new MsgSelectUnselectCard.Info({ code, location, response: i }),
); );
} }
......
...@@ -16,7 +16,7 @@ export default (data: Uint8Array) => { ...@@ -16,7 +16,7 @@ export default (data: Uint8Array) => {
const name_0 = cutString(decoder.decode(data.slice(offset, offset + LEN))); const name_0 = cutString(decoder.decode(data.slice(offset, offset + LEN)));
offset += LEN; offset += LEN;
const name_0_tag = cutString( const name_0_tag = cutString(
decoder.decode(data.slice(offset, offset + LEN)) decoder.decode(data.slice(offset, offset + LEN)),
); );
offset += LEN; offset += LEN;
const name_0_c = cutString(decoder.decode(data.slice(offset, offset + LEN))); const name_0_c = cutString(decoder.decode(data.slice(offset, offset + LEN)));
...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => { ...@@ -24,7 +24,7 @@ export default (data: Uint8Array) => {
const name_1 = cutString(decoder.decode(data.slice(offset, offset + LEN))); const name_1 = cutString(decoder.decode(data.slice(offset, offset + LEN)));
offset += LEN; offset += LEN;
const name_1_tag = cutString( const name_1_tag = cutString(
decoder.decode(data.slice(offset, offset + LEN)) decoder.decode(data.slice(offset, offset + LEN)),
); );
offset += LEN; offset += LEN;
const name_1_c = cutString(decoder.decode(data.slice(offset, offset + LEN))); const name_1_c = cutString(decoder.decode(data.slice(offset, offset + LEN)));
......
...@@ -29,7 +29,7 @@ export default (data: Uint8Array) => { ...@@ -29,7 +29,7 @@ export default (data: Uint8Array) => {
code, code,
location, location,
response: i, response: i,
}) }),
); );
} }
......
...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => { ...@@ -50,7 +50,7 @@ export default (data: Uint8Array) => {
try { try {
while (true) { while (true) {
const len = reader.inner.readInt32(); const len = reader.inner.readInt32();
if (len == 4) continue; if (len === 4) continue;
const pos = reader.inner.offset(); const pos = reader.inner.offset();
const action = _readUpdateAction(reader); const action = _readUpdateAction(reader);
if (action) { if (action) {
...@@ -66,10 +66,10 @@ export default (data: Uint8Array) => { ...@@ -66,10 +66,10 @@ export default (data: Uint8Array) => {
}; };
function _readUpdateAction( function _readUpdateAction(
reader: BufferReaderExt reader: BufferReaderExt,
): MsgUpdateData.Action | undefined { ): MsgUpdateData.Action | undefined {
const flag = reader.inner.readInt32(); const flag = reader.inner.readInt32();
if (flag == 0) return undefined; if (flag === 0) return undefined;
const mask = -1; const mask = -1;
let code = mask; let code = mask;
......
...@@ -24,7 +24,7 @@ export default class HsPlayerEnterAdapter implements StocAdapter { ...@@ -24,7 +24,7 @@ export default class HsPlayerEnterAdapter implements StocAdapter {
const decoder = new TextDecoder("utf-16"); const decoder = new TextDecoder("utf-16");
const name = decoder.decode( const name = decoder.decode(
_cutoff_name(exData.slice(0, UTF16_BUFFER_MAX_LEN * UINT8_PER_UINT16)) _cutoff_name(exData.slice(0, UTF16_BUFFER_MAX_LEN * UINT8_PER_UINT16)),
); );
const dataView = new DataView(exData.buffer); const dataView = new DataView(exData.buffer);
......
...@@ -17,7 +17,7 @@ export default class TypeChangeAdapter implements StocAdapter { ...@@ -17,7 +17,7 @@ export default class TypeChangeAdapter implements StocAdapter {
upcast(): ygopro.YgoStocMsg { upcast(): ygopro.YgoStocMsg {
const type_ = new DataView(this.packet.exData.buffer).getUint8(0); const type_ = new DataView(this.packet.exData.buffer).getUint8(0);
const isHost = ((type_ >> 4) & 0xf) != 0; const isHost = ((type_ >> 4) & 0xf) !== 0;
let selfType = ygopro.StocTypeChange.SelfType.UNKNOWN; let selfType = ygopro.StocTypeChange.SelfType.UNKNOWN;
switch (type_ & 0xf) { switch (type_ & 0xf) {
......
...@@ -67,7 +67,7 @@ export function utf8ArrayToStr(array: Uint8Array) { ...@@ -67,7 +67,7 @@ export function utf8ArrayToStr(array: Uint8Array) {
char2 = array[i++]; char2 = array[i++];
char3 = array[i++]; char3 = array[i++];
out += String.fromCharCode( out += String.fromCharCode(
((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0) ((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0),
); );
break; break;
} }
...@@ -115,7 +115,7 @@ export function cardZoneToNumber(zone: ygopro.CardZone): number { ...@@ -115,7 +115,7 @@ export function cardZoneToNumber(zone: ygopro.CardZone): number {
} }
export function numberToCardZone( export function numberToCardZone(
location: number location: number,
): ygopro.CardZone | undefined { ): ygopro.CardZone | undefined {
switch (location) { switch (location) {
case 0x01: { case 0x01: {
...@@ -156,7 +156,7 @@ export function numberToCardZone( ...@@ -156,7 +156,7 @@ export function numberToCardZone(
// TODO: 需要考虑超量叠加情况下的位运算 // TODO: 需要考虑超量叠加情况下的位运算
export function numberToCardPosition( export function numberToCardPosition(
position: number position: number,
): ygopro.CardPosition | undefined { ): ygopro.CardPosition | undefined {
switch (position) { switch (position) {
case 0x1: { case 0x1: {
...@@ -190,7 +190,7 @@ export function numberToCardPosition( ...@@ -190,7 +190,7 @@ export function numberToCardPosition(
} }
export function numberToChainFlag( export function numberToChainFlag(
flag: number flag: number,
): ygopro.StocGameMessage.MsgSelectChain.ChainFlag | undefined { ): ygopro.StocGameMessage.MsgSelectChain.ChainFlag | undefined {
switch (flag) { switch (flag) {
case 0: { case 0: {
...@@ -218,7 +218,7 @@ const chunkItems = <T>(items: T[]) => ...@@ -218,7 +218,7 @@ const chunkItems = <T>(items: T[]) =>
export function _cutoff_name(data: Uint8Array): Uint8Array { export function _cutoff_name(data: Uint8Array): Uint8Array {
let res: number[] = []; let res: number[] = [];
for (const char of chunkItems(Array.from(data))) { for (const char of chunkItems(Array.from(data))) {
if (!char.every((item) => item == 0)) { if (!char.every((item) => item === 0)) {
res = res.concat(char); res = res.concat(char);
} else { } else {
break; break;
......
...@@ -273,7 +273,7 @@ export function sendSelectBattleCmdResponse(value: number) { ...@@ -273,7 +273,7 @@ export function sendSelectBattleCmdResponse(value: number) {
select_battle_cmd: new ygopro.CtosGameMsgResponse.SelectBattleCmdResponse( select_battle_cmd: new ygopro.CtosGameMsgResponse.SelectBattleCmdResponse(
{ {
selected_cmd: value, selected_cmd: value,
} },
), ),
}), }),
}); });
......
...@@ -7,4 +7,4 @@ export const useConfig = () => ...@@ -7,4 +7,4 @@ export const useConfig = () =>
automation: automationConfig, automation: automationConfig,
defaults: defaultsConfig, defaults: defaultsConfig,
...envConfig, ...envConfig,
} satisfies Record<string, unknown>); }) satisfies Record<string, unknown>;
...@@ -21,7 +21,7 @@ declare global { ...@@ -21,7 +21,7 @@ declare global {
interface Console { interface Console {
color: ( color: (
color: string, color: string,
backgroundColor?: string backgroundColor?: string,
) => (...args: Parameters<console.log>) => void; ) => (...args: Parameters<console.log>) => void;
} }
} }
......
...@@ -3,7 +3,7 @@ console.color = ...@@ -3,7 +3,7 @@ console.color =
(...args: any[]) => { (...args: any[]) => {
console.log( console.log(
`%c${args.join(" ")}`, `%c${args.join(" ")}`,
`color: ${color}; backgroundColor: ${backgroundColor ?? "none"}` `color: ${color}; backgroundColor: ${backgroundColor ?? "none"}`,
); );
}; };
......
...@@ -16,14 +16,14 @@ const getEnd = (task: Task) => `${task}-end`; ...@@ -16,14 +16,14 @@ const getEnd = (task: Task) => `${task}-end`;
/** 在组件之中注册方法,注意注册的方法一旦执行成功,必须返回一个true */ /** 在组件之中注册方法,注意注册的方法一旦执行成功,必须返回一个true */
const register = <T extends unknown[]>( const register = <T extends unknown[]>(
task: Task, task: Task,
fn: (...args: T) => Promise<boolean> fn: (...args: T) => Promise<boolean>,
) => { ) => {
eventEmitter.on( eventEmitter.on(
task, task,
async ({ taskId, args }: { taskId: string; args: T }) => { async ({ taskId, args }: { taskId: string; args: T }) => {
const result = await fn(...args); const result = await fn(...args);
if (result) eventEmitter.emit(getEnd(task), taskId); if (result) eventEmitter.emit(getEnd(task), taskId);
} },
); );
}; };
......
...@@ -4,7 +4,7 @@ export async function pfetch( ...@@ -4,7 +4,7 @@ export async function pfetch(
options?: { options?: {
init?: RequestInit; init?: RequestInit;
progressCallback?: (progress: number) => void; progressCallback?: (progress: number) => void;
} },
): Promise<Response> { ): Promise<Response> {
const response = await fetch(input, options?.init); const response = await fetch(input, options?.init);
const clonedResponse = response.clone(); // Clone the response to create a new body stream const clonedResponse = response.clone(); // Clone the response to create a new body stream
...@@ -12,7 +12,7 @@ export async function pfetch( ...@@ -12,7 +12,7 @@ export async function pfetch(
if (typeof options?.progressCallback === "function") { if (typeof options?.progressCallback === "function") {
const contentLength = parseInt( const contentLength = parseInt(
response.headers.get("content-length") || "0", response.headers.get("content-length") || "0",
10 10,
); );
let bytesRead = 0; let bytesRead = 0;
......
...@@ -30,7 +30,7 @@ import { theme } from "@/ui/theme"; ...@@ -30,7 +30,7 @@ import { theme } from "@/ui/theme";
import { NeosRouter } from "./ui/NeosRouter"; import { NeosRouter } from "./ui/NeosRouter";
const root = ReactDOM.createRoot( const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement document.getElementById("root") as HTMLElement,
); );
root.render( root.render(
...@@ -40,5 +40,5 @@ root.render( ...@@ -40,5 +40,5 @@ root.render(
<NeosRouter /> <NeosRouter />
</ProConfigProvider> </ProConfigProvider>
</App> </App>
</ConfigProvider> </ConfigProvider>,
); );
...@@ -44,7 +44,7 @@ export default async function (action: socketAction) { ...@@ -44,7 +44,7 @@ export default async function (action: socketAction) {
const { initInfo: info, isReplay, replayInfo } = action; const { initInfo: info, isReplay, replayInfo } = action;
if (info) { if (info) {
ws = new WebSocketStream(info.ip, (conn, _event) => ws = new WebSocketStream(info.ip, (conn, _event) =>
handleSocketOpen(conn, info.ip, info.player, info.passWd) handleSocketOpen(conn, info.ip, info.player, info.passWd),
); );
await ws.execute(handleSocketMessage); await ws.execute(handleSocketMessage);
......
...@@ -59,13 +59,13 @@ function getFtsCondtions(conditions: FtsConditions): string { ...@@ -59,13 +59,13 @@ function getFtsCondtions(conditions: FtsConditions): string {
const atkCondition = atk const atkCondition = atk
? `atk BETWEEN ${handleFinite(atk.min, "min")} AND ${handleFinite( ? `atk BETWEEN ${handleFinite(atk.min, "min")} AND ${handleFinite(
atk.max, atk.max,
"max" "max",
)} AND ${assertMonster}` )} AND ${assertMonster}`
: undefined; : undefined;
const defCondition = def const defCondition = def
? `def BETWEEN ${handleFinite(def.min, "min")} AND ${handleFinite( ? `def BETWEEN ${handleFinite(def.min, "min")} AND ${handleFinite(
def.max, def.max,
"max" "max",
)} AND ${assertMonster}` )} AND ${assertMonster}`
: undefined; : undefined;
const raceCondition = races?.map((race) => `race = ${race}`).join(" OR "); const raceCondition = races?.map((race) => `race = ${race}`).join(" OR ");
......
...@@ -110,7 +110,7 @@ export default async function (action: sqliteAction): Promise<sqliteResult> { ...@@ -110,7 +110,7 @@ export default async function (action: sqliteAction): Promise<sqliteResult> {
export function constructCardMeta( export function constructCardMeta(
id: number, id: number,
data: CardData, data: CardData,
text: CardText text: CardText,
): CardMeta { ): CardMeta {
const level = data.level ?? 0; const level = data.level ?? 0;
data.level = level & 0xff; data.level = level & 0xff;
......
...@@ -11,7 +11,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => { ...@@ -11,7 +11,7 @@ export default async (attack: ygopro.StocGameMessage.MsgAttack) => {
const attacker = cardStore.at( const attacker = cardStore.at(
attack.attacker_location.zone, attack.attacker_location.zone,
attack.attacker_location.controller, attack.attacker_location.controller,
attack.attacker_location.sequence attack.attacker_location.sequence,
); );
if (attacker) { if (attacker) {
......
...@@ -6,7 +6,7 @@ export default (becomeTarget: ygopro.StocGameMessage.MsgBecomeTarget) => { ...@@ -6,7 +6,7 @@ export default (becomeTarget: ygopro.StocGameMessage.MsgBecomeTarget) => {
const target = cardStore.at( const target = cardStore.at(
location.zone, location.zone,
location.controller, location.controller,
location.sequence location.sequence,
); );
if (target) { if (target) {
console.info(`${target.meta.text.name} become target`); console.info(`${target.meta.text.name} become target`);
......
...@@ -23,7 +23,7 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => { ...@@ -23,7 +23,7 @@ export default async (chainSolved: ygopro.StocGameMessage.MsgChainSolved) => {
} }
} else { } else {
console.warn( console.warn(
`pop from chains return null! solved_index=${chainSolved.solved_index}, len of chains in store=${matStore.chains.length}` `pop from chains return null! solved_index=${chainSolved.solved_index}, len of chains in store=${matStore.chains.length}`,
); );
} }
}; };
...@@ -28,6 +28,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => { ...@@ -28,6 +28,6 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
await Promise.all( await Promise.all(
cardStore cardStore
.at(ygopro.CardZone.HAND, draw.player) .at(ygopro.CardZone.HAND, draw.player)
.map((card) => callCardMove(card.uuid)) .map((card) => callCardMove(card.uuid)),
); );
}; };
...@@ -53,7 +53,7 @@ export default async (move: MsgMove) => { ...@@ -53,7 +53,7 @@ export default async (move: MsgMove) => {
from.is_overlay ? ":" + from.overlay_sequence : "" from.is_overlay ? ":" + from.overlay_sequence : ""
}${ygopro.CardZone[to.zone]}:${to.sequence}${ }${ygopro.CardZone[to.zone]}:${to.sequence}${
to.is_overlay ? ":" + to.overlay_sequence : "" to.is_overlay ? ":" + to.overlay_sequence : ""
}` }`,
); );
let target: CardType; let target: CardType;
...@@ -64,14 +64,14 @@ export default async (move: MsgMove) => { ...@@ -64,14 +64,14 @@ export default async (move: MsgMove) => {
from.zone, from.zone,
from.controller, from.controller,
from.sequence, from.sequence,
from.overlay_sequence from.overlay_sequence,
); );
if (overlayMaterial) { if (overlayMaterial) {
target = overlayMaterial; target = overlayMaterial;
} else { } else {
console.warn( console.warn(
`<Move>overlayMaterial from zone=${from.zone}, controller=${from.controller}, `<Move>overlayMaterial from zone=${from.zone}, controller=${from.controller},
sequence=${from.sequence}, overlay_sequence=${from.overlay_sequence} is null` sequence=${from.sequence}, overlay_sequence=${from.overlay_sequence} is null`,
); );
return; return;
} }
...@@ -81,7 +81,7 @@ export default async (move: MsgMove) => { ...@@ -81,7 +81,7 @@ export default async (move: MsgMove) => {
target = card; target = card;
} else { } else {
console.warn( console.warn(
`<Move>card from zone=${from.zone}, controller=${from.controller} sequence=${from.sequence} is null` `<Move>card from zone=${from.zone}, controller=${from.controller} sequence=${from.sequence} is null`,
); );
console.info(cardStore.at(from.zone, from.controller)); console.info(cardStore.at(from.zone, from.controller));
return; return;
...@@ -106,7 +106,7 @@ export default async (move: MsgMove) => { ...@@ -106,7 +106,7 @@ export default async (move: MsgMove) => {
location.zone, location.zone,
location.controller, location.controller,
location.sequence, location.sequence,
location.overlay_sequence location.overlay_sequence,
); );
if (overlayMaterial) { if (overlayMaterial) {
// 超量素材的位置应该和超量怪兽保持一致 // 超量素材的位置应该和超量怪兽保持一致
...@@ -117,7 +117,7 @@ export default async (move: MsgMove) => { ...@@ -117,7 +117,7 @@ export default async (move: MsgMove) => {
await callCardMove(overlayMaterial.uuid); await callCardMove(overlayMaterial.uuid);
} else { } else {
console.warn( console.warn(
`<Move>overlayMaterial from zone=${location.zone}, controller=${location.controller}, sequence=${location.sequence}, overlay_sequence=${location.overlay_sequence} is null` `<Move>overlayMaterial from zone=${location.zone}, controller=${location.controller}, sequence=${location.sequence}, overlay_sequence=${location.overlay_sequence} is null`,
); );
} }
} }
...@@ -132,11 +132,11 @@ export default async (move: MsgMove) => { ...@@ -132,11 +132,11 @@ export default async (move: MsgMove) => {
!from.is_overlay !from.is_overlay
) )
fromCards.forEach( fromCards.forEach(
(c) => c.location.sequence > from.sequence && c.location.sequence-- (c) => c.location.sequence > from.sequence && c.location.sequence--,
); );
if ([HAND, GRAVE, REMOVED, DECK, EXTRA, TZONE].includes(to.zone)) if ([HAND, GRAVE, REMOVED, DECK, EXTRA, TZONE].includes(to.zone))
toCards.forEach( toCards.forEach(
(c) => c.location.sequence >= to.sequence && c.location.sequence++ (c) => c.location.sequence >= to.sequence && c.location.sequence++,
); );
if (from.is_overlay) { if (from.is_overlay) {
// 超量素材的序号也需要维护 // 超量素材的序号也需要维护
...@@ -144,7 +144,7 @@ export default async (move: MsgMove) => { ...@@ -144,7 +144,7 @@ export default async (move: MsgMove) => {
for (const overlay of cardStore.findOverlay( for (const overlay of cardStore.findOverlay(
from.zone, from.zone,
from.controller, from.controller,
from.sequence from.sequence,
)) { )) {
if (overlay.location.overlay_sequence > overlay_sequence) { if (overlay.location.overlay_sequence > overlay_sequence) {
overlay.location.overlay_sequence--; overlay.location.overlay_sequence--;
...@@ -174,7 +174,7 @@ export default async (move: MsgMove) => { ...@@ -174,7 +174,7 @@ export default async (move: MsgMove) => {
for (const overlay of cardStore.findOverlay( for (const overlay of cardStore.findOverlay(
from.zone, from.zone,
from.controller, from.controller,
from.sequence from.sequence,
)) { )) {
overlay.location.zone = to.zone; overlay.location.zone = to.zone;
overlay.location.controller = to.controller; overlay.location.controller = to.controller;
......
...@@ -41,7 +41,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd) => { ...@@ -41,7 +41,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd) => {
}); });
} else { } else {
console.warn( console.warn(
`<selectBattleCmd>target from zone=${location}, player=${player}, sequence=${sequence} is null` `<selectBattleCmd>target from zone=${location}, player=${player}, sequence=${sequence} is null`,
); );
} }
} else { } else {
...@@ -54,7 +54,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd) => { ...@@ -54,7 +54,7 @@ export default (selectBattleCmd: MsgSelectBattleCmd) => {
}; };
function battleTypeToInteracType( function battleTypeToInteracType(
battleType: MsgSelectBattleCmd.BattleCmd.BattleType battleType: MsgSelectBattleCmd.BattleCmd.BattleType,
): InteractType | undefined { ): InteractType | undefined {
switch (battleType) { switch (battleType) {
case MsgSelectBattleCmd.BattleCmd.BattleType.ATTACK: { case MsgSelectBattleCmd.BattleCmd.BattleType.ATTACK: {
......
...@@ -11,7 +11,7 @@ export default async (selectCard: MsgSelectCard) => { ...@@ -11,7 +11,7 @@ export default async (selectCard: MsgSelectCard) => {
// TODO: handle release_param // TODO: handle release_param
const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta( const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta(
cards cards,
); );
await displaySelectActionsModal({ await displaySelectActionsModal({
cancelable, cancelable,
......
...@@ -13,7 +13,7 @@ export default async (selectChain: MsgSelectChain) => { ...@@ -13,7 +13,7 @@ export default async (selectChain: MsgSelectChain) => {
const chains = selectChain.chains; const chains = selectChain.chains;
const chainSetting = matStore.chainSetting; const chainSetting = matStore.chainSetting;
if (chainSetting == ChainSetting.CHAIN_IGNORE) { if (chainSetting === ChainSetting.CHAIN_IGNORE) {
// 如果玩家配置了忽略连锁,直接回应后端并返回 // 如果玩家配置了忽略连锁,直接回应后端并返回
sendSelectSingleResponse(-1); sendSelectSingleResponse(-1);
return; return;
...@@ -28,7 +28,7 @@ export default async (selectChain: MsgSelectChain) => { ...@@ -28,7 +28,7 @@ export default async (selectChain: MsgSelectChain) => {
// 直接回答 // 直接回答
handle_flag = 0; handle_flag = 0;
} else { } else {
if (chainSetting == ChainSetting.CHAIN_ALL) { if (chainSetting === ChainSetting.CHAIN_ALL) {
// 配置了全部连锁,则处理多张 // 配置了全部连锁,则处理多张
handle_flag = 2; handle_flag = 2;
} else { } else {
...@@ -71,7 +71,7 @@ export default async (selectChain: MsgSelectChain) => { ...@@ -71,7 +71,7 @@ export default async (selectChain: MsgSelectChain) => {
selectHintData: 203, selectHintData: 203,
}); });
const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta( const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta(
chains chains,
); );
await displaySelectActionsModal({ await displaySelectActionsModal({
isChain: true, isChain: true,
......
...@@ -15,11 +15,11 @@ export default async (selectEffectYn: MsgSelectEffectYn) => { ...@@ -15,11 +15,11 @@ export default async (selectEffectYn: MsgSelectEffectYn) => {
? ( ? (
desc: string, desc: string,
cardMeta: CardMeta, cardMeta: CardMeta,
cardLocation: ygopro.CardLocation cardLocation: ygopro.CardLocation,
) => { ) => {
const desc1 = desc.replace( const desc1 = desc.replace(
`[%ls]`, `[%ls]`,
fetchStrings(Region.System, cardLocation.zone + 1000) fetchStrings(Region.System, cardLocation.zone + 1000),
); );
const desc2 = desc1.replace(`[%ls]`, cardMeta.text.name || "[?]"); const desc2 = desc1.replace(`[%ls]`, cardMeta.text.name || "[?]");
return desc2; return desc2;
......
...@@ -40,7 +40,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd) => { ...@@ -40,7 +40,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd) => {
}); });
} else { } else {
console.warn( console.warn(
`target from zone=${location}, controller=${player}, sequence=${sequence} is null` `target from zone=${location}, controller=${player}, sequence=${sequence} is null`,
); );
} }
} else { } else {
...@@ -54,7 +54,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd) => { ...@@ -54,7 +54,7 @@ export default (selectIdleCmd: MsgSelectIdleCmd) => {
}; };
function idleTypeToInteractType( function idleTypeToInteractType(
idleType: MsgSelectIdleCmd.IdleCmd.IdleType idleType: MsgSelectIdleCmd.IdleCmd.IdleType,
): InteractType | undefined { ): InteractType | undefined {
switch (idleType) { switch (idleType) {
case MsgSelectIdleCmd.IdleCmd.IdleType.SUMMON: { case MsgSelectIdleCmd.IdleCmd.IdleType.SUMMON: {
......
...@@ -16,7 +16,7 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => { ...@@ -16,7 +16,7 @@ export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
const meta = await fetchCard(code >> 4); const meta = await fetchCard(code >> 4);
const msg = getCardStr(meta, code & 0xf) || "[?]"; const msg = getCardStr(meta, code & 0xf) || "[?]";
return { msg, response }; return { msg, response };
}) }),
) ),
); );
}; };
...@@ -4,7 +4,7 @@ import { InteractType, placeStore } from "@/stores"; ...@@ -4,7 +4,7 @@ import { InteractType, placeStore } from "@/stores";
type MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace; type MsgSelectPlace = ygopro.StocGameMessage.MsgSelectPlace;
export default (selectPlace: MsgSelectPlace) => { export default (selectPlace: MsgSelectPlace) => {
if (selectPlace.count != 1) { if (selectPlace.count !== 1) {
console.warn(`Unhandled case: ${selectPlace}`); console.warn(`Unhandled case: ${selectPlace}`);
return; return;
} }
......
...@@ -6,7 +6,7 @@ type MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition; ...@@ -6,7 +6,7 @@ type MsgSelectPosition = ygopro.StocGameMessage.MsgSelectPosition;
export default async (selectPosition: MsgSelectPosition) => { export default async (selectPosition: MsgSelectPosition) => {
const _player = selectPosition.player; const _player = selectPosition.player;
const positions = selectPosition.positions.map( const positions = selectPosition.positions.map(
(position) => position.position (position) => position.position,
); );
await displayPositionModal(positions); await displayPositionModal(positions);
}; };
...@@ -7,7 +7,7 @@ type MsgSelectTribute = ygopro.StocGameMessage.MsgSelectTribute; ...@@ -7,7 +7,7 @@ type MsgSelectTribute = ygopro.StocGameMessage.MsgSelectTribute;
export default async (selectTribute: MsgSelectTribute) => { export default async (selectTribute: MsgSelectTribute) => {
// TODO: 当玩家选择卡数大于`max`时,是否也合法? // TODO: 当玩家选择卡数大于`max`时,是否也合法?
const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta( const { selecteds, mustSelects, selectables } = await fetchCheckCardMeta(
selectTribute.selectable_cards selectTribute.selectable_cards,
); );
await displaySelectActionsModal({ await displaySelectActionsModal({
overflow: true, overflow: true,
......
...@@ -27,16 +27,16 @@ export default async (shuffleHandExtra: MsgShuffleHandExtra) => { ...@@ -27,16 +27,16 @@ export default async (shuffleHandExtra: MsgShuffleHandExtra) => {
await callCardMove(card.uuid); await callCardMove(card.uuid);
} else { } else {
console.warn( console.warn(
`<ShuffleHandExtra>sequence poped is none, controller=${controller}, code=${card.code}, sequence=${sequence}` `<ShuffleHandExtra>sequence poped is none, controller=${controller}, code=${card.code}, sequence=${sequence}`,
); );
} }
} else { } else {
console.warn( console.warn(
`<ShuffleHandExtra>target from records is null, controller=${controller}, cards=${cards.map( `<ShuffleHandExtra>target from records is null, controller=${controller}, cards=${cards.map(
(card) => card.code (card) => card.code,
)}, codes=${codes}` )}, codes=${codes}`,
); );
} }
}) }),
); );
}; };
...@@ -7,13 +7,13 @@ import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard; ...@@ -7,13 +7,13 @@ import MsgShuffleSetCard = ygopro.StocGameMessage.MsgShuffleSetCard;
export default async (shuffleSetCard: MsgShuffleSetCard) => { export default async (shuffleSetCard: MsgShuffleSetCard) => {
const from_locations = shuffleSetCard.from_locations; const from_locations = shuffleSetCard.from_locations;
const overlay_locations = shuffleSetCard.overlay_locations; const overlay_locations = shuffleSetCard.overlay_locations;
if (from_locations.length == 0) { if (from_locations.length === 0) {
console.error("<ShuffleSetCard>from_locations is empty"); console.error("<ShuffleSetCard>from_locations is empty");
return; return;
} }
if (from_locations.length != overlay_locations.length) { if (from_locations.length !== overlay_locations.length) {
console.error( console.error(
"<ShuffleSetCard>length of from_locations and overlay_locations not matched" "<ShuffleSetCard>length of from_locations and overlay_locations not matched",
); );
} }
...@@ -39,7 +39,7 @@ export default async (shuffleSetCard: MsgShuffleSetCard) => { ...@@ -39,7 +39,7 @@ export default async (shuffleSetCard: MsgShuffleSetCard) => {
for (const overlay of cardStore.findOverlay( for (const overlay of cardStore.findOverlay(
from.zone, from.zone,
from.controller, from.controller,
from.sequence from.sequence,
)) { )) {
// 更新sequence // 更新sequence
overlay.location.sequence = overlay_location.sequence; overlay.location.sequence = overlay_location.sequence;
...@@ -48,6 +48,6 @@ export default async (shuffleSetCard: MsgShuffleSetCard) => { ...@@ -48,6 +48,6 @@ export default async (shuffleSetCard: MsgShuffleSetCard) => {
// 这里其实有个疑惑,如果超量素材也跟着洗切的话,洗切的意义好像就没有了,感觉算是个k社没想好的设计? // 这里其实有个疑惑,如果超量素材也跟着洗切的话,洗切的意义好像就没有了,感觉算是个k社没想好的设计?
} }
} }
}) }),
); );
}; };
...@@ -11,7 +11,7 @@ export default async (sortCard: MsgSortCard) => { ...@@ -11,7 +11,7 @@ export default async (sortCard: MsgSortCard) => {
meta, meta,
response: response!, response: response!,
}; };
}) }),
); );
await displaySortCardModal(options); await displaySortCardModal(options);
}; };
...@@ -69,9 +69,9 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => { ...@@ -69,9 +69,9 @@ export default async (start: ygopro.StocGameMessage.MsgStart) => {
}, },
isToken: !((i + 1) % 3), isToken: !((i + 1) % 3),
selected: false, selected: false,
}) }),
) ),
) ),
); );
cardStore.inner.push(...cards); cardStore.inner.push(...cards);
......
...@@ -23,7 +23,7 @@ export default async (updateData: MsgUpdateData) => { ...@@ -23,7 +23,7 @@ export default async (updateData: MsgUpdateData) => {
const meta = target.meta; const meta = target.meta;
if (action.location !== undefined) { if (action.location !== undefined) {
if (target.location.position != action.location.position) { if (target.location.position !== action.location.position) {
// Currently only update position // Currently only update position
target.location.position = action.location.position; target.location.position = action.location.position;
// animation // animation
...@@ -51,7 +51,7 @@ export default async (updateData: MsgUpdateData) => { ...@@ -51,7 +51,7 @@ export default async (updateData: MsgUpdateData) => {
// TODO: counters // TODO: counters
} else { } else {
console.warn( console.warn(
`<UpdateData>target from zone=${zone}, controller=${controller}, sequence=${sequence} is null` `<UpdateData>target from zone=${zone}, controller=${controller}, sequence=${sequence} is null`,
); );
console.info(field); console.info(field);
} }
......
...@@ -8,6 +8,6 @@ export default async (win: MsgWin) => { ...@@ -8,6 +8,6 @@ export default async (win: MsgWin) => {
await displayEndModal( await displayEndModal(
matStore.isMe(win_player), matStore.isMe(win_player),
fetchStrings(Region.Victory, `0x${reason.toString(16)}`) fetchStrings(Region.Victory, `0x${reason.toString(16)}`),
); );
}; };
...@@ -15,7 +15,7 @@ export default function handleSocketOpen( ...@@ -15,7 +15,7 @@ export default function handleSocketOpen(
ws: WebSocket | undefined, ws: WebSocket | undefined,
_ip: string, _ip: string,
player: string, player: string,
passWd: string passWd: string,
) { ) {
console.log("WebSocket opened."); console.log("WebSocket opened.");
......
...@@ -19,7 +19,7 @@ export default function handleHsPlayerChange(pb: ygopro.YgoStocMsg) { ...@@ -19,7 +19,7 @@ export default function handleHsPlayerChange(pb: ygopro.YgoStocMsg) {
"<HsPlayerChange>Player " + "<HsPlayerChange>Player " +
change.pos + change.pos +
" moved to " + " moved to " +
change.moved_pos change.moved_pos,
); );
roomStore.players[change.moved_pos] = roomStore.players[change.pos]; roomStore.players[change.moved_pos] = roomStore.players[change.pos];
roomStore.players[change.pos] = undefined; roomStore.players[change.pos] = undefined;
......
...@@ -23,11 +23,11 @@ const helper = async ( ...@@ -23,11 +23,11 @@ const helper = async (
mustSelects: Option[], mustSelects: Option[],
selectables: Option[], selectables: Option[],
selected?: boolean, selected?: boolean,
mustSelect?: boolean mustSelect?: boolean,
) => { ) => {
const controller = location.controller; const controller = location.controller;
const newID = const newID =
code != 0 code !== 0
? code ? code
: cardStore.at(location.zone, controller, location.sequence)?.code || 0; : cardStore.at(location.zone, controller, location.sequence)?.code || 0;
const meta = await fetchCard(newID); const meta = await fetchCard(newID);
...@@ -63,7 +63,7 @@ export const fetchCheckCardMeta = async ( ...@@ -63,7 +63,7 @@ export const fetchCheckCardMeta = async (
effect_description?: number; effect_description?: number;
}[], }[],
selected?: boolean, selected?: boolean,
mustSelect?: boolean mustSelect?: boolean,
) => { ) => {
const selecteds: Option[] = []; const selecteds: Option[] = [];
const mustSelects: Option[] = []; const mustSelects: Option[] = [];
...@@ -75,7 +75,7 @@ export const fetchCheckCardMeta = async ( ...@@ -75,7 +75,7 @@ export const fetchCheckCardMeta = async (
mustSelects, mustSelects,
selectables, selectables,
selected, selected,
mustSelect mustSelect,
); // TODO: 研究下改成并行 ); // TODO: 研究下改成并行
} }
return { selecteds, mustSelects, selectables }; return { selecteds, mustSelects, selectables };
......
...@@ -34,13 +34,13 @@ class CardStore implements NeosStore { ...@@ -34,13 +34,13 @@ class CardStore implements NeosStore {
zone: ygopro.CardZone, zone: ygopro.CardZone,
controller: number, controller: number,
sequence?: number, sequence?: number,
overlay_sequence?: number overlay_sequence?: number,
): CardType | undefined; ): CardType | undefined;
at( at(
zone: ygopro.CardZone, zone: ygopro.CardZone,
controller: number, controller: number,
sequence?: number, sequence?: number,
overlay_sequence?: number overlay_sequence?: number,
) { ) {
if (sequence !== undefined) { if (sequence !== undefined) {
if (overlay_sequence !== undefined) { if (overlay_sequence !== undefined) {
...@@ -51,7 +51,7 @@ class CardStore implements NeosStore { ...@@ -51,7 +51,7 @@ class CardStore implements NeosStore {
card.location.controller === controller && card.location.controller === controller &&
card.location.sequence === sequence && card.location.sequence === sequence &&
card.location.is_overlay === true && card.location.is_overlay === true &&
card.location.overlay_sequence === overlay_sequence card.location.overlay_sequence === overlay_sequence,
) )
.at(0); .at(0);
} else { } else {
...@@ -61,7 +61,7 @@ class CardStore implements NeosStore { ...@@ -61,7 +61,7 @@ class CardStore implements NeosStore {
card.location.zone === zone && card.location.zone === zone &&
card.location.controller === controller && card.location.controller === controller &&
card.location.sequence === sequence && card.location.sequence === sequence &&
card.location.is_overlay === false card.location.is_overlay === false,
) )
.at(0); .at(0);
} }
...@@ -70,7 +70,7 @@ class CardStore implements NeosStore { ...@@ -70,7 +70,7 @@ class CardStore implements NeosStore {
(card) => (card) =>
card.location.zone === zone && card.location.zone === zone &&
card.location.controller === controller && card.location.controller === controller &&
card.location.is_overlay === false card.location.is_overlay === false,
); );
} }
} }
...@@ -81,14 +81,14 @@ class CardStore implements NeosStore { ...@@ -81,14 +81,14 @@ class CardStore implements NeosStore {
findOverlay( findOverlay(
zone: ygopro.CardZone, zone: ygopro.CardZone,
controller: number, controller: number,
sequence: number sequence: number,
): CardType[] { ): CardType[] {
return this.inner.filter( return this.inner.filter(
(card) => (card) =>
card.location.zone === zone && card.location.zone === zone &&
card.location.controller === controller && card.location.controller === controller &&
card.location.sequence === sequence && card.location.sequence === sequence &&
card.location.is_overlay card.location.is_overlay,
); );
} }
reset(): void { reset(): void {
......
...@@ -22,7 +22,7 @@ export const deckStore = proxy({ ...@@ -22,7 +22,7 @@ export const deckStore = proxy({
async update(deckName: string, deck: IDeck): Promise<boolean> { async update(deckName: string, deck: IDeck): Promise<boolean> {
const index = deckStore.decks.findIndex( const index = deckStore.decks.findIndex(
(deck) => deck.deckName === deckName (deck) => deck.deckName === deckName,
); );
if (index === -1) return false; if (index === -1) return false;
deckStore.decks[index] = deck; deckStore.decks[index] = deck;
...@@ -40,7 +40,7 @@ export const deckStore = proxy({ ...@@ -40,7 +40,7 @@ export const deckStore = proxy({
async delete(deckName: string): Promise<boolean> { async delete(deckName: string): Promise<boolean> {
const index = deckStore.decks.findIndex( const index = deckStore.decks.findIndex(
(deck) => deck.deckName === deckName (deck) => deck.deckName === deckName,
); );
if (index === -1) return false; if (index === -1) return false;
deckStore.decks.splice(index, 1); deckStore.decks.splice(index, 1);
......
...@@ -25,7 +25,7 @@ export const fetchSelectHintMeta = async ({ ...@@ -25,7 +25,7 @@ export const fetchSelectHintMeta = async ({
const cardMeta = await fetchCard(selectHintData); const cardMeta = await fetchCard(selectHintData);
selectHintMeta = fetchStrings(Region.System, 569).replace( selectHintMeta = fetchStrings(Region.System, 569).replace(
"[%ls]", "[%ls]",
cardMeta.text.name || "[?]" cardMeta.text.name || "[?]",
); );
} else { } else {
selectHintMeta = await getStrings(selectHintData); selectHintMeta = await getStrings(selectHintData);
...@@ -67,7 +67,7 @@ export const fetchEsHintMeta = async ({ ...@@ -67,7 +67,7 @@ export const fetchEsHintMeta = async ({
const fieldMeta = cardStore.at( const fieldMeta = cardStore.at(
location.zone, location.zone,
location.controller, location.controller,
location.sequence location.sequence,
); );
if (fieldMeta?.meta.text.name) { if (fieldMeta?.meta.text.name) {
esHint = esHint.replace("[?]", fieldMeta.meta.text.name); esHint = esHint.replace("[?]", fieldMeta.meta.text.name);
......
...@@ -28,7 +28,7 @@ export const isMe = (controller: number): boolean => { ...@@ -28,7 +28,7 @@ export const isMe = (controller: number): boolean => {
default: default:
// 自己是观战者 // 自己是观战者
// 这里假设偶数方的玩家是自己 // 这里假设偶数方的玩家是自己
return controller % 2 == 0; return controller % 2 === 0;
} }
}; };
......
...@@ -54,7 +54,7 @@ class PlaceStore implements NeosStore { ...@@ -54,7 +54,7 @@ class PlaceStore implements NeosStore {
zone: ygopro.CardZone.MZONE | ygopro.CardZone.SZONE, zone: ygopro.CardZone.MZONE | ygopro.CardZone.SZONE,
controller: number, controller: number,
sequence: number, sequence: number,
state: BlockState state: BlockState,
) { ) {
placeStore.inner[zone][matStore.isMe(controller) ? "me" : "op"][sequence] = placeStore.inner[zone][matStore.isMe(controller) ? "me" : "op"][sequence] =
state; state;
...@@ -63,7 +63,7 @@ class PlaceStore implements NeosStore { ...@@ -63,7 +63,7 @@ class PlaceStore implements NeosStore {
(["me", "op"] as const).forEach((who) => { (["me", "op"] as const).forEach((who) => {
([MZONE, SZONE] as const).forEach((where) => { ([MZONE, SZONE] as const).forEach((where) => {
placeStore.inner[where][who].forEach( placeStore.inner[where][who].forEach(
(block) => (block.interactivity = undefined) (block) => (block.interactivity = undefined),
); );
}); });
}); });
......
...@@ -36,7 +36,7 @@ export enum RoomStage { ...@@ -36,7 +36,7 @@ export enum RoomStage {
class RoomStore implements NeosStore { class RoomStore implements NeosStore {
joined: boolean = false; // 是否已经加入房间 joined: boolean = false; // 是否已经加入房间
players: (Player | undefined)[] = Array.from({ length: 4 }).map( players: (Player | undefined)[] = Array.from({ length: 4 }).map(
(_) => undefined (_) => undefined,
); // 进入房间的玩家列表 ); // 进入房间的玩家列表
observerCount: number = 0; // 观战者数量 observerCount: number = 0; // 观战者数量
isHost: boolean = false; // 当前玩家是否是房主 isHost: boolean = false; // 当前玩家是否是房主
......
...@@ -29,7 +29,7 @@ export const CardDetail: React.FC<{ ...@@ -29,7 +29,7 @@ export const CardDetail: React.FC<{
extraCardTypes(card?.data.type ?? 0) extraCardTypes(card?.data.type ?? 0)
.map((t) => fetchStrings(Region.System, Type2StringCodeMap.get(t) || 0)) .map((t) => fetchStrings(Region.System, Type2StringCodeMap.get(t) || 0))
.join(" / "), .join(" / "),
[card?.data.type] [card?.data.type],
); );
return ( return (
<div className={classNames(styles.detail, { [styles.open]: open })}> <div className={classNames(styles.detail, { [styles.open]: open })}>
...@@ -59,7 +59,7 @@ export const CardDetail: React.FC<{ ...@@ -59,7 +59,7 @@ export const CardDetail: React.FC<{
<Descriptions.Item label="属性"> <Descriptions.Item label="属性">
{fetchStrings( {fetchStrings(
Region.System, Region.System,
Attribute2StringCodeMap.get(card?.data.attribute ?? 0) || 0 Attribute2StringCodeMap.get(card?.data.attribute ?? 0) || 0,
)} )}
</Descriptions.Item> </Descriptions.Item>
)} )}
...@@ -67,7 +67,7 @@ export const CardDetail: React.FC<{ ...@@ -67,7 +67,7 @@ export const CardDetail: React.FC<{
<Descriptions.Item label="种族" span={2}> <Descriptions.Item label="种族" span={2}>
{fetchStrings( {fetchStrings(
Region.System, Region.System,
Race2StringCodeMap.get(card?.data.race ?? 0) || 0 Race2StringCodeMap.get(card?.data.race ?? 0) || 0,
)} )}
</Descriptions.Item> </Descriptions.Item>
)} )}
......
...@@ -53,7 +53,7 @@ export const DeckSelect: React.FC<{ ...@@ -53,7 +53,7 @@ export const DeckSelect: React.FC<{
maskClosable: true, maskClosable: true,
onOk: async () => { onOk: async () => {
const results = await Promise.all( const results = await Promise.all(
newDeck.current.map((deck) => deckStore.add(deck)) newDeck.current.map((deck) => deckStore.add(deck)),
); );
newDeck.current = []; newDeck.current = [];
if (results.length) if (results.length)
...@@ -186,7 +186,7 @@ const DeckUploader: React.FC<{ onLoaded: (deck: IDeck) => void }> = ({ ...@@ -186,7 +186,7 @@ const DeckUploader: React.FC<{ onLoaded: (deck: IDeck) => void }> = ({
name: "file", name: "file",
multiple: true, multiple: true,
onChange(info) { onChange(info) {
if (uploadState != "ERROR") { if (uploadState !== "ERROR") {
info.file.status = "done"; info.file.status = "done";
} }
}, },
......
...@@ -218,7 +218,7 @@ const Search: React.FC = () => { ...@@ -218,7 +218,7 @@ const Search: React.FC = () => {
types: [], types: [],
}; };
const [searchConditions, setSearchConditions] = useState<FtsConditions>( const [searchConditions, setSearchConditions] = useState<FtsConditions>(
emptySearchConditions emptySearchConditions,
); );
const [searchResult, setSearchResult] = useState<CardMeta[]>([]); const [searchResult, setSearchResult] = useState<CardMeta[]>([]);
...@@ -236,7 +236,7 @@ const Search: React.FC = () => { ...@@ -236,7 +236,7 @@ const Search: React.FC = () => {
return () => return () =>
setSortRef( setSortRef(
(a: CardMeta, b: CardMeta) => (a: CardMeta, b: CardMeta) =>
((a.data?.[key] ?? 0) - (b.data?.[key] ?? 0)) * scale ((a.data?.[key] ?? 0) - (b.data?.[key] ?? 0)) * scale,
); );
}; };
...@@ -409,7 +409,7 @@ const DeckZone: React.FC<{ ...@@ -409,7 +409,7 @@ const DeckZone: React.FC<{
}, },
hover: ({ value, source }) => { hover: ({ value, source }) => {
setAllowToDrop( setAllowToDrop(
type !== source ? editDeckStore.canAdd(value, type).result : true type !== source ? editDeckStore.canAdd(value, type).result : true,
); );
}, },
collect: (monitor) => ({ collect: (monitor) => ({
......
...@@ -13,7 +13,7 @@ export interface EditingDeck { ...@@ -13,7 +13,7 @@ export interface EditingDeck {
} }
export const iDeckToEditingDeck = async ( export const iDeckToEditingDeck = async (
ideck: IDeck ideck: IDeck,
): Promise<EditingDeck> => ({ ): Promise<EditingDeck> => ({
deckName: ideck.deckName, deckName: ideck.deckName,
main: await Promise.all(ideck.main.map(fetchCard)), main: await Promise.all(ideck.main.map(fetchCard)),
......
...@@ -35,7 +35,7 @@ export const AnnounceModal = () => { ...@@ -35,7 +35,7 @@ export const AnnounceModal = () => {
open={isOpen} open={isOpen}
footer={ footer={
<Button <Button
disabled={selected.length != min} disabled={selected.length !== min}
onClick={() => { onClick={() => {
let response = selected.reduce((res, current) => res | current, 0); // 多个选择求或 let response = selected.reduce((res, current) => res | current, 0); // 多个选择求或
sendSelectOptionResponse(response); sendSelectOptionResponse(response);
...@@ -65,7 +65,7 @@ export const AnnounceModal = () => { ...@@ -65,7 +65,7 @@ export const AnnounceModal = () => {
let rs: (arg?: any) => void = () => {}; let rs: (arg?: any) => void = () => {};
export const displayAnnounceModal = async ( export const displayAnnounceModal = async (
args: Omit<AnnounceModalProps, "isOpen"> args: Omit<AnnounceModalProps, "isOpen">,
) => { ) => {
Object.entries(args).forEach(([key, value]) => { Object.entries(args).forEach(([key, value]) => {
// @ts-ignore // @ts-ignore
......
...@@ -33,7 +33,7 @@ export const CardListModal = () => { ...@@ -33,7 +33,7 @@ export const CardListModal = () => {
cardList = cardStore.findOverlay( cardList = cardStore.findOverlay(
monster.location.zone, monster.location.zone,
monster.location.controller, monster.location.controller,
monster.location.sequence monster.location.sequence,
); );
} }
......
...@@ -24,7 +24,7 @@ const RegexWrapper: React.FC<{ ...@@ -24,7 +24,7 @@ const RegexWrapper: React.FC<{
const matches = text.match(re); const matches = text.match(re);
if (!matches) return <>{text}</>; if (!matches) return <>{text}</>;
const sepRe = new RegExp( const sepRe = new RegExp(
matches?.reduce((acc, cur) => `${acc}|${cur}`) ?? "" matches?.reduce((acc, cur) => `${acc}|${cur}`) ?? "",
); );
const parts = text.split(sepRe); const parts = text.split(sepRe);
return ( return (
......
...@@ -104,7 +104,7 @@ const AttLine = (props: { ...@@ -104,7 +104,7 @@ const AttLine = (props: {
const attribute = props.attribute const attribute = props.attribute
? fetchStrings( ? fetchStrings(
Region.System, Region.System,
Attribute2StringCodeMap.get(props.attribute) || 0 Attribute2StringCodeMap.get(props.attribute) || 0,
) )
: undefined; : undefined;
const types = props.types const types = props.types
...@@ -153,7 +153,7 @@ const _CounterLine = (props: { counters: { [type: number]: number } }) => { ...@@ -153,7 +153,7 @@ const _CounterLine = (props: { counters: { [type: number]: number } }) => {
}; };
export const showCardModal = ( export const showCardModal = (
card: Partial<Pick<typeof store, "meta" | "counters">> card: Partial<Pick<typeof store, "meta" | "counters">>,
) => { ) => {
store.isOpen = true; store.isOpen = true;
store.meta = card?.meta ?? defaultStore.meta; store.meta = card?.meta ?? defaultStore.meta;
......
...@@ -34,7 +34,7 @@ export const CheckCounterModal = () => { ...@@ -34,7 +34,7 @@ export const CheckCounterModal = () => {
const options = snapCheckCounterModal.options; const options = snapCheckCounterModal.options;
const counterName = fetchStrings( const counterName = fetchStrings(
Region.Counter, Region.Counter,
`0x${snapCheckCounterModal.counterType!}` `0x${snapCheckCounterModal.counterType!}`,
); // FIXME: 这里转十六进制的逻辑有问题 ); // FIXME: 这里转十六进制的逻辑有问题
const [selected, setSelected] = useState(new Array(options.length)); const [selected, setSelected] = useState(new Array(options.length));
...@@ -93,7 +93,7 @@ export const CheckCounterModal = () => { ...@@ -93,7 +93,7 @@ export const CheckCounterModal = () => {
let rs: (arg?: any) => void = () => {}; let rs: (arg?: any) => void = () => {};
export const displayCheckCounterModal = async ( export const displayCheckCounterModal = async (
args: Omit<CheckCounterModalProps, "isOpen"> args: Omit<CheckCounterModalProps, "isOpen">,
) => { ) => {
Object.entries(args).forEach(([key, value]) => { Object.entries(args).forEach(([key, value]) => {
// @ts-ignore // @ts-ignore
......
...@@ -59,7 +59,7 @@ export const HintNotification = () => { ...@@ -59,7 +59,7 @@ export const HintNotification = () => {
if (meHand !== HandResult.UNKNOWN && opHand !== HandResult.UNKNOWN) { if (meHand !== HandResult.UNKNOWN && opHand !== HandResult.UNKNOWN) {
notify.open({ notify.open({
message: `{我方出示${getHandResultText( message: `{我方出示${getHandResultText(
meHand meHand,
)},对方出示${getHandResultText(opHand)}}`, )},对方出示${getHandResultText(opHand)}}`,
placement: "topLeft", placement: "topLeft",
style: style, style: style,
...@@ -71,7 +71,7 @@ export const HintNotification = () => { ...@@ -71,7 +71,7 @@ export const HintNotification = () => {
if (currentPhase) { if (currentPhase) {
const message = fetchStrings( const message = fetchStrings(
Region.System, Region.System,
Phase2StringCodeMap.get(currentPhase) ?? 0 Phase2StringCodeMap.get(currentPhase) ?? 0,
); );
notify.open({ notify.open({
message, message,
...@@ -79,7 +79,7 @@ export const HintNotification = () => { ...@@ -79,7 +79,7 @@ export const HintNotification = () => {
style: style, style: style,
}); });
console.color("DeepPink")( console.color("DeepPink")(
`${message}(${matStore.isMe(matStore.currentPlayer) ? "me" : "op"})` `${message}(${matStore.isMe(matStore.currentPlayer) ? "me" : "op"})`,
); );
} }
}, [currentPhase]); }, [currentPhase]);
......
...@@ -71,7 +71,7 @@ export const handleEffectActivation = async ( ...@@ -71,7 +71,7 @@ export const handleEffectActivation = async (
desc: string; desc: string;
response: number; response: number;
effectCode: number | undefined; effectCode: number | undefined;
}[] }[],
) => { ) => {
if (!effectInteractivies.length) { if (!effectInteractivies.length) {
return; return;
......
...@@ -19,7 +19,7 @@ const localStore = proxy<PositionModalProps>(defaultProps); ...@@ -19,7 +19,7 @@ const localStore = proxy<PositionModalProps>(defaultProps);
export const PositionModal = () => { export const PositionModal = () => {
const { isOpen, positions } = useSnapshot(localStore); const { isOpen, positions } = useSnapshot(localStore);
const [selected, setSelected] = useState<ygopro.CardPosition | undefined>( const [selected, setSelected] = useState<ygopro.CardPosition | undefined>(
undefined undefined,
); );
return ( return (
...@@ -84,7 +84,7 @@ function cardPositionToChinese(position: ygopro.CardPosition): string { ...@@ -84,7 +84,7 @@ function cardPositionToChinese(position: ygopro.CardPosition): string {
let rs: (arg?: any) => void = () => {}; let rs: (arg?: any) => void = () => {};
export const displayPositionModal = async ( export const displayPositionModal = async (
positions: ygopro.CardPosition[] positions: ygopro.CardPosition[],
) => { ) => {
localStore.positions = positions; localStore.positions = positions;
localStore.isOpen = true; localStore.isOpen = true;
......
...@@ -69,7 +69,7 @@ export const SelectActionsModal: React.FC = () => { ...@@ -69,7 +69,7 @@ export const SelectActionsModal: React.FC = () => {
let rs: (v?: any) => void = () => {}; let rs: (v?: any) => void = () => {};
export const displaySelectActionsModal = async ( export const displaySelectActionsModal = async (
args: Partial<Omit<typeof defaultProps, "isOpen">> args: Partial<Omit<typeof defaultProps, "isOpen">>,
) => { ) => {
resetSelectActionsModal(); // 先重置为初始状态 resetSelectActionsModal(); // 先重置为初始状态
Object.entries(args).forEach(([key, value]) => { Object.entries(args).forEach(([key, value]) => {
......
...@@ -65,7 +65,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -65,7 +65,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
const [sumLevel1, sumLevel2] = (["level1", "level2"] as const).map((key) => const [sumLevel1, sumLevel2] = (["level1", "level2"] as const).map((key) =>
[...mustSelects, ...result] [...mustSelects, ...result]
.map((option) => option[key] || 0) .map((option) => option[key] || 0)
.reduce((sum, current) => sum + current, 0) .reduce((sum, current) => sum + current, 0),
); );
const levelMatched = overflow const levelMatched = overflow
? sumLevel1 >= totalLevels || sumLevel2 >= totalLevels ? sumLevel1 >= totalLevels || sumLevel2 >= totalLevels
...@@ -73,7 +73,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -73,7 +73,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
setSubmitable( setSubmitable(
single single
? result.length === 1 ? result.length === 1
: result.length >= min && result.length <= max && levelMatched : result.length >= min && result.length <= max && levelMatched,
); );
}, [result.length]); }, [result.length]);
...@@ -91,7 +91,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -91,7 +91,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
}, [selectables]); }, [selectables]);
const [submitText, finishText, cancelText] = [1211, 1296, 1295].map((n) => const [submitText, finishText, cancelText] = [1211, 1296, 1295].map((n) =>
fetchStrings(Region.System, n) fetchStrings(Region.System, n),
); );
return ( return (
...@@ -167,7 +167,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -167,7 +167,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
))} ))}
</CheckCard.Group> </CheckCard.Group>
</div> </div>
) ),
)} )}
<p> <p>
<span> <span>
......
...@@ -35,12 +35,12 @@ export const SimpleSelectCardsModal: React.FC = () => { ...@@ -35,12 +35,12 @@ export const SimpleSelectCardsModal: React.FC = () => {
let rs: (options: Snapshot<Option[]>) => void = () => {}; let rs: (options: Snapshot<Option[]>) => void = () => {};
export const displaySimpleSelectCardsModal = async ( export const displaySimpleSelectCardsModal = async (
args: Omit<typeof defaultProps, "isOpen"> args: Omit<typeof defaultProps, "isOpen">,
) => { ) => {
localStore.selectables = args.selectables; localStore.selectables = args.selectables;
localStore.isOpen = true; localStore.isOpen = true;
const res = await new Promise<Snapshot<Option[]>>( const res = await new Promise<Snapshot<Option[]>>(
(resolve) => (rs = resolve) (resolve) => (rs = resolve),
); // 等待在组件内resolve ); // 等待在组件内resolve
localStore.isOpen = false; localStore.isOpen = false;
return res; return res;
......
...@@ -50,7 +50,7 @@ export const SortCardModal = () => { ...@@ -50,7 +50,7 @@ export const SortCardModal = () => {
useSensor(PointerSensor), useSensor(PointerSensor),
useSensor(KeyboardSensor, { useSensor(KeyboardSensor, {
coordinateGetter: sortableKeyboardCoordinates, coordinateGetter: sortableKeyboardCoordinates,
}) }),
); );
const onFinish = () => { const onFinish = () => {
......
...@@ -54,7 +54,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -54,7 +54,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
focusOpacity: 1, focusOpacity: 1,
subZ: 0, subZ: 0,
opacity: 1, opacity: 1,
} satisfies SpringApiProps) }) satisfies SpringApiProps,
); );
// 每张卡都需要移动到初始位置 // 每张卡都需要移动到初始位置
...@@ -76,7 +76,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -76,7 +76,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
const register = <T extends any[]>( const register = <T extends any[]>(
task: Task, task: Task,
fn: (...args: T) => Promise<unknown> fn: (...args: T) => Promise<unknown>,
) => { ) => {
eventbus.register(task, async (uuid, ...rest: T) => { eventbus.register(task, async (uuid, ...rest: T) => {
if (uuid === card.uuid) { if (uuid === card.uuid) {
...@@ -108,7 +108,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -108,7 +108,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
useEffect(() => { useEffect(() => {
setGrowing( setGrowing(
!!idleInteractivities.length && !!idleInteractivities.length &&
[MZONE, SZONE, HAND, TZONE].includes(card.location.zone) [MZONE, SZONE, HAND, TZONE].includes(card.location.zone),
); );
}, [idleInteractivities]); }, [idleInteractivities]);
...@@ -142,7 +142,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -142,7 +142,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
} }
const actions = [...map.entries()]; const actions = [...map.entries()];
const nonEffectActions = actions.filter( const nonEffectActions = actions.filter(
([action]) => action !== InteractType.ACTIVATE ([action]) => action !== InteractType.ACTIVATE,
); );
const getNonEffectResponse = (action: InteractType, card: CardType) => const getNonEffectResponse = (action: InteractType, card: CardType) =>
card.idleInteractivities.find((item) => item.interactType === action)! card.idleInteractivities.find((item) => item.interactType === action)!
...@@ -170,17 +170,17 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -170,17 +170,17 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
sendSelectIdleCmdResponse(option[0].response!); sendSelectIdleCmdResponse(option[0].response!);
} }
}, },
}) }),
); );
const hasEffect = const hasEffect =
cards.reduce( cards.reduce(
(prev, acc) => [ (prev, acc) => [
...prev, ...prev,
...acc.idleInteractivities.filter( ...acc.idleInteractivities.filter(
({ interactType }) => interactType === InteractType.ACTIVATE ({ interactType }) => interactType === InteractType.ACTIVATE,
), ),
], ],
[] as Interactivity<number>[] [] as Interactivity<number>[],
).length > 0; ).length > 0;
const effectItem: DropdownItem = { const effectItem: DropdownItem = {
key: nonEffectItem.length, key: nonEffectItem.length,
...@@ -200,8 +200,9 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -200,8 +200,9 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
.filter( .filter(
(card) => (card) =>
card.idleInteractivities.find( card.idleInteractivities.find(
({ interactType }) => interactType === InteractType.ACTIVATE ({ interactType }) =>
) !== undefined interactType === InteractType.ACTIVATE,
) !== undefined,
) )
.map((card) => ({ .map((card) => ({
meta: card.meta, meta: card.meta,
...@@ -215,14 +216,14 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -215,14 +216,14 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
handleEffectActivation( handleEffectActivation(
tmpCard.idleInteractivities tmpCard.idleInteractivities
.filter( .filter(
({ interactType }) => interactType === InteractType.ACTIVATE ({ interactType }) => interactType === InteractType.ACTIVATE,
) )
.map((x) => ({ .map((x) => ({
desc: interactTypeToString(x.interactType), desc: interactTypeToString(x.interactType),
response: x.response, response: x.response,
effectCode: x.activateIndex, effectCode: x.activateIndex,
})), })),
tmpCard.meta tmpCard.meta,
); );
}, },
}; };
...@@ -242,7 +243,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -242,7 +243,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
const overlayMaterials = cardStore.findOverlay( const overlayMaterials = cardStore.findOverlay(
card.location.zone, card.location.zone,
card.location.controller, card.location.controller,
card.location.sequence card.location.sequence,
); );
if (overlayMaterials.length > 0) { if (overlayMaterials.length > 0) {
displayCardListModal({ displayCardListModal({
...@@ -279,7 +280,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -279,7 +280,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
transform: to( transform: to(
[spring.x, spring.y, spring.z, spring.rx, spring.ry, spring.rz], [spring.x, spring.y, spring.z, spring.rx, spring.ry, spring.rz],
(x, y, z, rx, ry, rz) => (x, y, z, rx, ry, rz) =>
`translate(${x}px, ${y}px) rotateX(${rx}deg) rotateZ(${rz}deg)` `translate(${x}px, ${y}px) rotateX(${rx}deg) rotateZ(${rz}deg)`,
), ),
"--z": spring.z, "--z": spring.z,
"--sub-z": spring.subZ.to([0, 50, 100], [0, 200, 0]), // 中间高,两边低 "--sub-z": spring.subZ.to([0, 50, 100], [0, 200, 0]), // 中间高,两边低
...@@ -335,7 +336,7 @@ type DropdownItem = NonNullable<MenuProps["items"]>[number] & { ...@@ -335,7 +336,7 @@ type DropdownItem = NonNullable<MenuProps["items"]>[number] & {
const handleEffectActivation = ( const handleEffectActivation = (
effectInteractivies: Interactivy[], effectInteractivies: Interactivy[],
meta?: CardMeta meta?: CardMeta,
) => { ) => {
if (!effectInteractivies.length) return; if (!effectInteractivies.length) return;
else if (effectInteractivies.length === 1) { else if (effectInteractivies.length === 1) {
......
...@@ -8,8 +8,8 @@ import { asyncStart } from "./utils"; ...@@ -8,8 +8,8 @@ import { asyncStart } from "./utils";
export const focus = async (props: { card: CardType; api: SpringApi }) => { export const focus = async (props: { card: CardType; api: SpringApi }) => {
const { card, api } = props; const { card, api } = props;
if ( if (
card.location.zone == ygopro.CardZone.HAND || card.location.zone === ygopro.CardZone.HAND ||
card.location.zone == ygopro.CardZone.DECK card.location.zone === ygopro.CardZone.DECK
) { ) {
const current = { ...api.current[0].get() }; const current = { ...api.current[0].get() };
await asyncStart(api)({ await asyncStart(api)({
......
...@@ -31,7 +31,7 @@ export const moveToHand: MoveFunc = async (props) => { ...@@ -31,7 +31,7 @@ export const moveToHand: MoveFunc = async (props) => {
const THETA = const THETA =
2 * 2 *
Math.atan( Math.atan(
hand_card_width / 2 / (HAND_CIRCLE_CENTER_OFFSET_Y + HAND_CARD_HEIGHT) hand_card_width / 2 / (HAND_CIRCLE_CENTER_OFFSET_Y + HAND_CARD_HEIGHT),
) * ) *
0.9; 0.9;
// 接下来计算每一张手卡 // 接下来计算每一张手卡
......
...@@ -61,7 +61,7 @@ export const Menu = () => { ...@@ -61,7 +61,7 @@ export const Menu = () => {
phase: PhaseType, phase: PhaseType,
label: string, label: string,
response: number, response: number,
show: boolean show: boolean,
][] = [ ][] = [
[PhaseType.DRAW, "抽卡阶段", -1, true], [PhaseType.DRAW, "抽卡阶段", -1, true],
[PhaseType.STANDBY, "准备阶段", -1, true], [PhaseType.STANDBY, "准备阶段", -1, true],
...@@ -122,7 +122,7 @@ export const Menu = () => { ...@@ -122,7 +122,7 @@ export const Menu = () => {
onClick: () => { onClick: () => {
matStore.chainSetting = key; matStore.chainSetting = key;
}, },
}) }),
); );
const surrenderMenuItems: MenuProps["items"] = [ const surrenderMenuItems: MenuProps["items"] = [
...@@ -176,7 +176,7 @@ export const Menu = () => { ...@@ -176,7 +176,7 @@ export const Menu = () => {
}; };
const DropdownWithTitle: React.FC<DropdownProps & { title?: string }> = ( const DropdownWithTitle: React.FC<DropdownProps & { title?: string }> = (
props props,
) => { ) => {
const { token } = useToken(); const { token } = useToken();
const contentStyle = { const contentStyle = {
......
export const groupBy = <K, V extends Record<string, any>>( export const groupBy = <K, V extends Record<string, any>>(
array: readonly V[], array: readonly V[],
getKey: (cur: V, idx: number, src: readonly V[]) => K getKey: (cur: V, idx: number, src: readonly V[]) => K,
): [K, V[]][] => ): [K, V[]][] =>
Array.from( Array.from(
array.reduce((map, cur, idx, src) => { array.reduce((map, cur, idx, src) => {
...@@ -9,5 +9,5 @@ export const groupBy = <K, V extends Record<string, any>>( ...@@ -9,5 +9,5 @@ export const groupBy = <K, V extends Record<string, any>>(
if (list) list.push(cur); if (list) list.push(cur);
else map.set(key, [cur]); else map.set(key, [cur]);
return map; return map;
}, new Map<K, V[]>()) }, new Map<K, V[]>()),
); );
...@@ -43,7 +43,7 @@ const Icon: React.FC<{ type: string; size?: number }> = ({ ...@@ -43,7 +43,7 @@ const Icon: React.FC<{ type: string; size?: number }> = ({
export function interactTypeToIcon( export function interactTypeToIcon(
t: InteractType, t: InteractType,
position?: CardPosition position?: CardPosition,
): JSX.Element { ): JSX.Element {
switch (t) { switch (t) {
case InteractType.POS_CHANGE: case InteractType.POS_CHANGE:
......
export function zip<S1, S2>( export function zip<S1, S2>(
firstCollection: Array<S1>, firstCollection: Array<S1>,
lastCollection: Array<S2> lastCollection: Array<S2>,
): Array<[S1, S2]> { ): Array<[S1, S2]> {
const length = Math.min(firstCollection.length, lastCollection.length); const length = Math.min(firstCollection.length, lastCollection.length);
const zipped: Array<[S1, S2]> = []; const zipped: Array<[S1, S2]> = [];
......
...@@ -33,7 +33,7 @@ export const MatchModal: React.FC = ({}) => { ...@@ -33,7 +33,7 @@ export const MatchModal: React.FC = ({}) => {
const [player, setPlayer] = useState(user?.name ?? defaultPlayer); const [player, setPlayer] = useState(user?.name ?? defaultPlayer);
const [passwd, setPasswd] = useState(defaultPassword); const [passwd, setPasswd] = useState(defaultPassword);
const [server, setServer] = useState( const [server, setServer] = useState(
`${serverConfig[0].ip}:${serverConfig[0].port}` `${serverConfig[0].ip}:${serverConfig[0].port}`,
); );
const [confirmLoading, setConfirmLoading] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false);
const navigate = useNavigate(); const navigate = useNavigate();
......
...@@ -18,7 +18,7 @@ const NeosConfig = useConfig(); ...@@ -18,7 +18,7 @@ const NeosConfig = useConfig();
export const Component: React.FC = () => { export const Component: React.FC = () => {
const serverList = NeosConfig.servers; const serverList = NeosConfig.servers;
const [server, setServer] = useState( const [server, setServer] = useState(
`${serverList[0].ip}:${serverList[0].port}` `${serverList[0].ip}:${serverList[0].port}`,
); );
const { decks } = useSnapshot(deckStore); const { decks } = useSnapshot(deckStore);
const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0]))); const [deck, setDeck] = useState<IDeck>(JSON.parse(JSON.stringify(decks[0])));
......
...@@ -5,7 +5,7 @@ import styles from "./index.module.scss"; ...@@ -5,7 +5,7 @@ import styles from "./index.module.scss";
/** HOC: 将组件发射到body下 */ /** HOC: 将组件发射到body下 */
export const withPortalToBody = <P extends object>( export const withPortalToBody = <P extends object>(
WrappedComponent: React.ComponentType<P> WrappedComponent: React.ComponentType<P>,
) => { ) => {
return (props: P) => { return (props: P) => {
useEffect(() => { useEffect(() => {
......
...@@ -27,7 +27,7 @@ const RegexWrapper: React.FC<{ ...@@ -27,7 +27,7 @@ const RegexWrapper: React.FC<{
const matches = text.match(re); const matches = text.match(re);
if (!matches) return <>{text}</>; if (!matches) return <>{text}</>;
const sepRe = new RegExp( const sepRe = new RegExp(
matches?.reduce((acc, cur) => `${acc}|${cur}`) ?? "" matches?.reduce((acc, cur) => `${acc}|${cur}`) ?? "",
); );
const parts = text.split(sepRe); const parts = text.split(sepRe);
return ( return (
......
...@@ -36,7 +36,7 @@ export const YgoCard: React.FC<Props> = (props) => { ...@@ -36,7 +36,7 @@ export const YgoCard: React.FC<Props> = (props) => {
onLoad={onLoad} onLoad={onLoad}
/> />
), ),
[code] [code],
); );
}; };
......
...@@ -14,7 +14,7 @@ const toCssProperties = (config: CSSConfig) => ...@@ -14,7 +14,7 @@ const toCssProperties = (config: CSSConfig) =>
.map((s) => s.toLowerCase()) .map((s) => s.toLowerCase())
.join("-")}`, .join("-")}`,
`${v[0]}${v[1]}`, `${v[0]}${v[1]}`,
] as [string, string] ] as [string, string],
) )
.reduce((acc, cur) => [...acc, cur], [] as [string, string][]); .reduce((acc, cur) => [...acc, cur], [] as [string, string][]);
...@@ -50,7 +50,7 @@ export const matConfig = Object.keys(matConfigWithUnit).reduce( ...@@ -50,7 +50,7 @@ export const matConfig = Object.keys(matConfigWithUnit).reduce(
// @ts-ignore // @ts-ignore
[key]: matConfigWithUnit[key][0], [key]: matConfigWithUnit[key][0],
}), }),
{} as Record<keyof typeof matConfigWithUnit, number> {} as Record<keyof typeof matConfigWithUnit, number>,
); );
toCssProperties(matConfigWithUnit).forEach(([k, v]) => { toCssProperties(matConfigWithUnit).forEach(([k, v]) => {
......
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