<commit_before>/**
 * Created by JarvisWalker on 13/2/17.
 */

function AnimalSprite(options) {
    this.image = options.image;
    this.referenceObject = options.referenceObject;

    if(options.context !== undefined)
        this.context = options.context;
    else
        this.context = drawingBoard;

    if (options.idlePosition !== undefined)
        this.idlePosition = options.idlePosition;
    else
        this.idlePosition = new SpritePosition({
            name: "idlePosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 15,
            canvasY: 0
        });

    this.currentPosition = this.idlePosition;

    if (options.walkingPosition !== undefined)
        this.walkingPosition = options.walkingPosition;
    else
        this.walkingPosition = new SpritePosition({
            name: "walkingPosition",
            spriteSheetX: 80, // fifth position on the sprite sheet
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 15,
            canvasY: 0
        });

    if (options.cryingOutPosition !== undefined) {
        this.cryingOutPosition = options.cryingOutPosition;
    }
    else
        this.cryingOutPosition = new SpritePosition({
            name: "cryingOutPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 15,
            canvasY: 0
        });

    if (options.sickPosition !== undefined)
        this.sickPosition = options.sickPosition;
    else
        this.sickPosition = new SpritePosition({
            name: "sickPosition",
            spriteSheetX: 48,
            spriteSheetY: 0,
            maxFrame: 0,
            canvasX: 15,
            canvasY: 0
        });
        
    if (options.slidingPosition !== undefined)
        this.slidingPosition = options.slidingPosition;
    else
        this.slidingPosition = new SpritePosition({
            name: "slidingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 4,
            multiplier: -8,
            canvasX: DEFAULT_SCREEN_SIZE.X,
            canvasY: 0
        });

    if (options.barkingPosition !== undefined)
        this.barkingPosition = options.barkingPosition;
    else
        this.barkingPosition = new SpritePosition({
            name: "barkingPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 15, //DEFAULT_SCREEN_SIZE.X,//DEFAULT_SCREEN_SIZE.X - DEFAULT_SPRITE_SIZE,
            canvasY: 0
        });

    if (options.attackingPosition !== undefined)
        this.attackingPosition = options.attackingPosition;
    else
        this.attackingPosition = new SpritePosition({
            name: "attackingPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 45 - 16,
            canvasY: 0
        });

    if (options.receivingPosition !== undefined)
        this.receivingPosition = options.receivingPosition;
    else
        this.receivingPosition = new SpritePosition({
            name: "receivingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 0,
            multiplier: 0,
            canvasX: 29,
            canvasY: 0
        });

    if (options.rejoicingPosition !== undefined)
        this.rejoicingPosition = options.rejoicingPosition;
    else
        this.rejoicingPosition = new SpritePosition({
            name: "rejoicingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: 64,
            canvasX: 15,
            canvasY: 0
        });

    if (options.saddenedPosition !== undefined)
        this.saddenedPosition = options.saddenedPosition;
    else
        this.saddenedPosition = new SpritePosition({
            name: "saddenedPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: 48,
            canvasX: 15,
            canvasY: 0
        });
    if (options.presentationPosition !== undefined)
        this.presentationPosition = options.presentationPosition;
    else
        this.presentationPosition = new SpritePosition({
            name: "presentationPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 3,
            canvasY: 2
        });
	
	if (options.isEvolved !== undefined)
		this.isEvolved = options.isEvolved;
	else
		this.isEvolved = 0;

    var referenceState = ANIMAL_STATES.IDLE;

    if (options.size !== undefined)
        this.size = options.size;
    else
        this.size = {width: DEFAULT_SPRITE_SIZE, height: DEFAULT_SPRITE_SIZE};

    if (options.update !== undefined)
        this.update = options.update;
    else // default to a pet object
        this.update = function() {
            if (currentScreen.referenceState === SCREEN_STATES.START_BATTLE.substates.SLIDE) {
                console.log("trying to slide now");
                if (this.currentPosition !== this.slidingPosition)
                    this.currentPosition = this.slidingPosition;
                else
                    console.log("it is sliding now");
                //this.currentPosition.updateCanvas();
            }
            else if (this.referenceObject.state !== referenceState && currentScreen.referenceState === SCREEN_STATES.PETS) {
                if (this.referenceObject.state === ANIMAL_STATES.IDLE) {
                    referenceState = ANIMAL_STATES.IDLE;
                    this.currentPosition = this.idlePosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.WALKING) {
                    referenceState = ANIMAL_STATES.WALKING;
                    this.currentPosition = this.walkingPosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.SICK) {
                    referenceState = ANIMAL_STATES.SICK;
                    this.currentPosition = this.sickPosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.IN_BATTLE) {
                    referenceState = ANIMAL_STATES.IN_BATTLE;
                    this.currentPosition = this.cryingOutPosition;
                }
            }
            
            else if (currentScreen.referenceState === SCREEN_STATES.STATS.substates.CURRENT_STATS) {
                this.currentPosition = this.presentationPosition;
            }
            else if (game.currentScreenState.state === SCREEN_STATES.ATTACK_SEQUENCE) {
                this.currentPosition = this.attackingPosition;
            }<commit_msg>Growling has been fixed, new code was breaking things it seems.<commit_after>/**
 * Created by JarvisWalker on 13/2/17.
 */

function AnimalSprite(options) {
    this.image = options.image;
    this.referenceObject = options.referenceObject;

    if(options.context !== undefined)
        this.context = options.context;
    else
        this.context = drawingBoard;

    if (options.idlePosition !== undefined)
        this.idlePosition = options.idlePosition;
    else
        this.idlePosition = new SpritePosition({
            name: "idlePosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 15,
            canvasY: 0
        });

    this.currentPosition = this.idlePosition;

    if (options.walkingPosition !== undefined)
        this.walkingPosition = options.walkingPosition;
    else
        this.walkingPosition = new SpritePosition({
            name: "walkingPosition",
            spriteSheetX: 80, // fifth position on the sprite sheet
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 15,
            canvasY: 0
        });

    if (options.cryingOutPosition !== undefined) {
        this.cryingOutPosition = options.cryingOutPosition;
    }
    else
        this.cryingOutPosition = new SpritePosition({
            name: "cryingOutPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 15,
            canvasY: 0
        });

    if (options.sickPosition !== undefined)
        this.sickPosition = options.sickPosition;
    else
        this.sickPosition = new SpritePosition({
            name: "sickPosition",
            spriteSheetX: 48,
            spriteSheetY: 0,
            maxFrame: 0,
            canvasX: 15,
            canvasY: 0
        });
        
    if (options.slidingPosition !== undefined)
        this.slidingPosition = options.slidingPosition;
    else
        this.slidingPosition = new SpritePosition({
            name: "slidingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 4,
            multiplier: -8,
            canvasX: DEFAULT_SCREEN_SIZE.X,
            canvasY: 0
        });

    if (options.barkingPosition !== undefined)
        this.barkingPosition = options.barkingPosition;
    else
        this.barkingPosition = new SpritePosition({
            name: "barkingPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 15, //DEFAULT_SCREEN_SIZE.X,//DEFAULT_SCREEN_SIZE.X - DEFAULT_SPRITE_SIZE,
            canvasY: 0
        });

    if (options.attackingPosition !== undefined)
        this.attackingPosition = options.attackingPosition;
    else
        this.attackingPosition = new SpritePosition({
            name: "attackingPosition",
            spriteSheetX: 32,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: -32,
            canvasX: 45 - 16,
            canvasY: 0
        });

    if (options.receivingPosition !== undefined)
        this.receivingPosition = options.receivingPosition;
    else
        this.receivingPosition = new SpritePosition({
            name: "receivingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 0,
            multiplier: 0,
            canvasX: 29,
            canvasY: 0
        });

    if (options.rejoicingPosition !== undefined)
        this.rejoicingPosition = options.rejoicingPosition;
    else
        this.rejoicingPosition = new SpritePosition({
            name: "rejoicingPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: 64,
            canvasX: 15,
            canvasY: 0
        });

    if (options.saddenedPosition !== undefined)
        this.saddenedPosition = options.saddenedPosition;
    else
        this.saddenedPosition = new SpritePosition({
            name: "saddenedPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            multiplier: 48,
            canvasX: 15,
            canvasY: 0
        });
    if (options.presentationPosition !== undefined)
        this.presentationPosition = options.presentationPosition;
    else
        this.presentationPosition = new SpritePosition({
            name: "presentationPosition",
            spriteSheetX: 0,
            spriteSheetY: 0,
            maxFrame: 1,
            canvasX: 3,
            canvasY: 2
        });
	
	if (options.isEvolved !== undefined)
		this.isEvolved = options.isEvolved;
	else
		this.isEvolved = 0;

    var referenceState = ANIMAL_STATES.IDLE;

    if (options.size !== undefined)
        this.size = options.size;
    else
        this.size = {width: DEFAULT_SPRITE_SIZE, height: DEFAULT_SPRITE_SIZE};

    if (options.update !== undefined)
        this.update = options.update;
    else // default to a pet object
        this.update = function() {
            if (currentScreen.referenceState === SCREEN_STATES.START_BATTLE.substates.SLIDE) {
                if (this.currentPosition !== this.slidingPosition)
                    this.currentPosition = this.slidingPosition;
            }
            else if (this.referenceObject.state !== referenceState) {
                if (this.referenceObject.state === ANIMAL_STATES.IDLE) {
                    referenceState = ANIMAL_STATES.IDLE;
                    this.currentPosition = this.idlePosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.WALKING) {
                    referenceState = ANIMAL_STATES.WALKING;
                    this.currentPosition = this.walkingPosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.SICK) {
                    referenceState = ANIMAL_STATES.SICK;
                    this.currentPosition = this.sickPosition;
                }
                else if (this.referenceObject.state === ANIMAL_STATES.IN_BATTLE) {
                    referenceState = ANIMAL_STATES.IN_BATTLE;
                    this.currentPosition = this.cryingOutPosition;
                }
            }
            
            else if (currentScreen.referenceState === SCREEN_STATES.STATS.substates.CURRENT_STATS) {
                this.currentPosition = this.presentationPosition;
            }
            else if (game.currentScreenState.state === SCREEN_STATES.ATTACK_SEQUENCE) {
                this.currentPosition = this.attackingPosition;
            }
{'fraction_non_alphanumeric': 0.08877634616816861, 'fraction_numerical': 0.013107916883890668, 'mean_word_length': 1.713823767178658, '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': '6779092', 'n_tokens_mistral': 3871, 'n_tokens_neox': 3623, 'n_words': 752}