Skip to content

Commit

Permalink
sǝɹoɥɔ: migrate ESLint to v9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lchzh3473 committed Nov 1, 2024
1 parent 6bcceeb commit 11a702a
Show file tree
Hide file tree
Showing 24 changed files with 336 additions and 308 deletions.
32 changes: 0 additions & 32 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ["https://afdian.net/@lchz\x683\x3473"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ["https://afdian.com/@lchz\x683\x3473"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
60 changes: 38 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
# <!-- prettier-ignore -->[Phixos](https://lchz&#104;3473.github.io/sim-phi/index)
# <!-- prettier-ignore -->[SimPhiCore](https://lchz&#104;3473.github.io/sim-phi/index)

## 简介
> 这不是 Phi&#103;ros,这是在线的模拟器!
> This is not Phi&#103;ros; it's an online simulator!
$\text{Phi\color{red}x\color{green}os}=\color{red}\xcancel{\text{\color{black}Phi{g}ros}}\text{ \color{green}Online Simulator}$
## 简介 | Introduction

> 这不是 Phi&#103;ros,这是在线的模拟器!
如题,用 JS/Canvas 重现 [Phi&#103;ros](https://www.taptap.com/app/165287) 游戏画面。
As mentioned, this project uses JS/Canvas to recreate the visuals of [Phi&#103;ros](https://www.taptap.com/app/165287).

如题,用 JS/Canvas 还原 [Phi&#103;ros](https://www.taptap.com/app/165287) 游戏画面。
本项目属于个人兴趣项目,仅用于学习和测试。
This is a personal interest project, intended for learning and testing only.

本项目属于个人兴趣项目,仅用于学习和测试。
**由于本项目正在进行模块化重构,近期代码可能存在较大变动。**
**As the project undergoes modular restructuring, significant changes in the code are expected in the near future.**

由于本项目正在进行模块化重构,近期代码可能存在较大变动。
特别感谢 [@AsakuraMizu](https://github.com/AsakuraMizu) 强力推荐的 [Vite](https://vitejs.dev) 驱动!
Special thanks to [@AsakuraMizu](https://github.com/AsakuraMizu) for the strong recommendation of [Vite](https://vitejs.dev)!

### 特别感谢
以及看到这个页面的你!
And You, for visiting this page!

- [@luch4736](https://github.com/luch4736) 提供 iPad (Safari on iOS 15.6+)
- [@cgluWxh](https://github.com/cgluWxh) 提供 iPhone (Safari on iOS 12.5.7)
- [@AsakuraMizu](https://github.com/AsakuraMizu) 强力推荐的 [Vite](https://vitejs.dev) 驱动!
- 以及看到这个页面的你!
## 文档 | Documentation

## 文档
访问 <!-- prettier-ignore -->[docs.lchz&#104;.net](https://docs.lchz&#104;.net/project/sim-phi-core) (WIP/开发中) 以查看文档。
There is no English documentation available yet; use a translator if necessary.

访问 <!-- prettier-ignore -->[docs.lchz&#104;.net](https://docs.lchz&#104;.net/project/sim-phi-core) (Working in progress)
## 更新日志 | Changelog

## 更新日志
每个版本的详细更改都记录在 [CHANGELOG.md](CHANGELOG.md) 中。
Detailed changes for each version are documented in [CHANGELOG.md](CHANGELOG.md).

每个版本的详细更改都记录在 [CHANGELOG.md](CHANGELOG.md) 中。
## 声明 | Disclaimer

## 许可证
本项目源码由 [lchz&#104;3473](https://github.com/lchz&#104;3473) 独立编写,与游戏本体无关;
This project’s source code is independently developed by [lchz&#104;3473](https://github.com/lchz&#104;3473) and is not associated with the original game.

本项目源码按 [GPL-3.0](LICENSE.txt) 协议开源;不鼓励、不支持一切商业用途。
因使用或修改代码造成的一切后果由您自行承担。
You are solely responsible for any consequences arising from the use or modification of the code.

本项目不提供游戏本体安装包及逆向工具/教程,也不提供谱面下载。
不提供游戏安装包及逆向工具/教程,也不提供谱面下载。
This project does not provide game installation packages, reverse engineering tools or tutorials, nor chart downloads.

模拟器代码部分为 [lchz&#104;3473](https://space.bilibili.com/274753872) (以下简称 lchz&#104;) 独立编写,与游戏本体无关;
**本仓库及其所有者与 Pigeon Games 及其关联公司无关,且未获得其任何赞助或授权。**
**This repository and its owner are not affiliated with, sponsored by, or authorized by Pigeon Games or its affiliates.**

您因使用或修改代码所造成的一切后果由您自己承担;
## 许可证 | License

如有任何疑问请 [联系 lchz&#104;](mailto:lchz%683%[email protected]?subject=[GitHub]lchz%683%3473/sim-phi)
本项目源码按 [GPL-3.0](LICENSE.txt) 协议开源;不鼓励、不支持一切商业用途。
This project’s source code is open-source under the [GPL-3.0](LICENSE.txt) license.
Commercial use is neither encouraged nor supported.

## 联系 | Contact

如有任何疑问,欢迎通过 [GitHub Issue](../../issues) 提交问题,或[直接联系 lchz&#104;](mailto:lchz%683%[email protected]?subject=[GitHub]lchz%683%3473/sim-phi)
If you have any questions, feel free to [submit an issue on GitHub](../../issues), or [contact lchz&#104;](mailto:lchz%683%[email protected]?subject=[GitHub]lchz%683%3473/sim-phi).

Copyright &copy; 2020-present, lchz&#104;3473
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import globals from 'globals';
import eslintConfigv2 from './tools/eslint-config.mjs';
/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: ['**/* copy.*', 'dist', 'rubbish']
},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
}
},
...eslintConfigv2,
{
languageOptions: {
globals: {
...globals.browser,
...globals.worker,
...globals.node,
hook: 'writable',
Utils: 'readonly'
}
}
}
];
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "sim-phi-vite",
"private": true,
"version": "1.5.9",
"version": "1.5.9.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build && node scripts/build.js",
"preview": "vite preview",
"eslint:check": "eslint --ext .js,.ts src",
"eslint:format": "eslint --fix \"src/**/*.{js,ts}\""
"eslint:check": "eslint src",
"eslint:format": "eslint --fix src"
},
"dependencies": {
"@sim-phi/extends": "^0.3.4",
Expand All @@ -17,20 +17,20 @@
"stackblur-canvas": "^2.7.0"
},
"devDependencies": {
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.1",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.25.9",
"@eslint/js": "^9.13.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-terser": "^0.4.4",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/eslint": "^8.56.9",
"@stylistic/eslint-plugin": "^2.10.0",
"@types/eslint": "^9.6.1",
"@types/md5": "^2.3.5",
"@types/prompts": "^2.4.9",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"eslint": "^8.57.0",
"eslint-plugin-rulesdir": "^0.2.2",
"picocolors": "^1.0.0",
"eslint": "^9.13.0",
"globals": "^15.11.0",
"picocolors": "^1.1.1",
"prompts": "^2.4.2",
"typescript": "^5.4.5",
"vite": "^5.2.8"
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2",
"vite": "^5.4.10"
}
}
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Phixos",
"short_name": "Phixos",
"name": "Phi\u0067ros Simulator",
"short_name": "sim-phi",
"theme_color": "#7b1fa2",
"background_color": "#f1eff6",
"icons": [{
Expand Down
4 changes: 2 additions & 2 deletions scripts/meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.9",
"version": "1.5.9.1",
"pubdate": 1611795955,
"lastupdate": 1717253833
"lastupdate": 1726269638
}
2 changes: 1 addition & 1 deletion src/components/InfoHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const table = { sp: [0, 0], ez: [1, 7], hd: [3, 13], in: [6, 15], at: [13, 16] } as const;
const table = { sp: [0, 0], ez: [1, 8], hd: [3, 13], in: [7, 15], at: [13, 16] } as const;
const keys = ['ez', 'hd', 'in', 'at'] as const;
type DifficultyLowerCase = keyof typeof table;
type Difficulty = Uppercase<DifficultyLowerCase | ''>;
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class Renderer {
this.ctxfg = this.canvasfg.getContext('2d') || fail();
this.stage.appendChild(this.canvas);
this.canvas.style.cssText = ';position:absolute;top:0px;left:0px;right:0px;bottom:0px';
console.log('Hello, Phixos!');
console.log('Hello, Phi\x67ros Simulator!');
// config
this.speed = 1;
this.lineScale = 57.6;
Expand Down
50 changes: 18 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { fixme } from '@/utils/fixme';
import { MessageHandler } from '@/components/MessageHandler';
import { AudioController } from '@/utils/AudioTools';
import { LevelInfoHandler } from '@/components/InfoHandler';
const meta = ['Phixos', version.split('.'), pubdate, lastupdate] as typeof self._i;
const meta = ['Phi\x67ros模拟器', version.split('.'), pubdate, lastupdate] as typeof self._i;
self._i = meta;
const $id = (query: string): HTMLElement => document.getElementById(query) || (() => { throw new Error(`Cannot find element: ${query}`) })();
const $ = (query: string) => document.body.querySelector(query);
Expand Down Expand Up @@ -388,6 +388,7 @@ const uploader = new FileEmitter();
selectchart.dispatchEvent(new Event('change'));
break;
}
case 'unknown': // fallthrough
default:
console.warn(`Unsupported file: ${data.pathname}`);
console.log(data.data);
Expand Down Expand Up @@ -535,8 +536,7 @@ async function playVideo(data: HTMLVideoElement, offset?: number) {
data.muted = true;
await data.play();
}
const hitImageList = new HitEvents({
// 存放点击特效
const hitImageList = new HitEvents({ // 存放点击特效
updateCallback: (i: HitImage) => nowTimeMS >= i.time + i.duration,
iterateCallback(i: HitImage) {
const tick = (nowTimeMS - i.time) / i.duration;
Expand All @@ -554,8 +554,7 @@ const hitImageList = new HitEvents({
}
}
});
const hitWordList = new HitEvents({
// 存放点击特效
const hitWordList = new HitEvents({ // 存放点击特效
updateCallback: (i: HitWord) => nowTimeMS >= i.time + i.duration,
iterateCallback(i: HitWord) {
const tick = (nowTimeMS - i.time) / i.duration;
Expand Down Expand Up @@ -603,14 +602,12 @@ const judgeManager = {
const deltaTime = note.seconds - seconds;
if (deltaTime > 0.2) break; // 跳过判定范围外的Note
if (note.type !== 1 && deltaTime > 0.16) continue;
if (deltaTime < -0.16 && note.frameCount > 4 && !note.holdStatus) {
// 超时且不为Hold拖判,判为Miss
if (deltaTime < -0.16 && note.frameCount > 4 && !note.holdStatus) { // 超时且不为Hold拖判,判为Miss
// console.log('Miss', i.name);
note.status = 2;
stat.addCombo(2, note.type);
note.scored = true;
} else if (note.type === 2) {
// Drag音符
} else if (note.type === 2) { // Drag音符
if (deltaTime > 0) {
for (const judgeEvent of list) {
if (judgeEvent.type !== 1) continue; // 跳过非Tap判定
Expand All @@ -632,20 +629,17 @@ const judgeManager = {
stat.addCombo(4, 2);
note.scored = true;
}
} else if (note.type === 4) {
// Flick音符
} else if (note.type === 4) { // Flick音符
if (deltaTime > 0 || note.status !== 4) {
for (const judgeEvent of list) {
if (judgeEvent.type !== 1) continue;
// 跳过非Tap判定
if (judgeEvent.type !== 1) continue; // 跳过非Tap判定
if (getJudgeOffset(judgeEvent, note) > width) continue;
judgeEvent.preventBad = true;
}
}
if (note.status !== 4) {
for (const judgeEvent of list) {
if (judgeEvent.type !== 3) continue;
// 跳过非Move判定
if (judgeEvent.type !== 3) continue; // 跳过非Move判定
if (getJudgeOffset(judgeEvent, note) > width) continue;
let distance = getJudgeDistance(judgeEvent, note);
let noteJudge = note;
Expand Down Expand Up @@ -677,12 +671,9 @@ const judgeManager = {
stat.addCombo(4, 4);
note.scored = true;
}
} else {
// Hold音符
if (note.type === 3 && note.holdTapTime) {
// 是否触发头判
if ((performance.now() - note.holdTapTime) * note.holdTime >= 1.6e4 * note.holdSeconds) {
// 间隔时间与bpm成反比
} else { // Hold音符
if (note.type === 3 && note.holdTapTime) { // 是否触发头判
if ((performance.now() - note.holdTapTime) * note.holdTime >= 1.6e4 * note.holdSeconds) { // 间隔时间与bpm成反比
if (note.holdStatus % 4 === 0) hitImageList.add(HitImage.perfect(note.projectX, note.projectY, note));
else if (note.holdStatus % 4 === 1) hitImageList.add(HitImage.perfect(note.projectX, note.projectY, note));
else if (note.holdStatus % 4 === 3) hitImageList.add(HitImage.good(note.projectX, note.projectY, note));
Expand All @@ -696,19 +687,16 @@ const judgeManager = {
note.holdBroken = true; // 若1帧内未按住并使其转为false,则判定为Miss
}
for (const judgeEvent of list) {
if (note.holdTapTime) {
// 头判
if (note.holdTapTime) { // 头判
if (judgeEvent.type !== 2) continue;
if (getJudgeOffset(judgeEvent, note) <= width) {
note.holdBroken = false;
break;
}
continue;
}
if (judgeEvent.type !== 1) continue;
// 跳过非Tap判定
if (judgeEvent.judged) continue;
// 跳过已触发的判定
if (judgeEvent.type !== 1) continue; // 跳过非Tap判定
if (judgeEvent.judged) continue; // 跳过已触发的判定
if (getJudgeOffset(judgeEvent, note) > width) continue;
let deltaTime2 = deltaTime;
let distance = getJudgeDistance(judgeEvent, note);
Expand Down Expand Up @@ -779,8 +767,7 @@ const judgeManager = {
}
}
};
const hitFeedbackList = new HitEvents({
// 存放点击特效
const hitFeedbackList = new HitEvents({ // 存放点击特效
updateCallback: (i: HitFeedback) => i.time++ > 0,
iterateCallback(i: HitFeedback) {
ctxfg.globalAlpha = 0.85;
Expand Down Expand Up @@ -1098,7 +1085,7 @@ function mainLoop() {
ctx.fillStyle = '#fff';
ctx.globalAlpha = 0.8;
ctx.textAlign = 'right';
ctx.fillText(`${meta[0]} v${meta[1].join('.')} - Code by lchz\x683\x3473`, (canvas.width + canvasfg.width) / 2 - lineScale * 0.1, canvas.height - lineScale * 0.1);
ctx.fillText(`Phi\x67ros Simulator v${meta[1].join('.')} - Code by lchz\x683\x3473`, (canvas.width + canvasfg.width) / 2 - lineScale * 0.1, canvas.height - lineScale * 0.1);
ctx.globalCompositeOperation = 'source-over';
}
function loopNoCanvas() {
Expand Down Expand Up @@ -1442,8 +1429,7 @@ function drawTap(note: Renderer.Note) {
ctxfg.setTransform(nsr * note.cosr, nsr * note.sinr, -nsr * note.sinr, nsr * note.cosr, note.offsetX, note.offsetY);
if (note.badTime == null) {
ctxfg.globalAlpha = note.alpha || (note.showPoint && showPoint.checked ? 0.45 : 0);
if (main.awawa) ctxfg.globalAlpha *= Math.max(1 + (timeChart - note.seconds) / 1.5, 0);
// 过线前1.5s出现
if (main.awawa) ctxfg.globalAlpha *= Math.max(1 + (timeChart - note.seconds) / 1.5, 0); // 过线前1.5s出现
noteRender.note[HL ? 'TapHL' : 'Tap'].full(ctxfg);
} else {
ctxfg.globalAlpha = 1 - clip((performance.now() - note.badTime) / 500);
Expand Down
2 changes: 1 addition & 1 deletion src/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const isUndefined = name => self[name] === undefined;
// EventTarget.constructor polyfill for Safari 14-
try {
Reflect.construct(EventTarget, []);
} catch (e) {
} catch (ignoreErr) {
self.EventTarget = function() {
this.listeners = {};
};
Expand Down
3 changes: 2 additions & 1 deletion src/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface Event {
readonly target: EventTarget;
}
interface EventTarget {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
dispatchEvent: <K extends keyof CustomEventMap>(event: CustomEventMap[K]) => boolean;
addEventListener: <K extends keyof CustomEventMap>(type: K, listener: (this: EventTarget, ev: CustomEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean) => void;
removeEventListener: <K extends keyof CustomEventMap>(type: K, listener: (this: EventTarget, ev: CustomEventMap[K]) => unknown, options?: AddEventListenerOptions | boolean) => void;
Expand Down Expand Up @@ -213,4 +214,4 @@ declare const Utils: {
escapeHTML: (str: string) => string;
addFont: (name: string, alt?: FontOptions) => Promise<unknown>;
randomUUID: () => string;
} = {};
};
Loading

0 comments on commit 11a702a

Please sign in to comment.