DatingEventSceneModel.ts
2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ConfigManager } from "simba-config-manager";
import { GameRecord, getPlot, ReadonlyPlot } from "../../avg/AVG";
import { DateType } from "../../avg/EditorEnums";
import { dateSceneConfig } from "../../config/DateSceneConfig";
import { GameModelManager } from "./GameModelManager";
/**
* 剧情状态
*/
export enum DatingEventStatus {
/**剧情未解锁 */
Locked = 1,
/**新剧情 */
New,
/**剧情在进度中 */
InProgress,
/**完成剧情 */
Completed
}
export class DatingEventSceneModel {
private _id: number;
get id() { return this._id }
get config() { return ConfigManager.getConfig(dateSceneConfig, this._id); }
private _status: DatingEventStatus;
get status() { return this._status; }
set status(v: DatingEventStatus) {
if (this._status !== v) {
this._status = v;
GameRecord.recordVariables[this._recordKey + ".s"] = v;
}
}
private _firstPlot: ReadonlyPlot;
get firstPlot() { return this._firstPlot; }
set firstPlot(plot: ReadonlyPlot) {
this._firstPlot = plot;
GameRecord.recordVariables[this._recordKey + ".f"] = plot.id;
}
private _bg: string;
get background() { return this._bg; }
set background(bg: string) {
this._bg = bg;
GameRecord.recordVariables[this._recordKey + ".bg"] = bg;
}
private _recordKey: string;
constructor(id: number) {
this._id = id;
this._recordKey = "de" + this._id;
this._bg = "";
}
async initFromRecords() {
this._status = GameRecord.recordVariables[this._recordKey + ".s"] as number || DatingEventStatus.Locked;
let inProgress = GameModelManager.checkBranchIsInProgress(this.id);
if (inProgress) {
this._status = DatingEventStatus.InProgress;
}
let comp = GameModelManager.checkBranchIsComplete(this.id);
if (comp) {
this._status = DatingEventStatus.Completed;
}
let firstPlotId = this.config.DateType === DateType.Date_Normal ? GameRecord.recordVariables[this._recordKey + ".f"] as number : this.config.start_plot_id;
this._firstPlot = (await getPlot(firstPlotId))!;
this._bg = GameRecord.recordVariables[this._recordKey + ".bg"] as string || "";
}
private _isExtra: boolean = false;
get isExtra() { return this._isExtra; }
set isExtra(isExtra: boolean) {
this._isExtra = isExtra;
}
}