<commit_before>ig.module(
    'game.main'
)
.requires(
    'impact.game',
    'impact.debug.debug',
    'game.levels.basic',
    /* Spell/Arte Catalogs */
    'game.entities.catalogs.artes',
    'game.entities.catalogs.spells',
    'game.entities.misc.pointer',

    /* spell, arte menus */
    'game.entities.menus.artemenu',
    'game.entities.menus.spellmenu',

    /* Arte boxes for arte menu */
    'game.entities.menus.arteboxA',
    'game.entities.menus.arteboxB',
    'game.entities.menus.arteboxC',
    'game.entities.menus.arteboxD',

    /* Arte skill level increase/decrease */
    'game.entities.menus.increaseLightningBlade',
    'game.entities.menus.decreaseLightningBlade',
    'game.entities.menus.decreaseHellPyre', 
    'game.entities.menus.increaseHellPyre',
    'game.entities.menus.increaseSonicThrust',
    'game.entities.menus.decreaseSonicThrust',
    'game.entities.menus.decreaseSuperSonicThrust',
    'game.entities.menus.increaseSuperSonicThrust',

    /* Spell boxes for spell menu */
    'game.entities.menus.spellboxA',
    'game.entities.menus.spellboxB',
    'game.entities.menus.spellboxC',
    'game.entities.menus.spellboxD',

    /* Spell skill level increase/decrease */
    'game.entities.menus.decreaseFireball',
    'game.entities.menus.increaseFireball',
    'game.entities.menus.decreaseHeal',
    'game.entities.menus.increaseHeal',
    'game.entities.menus.decreaseLightning',
    'game.entities.menus.increaseLightning',
    'game.entities.menus.decreaseWind',
    'game.entities.menus.increaseWind',

    /* Menu screen */
    'game.entities.menus.transmenu',

    /* Plugins */
    'plugins.camera.camera',
    'plugins.font-sugar.font',
    'plugins.hud.hud'
)

