mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-08 01:01:36 +08:00

- When adding a new event while an existing event is selected, the new event will now have the selected event as parent - Generated event IDs now follow the SEGA convention more closely
26 lines
808 B
TypeScript
26 lines
808 B
TypeScript
import { Action } from "../../core/undo/Action";
|
|
import { QuestModel } from "../model/QuestModel";
|
|
import { QuestEventDagModel } from "../model/QuestEventDagModel";
|
|
import { QuestEventModel } from "../model/QuestEventModel";
|
|
|
|
export class CreateEventAction implements Action {
|
|
readonly description: string;
|
|
|
|
constructor(
|
|
private readonly quest: QuestModel,
|
|
private readonly event_dag: QuestEventDagModel,
|
|
private readonly event: QuestEventModel,
|
|
private readonly parent_event?: QuestEventModel,
|
|
) {
|
|
this.description = `Add event ${event.id}`;
|
|
}
|
|
|
|
undo(): void {
|
|
this.quest.remove_event(this.event_dag, this.event);
|
|
}
|
|
|
|
redo(): void {
|
|
this.quest.add_event(this.event, this.parent_event ? [this.parent_event] : [], []);
|
|
}
|
|
}
|