{"size": 1226, "ext": "js", "max_stars_repo_path": "common/action/Teleport.js", "max_stars_repo_name": "ftheriault/Resist-Game2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "common/action/Teleport.js", "max_issues_repo_name": "ftheriault/Resist-Game2", "max_issues_repo_issues_event_min_datetime": "2021-03-09T00:38:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-29T01:55:24.000Z", "max_forks_repo_path": "common/action/Teleport.js", "max_forks_repo_name": "ftheriault/Resist-Game2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 21.5087719298, "max_line_length": 83, "alphanum_fraction": 0.6851549755}
var Action = require('./Action');

module.exports = Teleport = function (data, level) {
	if (data == null) {
		Action.call(this, level, "teleport", 10000, 0);
	}
	else {
		Action.call(this, data.level, "teleport", data.cooldown);
		this.data = data;
	}

	if (level != null) {
		this.data.level = level;
	}

	this.needTarget = false;
}

Teleport.prototype = new Action();
Teleport.prototype.constructor = Teleport;

Teleport.prototype.getName = function () {
	return "Teleport";
}

Teleport.prototype.getTooltip = function() {
	return "Teleports mage to wanted location";
}

Teleport.prototype.getActiveTooltipData = function() {
	return "";
}

Teleport.prototype.update = function (fromSprite, delta) {
	this.data.cooldown = 10000 - this.data.level * 500;
	this.data.manaCost = 25 - this.data.level * 2;

	if (this.data.cooldown < 5000) {
		this.data.cooldown = 5000;		
	}

	if (this.data.manaCost < 5) {
		this.data.manaCost = 5;
	}
}

Teleport.prototype.triggerEvent = function (fromSprite, mouseX, mouseY, toSprite) {
	var success = false;

	if (global.level.getWalkableCost(mouseX, mouseY, [], true) == 0) {
		success = true;
		fromSprite.setLocation(mouseX, mouseY);
		fromSprite.broadcastState();
	}
	
	return success;
}