.defines(function(){
    MyGame = ig.Game.extend({
        /* Fonts */
        font: new ig.Font('media/04b03.font.png'),
        fontContent10: new ig.Font('media/verdana_10.font.png',  { fontColor: '#E5E5E5', letterSpacing: -1 }),

        /* Game images */
        statusScreen: new ig.Image('media/statusScreen.png'), // Status Screen image
        transScreen:  new ig.Image('media/transScreen.png'), // Artes Screen Image
        artesBox: new ig.Image('media/artebox.png'), // Arte box
        kratosMugshot: new ig.Image('media/kratos.png'), // Kratos mugshot
        lightningBladeDescription: new ig.Image('media/description.png'),

        /* Arte Description booleans */
        displayedLightningBladeDescription: false,  
        displayedHellPyreDescription: false,
        displayedSonicThrustDescription: false,
        displayedSuperSonicThrustDescription: false, 

        /* Spell Description booleans */
        displayedFireBallDescription: false,
        displayedLightningDescription: false,
        displayedWindDescription: false,
        displayedHealDescription: false,


        /* Physics Properties */
        gravity: 300, // How much does gravity affect all the entities in the game world?

        /* Camera properties */
        camera: null, // Set the initial camera to be null
        lastCheckpoint: null, // Set initial checkpoint to null 
        playerSpawnPos: {x: 0, y: 0}, // Set initial player spawn point to 0, 0

        /* Booleans for control */
        menuVisible: false, // Used to make menus stay open, prevents duplicate re-spawning of menus
        gameState: null, // Used for controlling the state of the game, i.e: equipping, viewing stats, etc

        /* Pointer properties */
        pointer: null,
        arteMenu: null,
        spawnedArteBoxes: false,
        artesCatalog: new ig.global.ArtesCatalog(),
        spellsCatalog: new ig.global.SpellsCatalog(),

        hud: new ig.hud(),

        /* Bind keys here, set up initial variables */
        init: function(){
            /* Set up camera plugin */
            var player = ig.game.getEntitiesByType('EntityPlayer')[0];
            // Initiate camera plugin, which takes width and height as parameters for the constructor
            this.camera = new Camera( ig.system.width/4, ig.system.height/3, 5 );
            // How far should the camera look ahead?
            this.camera.trap.size.x = ig.system.width/10;
            this.camera.trap.size.y = ig.system.height/3;
            this.camera.lookAhead.x = ig.ua.mobile ? ig.system.width/6 : 0;
            // Bind key inputs
            ig.input.bind(ig.KEY.MOUSE1,     'leftClick' );
            ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
            ig.input.bind(ig.KEY.RIGHT_ARROW, 'right');
            ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
            ig.input.bind(ig.KEY.UP_ARROW, 'up');
            ig.input.bind(ig.KEY.X, 'jump');
            ig.input.bind(ig.KEY.A, 'attack');
            ig.input.bind(ig.KEY.ENTER, 'menu');
            ig.input.bind(ig.KEY.ESC, 'escape');

            // Load the first level, basic.js
            this.loadLevel(LevelBasic);
            this.pointer = this.spawnEntity(EntityPointer, 100, 100);
            this.arteMenu = this.spawnEntity(EntityArteMenu, ig.system.width / 2, 8);
            this.spellMenu = this.spawnEntity(EntitySpellMenu, ig.system.width / 2 + 64, 8);
        },

        // Here we set up menu interactions, camera updates
        update: function() {
            this.parent();
            this.arteMenu.pos.x = ig.game.screen.x + 250;
            this.arteMenu.pos.y = 8;
            this.spellMenu.pos.x = ig.game.screen.x + 250 - 32
            this.spellMenu.pos.y = 8;
            //this.pointer = this.spawnEntity(EntityPlayer, 100, 100);
            // The camera plugin "follow" method takes an entity as input.
            // Pass in the player entity. 
            this.camera.follow( this.player );
            // If user presses enter, and menu is not showing...
            // ....display the stat screen menu
            if(ig.input.pressed('menu') && !this.menuVisible){
                // Set the game state to be 'stats', which means we
                // are viewing the status screen
                this.gameState = 'stats';
                // Toggle menuVisible so the user cannot spawn multiple
                // copies of the menu
                this.menuVisible = true;
            }
            
        },

        // loadLevel is called when a level is loaded
        loadLevel: function( level ) {        
            this.parent( level );

            // Set up checkpoint data for respawning of player
            // Grab an instance of the player
            this.player = this.getEntitiesByType( EntityPlayer )[0];
            // Set the last checkpoint to be null
            this.lastCheckpoint = null;
            // Set the player spawn position to be the initial position
            // as set from Weltmeister. 
            this.playerSpawnPos = {
                x: this.player.pos.x,
                y: this.player.pos.y
            };
            
            // Set camera max and reposition trap
            this.camera.max.x = this.collisionMap.width * this.collisionMap.tilesize - ig.system.width;
            this.camera.max.y = this.collisionMap.height * this.collisionMap.tilesize - ig.system.height;
            
            // Set the camera to follow the player
            this.camera.set( this.player );
        },

        // Method for respawning the player
        // repspawnPlayerAtLastCheckpoint (x, y)
        //    x: number
        //       - the x position of the entity
        //    y: number
        //       - the y position of the entity
        respawnPlayerAtLastCheckpoint: function(x,y){
            var pos = this.playerSpawnPos;
            // If one of the checkpoints were triggered, call
            // the getSpawnPos method from the checkpoint entity, respawn.js
            if(this.lastCheckpoint){
                // Get new player position and save it
                pos = this.lastCheckpoint.getSpawnPos()
            }
            // Respawn the player at the given x, y position
            this.player = this.spawnEntity(EntityPlayer, pos.x, pos.y);
        },

        // Method for setting the game class to be game over
        gameOver: function(){
            ig.system.setGame(GameOverScreen);
        },

        // Draw method, used for drawing images, text and menus
        draw: function(){
            this.parent();

            /* Begin drawing spell menu */
            if(this.gameState === 'spellsMenu' && this.menuVisible && this.gameState !== 'artesMenu'){
                var player = ig.game.getEntitiesByType('EntityPlayer')[0];

                // Draw spells menu
                if(typeof this.getEntityByName('transparentmenu') === 'undefined'){
                    this.spawnEntity(EntityTransMenu, ig.game.screen.x, 0);
                }<commit_msg>Adding function for generating random integers within a range<commit_after>ig.module(
    'game.main'
)
.requires(
    'impact.game',
    'impact.debug.debug',
    'game.levels.basic',
    /* Spell/Arte Catalogs */
    'game.entities.catalogs.artes',
    'game.entities.catalogs.spells',
    'game.entities.misc.pointer',

    /* spell, arte menus */
    'game.entities.menus.artemenu',
    'game.entities.menus.spellmenu',

    /* Arte boxes for arte menu */
    'game.entities.menus.arteboxA',
    'game.entities.menus.arteboxB',
    'game.entities.menus.arteboxC',
    'game.entities.menus.arteboxD',

    /* Arte skill level increase/decrease */
    'game.entities.menus.increaseLightningBlade',
    'game.entities.menus.decreaseLightningBlade',
    'game.entities.menus.decreaseHellPyre', 
    'game.entities.menus.increaseHellPyre',
    'game.entities.menus.increaseSonicThrust',
    'game.entities.menus.decreaseSonicThrust',
    'game.entities.menus.decreaseSuperSonicThrust',
    'game.entities.menus.increaseSuperSonicThrust',

    /* Spell boxes for spell menu */
    'game.entities.menus.spellboxA',
    'game.entities.menus.spellboxB',
    'game.entities.menus.spellboxC',
    'game.entities.menus.spellboxD',

    /* Spell skill level increase/decrease */
    'game.entities.menus.decreaseFireball',
    'game.entities.menus.increaseFireball',
    'game.entities.menus.decreaseHeal',
    'game.entities.menus.increaseHeal',
    'game.entities.menus.decreaseLightning',
    'game.entities.menus.increaseLightning',
    'game.entities.menus.decreaseWind',
    'game.entities.menus.increaseWind',

    /* Menu screen */
    'game.entities.menus.transmenu',

    /* Plugins */
    'plugins.camera.camera',
    'plugins.font-sugar.font',
    'plugins.hud.hud'
)

.defines(function(){
    MyGame = ig.Game.extend({
        /* Fonts */
        font: new ig.Font('media/04b03.font.png'),
        fontContent10: new ig.Font('media/verdana_10.font.png',  { fontColor: '#E5E5E5', letterSpacing: -1 }),

        /* Game images */
        statusScreen: new ig.Image('media/statusScreen.png'), // Status Screen image
        transScreen:  new ig.Image('media/transScreen.png'), // Artes Screen Image
        artesBox: new ig.Image('media/artebox.png'), // Arte box
        kratosMugshot: new ig.Image('media/kratos.png'), // Kratos mugshot
        lightningBladeDescription: new ig.Image('media/description.png'),

        /* Arte Description booleans */
        displayedLightningBladeDescription: false,  
        displayedHellPyreDescription: false,
        displayedSonicThrustDescription: false,
        displayedSuperSonicThrustDescription: false, 

        /* Spell Description booleans */
        displayedFireBallDescription: false,
        displayedLightningDescription: false,
        displayedWindDescription: false,
        displayedHealDescription: false,


        /* Physics Properties */
        gravity: 300, // How much does gravity affect all the entities in the game world?

        /* Camera properties */
        camera: null, // Set the initial camera to be null
        lastCheckpoint: null, // Set initial checkpoint to null 
        playerSpawnPos: {x: 0, y: 0}, // Set initial player spawn point to 0, 0

        /* Booleans for control */
        menuVisible: false, // Used to make menus stay open, prevents duplicate re-spawning of menus
        gameState: null, // Used for controlling the state of the game, i.e: equipping, viewing stats, etc

        /* Pointer properties */
        pointer: null,
        arteMenu: null,
        spawnedArteBoxes: false,
        artesCatalog: new ig.global.ArtesCatalog(),
        spellsCatalog: new ig.global.SpellsCatalog(),

        hud: new ig.hud(),

        /* Bind keys here, set up initial variables */
        init: function(){
            /* Set up camera plugin */
            var player = ig.game.getEntitiesByType('EntityPlayer')[0];
            // Initiate camera plugin, which takes width and height as parameters for the constructor
            this.camera = new Camera( ig.system.width/4, ig.system.height/3, 5 );
            // How far should the camera look ahead?
            this.camera.trap.size.x = ig.system.width/10;
            this.camera.trap.size.y = ig.system.height/3;
            this.camera.lookAhead.x = ig.ua.mobile ? ig.system.width/6 : 0;
            // Bind key inputs
            ig.input.bind(ig.KEY.MOUSE1,     'leftClick' );
            ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
            ig.input.bind(ig.KEY.RIGHT_ARROW, 'right');
            ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
            ig.input.bind(ig.KEY.UP_ARROW, 'up');
            ig.input.bind(ig.KEY.X, 'jump');
            ig.input.bind(ig.KEY.A, 'attack');
            ig.input.bind(ig.KEY.ENTER, 'menu');
            ig.input.bind(ig.KEY.ESC, 'escape');

            // Load the first level, basic.js
            this.loadLevel(LevelBasic);
            this.pointer = this.spawnEntity(EntityPointer, 100, 100);
            this.arteMenu = this.spawnEntity(EntityArteMenu, ig.system.width / 2, 8);
            this.spellMenu = this.spawnEntity(EntitySpellMenu, ig.system.width / 2 + 64, 8);
        },

        // Here we set up menu interactions, camera updates
        update: function() {
            this.parent();
            this.arteMenu.pos.x = ig.game.screen.x + 250;
            this.arteMenu.pos.y = 8;
            this.spellMenu.pos.x = ig.game.screen.x + 250 - 32
            this.spellMenu.pos.y = 8;
            //this.pointer = this.spawnEntity(EntityPlayer, 100, 100);
            // The camera plugin "follow" method takes an entity as input.
            // Pass in the player entity. 
            this.camera.follow( this.player );
            // If user presses enter, and menu is not showing...
            // ....display the stat screen menu
            if(ig.input.pressed('menu') && !this.menuVisible){
                // Set the game state to be 'stats', which means we
                // are viewing the status screen
                this.gameState = 'stats';
                // Toggle menuVisible so the user cannot spawn multiple
                // copies of the menu
                this.menuVisible = true;
            }
            
        },

        // loadLevel is called when a level is loaded
        loadLevel: function( level ) {        
            this.parent( level );

            // Set up checkpoint data for respawning of player
            // Grab an instance of the player
            this.player = this.getEntitiesByType( EntityPlayer )[0];
            // Set the last checkpoint to be null
            this.lastCheckpoint = null;
            // Set the player spawn position to be the initial position
            // as set from Weltmeister. 
            this.playerSpawnPos = {
                x: this.player.pos.x,
                y: this.player.pos.y
            };
            
            // Set camera max and reposition trap
            this.camera.max.x = this.collisionMap.width * this.collisionMap.tilesize - ig.system.width;
            this.camera.max.y = this.collisionMap.height * this.collisionMap.tilesize - ig.system.height;
            
            // Set the camera to follow the player
            this.camera.set( this.player );
        },

        // Method for respawning the player
        // repspawnPlayerAtLastCheckpoint (x, y)
        //    x: number
        //       - the x position of the entity
        //    y: number
        //       - the y position of the entity
        respawnPlayerAtLastCheckpoint: function(x,y){
            var pos = this.playerSpawnPos;
            // If one of the checkpoints were triggered, call
            // the getSpawnPos method from the checkpoint entity, respawn.js
            if(this.lastCheckpoint){
                // Get new player position and save it
                pos = this.lastCheckpoint.getSpawnPos()
            }
            // Respawn the player at the given x, y position
            this.player = this.spawnEntity(EntityPlayer, pos.x, pos.y);
        },

        // Method for setting the game class to be game over
        gameOver: function(){
            ig.system.setGame(GameOverScreen);
        },

        /**
         * number generateRandomInt(number min, number max)
         * ------
         * Returns a random number between min and max
        */
        generateRandomInt: function(min, max){
            return Math.floor(Math.random() * (max - min + 1)) + min;
        },

        // Draw method, used for drawing images, text and menus
        draw: function(){
            this.parent();

            /* Begin drawing spell menu */
            if(this.gameState === 'spellsMenu' && this.menuVisible && this.gameState !== 'artesMenu'){
                var player = ig.game.getEntitiesByType('EntityPlayer')[0];

                // Draw spells menu
                if(typeof this.getEntityByName('transparentmenu') === 'undefined'){
                    this.spawnEntity(EntityTransMenu, ig.game.screen.x, 0);
                }
{'fraction_non_alphanumeric': 0.11479462830814183, 'fraction_numerical': 0.006798898690790583, 'mean_word_length': 1.9727743444128947, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6226128', 'n_tokens_mistral': 5292, 'n_tokens_neox': 5149, 'n_words': 1234}