<commit_before>
/**
 * Class with behavior and attributes for players
 * @param {number} x initial x-coordinate
 * @param {number} y initial y-coordinate
 * @param {number} initiative
 * @constructor
 */
var Player = function(x, y, initiative) {
	this.x = x; // now im thinking that maybe we should instead change these to map grid coordinates
	this.y = y; // now im thinking that maybe we should instead change these to map grid coordinates
	this.initiative = initiative; // this is a skill used for determining player turn in default advanceturn.js
	this.moveSpeed = 4; // sort of useless stat, how fast they move on the map (px/frame)
	this.attackSpeed = 1; // skill that determines how many attacks you can make in a single turn
	//Scout is skill affecting how hard it is for enemies to detect player, and how far player can see/move
	this.turnCounter = 0;
	this.level = 1;
	this.xp = 0;
	this.hp = 100 * this.level;
	this.maxHP = this.hp;
	this.skillPoints = 1;
	this.attack = 2;
	this.actionMenu = {};
	this.totalTurns = 0; // counts how many turns this player has taken.
	this.spriteSheet =  new createjs.SpriteSheet({
		"images": [loader.getResult("player")],
		"frames": {
			"width": 16,
			"height": 16,
			"count": 16
		},
		"animations": {
			"stand-front": {
				"frames": [0],
				"next": "stand-front",
				"speed": 1
			},
			"stand-left": {
				"frames": [4],
				"next": "stand-left",
				"speed": 1
			},
			"stand-right": {
				"frames": [8],
				"next": "stand-right",
				"speed": 1
			},
			"stand-back": {
				"frames": [12],
				"next": "stand-back",
				"speed": 1
			},
			"spin-left": {
				"frames": [0, 8, 12, 4],
				"next": "spin-left",
				"speed": .1
			},
			"spin-right": {
				"frames": [0, 4, 12, 8],
				"next": "spin-right",
				"speed": .1
			},
			"walk-front": {
				"frames": [1, 2, 3, 2],
				"next": "walk-front",
				"speed": 1
			},
			"walk-left": {
				"frames": [5, 6, 7, 6],
				"next": "walk-left",
				"speed": 1
			},
			"walk-right": {
				"frames": [9, 10, 11, 10],
				"next": "walk-right",
				"speed": 1
			},
			"walk-back": {
				"frames": [13, 14, 15, 14],
				"next": "walk-back",
				"speed": 1
			},
			"run-front": {
				"frames": [1, 3],
				"next": "run-front",
				"speed": 1
			},
			"run-left": {
				"frames": [5, 6, 7, 6],
				"next": "run-left",
				"speed": 3
			},
			"run-right": {
				"frames": [9, 10, 11, 10],
				"next": "run-right",
				"speed": 3
			},
			"run-back": {
				"frames": [13, 15],
				"next": "run-back",
				"speed": 1
			}
		}
	});

	this.animations = new createjs.Sprite(this.spriteSheet, "stand-front"); // change the second string to an animation from the spritesheet
	this.animations.x = this.x;
	this.animations.y = this.y;
	this.watchedElements = [];

	var slashSpriteSheet = new createjs.SpriteSheet({
		"images": [loader.getResult("slash")],
		"frames": {
			"width": 3, "height": 3, "count": 4
		},
		"animations": {
			"slash": {
				"frames" : [0, 1, 2, 3],
				"next" : "slash",
				"speed" : 0.5
			}
		}
	});

	this.attackAnimation = new createjs.Sprite(slashSpriteSheet, "slash");
	this.attackAnimation.scaleX = 2;
	this.attackAnimation.scaleY = 2;

	var playerName = "Player"; // The name of the player, right now is only used when declaring the winner.

	// add our animations to global gamestage:
	renderer.activeObjectsContainer.addChild(this.animations);

	/**
	 * Run on each frame rendering in main loop
	 */
	this.tickActions = function() {

	};

	//
	var attackTarget = null;

	/**
	 * Removes the player from the map, gives a gameover screen if no players are left alive
	 */
	this.die = function() {
		this.animations.gotoAndPlay("spin-right");
		setTimeout(function() {
			renderer.activeObjectsContainer.removeChild(this.animations);
		}.bind(this), 1000);

		for (var i = 0; i < activeObjects.length; i++) {
			if (activeObjects[i] === this) {
				activeObjects.splice(i, 1);
				return;
			}
		}
	};

	/**
	 * Reduces Player's HP by the amount of damage received and updates health bar
 	 * @param  {Object} attackingObject
	 */
	this.receiveDamage = function(attackingObject) {
		this.hp -= attackingObject.attack;

		if (this.hp <= 0){
			this.die();
		}

	};

	/**
	 * Click handler for attack
	 * @return {MouseEvent} event
	 */
	var attackClickHandler = function(event) {
		var x = event.pageX / gamezoom;
		var y = event.pageY / gamezoom;

		var collisionCoordinate = collisionSystem.getCollisionCoordinateFromCell(x, y);
		if (isSelectionInSelectableBounds(this, x, y) && collisionSystem.checkCellValidForObject(collisionCoordinate)) {
			var clickEventSpriteSheet = new createjs.SpriteSheet({
				"images": [loader.getResult("player")], // who cares, it's already preloaded
				"frames": {
					"width": 1, "height": 1, "count": 1
				},
				"animations": {
					"exist": {
						"frames" : [0],
						"next" : "exist"
					}<commit_msg>You can Lose The Game<commit_after>
/**
 * Class with behavior and attributes for players
 * @param {number} x initial x-coordinate
 * @param {number} y initial y-coordinate
 * @param {number} initiative
 * @constructor
 */
var Player = function(x, y, initiative) {
	this.x = x; // now im thinking that maybe we should instead change these to map grid coordinates
	this.y = y; // now im thinking that maybe we should instead change these to map grid coordinates
	this.initiative = initiative; // this is a skill used for determining player turn in default advanceturn.js
	this.moveSpeed = 4; // sort of useless stat, how fast they move on the map (px/frame)
	this.attackSpeed = 1; // skill that determines how many attacks you can make in a single turn
	//Scout is skill affecting how hard it is for enemies to detect player, and how far player can see/move
	this.turnCounter = 0;
	this.level = 1;
	this.xp = 0;
	this.hp = 100 * this.level;
	this.maxHP = this.hp;
	this.skillPoints = 1;
	this.attack = 2;
	this.actionMenu = {};
	this.totalTurns = 0; // counts how many turns this player has taken.
	this.spriteSheet =  new createjs.SpriteSheet({
		"images": [loader.getResult("player")],
		"frames": {
			"width": 16,
			"height": 16,
			"count": 16
		},
		"animations": {
			"stand-front": {
				"frames": [0],
				"next": "stand-front",
				"speed": 1
			},
			"stand-left": {
				"frames": [4],
				"next": "stand-left",
				"speed": 1
			},
			"stand-right": {
				"frames": [8],
				"next": "stand-right",
				"speed": 1
			},
			"stand-back": {
				"frames": [12],
				"next": "stand-back",
				"speed": 1
			},
			"spin-left": {
				"frames": [0, 8, 12, 4],
				"next": "spin-left",
				"speed": .1
			},
			"spin-right": {
				"frames": [0, 4, 12, 8],
				"next": "spin-right",
				"speed": .1
			},
			"walk-front": {
				"frames": [1, 2, 3, 2],
				"next": "walk-front",
				"speed": 1
			},
			"walk-left": {
				"frames": [5, 6, 7, 6],
				"next": "walk-left",
				"speed": 1
			},
			"walk-right": {
				"frames": [9, 10, 11, 10],
				"next": "walk-right",
				"speed": 1
			},
			"walk-back": {
				"frames": [13, 14, 15, 14],
				"next": "walk-back",
				"speed": 1
			},
			"run-front": {
				"frames": [1, 3],
				"next": "run-front",
				"speed": 1
			},
			"run-left": {
				"frames": [5, 6, 7, 6],
				"next": "run-left",
				"speed": 3
			},
			"run-right": {
				"frames": [9, 10, 11, 10],
				"next": "run-right",
				"speed": 3
			},
			"run-back": {
				"frames": [13, 15],
				"next": "run-back",
				"speed": 1
			}
		}
	});

	this.animations = new createjs.Sprite(this.spriteSheet, "stand-front"); // change the second string to an animation from the spritesheet
	this.animations.x = this.x;
	this.animations.y = this.y;
	this.watchedElements = [];

	var slashSpriteSheet = new createjs.SpriteSheet({
		"images": [loader.getResult("slash")],
		"frames": {
			"width": 3, "height": 3, "count": 4
		},
		"animations": {
			"slash": {
				"frames" : [0, 1, 2, 3],
				"next" : "slash",
				"speed" : 0.5
			}
		}
	});

	this.attackAnimation = new createjs.Sprite(slashSpriteSheet, "slash");
	this.attackAnimation.scaleX = 2;
	this.attackAnimation.scaleY = 2;

	var playerName = "Player"; // The name of the player, right now is only used when declaring the winner.

	// add our animations to global gamestage:
	renderer.activeObjectsContainer.addChild(this.animations);

	/**
	 * Run on each frame rendering in main loop
	 */
	this.tickActions = function() {

	};

	//
	var attackTarget = null;

	/**
	 * Removes the player from the map, gives a gameover screen if no players are left alive
	 */
	this.die = function() {
		this.animations.gotoAndPlay("spin-right");
		setTimeout(function() {
			renderer.activeObjectsContainer.removeChild(this.animations);
		}.bind(this), 1000);

		for (var i = 0; i < activeObjects.length; i++) {
			if (activeObjects[i] === this) {
				activeObjects.splice(i, 1);
				return;
			}
		}
	};

	/**
	 * Reduces Player's HP by the amount of damage received and updates health bar
 	 * @param  {Object} attackingObject
	 */
	this.receiveDamage = function(attackingObject) {
		this.hp -= attackingObject.attack;

		if (this.hp <= 0){
			this.die();
		}

		alivePlayers = 0;
		for (var i = 0; i < activeObjects.length; i++) {
			if (activeObjects[i] instanceof Player) {
				alivePlayers++;
			}
		}

		if (alivePlayers == 0){
			alert("you lost");
		}

	};

	/**
	 * Click handler for attack
	 * @return {MouseEvent} event
	 */
	var attackClickHandler = function(event) {
		var x = event.pageX / gamezoom;
		var y = event.pageY / gamezoom;

		var collisionCoordinate = collisionSystem.getCollisionCoordinateFromCell(x, y);
		if (isSelectionInSelectableBounds(this, x, y) && collisionSystem.checkCellValidForObject(collisionCoordinate)) {
			var clickEventSpriteSheet = new createjs.SpriteSheet({
				"images": [loader.getResult("player")], // who cares, it's already preloaded
				"frames": {
					"width": 1, "height": 1, "count": 1
				},
				"animations": {
					"exist": {
						"frames" : [0],
						"next" : "exist"
					}
{'fraction_non_alphanumeric': 0.16962940644772523, 'fraction_numerical': 0.021994576679722808, 'mean_word_length': 2.922016541945648, 'pattern_counts': {'":': 152, '<': 8, '<?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': '724864', 'n_tokens_mistral': 4260, 'n_tokens_neox': 3452, 'n_words': 989}