Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👕 ESLintのエラーを修正 #33

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ const config: Phaser.Types.Core.GameConfig = {
scene: Scenes,
}

new Phaser.Game(config)
const game = new Phaser.Game(config) // eslint-disable-line @typescript-eslint/no-unused-vars
2 changes: 0 additions & 2 deletions src/class/Band.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import bms from "bms"

export class Band {
public startBeat: number
public endBeat: number
Expand Down
24 changes: 12 additions & 12 deletions src/class/ChartPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,23 @@ export class ChartPlayer {
let bandDisplaySizeX: number = 0
let positionX: number = 0
let visible: boolean = true
if (key == 4) {
if (key === 4) {
if (laneIndex >= 1 && laneIndex <= 2) {
positionX = 361 + 186 * (laneIndex - 1)
} else if (laneIndex >= 4 && laneIndex <= 5) {
positionX = 361 + 186 * (laneIndex - 2)
}
} else if (key == 5) {
} else if (key === 5) {
if (laneIndex >= 1 && laneIndex <= 5) {
positionX = 343 + 148.5 * (laneIndex - 1)
}
} else if (key == 6) {
} else if (key === 6) {
if (laneIndex <= 2) {
positionX = 330 + 124 * laneIndex
} else if (laneIndex >= 4) {
positionX = 330 + 124 * (laneIndex - 1)
}
} else if (key == 7) {
} else if (key === 7) {
positionX = 322 + 106 * laneIndex
}
if (playConfig.noteType === "rectangle") {
Expand All @@ -128,10 +128,10 @@ export class ChartPlayer {
displaySizeY = 40
bandDisplaySizeX = displaySizeX

if (laneIndex == 1 || laneIndex == 5) {
if (laneIndex === 1 || laneIndex === 5) {
noteImage = "note-rectangle-2"
longNoteImage = "longnote-2"
} else if (laneIndex == 3) {
} else if (laneIndex === 3) {
noteImage = "note-rectangle-3"
longNoteImage = "longnote-3"
} else {
Expand Down Expand Up @@ -164,7 +164,7 @@ export class ChartPlayer {
bandDisplaySizeX = { 4: 185, 5: 147, 6: 120, 7: 103 }[key]
}

if (isLongNoteEnd && isLatestEndLongNote[laneIndex] && beatLatestEndLongNote[laneIndex] != beat) {
if (isLongNoteEnd && isLatestEndLongNote[laneIndex] && beatLatestEndLongNote[laneIndex] !== beat) {
isLatestEndLongNote[laneIndex] = false

const band = new Band(
Expand Down Expand Up @@ -208,7 +208,7 @@ export class ChartPlayer {
}

if (laneIndex >= 0 && laneIndex <= 7) {
if (!eachLinePositions.hasOwnProperty(beat)) {
if (!Object.prototype.hasOwnProperty.call(eachLinePositions, beat)) {
eachLinePositions[beat] = [positionX, positionX]
}
eachLinePositions[beat][0] = Math.min(eachLinePositions[beat][0], positionX)
Expand Down Expand Up @@ -259,7 +259,7 @@ export class ChartPlayer {
playingSec: number,
noteSpeed: number,
keySoundPlayer: KeySoundPlayer,
) {
): void {
for (const note of this.bgmLane) {
if (note.sec < playingSec) {
if (!note.isJudged) {
Expand Down Expand Up @@ -324,7 +324,7 @@ export class ChartPlayer {
this.judges[judgeIndex]++
this.combo++
for (const band of this.longNoteBands[laneIndex]) {
if (band.startBeat == note.beat) {
if (band.startBeat === note.beat) {
band.image.visible = false
break
}
Expand Down Expand Up @@ -390,7 +390,7 @@ export class ChartPlayer {
return false
}

public judgeKeyHold = (playingSec: number, laneIndex: number) => {
public judgeKeyHold = (playingSec: number, laneIndex: number): void => {
this.isHolds[laneIndex] = false
for (const note of this.lanes[laneIndex]) {
if (!note.isJudged && note.isLongEnd) {
Expand All @@ -415,7 +415,7 @@ export class ChartPlayer {
this.latestJudgeSec = playingSec
this.latestJudgeDiff = note.sec - playingSec
for (const band of this.longNoteBands[laneIndex]) {
if (band.endBeat == note.beat) {
if (band.endBeat === note.beat) {
band.image.visible = false
break
}
Expand Down
4 changes: 2 additions & 2 deletions src/class/DebugGUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class DebugGUI {
sceneFolder.add(this.params, "result")
}

public changeScene(key: string) {
public changeScene(key: string): void {
this.destroy()
this.scene.scene.start(key)
}

public destroy() {
public destroy(): void {
this.gui.destroy()
}
}
2 changes: 1 addition & 1 deletion src/class/JudgeMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class JudgeMeter {
this.rectangle = scene.add.rectangle(640 - deltaTime * 1200, 360, 1, 30, color).setDepth(20)
}

public update() {
public update(): void {
this.rectangle.setAlpha(1 - (new Date().getTime() - this.judgedTime) / 5000)
}
}
4 changes: 2 additions & 2 deletions src/class/KeySoundPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class KeySoundPlayer {
this.keySoundMap = bms.Keysounds.fromBMSChart(chart.bmsChart)._map
}

public loadKeySounds(scene: Phaser.Scene, url: string) {
public loadKeySounds(scene: Phaser.Scene, url: string): void {
Object.keys(this.keySoundMap).forEach((noteValue) => {
const soundFileName = this.keySoundMap[noteValue]
if (typeof soundFileName === "string") {
Expand All @@ -29,7 +29,7 @@ export class KeySoundPlayer {
})
}

public playKeySound(scene: Phaser.Scene, noteValue: string) {
public playKeySound(scene: Phaser.Scene, noteValue: string): void {
if (this.keySoundSet.has(noteValue)) {
scene.sound.play(noteValue)
}
Expand Down
8 changes: 4 additions & 4 deletions src/class/MusicTile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ export class MusicTile extends Phaser.GameObjects.Container {
this.add(this.jacketImage)
}

public setTitle(title: string) {
public setTitle(title: string): void {
this.titleText.setText(title)
}

public setArtist(artist: string) {
public setArtist(artist: string): void {
this.artistText.setText(artist)
}

public setNoter(noter: string) {
public setNoter(noter: string): void {
this.noterText.setText(noter)
}

public setMusic(music: Music) {
public setMusic(music: Music): void {
this.titleText.setText(music.title)
this.artistText.setText(music.artist)
this.noterText.setText(music.noter)
Expand Down
16 changes: 8 additions & 8 deletions src/class/MusicTileManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Music } from "./Music"
import { type Beatmap, type Music } from "./Music"
import { MusicTile } from "./MusicTile"

export class MusicTileManager {
Expand Down Expand Up @@ -74,15 +74,15 @@ export class MusicTileManager {
}
}

public update(time: number) {
public update(time: number): void {
for (const musicTileIndex of Array(7).keys()) {
const musicTile = this.musicTiles[musicTileIndex]
this.musicTiles[musicTileIndex].setAlpha(1 - (0.8 * Math.abs(musicTile.y - 315)) / 315)
}
this.selectedMusicTile.setAlpha(0.5 + 0.5 * Math.abs(Math.sin((time * 2 * Math.PI * 0.25) / 1000)))
}

public scroll(asc: boolean) {
public scroll(asc: boolean): void {
if (asc) {
this.scrollIndex = (this.scrollIndex + 1) % this.musicList.length
for (const musicTileIndex of Array(7).keys()) {
Expand All @@ -102,19 +102,19 @@ export class MusicTileManager {
}
}

public isPlayable(key: number, difficulty: number) {
return this.musicList[this.scrollIndex].hasOwnProperty(`beatmap_${key}k_${difficulty}`)
public isPlayable(key: number, difficulty: number): boolean {
return Object.prototype.hasOwnProperty.call(this.musicList[this.scrollIndex], `beatmap_${key}k_${difficulty}`)
}

public getMusic() {
public getMusic(): Music {
return this.musicList[this.scrollIndex]
}

public getBeatmap(key: number, difficulty: number) {
public getBeatmap(key: number, difficulty: number): Beatmap {
return this.musicList[this.scrollIndex][`beatmap_${key}k_${difficulty}`]
}

public getJacketImageKey() {
public getJacketImageKey(): string {
const selectedMusic = this.musicList[this.scrollIndex]

return `jacket-${selectedMusic.folder}/${selectedMusic.jacket}`
Expand Down
2 changes: 1 addition & 1 deletion src/class/ToggleButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ToggleButton extends Phaser.GameObjects.Container {
this.add(this.rightZone)
}

public setText(text: string) {
public setText(text: string): void {
this.text.setText(text)
}
}
16 changes: 8 additions & 8 deletions src/class/User.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export class User {
public screen_name: string
public screenName: string
public id: number
public rank: number
public performance_point: number
public performancePoint: number

constructor({
screen_name,
screenName,
id,
rank,
performance_point,
performancePoint,
}: {
screen_name: string
screenName: string
id: number
rank: number
performance_point: number
performancePoint: number
}) {
this.screen_name = screen_name
this.screenName = screenName
this.id = id
this.rank = rank
this.performance_point = performance_point
this.performancePoint = performancePoint
}

get ordinalRank(): string {
Expand Down
6 changes: 3 additions & 3 deletions src/scene/ConfigScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class ConfigScene extends Phaser.Scene {
super("config")
}

init(data: any) {
init(data: any): void {
this.playConfig = data.playConfig
this.previewTimer = new Date()
}

create() {
create(): void {
const { width, height } = this.game.canvas

this.add
Expand Down Expand Up @@ -297,7 +297,7 @@ export class ConfigScene extends Phaser.Scene {
})
}

update(time: number, dt: number) {
update(time: number, dt: number): void {
if (this.playConfig.noteType === "circle") {
this.previewNote.setTexture("note-circle-1").setDisplaySize(100, 100)
} else if (this.playConfig.noteType === "rectangle") {
Expand Down
7 changes: 4 additions & 3 deletions src/scene/CreditScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ export class CreditScene extends Phaser.Scene {
super("credit")
}

init() {}
init(): void {}

create() {
create(): void {
const { width, height } = this.game.canvas

this.add
Expand Down Expand Up @@ -56,7 +56,8 @@ export class CreditScene extends Phaser.Scene {
"",
]

const rightCredits = (process.env.CREDITS || "").split(/\\r\\n|\\n|\\r/)
const credits = process.env.CREDITS
const rightCredits = credits !== undefined && credits !== "" ? credits.split(/\\r\\n|\\n|\\r/) : []

const headerText = this.add
.text(width / 2 - 260, height / 2 - 200 - 5, "RICORA Beats", {
Expand Down
10 changes: 4 additions & 6 deletions src/scene/LoadingScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class LoadingScene extends Phaser.Scene {
super("loading")
}

preload() {
preload(): void {
this.load.image("logo", "./assets/skin/logo.png")

this.load.image("frame-title", "./assets/skin/frame_title.png")
Expand Down Expand Up @@ -144,13 +144,11 @@ export class LoadingScene extends Phaser.Scene {
})
}

create() {
const { width, height } = this.game.canvas

create(): void {
this.add.text(0, 0, "Loading...").setDepth(1)

// Web Font Loaderのロード完了判定がうまく動かないので選曲シーンで使用する文字を予め強制的に読み込む
new MusicTileManager(this, 0)
const musicTileManager = new MusicTileManager(this, 0) // eslint-disable-line @typescript-eslint/no-unused-vars
this.add.rectangle(640, 360, 1280, 720, 0x000000).setDepth(0)

this.load.on("complete", () => {
Expand All @@ -160,7 +158,7 @@ export class LoadingScene extends Phaser.Scene {
this.load.start()
}

update() {
update(): void {
if (this.hasLoadedFont && this.hasLoadedPhaser) {
this.scene.start("title")
}
Expand Down
Loading