格式化代码
This commit is contained in:
@@ -1,81 +1,79 @@
|
||||
|
||||
|
||||
import { DataBlock } from "../types/global";
|
||||
import type { DataBlock } from "../types/global"
|
||||
import { StorageManager } from "./StorageManager"
|
||||
|
||||
export class DOBlock {
|
||||
private data: DataBlock
|
||||
private preset: boolean = false// 预设格子
|
||||
private correct: number = 0
|
||||
private checked: boolean = false// 是否正确
|
||||
|
||||
private data: DataBlock
|
||||
private preset: boolean = false//预设格子
|
||||
private correct: number = 0;
|
||||
private checked: boolean = false//是否正确
|
||||
|
||||
constructor(dataBlock: DataBlock, preset: boolean, correct: number) {
|
||||
this.data = dataBlock
|
||||
this.preset = preset
|
||||
this.correct = correct
|
||||
this.checked = preset || (dataBlock.show == correct)
|
||||
}
|
||||
|
||||
constructor(dataBlock: DataBlock, preset: boolean, correct: number) {
|
||||
this.data = dataBlock
|
||||
this.preset = preset
|
||||
this.correct = correct
|
||||
this.checked = preset || (dataBlock.show == correct)
|
||||
}
|
||||
// ====================================持久化数据
|
||||
public get_index(): number {
|
||||
return this.data.index
|
||||
}
|
||||
|
||||
//====================================持久化数据
|
||||
public get_index(): number {
|
||||
return this.data.index
|
||||
}
|
||||
public get_show(): number {
|
||||
return this.data.show
|
||||
}
|
||||
|
||||
public get_show(): number {
|
||||
return this.data.show
|
||||
}
|
||||
public set_show(show: number): void {
|
||||
this.data.show = show
|
||||
this.checked = show == this.get_correct()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
public set_show(show: number): void {
|
||||
this.data.show = show
|
||||
this.checked = show == this.get_correct()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_score(): number {
|
||||
return this.data.score
|
||||
}
|
||||
public set_score(score: number): void {
|
||||
this.data.score = score
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
public get_score(): number {
|
||||
return this.data.score
|
||||
}
|
||||
|
||||
public get_notes(): Array<number> {
|
||||
return this.data.notes
|
||||
}
|
||||
public add_note(noteNumber: number): void {
|
||||
if (this.data.notes.indexOf(noteNumber) < 0) {
|
||||
this.data.notes.push(noteNumber)
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
public remove_note(noteNumber: number): void {
|
||||
var find = this.data.notes.indexOf(noteNumber)
|
||||
if (find >= 0) {
|
||||
this.data.notes.splice(find, 1)
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
public clean_notes(): void {
|
||||
if (this.data.notes.length > 0) {
|
||||
this.data.notes = new Array()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
//====================================持久化数据
|
||||
public set_score(score: number): void {
|
||||
this.data.score = score
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_preset(): boolean {
|
||||
return this.preset
|
||||
public get_notes(): Array<number> {
|
||||
return this.data.notes
|
||||
}
|
||||
|
||||
public add_note(noteNumber: number): void {
|
||||
if (!this.data.notes.includes(noteNumber)) {
|
||||
this.data.notes.push(noteNumber)
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
|
||||
public get_correct(): number {
|
||||
return this.correct
|
||||
public remove_note(noteNumber: number): void {
|
||||
const find = this.data.notes.indexOf(noteNumber)
|
||||
if (find >= 0) {
|
||||
this.data.notes.splice(find, 1)
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
|
||||
public get_checked(): boolean {
|
||||
return this.checked
|
||||
public clean_notes(): void {
|
||||
if (this.data.notes.length > 0) {
|
||||
this.data.notes = []
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
// ====================================持久化数据
|
||||
|
||||
public get_preset(): boolean {
|
||||
return this.preset
|
||||
}
|
||||
|
||||
public get_correct(): number {
|
||||
return this.correct
|
||||
}
|
||||
|
||||
}
|
||||
public get_checked(): boolean {
|
||||
return this.checked
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user