<commit_before>"use strict";

function init() {
    // Everything is so nice and highly abstracted now
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");

    var game = new Game(ctx);
    var marathon = new MarathonLevel();

    var images = [
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image()
      ];
    images[0].src = 'resources/40px_Moon.png';
    images[1].src = 'resources/gameover.png';
    images[2].src = 'resources/hackrva.png';
    images[3].src = 'resources/cutScene1.png';
    images[4].src = 'resources/cutScene2.png';
    images[5].src = 'resources/cutScene3.png';
    images[6].src = 'resources/cutScene4.png';
    images[7].src = 'resources/cutScene5.png';
    images[8].src = 'resources/cutScene6.png';
    images[9].src = 'resources/cutScene7.png';
    images[10].src = 'resources/cutScene8.png';
    images[11].src = 'resources/cutScene9.png';
    images[12].src = 'resources/cutScene10.png';
    images[13].src = 'resources/menuBackground.png';

    var media = [
        new Audio(),
        new Audio(),
        new Audio(),
        new Audio(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest()];
    media[0].src = 'resources/theme1.ogg';
    media[1].src = 'resources/blaster.ogg';
    media[2].src = 'resources/ambient.ogg';
    media[3].src = 'resources/torpedo.ogg';
    var requests = [
        "resources/random_text.json",
        "resources/level_one.json",
        "resources/level_two.json",
        "resources/level_three.json",
        "resources/level_four.json",
        "resources/level_five.json",
        "resources/level_six.json",
        "resources/level_seven.json",
        "resources/level_eight.json",
        "resources/level_nine.json",
        "resources/level_ten.json"];
    var jsonStart = 4;
    for(var c = jsonStart; c < media.length; c++) {
        media[c].open("GET", requests[c - jsonStart], true);
        media[c].responseType = "json";
        media[c].send();
    }

    var playScreen = new PlayScreen(ctx, game);
    game.setScreen(playScreen);

    var menuScreen = new MenuScreen(ctx);
    var optionScreen = new MenuScreen(ctx);
    // Allow just clicking through splash screens
    var splashScreen = new TimedSplashScreen(ctx, 3, menuScreen);
    var gameoverScreen = new TimedSplashScreen(ctx, 3, menuScreen);


    // Use prototype well enough
    function MainLevel(ctx, next, request, render) {
        SplashScreen.call(this, ctx, next);
        if(render !== undefined)
            this.render = render;
        this.level_request = request;
    }
    MainLevel.prototype = new SplashScreen();
    MainLevel.prototype.game = game;
    MainLevel.prototype.nextScreen = null;
    MainLevel.prototype.render = function(ctx, currentTime, dt) {
        ctx.fillStyle = "#FFFFFF";
        ctx.font = "20px Arial";
        if("image" in this){
            ctx.drawImage(this.image,0,0,800,600);
        }
        else{
            ctx.fillText("Level Intro Placeholder", 200, 200);
        }
    }
    MainLevel.prototype.close = function() {
        this.game.playLevel(new Level(this.level_request.response));
        // Set the win screen
        this.game.setWinScreen(this.nextScreen);
        SplashScreen.prototype.close.call(this);
    }

    // We'll have ten levels for some reason
    var levelScreens = new Array(10);
    for(var c = 0; c < levelScreens.length; c++) {
        levelScreens[c] = new MainLevel(ctx, playScreen, media[5 + c]);
    }
    for(var c = 0; c < levelScreens.length - 1; c++) {
        levelScreens[c].nextScreen = levelScreens[c + 1];
    }
    gameoverScreen.image = images[1];
    levelScreens[0].image = images[3];
    levelScreens[1].image = images[4];
    levelScreens[2].image = images[5];
    levelScreens[3].image = images[6];
    levelScreens[4].image = images[7];
    levelScreens[5].image = images[8];
    levelScreens[6].image = images[9];
    levelScreens[7].image = images[10];
    levelScreens[8].image = images[11];
    levelScreens[9].image = images[12];

    game.setLossScreen(gameoverScreen);

    splashScreen.image = images[2];<commit_msg>Added placeholder for victory screen<commit_after>"use strict";

function init() {
    // Everything is so nice and highly abstracted now
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");

    var game = new Game(ctx);
    var marathon = new MarathonLevel();

    var images = [
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image(),
        new Image()
      ];
    images[0].src = 'resources/40px_Moon.png';
    images[1].src = 'resources/gameover.png';
    images[2].src = 'resources/hackrva.png';
    images[3].src = 'resources/cutScene1.png';
    images[4].src = 'resources/cutScene2.png';
    images[5].src = 'resources/cutScene3.png';
    images[6].src = 'resources/cutScene4.png';
    images[7].src = 'resources/cutScene5.png';
    images[8].src = 'resources/cutScene6.png';
    images[9].src = 'resources/cutScene7.png';
    images[10].src = 'resources/cutScene8.png';
    images[11].src = 'resources/cutScene9.png';
    images[12].src = 'resources/cutScene10.png';
    images[13].src = 'resources/menuBackground.png';

    var media = [
        new Audio(),
        new Audio(),
        new Audio(),
        new Audio(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest(),
        new XMLHttpRequest()];
    media[0].src = 'resources/theme1.ogg';
    media[1].src = 'resources/blaster.ogg';
    media[2].src = 'resources/ambient.ogg';
    media[3].src = 'resources/torpedo.ogg';
    var requests = [
        "resources/random_text.json",
        "resources/level_one.json",
        "resources/level_two.json",
        "resources/level_three.json",
        "resources/level_four.json",
        "resources/level_five.json",
        "resources/level_six.json",
        "resources/level_seven.json",
        "resources/level_eight.json",
        "resources/level_nine.json",
        "resources/level_ten.json"];
    var jsonStart = 4;
    for(var c = jsonStart; c < media.length; c++) {
        media[c].open("GET", requests[c - jsonStart], true);
        media[c].responseType = "json";
        media[c].send();
    }

    var playScreen = new PlayScreen(ctx, game);
    game.setScreen(playScreen);

    var menuScreen = new MenuScreen(ctx);
    var optionScreen = new MenuScreen(ctx);
    // Allow just clicking through splash screens
    var splashScreen = new TimedSplashScreen(ctx, 3, menuScreen);
    var gameoverScreen = new TimedSplashScreen(ctx, 3, menuScreen);
    var victoryScreen = new SplashScreen(ctx, splashScreen);

    victoryScreen.render = function(ctx, currentTime, dt) {
        ctx.fillStyle = "#EE1111";
        ctx.textAlign = "center";
        ctx.textBaseline = "top";
        ctx.fillText("The moon is saved!", 400, 300);
    }

    // Use prototype well enough
    function MainLevel(ctx, next, request, render) {
        SplashScreen.call(this, ctx, next);
        if(render !== undefined)
            this.render = render;
        this.level_request = request;
    }
    MainLevel.prototype = new SplashScreen();
    MainLevel.prototype.game = game;
    MainLevel.prototype.nextScreen = null;
    MainLevel.prototype.render = function(ctx, currentTime, dt) {
        ctx.fillStyle = "#FFFFFF";
        ctx.font = "20px Arial";
        if("image" in this){
            ctx.drawImage(this.image,0,0,800,600);
        }
        else{
            ctx.fillText("Level Intro Placeholder", 200, 200);
        }
    }
    MainLevel.prototype.close = function() {
        this.game.playLevel(new Level(this.level_request.response));
        // Set the win screen
        this.game.setWinScreen(this.nextScreen);
        SplashScreen.prototype.close.call(this);
    }

    // We'll have ten levels for some reason
    var levelScreens = new Array(10);
    for(var c = 0; c < levelScreens.length; c++) {
        levelScreens[c] = new MainLevel(ctx, playScreen, media[5 + c]);
    }
    for(var c = 0; c < levelScreens.length - 1; c++) {
        levelScreens[c].nextScreen = levelScreens[c + 1];
    }
    levelScreens[levelScreens.length - 1].nextScreen = victoryScreen;
    gameoverScreen.image = images[1];
    levelScreens[0].image = images[3];
    levelScreens[1].image = images[4];
    levelScreens[2].image = images[5];
    levelScreens[3].image = images[6];
    levelScreens[4].image = images[7];
    levelScreens[5].image = images[8];
    levelScreens[6].image = images[9];
    levelScreens[7].image = images[10];
    levelScreens[8].image = images[11];
    levelScreens[9].image = images[12];

    game.setLossScreen(gameoverScreen);

    splashScreen.image = images[2];
{'fraction_non_alphanumeric': 0.14211672022390381, 'fraction_numerical': 0.019384264538198404, 'mean_word_length': 2.5759822090437363, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6734147', 'n_tokens_mistral': 3082, 'n_tokens_neox': 2937, 'n_words': 621}