import { PegjsService } from "../services/pegjs.service";
import { QuestEntryModel } from "./atlasData/questEntry.model";
import { Deserialize } from "./util/deserialize.model";

export class GlobalGameplaySetupModel implements Deserialize {
  QuestEntries: QuestEntryModel[];

  public deserialize(raw: string): this {
    const rawData = PegjsService.parse(raw);
    Object.assign(this, rawData);
    this.QuestEntries = this.QuestEntries.map(i => new QuestEntryModel().deserialize(i));
    return this;
  }

  public toJSON(): string {
    return PegjsService.format(this, true);
  }
}
