class Level {
  levelCompleteCallback: VoidFunction;
  levelCheckCallback: () => boolean;
  levelSetupCallback: VoidFunction;
  levelUpdateCallback: VoidFunction;
  levelResetCallback: VoidFunction;
  isCompleted: boolean = false;
  isSetup: boolean = false;

  constructor(
    levelSetupCallback: VoidFunction,
    levelUpdateCallback: VoidFunction,
    levelCompleteCallback: VoidFunction,
    levelCheckCallback: () => boolean,
    levelResetCallback: VoidFunction = () => {}
  ) {
    this.levelSetupCallback = levelSetupCallback;
    this.levelCompleteCallback = levelCompleteCallback;
    this.levelCheckCallback = levelCheckCallback;
    this.levelUpdateCallback = levelUpdateCallback;
    this.levelResetCallback = levelResetCallback;
  }

  setup() {
    this.levelSetupCallback();
  }

  update() {
    if (!this.isSetup) {
      this.setup();
      this.isSetup = true;
    }
    this.levelUpdateCallback();
    if (this.levelCheckCallback() && !this.isCompleted) {
      this.levelCompleteCallback();
      this.isCompleted = true;
    }
  }

  reset() {
    this.levelResetCallback();
    this.isCompleted = false;
  }
}

//nextlevel
//mindkeeper
//pupeteer

export default Level;
