2025-05-13 20:31:44 +08:00
|
|
|
|
|
|
|
|
|
2025-05-14 20:05:17 +08:00
|
|
|
import { DataBlock } from "../types/global";
|
2025-05-14 19:22:21 +08:00
|
|
|
import { StorageManager } from "./StorageManager"
|
2025-05-13 20:31:44 +08:00
|
|
|
|
|
|
|
|
export class DOBlock {
|
|
|
|
|
|
2025-05-14 20:05:17 +08:00
|
|
|
private data: DataBlock
|
2025-05-13 20:31:44 +08:00
|
|
|
private preset: boolean = false//预设格子
|
|
|
|
|
private correct: number = 0;
|
|
|
|
|
private checked: boolean = false//是否正确
|
|
|
|
|
|
|
|
|
|
|
2025-05-14 20:05:17 +08:00
|
|
|
constructor(dataBlock: DataBlock, preset: boolean, correct: number) {
|
2025-05-13 20:31:44 +08:00
|
|
|
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_show(): number {
|
|
|
|
|
return this.data.show
|
|
|
|
|
}
|
|
|
|
|
public set_show(show: number): void {
|
|
|
|
|
this.data.show = show
|
2025-05-17 16:36:42 +08:00
|
|
|
this.checked = show == this.get_correct()
|
2025-05-22 14:54:48 +08:00
|
|
|
StorageManager.getInstance().onStageChanged()
|
2025-05-13 20:31:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get_score(): number {
|
|
|
|
|
return this.data.score
|
|
|
|
|
}
|
|
|
|
|
public set_score(score: number): void {
|
|
|
|
|
this.data.score = score
|
2025-05-22 14:54:48 +08:00
|
|
|
StorageManager.getInstance().onStageChanged()
|
2025-05-13 20:31:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get_notes(): Array<number> {
|
|
|
|
|
return this.data.notes
|
|
|
|
|
}
|
2025-05-15 21:36:03 +08:00
|
|
|
public add_note(noteNumber: number): void {
|
2025-05-13 20:31:44 +08:00
|
|
|
if (this.data.notes.indexOf(noteNumber) < 0) {
|
|
|
|
|
this.data.notes.push(noteNumber)
|
2025-05-22 14:54:48 +08:00
|
|
|
StorageManager.getInstance().onStageChanged()
|
2025-05-13 20:31:44 +08:00
|
|
|
}
|
2025-05-15 21:36:03 +08:00
|
|
|
}
|
|
|
|
|
public remove_note(noteNumber: number): void {
|
|
|
|
|
var find = this.data.notes.indexOf(noteNumber)
|
|
|
|
|
if (find >= 0) {
|
|
|
|
|
this.data.notes.splice(find, 1)
|
2025-05-22 14:54:48 +08:00
|
|
|
StorageManager.getInstance().onStageChanged()
|
2025-05-15 21:36:03 +08:00
|
|
|
}
|
2025-05-13 20:31:44 +08:00
|
|
|
}
|
|
|
|
|
public clean_notes(): void {
|
|
|
|
|
if (this.data.notes.length > 0) {
|
|
|
|
|
this.data.notes = new Array()
|
2025-05-22 14:54:48 +08:00
|
|
|
StorageManager.getInstance().onStageChanged()
|
2025-05-13 20:31:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//====================================持久化数据
|
|
|
|
|
|
|
|
|
|
public get_preset(): boolean {
|
|
|
|
|
return this.preset
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get_correct(): number {
|
|
|
|
|
return this.correct
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public get_checked(): boolean {
|
|
|
|
|
return this.checked
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|