async playLevel(levelNumber) {
    const { tower, warriorName, epic } = this.profile;
    const levelConfig = getLevelConfig(tower, levelNumber, warriorName, epic);

    const level = getLevel(levelConfig);
    printLevel(level);

    const playerCode = this.profile.readPlayerCode();
    const levelResult = runLevel(levelConfig, playerCode);

    if (!this.silencePlay) {
      await printPlay(levelResult.events, this.delay);
    }

    printSeparator();

    if (!levelResult.passed) {
      printFailureLine(
        `Sorry, you failed level ${levelNumber}. Change your script and try again.`,
      );

      if (levelConfig.clue && !this.profile.isShowingClue()) {
        const showClue =
          this.assumeYes ||
          (await requestConfirmation(
            'Would you like to read the additional clues for this level?',
          ));
        if (showClue) {
          this.profile.requestClue();
          this.generateProfileFiles();
          printSuccessLine(
            `See ${this.profile.getReadmeFilePath()} for the clues.`,
          );
        }
      }

      return false;
    }

    const hasNextLevel = this.profile.tower.hasLevel(levelNumber + 1);

    if (hasNextLevel) {
      printSuccessLine('Success! You have found the stairs.');
    } else {
      printSuccessLine(
        'CONGRATULATIONS! You have climbed to the top of the tower.',
      );
    }

    const scoreParts = getLevelScore(levelResult, levelConfig);
    const totalScore = Object.values(scoreParts).reduce(
      (sum, value) => sum + value,
      0,
    );
    const grade = (totalScore * 1.0) / levelConfig.aceScore;
    printLevelReport(this.profile, scoreParts, totalScore, grade);
    this.profile.tallyPoints(levelNumber, totalScore, grade);

    if (this.profile.isEpic()) {
      if (!hasNextLevel && !this.practiceLevel) {
        printTowerReport(this.profile);
      }
    } else {
      await this.requestNextLevel();
    }

    return hasNextLevel;
  }
/**
   * Plays the level with the given number.
   *
   * @param {number} levelNumber The number of the level to play.
   *
   * @returns {boolean} Whether playing can continue or not (for epic mode),
   */
Plays the level with the given number.
@param {number} levelNumber The number of the level to play.

@returns {boolean} Whether playing can continue or not (for epic mode).
Plays the level with the given number . @param { number } levelNumber The number of the level to play . @returns { boolean } Whether playing can continue or not ( for epic mode ) .
async playLevel(levelNumber) {
    const { tower, warriorName, epic } = this.profile;
    const levelConfig = getLevelConfig(tower, levelNumber, warriorName, epic);
    const level = getLevel(levelConfig);
    printLevel(level);
    const playerCode = this.profile.readPlayerCode();
    const levelResult = runLevel(levelConfig, playerCode);
    if (!this.silencePlay) {
      await printPlay(levelResult.events, this.delay);
    }
    printSeparator();
    if (!levelResult.passed) {
      printFailureLine(
        `Sorry, you failed level ${levelNumber}. Change your script and try again.`,
      );
      if (levelConfig.clue && !this.profile.isShowingClue()) {
        const showClue =
          this.assumeYes ||
          (await requestConfirmation(
            'Would you like to read the additional clues for this level?',
          ));
        if (showClue) {
          this.profile.requestClue();
          this.generateProfileFiles();
          printSuccessLine(
            `See ${this.profile.getReadmeFilePath()} for the clues.`,
          );
        }
      }
      return false;
    }
    const hasNextLevel = this.profile.tower.hasLevel(levelNumber + 1);
    if (hasNextLevel) {
      printSuccessLine('Success! You have found the stairs.');
    } else {
      printSuccessLine(
        'CONGRATULATIONS! You have climbed to the top of the tower.',
      );
    }
    const scoreParts = getLevelScore(levelResult, levelConfig);
    const totalScore = Object.values(scoreParts).reduce(
      (sum, value) => sum + value,
      0,
    );
    const grade = (totalScore * 1.0) / levelConfig.aceScore;
    printLevelReport(this.profile, scoreParts, totalScore, grade);
    this.profile.tallyPoints(levelNumber, totalScore, grade);
    if (this.profile.isEpic()) {
      if (!hasNextLevel && !this.practiceLevel) {
        printTowerReport(this.profile);
      }
    } else {
      await this.requestNextLevel();
    }
    return hasNextLevel;
  }
async playLevel ( levelNumber ) { const { tower , warriorName , epic } = this . profile ; const levelConfig = getLevelConfig ( tower , levelNumber , warriorName , epic ) ; const level = getLevel ( levelConfig ) ; printLevel ( level ) ; const playerCode = this . profile . readPlayerCode ( ) ; const levelResult = runLevel ( levelConfig , playerCode ) ; if ( ! this . silencePlay ) { await printPlay ( levelResult . events , this . delay ) ; } printSeparator ( ) ; if ( ! levelResult . passed ) { printFailureLine ( ` ${ levelNumber } ` , ) ; if ( levelConfig . clue && ! this . profile . isShowingClue ( ) ) { const showClue = this . assumeYes || ( await requestConfirmation ( 'Would you like to read the additional clues for this level?' , ) ) ; if ( showClue ) { this . profile . requestClue ( ) ; this . generateProfileFiles ( ) ; printSuccessLine ( ` ${ this . profile . getReadmeFilePath ( ) } ` , ) ; } } return false ; } const hasNextLevel = this . profile . tower . hasLevel ( levelNumber + 1 ) ; if ( hasNextLevel ) { printSuccessLine ( 'Success! You have found the stairs.' ) ; } else { printSuccessLine ( 'CONGRATULATIONS! You have climbed to the top of the tower.' , ) ; } const scoreParts = getLevelScore ( levelResult , levelConfig ) ; const totalScore = Object . values ( scoreParts ) . reduce ( ( sum , value ) => sum + value , 0 , ) ; const grade = ( totalScore * 1.0 ) / levelConfig . aceScore ; printLevelReport ( this . profile , scoreParts , totalScore , grade ) ; this . profile . tallyPoints ( levelNumber , totalScore , grade ) ; if ( this . profile . isEpic ( ) ) { if ( ! hasNextLevel && ! this . practiceLevel ) { printTowerReport ( this . profile ) ; } } else { await this . requestNextLevel ( ) ; } return hasNextLevel ; }
Plays the level with the given number.
Plays the level with the given number .