<commit_before>/*	Class UI
*
*	Object containing UI DOM element, update functions and event managment on UI.
*
*/
var UI = Class.create({

	/*	Attributes
	*	
	*	NOTE : attributes and variables starting with $ are jquery element 
	*	and jquery function can be called dirrectly from them.
	*
	*	$display :		UI container 
	*	$queue :		Queue container
	*	$textbox :		Chat and log container
	*	$activebox :	Current active creature panel (left panel) container
	*	$dash :			Overview container
	*	$grid :			Creature grid container
	*
	*	selectedCreature : 	String : 	ID of the visible creature card
	*	selectedPlayer : 	Integer : 	ID of the selected player in the dash
	*
	*/


	/*	Constructor
	*	
	* 	Create attributes and default buttons
	*
	*/
	initialize: function(){
		this.$display = $j("#ui");
		this.$queue = $j("#queuewrapper");
		this.$dash = $j("#dash");
		this.$grid = $j("#creaturegrid");
		this.$activebox = $j("#activebox");

		//Chat
		this.chat = new Chat();

		//Buttons Objects
		this.buttons = [];
		this.abilitiesButtons = [];

		//Dash Button
		this.btnToggleDash = new Button({
			$button : $j(".toggledash"),
			click : function(e){G.UI.toggleDash();},
		});
		this.buttons.push(this.btnToggleDash);

		//Skip Turn Button
		this.btnSkipTurn = new Button({
			$button : $j("#skip.button"),
			click : function(e){G.skipTurn();},
		});
		this.buttons.push(this.btnSkipTurn);

		//Delay Creature Button
		this.btnDelay = new Button({
			$button : $j("#delay.button"),
			click : function(e){G.delayCreature();},
		});
		this.buttons.push(this.btnDelay);

		//Flee Match Button
		this.btnFlee = new Button({
			$button : $j("#flee.button"),
			click : function(e){G.activeCreature.player.flee();},
			state : "disabled",
		});
		this.buttons.push(this.btnFlee);

		//Binding Hotkeys
		$j(document).on('keypress', function(e){

			var keypressed = e.keyCode;
			// console.log(keypressed);

			hotkeys = {
				attack: 119, //W
				ability: 101, //E
				ultimate: 114, //R
				overview: 97, //A
				skip: 115, //S
				delay: 100, //D
				flee: 102, //F
				chat: 99, //C
			};

			var prevD = false;

			$j.each(hotkeys,function(k,v){
				if(v==keypressed){
					switch(k){
						case "attack": G.UI.abilitiesButtons[1].click(); break;
						case "ability": G.UI.abilitiesButtons[2].click(); break;
						case "ultimate": G.UI.abilitiesButtons[3].click(); break;
						case "overview": G.UI.btnToggleDash.click(); break;
						case "skip": G.UI.btnSkipTurn.click(); break;
						case "delay": G.UI.btnDelay.click(); break;
						case "flee": G.UI.btnFlee.click(); break;
						case "chat": G.UI.chat.toggle(); break;
					}
					prevD = true;
				}
			});
			if(prevD){
				e.preventDefault();
				return false;
			}
		});

		for (var i = 0; i < 4; i++) {
			var b = new Button({
				$button : $j("#abilities .ability:nth-child("+(i+1)+")"),
				abilityId : i,
			});
			this.buttons.push(b);
			this.abilitiesButtons.push(b);
		};

		this.$dash.children("#playertabswrapper").addClass("numplayer"+G.nbrPlayer);

		this.selectedCreature = "";
		this.selectedPlayer = 0;
		this.selectedAbility = -1;
		
		this.materializeToggled = false;

		if(G.turnTimePool) $j(".turntime").text(zfill(Math.floor(G.turnTimePool/60),2)+":"+zfill(G.turnTimePool%60,2));
		if(G.timePool) $j(".timepool").text(zfill(Math.floor(G.timePool/60),2)+":"+zfill(G.timePool%60,2));
			

		//Show UI
		this.$display.show();
	},

	
	resizeDash: function(){
		var zoom = $j("#cardwrapper").outerWidth()/$j("#card").outerWidth();
		zoom = (zoom<1) ? zoom : 1;
		$j("#cardwrapper_inner").css("zoom",zoom);

		zoom = $j("#creaturegridwrapper").innerWidth()/$j("#creaturegrid").innerWidth();
		zoom = (zoom<1) ? zoom : 1;
		$j("#creaturegrid").css("zoom",zoom);
	},


	/*	showCreature(creatureType,player)
	*	
	*	creatureType : 	String : 	Creature type
	*	player : 		Integer : 	Player ID
	*
	* 	Query a creature in the available creatures of the active player
	*
	*/
	showCreature: function(creatureType,player){

		//Set dash active
		this.$dash.addClass("active");
		this.$dash.children("#tooltip").removeClass("active");
		this.$dash.children("#playertabswrapper").addClass("active");
		this.changePlayerTab(G.activeCreature.team);

		this.$dash.children("#playertabswrapper").children(".playertabs").unbind('click').bind('click',function(e){
			if(G.freezedInput) return;
			G.UI.showCreature("--",$j(this).attr("player")-0);
		});

		//Change player infos
		for (var i = G.players.length - 1; i >= 0; i--) {
			$j("#dash .playertabs.p"+i+" .vignette").css("background-image","url('"+G.players[i].avatar+"')");
			$j("#dash .playertabs.p"+i+" .name").text(G.players[i].name);
			$j("#dash .playertabs.p"+i+" .plasma").text("Plasma "+G.players[i].plasma);
			$j("#dash .playertabs.p"+i+" .score").text("Score "+G.players[i].getScore().total);
		};

		//Change to the player tab
		if(player != G.UI.selectedPlayer){this.changePlayerTab(player);}

		this.$grid.children(".vignette").removeClass("active")
		.filter("[creature='"+creatureType+"']").addClass("active");

		this.selectedCreature = creatureType;

		var stats = G.retreiveCreatureStats(creatureType);

		//TODO card animation
		if( $j.inArray(creatureType, G.players[player].availableCreatures)>0 || creatureType=="--"){
			//If creature is available

			//Retreive the summoned creature if it exists
			var crea = undefined;
			G.players[player].creatures.each(function(){
				if(this.type == creatureType)
					crea = this;
			});

			//Recto
			$j("#card .card.recto").css({"background-image":"url('../bestiary/"+stats.name+"/artwork.jpg')"});
			$j("#card .card.recto .section.info").removeClass("sin- sinA sinE sinG sinL sinP sinS sinW").addClass("sin"+stats.type.substring(0,1));
			$j("#card .card.recto .type").text(stats.type);
			$j("#card .card.recto .name").text(stats.name);
			$j("#card .card.recto .hexs").text(stats.size+"H");

			//Verso
			$j.each(stats.stats,function(key,value){
				var $stat = $j("#card .card.verso ."+key+" .value");
				$stat.removeClass("buff debuff");
				if(crea){
					if(key=="health"){
						$stat.text(crea.health+"/"+value);
					}else{
						$stat.text(crea.stats[key]);
						if(crea.stats[key]>value){ //Buff
							$stat.addClass("buff");
						}else if(crea.stats[key]<value){ //Debuff
							$stat.addClass("debuff");
						}
					}
				}else{
					$stat.text(value);
				}
			});
			$j.each(abilities[stats.id],function(key,value){
				$ability = $j("#card .card.verso .abilities .ability:eq("+key+")");
				$ability.children('.icon').css({"background-image":"url('../bestiary/"+stats.name+"/"+key+".svg')"});
				$ability.children(".wrapper").children(".info").children("h3").text(stats.ability_info[key].title);
				$ability.children(".wrapper").children(".info").children("#desc").text(stats.ability_info[key].desc);
				$ability.children(".wrapper").children(".info").children("#info").text(stats.ability_info[key].info);
			});

			var summonedOrDead = false;
			G.players[player].creatures.each(function(){
				if(this.type == creatureType){
					summonedOrDead = true;
				}
			});

			//Materialize button
			$j('#materialize_button').unbind('click');
			if(
				!summonedOrDead && 
				G.activeCreature.player.id==player && 
				G.activeCreature.type=="--" &&
				G.activeCreature.abilities[3].used==false
			  )
			{	
				var lvl = creatureType.substring(1,2)-0;
				var size = G.retreiveCreatureStats(creatureType).size-0;
				plasmaCost = lvl+size;

				//Messages
				if(G.activeCreature.player.getNbrOfCreatures() > G.creaLimitNbr){
					$j('#materialize_button p').text(G.msg.ui.dash.materialize_overload);
				}else if(plasmaCost>G.activeCreature.player.plasma){
					$j('#materialize_button p').text("Low Plasma! Cannot materialize the selected unit");
				}else{
					$j('#materialize_button p').text("Materialize unit at target location for "+plasmaCost+" plasma");

					//Bind button
					$j('#materialize_button').bind('click',function(e){
						if(G.freezedInput) return;
						G.UI.materializeToggled = true;
						G.UI.selectAbility(3);
						G.UI.toggleDash();
						G.activeCreature.abilities[3].materialize(G.UI.selectedCreature);
					});
				}

			}else{
				if (
					G.activeCreature.player.id==player && 
					G.activeCreature.type=="--" &&
					G.activeCreature.abilities[3].used==true
				){
					$j('#materialize_button p').text("Materialization has already been used this round");
				}else if(
					G.activeCreature.player.id==player && 
					G.activeCreature.type=="--"
				){
					$j('#materialize_button p').text("Please select an available unit from the left grid");
				}else if (G.activeCreature.type!="--"){
					$j('#materialize_button p').text("The current active unit cannot materialize others");
				}
			}

		}else{
			//TODO Locked card
			//$j("#card").text("Locked");
		}
	},


	selectAbility: function(i){
		if( this.selectedAbility > -1 )
			this.abilitiesButtons[this.selectedAbility].changeState("normal");
		this.selectedAbility = i;
		if( i>-1 )
			this.abilitiesButtons[i].changeState("active");
	},


	/*	changePlayerTab(id)
	*
	*	id : 	Integer : 	player id
	*
	*	Change to the specified player tab in the dash
	*
	*/
	changePlayerTab: function(id){
		this.selectedPlayer = id;
		this.$dash //Dash class
		.removeClass("selected0 selected1 selected2 selected3")
		.addClass("selected"+id);

		this.$grid.children(".vignette") //vignettes class
		.removeClass("active dead queued")
		.addClass("locked");

		//change creature status
		G.players[id].availableCreatures.each(function(){
			G.UI.$grid.children(".vignette[creature='"+this+"']").removeClass("locked");
		});
		G.players[id].creatures.each(function(){
			if(this.dead == true){
				G.UI.$grid.children(".vignette[creature='"+this.type+"']").addClass("dead");
			}else{
				G.UI.$grid.children(".vignette[creature='"+this.type+"']").addClass("queued");
			}
		});

		//Bind creature vignette click
		this.$grid.children(".vignette").unbind('click').bind("click",function(e){
			e.preventDefault();
			if(G.freezedInput) return;

			if($j(this).hasClass("locked")){
				G.UI.$dash.children("#tooltip").text("Creature locked.");
			}

			var creatureType = $j(this).attr("creature");
			G.UI.showCreature(creatureType,G.UI.selectedPlayer);
		});

	},


	/*	toggleDash()
	*
	*	Show the dash and hide some buttons
	*
	*/
	toggleDash: function(){
		if(!this.$dash.hasClass("active")){
			this.showCreature("--",G.activeCreature.team);
		}else{
			this.$dash.removeClass("active");
			if(this.materializeToggled){
				this.selectAbility(-1);
				G.activeCreature.queryMove();
			}
			this.materializeToggled = false;
		}

	},


	/*	updateActiveBox()
	*
	*	Update activebox with new current creature's abilities
	*
	*/
	updateActivebox: function(){
		var $abilitiesButtons = G.UI.$activebox.children("#abilities").children(".ability");
		$abilitiesButtons.unbind("click");

		this.$activebox.children("#abilities").clearQueue().transition({y:"-420px"},function(){//Hide panel	
			$j(this).removeClass("p0 p1 p2 p3").addClass("p"+G.activeCreature.player.id);
			//Change abilities buttons
			G.UI.abilitiesButtons.each(function(){
				var ab = G.activeCreature.abilities[this.abilityId];
				this.css.normal = {"background-image":"url('../bestiary/"+G.activeCreature.name+"/"+this.abilityId+".svg')"};
				this.$button.children(".desc").html("<span>"+ab.title+"</span><p>"+ab.desc+"<br>"+ab.info+"</p>");
				this.click = function(){
					G.grid.clearHexViewAlterations();
					if(G.UI.selectedAbility!=this.abilityId){
						//Activate Abilitie
						G.activeCreature.abilities[this.abilityId].use();
					}else{
						//Cancel Abilitie
						G.activeCreature.queryMove();
					}<commit_msg>Fixed #279<commit_after>/*	Class UI
*
*	Object containing UI DOM element, update functions and event managment on UI.
*
*/
var UI = Class.create({

	/*	Attributes
	*	
	*	NOTE : attributes and variables starting with $ are jquery element 
	*	and jquery function can be called dirrectly from them.
	*
	*	$display :		UI container 
	*	$queue :		Queue container
	*	$textbox :		Chat and log container
	*	$activebox :	Current active creature panel (left panel) container
	*	$dash :			Overview container
	*	$grid :			Creature grid container
	*
	*	selectedCreature : 	String : 	ID of the visible creature card
	*	selectedPlayer : 	Integer : 	ID of the selected player in the dash
	*
	*/


	/*	Constructor
	*	
	* 	Create attributes and default buttons
	*
	*/
	initialize: function(){
		this.$display = $j("#ui");
		this.$queue = $j("#queuewrapper");
		this.$dash = $j("#dash");
		this.$grid = $j("#creaturegrid");
		this.$activebox = $j("#activebox");

		//Chat
		this.chat = new Chat();

		//Buttons Objects
		this.buttons = [];
		this.abilitiesButtons = [];

		//Dash Button
		this.btnToggleDash = new Button({
			$button : $j(".toggledash"),
			click : function(e){G.UI.toggleDash();},
		});
		this.buttons.push(this.btnToggleDash);

		//Skip Turn Button
		this.btnSkipTurn = new Button({
			$button : $j("#skip.button"),
			click : function(e){G.skipTurn();},
		});
		this.buttons.push(this.btnSkipTurn);

		//Delay Creature Button
		this.btnDelay = new Button({
			$button : $j("#delay.button"),
			click : function(e){G.delayCreature();},
		});
		this.buttons.push(this.btnDelay);

		//Flee Match Button
		this.btnFlee = new Button({
			$button : $j("#flee.button"),
			click : function(e){G.activeCreature.player.flee();},
			state : "disabled",
		});
		this.buttons.push(this.btnFlee);

		//Binding Hotkeys
		$j(document).on('keypress', function(e){

			var keypressed = e.keyCode;
			// console.log(keypressed);

			hotkeys = {
				attack: 119, //W
				ability: 101, //E
				ultimate: 114, //R
				overview: 97, //A
				skip: 115, //S
				delay: 100, //D
				flee: 102, //F
				chat: 99, //C
			};

			var prevD = false;

			$j.each(hotkeys,function(k,v){
				if(v==keypressed){
					switch(k){
						case "attack": G.UI.abilitiesButtons[1].click(); break;
						case "ability": G.UI.abilitiesButtons[2].click(); break;
						case "ultimate": G.UI.abilitiesButtons[3].click(); break;
						case "overview": G.UI.btnToggleDash.click(); break;
						case "skip": G.UI.btnSkipTurn.click(); break;
						case "delay": G.UI.btnDelay.click(); break;
						case "flee": G.UI.btnFlee.click(); break;
						case "chat": G.UI.chat.toggle(); break;
					}
					prevD = true;
				}
			});
			if(prevD){
				e.preventDefault();
				return false;
			}
		});

		for (var i = 0; i < 4; i++) {
			var b = new Button({
				$button : $j("#abilities .ability:nth-child("+(i+1)+")"),
				abilityId : i,
			});
			this.buttons.push(b);
			this.abilitiesButtons.push(b);
		};

		this.$dash.children("#playertabswrapper").addClass("numplayer"+G.nbrPlayer);

		this.selectedCreature = "";
		this.selectedPlayer = 0;
		this.selectedAbility = -1;
		
		this.materializeToggled = false;

		if(G.turnTimePool) $j(".turntime").text(zfill(Math.floor(G.turnTimePool/60),2)+":"+zfill(G.turnTimePool%60,2));
		if(G.timePool) $j(".timepool").text(zfill(Math.floor(G.timePool/60),2)+":"+zfill(G.timePool%60,2));
			

		//Show UI
		this.$display.show();
	},

	
	resizeDash: function(){
		var zoom = $j("#cardwrapper").outerWidth()/$j("#card").outerWidth();
		zoom = (zoom<1) ? zoom : 1;
		$j("#cardwrapper_inner").css("zoom",zoom);

		zoom = $j("#creaturegridwrapper").innerWidth()/$j("#creaturegrid").innerWidth();
		zoom = (zoom<1) ? zoom : 1;
		$j("#creaturegrid").css("zoom",zoom);
	},


	/*	showCreature(creatureType,player)
	*	
	*	creatureType : 	String : 	Creature type
	*	player : 		Integer : 	Player ID
	*
	* 	Query a creature in the available creatures of the active player
	*
	*/
	showCreature: function(creatureType,player){

		//Set dash active
		this.$dash.addClass("active");
		this.$dash.children("#tooltip").removeClass("active");
		this.$dash.children("#playertabswrapper").addClass("active");
		this.changePlayerTab(G.activeCreature.team);

		this.$dash.children("#playertabswrapper").children(".playertabs").unbind('click').bind('click',function(e){
			if(G.freezedInput) return;
			G.UI.showCreature("--",$j(this).attr("player")-0);
		});

		//Change player infos
		for (var i = G.players.length - 1; i >= 0; i--) {
			$j("#dash .playertabs.p"+i+" .vignette").css("background-image","url('"+G.players[i].avatar+"')");
			$j("#dash .playertabs.p"+i+" .name").text(G.players[i].name);
			$j("#dash .playertabs.p"+i+" .plasma").text("Plasma "+G.players[i].plasma);
			$j("#dash .playertabs.p"+i+" .score").text("Score "+G.players[i].getScore().total);
		};

		//Change to the player tab
		if(player != G.UI.selectedPlayer){this.changePlayerTab(player);}

		this.$grid.children(".vignette").removeClass("active")
		.filter("[creature='"+creatureType+"']").addClass("active");

		this.selectedCreature = creatureType;

		var stats = G.retreiveCreatureStats(creatureType);

		//TODO card animation
		if( $j.inArray(creatureType, G.players[player].availableCreatures)>0 || creatureType=="--"){
			//If creature is available

			//Retreive the summoned creature if it exists
			var crea = undefined;
			G.players[player].creatures.each(function(){
				if(this.type == creatureType)
					crea = this;
			});

			//Recto
			$j("#card .card.recto").css({"background-image":"url('../bestiary/"+stats.name+"/artwork.jpg')"});
			$j("#card .card.recto .section.info").removeClass("sin- sinA sinE sinG sinL sinP sinS sinW").addClass("sin"+stats.type.substring(0,1));
			$j("#card .card.recto .type").text(stats.type);
			$j("#card .card.recto .name").text(stats.name);
			$j("#card .card.recto .hexs").text(stats.size+"H");

			//Verso
			$j.each(stats.stats,function(key,value){
				var $stat = $j("#card .card.verso ."+key+" .value");
				$stat.removeClass("buff debuff");
				if(crea){
					if(key=="health"){
						$stat.text(crea.health+"/"+value);
					}else{
						$stat.text(crea.stats[key]);
						if(crea.stats[key]>value){ //Buff
							$stat.addClass("buff");
						}else if(crea.stats[key]<value){ //Debuff
							$stat.addClass("debuff");
						}
					}
				}else{
					$stat.text(value);
				}
			});
			$j.each(abilities[stats.id],function(key,value){
				$ability = $j("#card .card.verso .abilities .ability:eq("+key+")");
				$ability.children('.icon').css({"background-image":"url('../bestiary/"+stats.name+"/"+key+".svg')"});
				$ability.children(".wrapper").children(".info").children("h3").text(stats.ability_info[key].title);
				$ability.children(".wrapper").children(".info").children("#desc").text(stats.ability_info[key].desc);
				$ability.children(".wrapper").children(".info").children("#info").text(stats.ability_info[key].info);
			});

			var summonedOrDead = false;
			G.players[player].creatures.each(function(){
				if(this.type == creatureType){
					summonedOrDead = true;
				}
			});

			//Materialize button
			$j('#materialize_button').unbind('click');
			if(
				!summonedOrDead && 
				G.activeCreature.player.id==player && 
				G.activeCreature.type=="--" &&
				G.activeCreature.abilities[3].used==false
			  )
			{	
				var lvl = creatureType.substring(1,2)-0;
				var size = G.retreiveCreatureStats(creatureType).size-0;
				plasmaCost = lvl+size;

				//Messages
				if(G.activeCreature.player.getNbrOfCreatures() > G.creaLimitNbr){
					$j('#materialize_button p').text(G.msg.ui.dash.materialize_overload);
				}else if(plasmaCost>G.activeCreature.player.plasma){
					$j('#materialize_button p').text("Low Plasma! Cannot materialize the selected unit");
				}else{
					$j('#materialize_button p').text("Materialize unit at target location for "+plasmaCost+" plasma");

					//Bind button
					$j('#materialize_button').bind('click',function(e){
						if(G.freezedInput) return;
						G.UI.materializeToggled = true;
						G.UI.selectAbility(3);
						G.UI.toggleDash();
						G.activeCreature.abilities[3].materialize(G.UI.selectedCreature);
					});
				}

			}else{
				if (
					G.activeCreature.player.id==player && 
					G.activeCreature.type=="--" &&
					G.activeCreature.abilities[3].used==true
				){
					$j('#materialize_button p').text("Materialization has already been used this round");
				}else if(
					G.activeCreature.player.id==player && 
					G.activeCreature.type=="--"
				){
					$j('#materialize_button p').text("Please select an available unit from the left grid");
				}else if (G.activeCreature.type!="--"){
					$j('#materialize_button p').text("The current active unit cannot materialize others");
				}
			}

		}else{
			//TODO Locked card
			//$j("#card").text("Locked");
		}
	},


	selectAbility: function(i){
		if( this.selectedAbility > -1 )
			this.abilitiesButtons[this.selectedAbility].changeState("normal");
		this.selectedAbility = i;
		if( i>-1 )
			this.abilitiesButtons[i].changeState("active");
	},


	/*	changePlayerTab(id)
	*
	*	id : 	Integer : 	player id
	*
	*	Change to the specified player tab in the dash
	*
	*/
	changePlayerTab: function(id){
		this.selectedPlayer = id;
		this.$dash //Dash class
		.removeClass("selected0 selected1 selected2 selected3")
		.addClass("selected"+id);

		this.$grid.children(".vignette") //vignettes class
		.removeClass("active dead queued")
		.addClass("locked");

		//change creature status
		G.players[id].availableCreatures.each(function(){
			G.UI.$grid.children(".vignette[creature='"+this+"']").removeClass("locked");
		});
		G.players[id].creatures.each(function(){
			if(this.dead == true){
				G.UI.$grid.children(".vignette[creature='"+this.type+"']").addClass("dead");
			}else{
				G.UI.$grid.children(".vignette[creature='"+this.type+"']").addClass("queued");
			}
		});

		//Bind creature vignette click
		this.$grid.children(".vignette").unbind('click').bind("click",function(e){
			e.preventDefault();
			if(G.freezedInput) return;

			if($j(this).hasClass("locked")){
				G.UI.$dash.children("#tooltip").text("Creature locked.");
			}

			var creatureType = $j(this).attr("creature");
			G.UI.showCreature(creatureType,G.UI.selectedPlayer);
		});

	},


	/*	toggleDash()
	*
	*	Show the dash and hide some buttons
	*
	*/
	toggleDash: function(){
		if(!this.$dash.hasClass("active")){
			this.showCreature("--",G.activeCreature.team);
		}else{
			this.closeDash();
		}

	},

	closeDash: function(){
		this.$dash.removeClass("active");
		if(this.materializeToggled){
			this.selectAbility(-1);
			G.activeCreature.queryMove();
		}
		this.materializeToggled = false;
	},


	/*	updateActiveBox()
	*
	*	Update activebox with new current creature's abilities
	*
	*/
	updateActivebox: function(){
		var $abilitiesButtons = G.UI.$activebox.children("#abilities").children(".ability");
		$abilitiesButtons.unbind("click");

		this.$activebox.children("#abilities").clearQueue().transition({y:"-420px"},function(){//Hide panel	
			$j(this).removeClass("p0 p1 p2 p3").addClass("p"+G.activeCreature.player.id);
			//Change abilities buttons
			G.UI.abilitiesButtons.each(function(){
				var ab = G.activeCreature.abilities[this.abilityId];
				this.css.normal = {"background-image":"url('../bestiary/"+G.activeCreature.name+"/"+this.abilityId+".svg')"};
				this.$button.children(".desc").html("<span>"+ab.title+"</span><p>"+ab.desc+"<br>"+ab.info+"</p>");
				this.click = function(){
					G.grid.clearHexViewAlterations();
					if(G.UI.selectedAbility!=this.abilityId){
						//Activate Abilitie
						G.activeCreature.abilities[this.abilityId].use();
					}else{
						//Cancel Abilitie
						G.UI.closeDash();
						G.activeCreature.queryMove();
					}
{'fraction_non_alphanumeric': 0.19682052593444999, 'fraction_numerical': 0.00652090525508247, 'mean_word_length': 3.6815642458100557, 'pattern_counts': {'":': 26, '<': 21, '<?xml version=': 0, '>': 27, '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': '1625275', 'n_tokens_mistral': 9614, 'n_tokens_neox': 8120, 'n_words': 1339}