<commit_before>var app = angular.module('Hangular');

app.service('HangularService', function($http, $q) {
		/*GAME ESSENTIALS*/
	this.playAgain = false;
	
	
//			**LEGACY** BEFORE MONGO
/*	this.pickWord = function() {
		var words = ['entourage', 'wheat', 'three'];
		console.log('this.pickWord HIT')
		return words[Math.floor(Math.random() * words.length)];
	};//end pickWord*/
	
	this.word;
	this.wordErr;
	this.remainingGuesses;
	
	this.setupGame = function() {
		var dfd = $q.defer();
		var that = this;
		$http({
			method : 'GET',
			url : 'http://127.0.0.1:9420/api/words'
		}).then(function(response){
			dfd.resolve(response.data);
			console.log(response.data);
			var word = response.data[Math.floor(Math.random() * response.data.length)].word;
			console.log(word);
			that.word = word;
			that.answerArray = that.setupAnswerArray(that.word);
			that.remainingLetters = that.word.length;
			that.remainingGuesses = 7;
			that.playAgain = false;
		});
		return dfd.promise;
	};
	
	this.addWord = function(word) {
		if((!word) || (word.length <= 2)) {
		 	this.wordErr = true;
			return;
		}
		$http({
			method: 'POST',
			url : 'http://127.0.0.1:9420/api/words',
			data: {
				"word" : word
			}
		});
	};


	
	this.setupAnswerArray = function(word) {
		console.log('this.setupAnswerArray HIT');
		var answerArray = [];
		for(var i = 0; i < word.length; i++) {
			answerArray[i] = " _";
		}
		console.log(answerArray);
		return answerArray;
	}; // end setupAnswerArray
	
	//GAME STATE CREATION AND GAME EXECUTION//
	
//	this.setupGame = function() {
//		console.log(this.word);
//		this.answerArray = this.setupAnswerArray(this.word);
//		this.remainingLetters = this.word.length;
//		this.playAgain = false;
//	};//end setupGame
	
	this.updateGameState = function(guess, word, answerArray, remGuesses) {
		console.log('this.uGS HIT');
		var count = 0;
		var newWord;
		for(var i = 0; i < word.length; i++) {
			var splitWord = word.split('');
			console.log(splitWord);
			if(guess === word[i]) {
				answerArray[i] = guess;
				splitWord[i] = ' ';
				this.remainingLetters -= 1;
				console.log(this.remainingLetters);
				count +=1;
				remGuesses += count;
				newWord = splitWord.join('')
				if(this.remainingLetters === 0) {
					this.answerArray = "You got it! The answer was " + this.word + "!!";
					this.playAgain = true;
					
				}// end You Win! section
			
			}// end correct guess section
			
		}// end for loop
		if(count > 0) { return };
		return this.remainingGuesses = remGuesses -=1;
	};// end updateGameState
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});//end HangularService<commit_msg>git diff test<commit_after>var app = angular.module('Hangular');

app.service('HangularService', function($http, $q) {
		/*GAME ESSENTIALS*/
	this.playAgain = false;
	
	
//			**LEGACY** BEFORE MONGO
/*	this.pickWord = function() {
		var words = ['entourage', 'wheat', 'three'];
		console.log('this.pickWord HIT')
		return words[Math.floor(Math.random() * words.length)];
	};//end pickWord*/
	
	this.word;
	this.wordErr;
	this.remainingGuesses;
	
	this.setupGame = function() {
		var dfd = $q.defer();
		var that = this;
		$http({
			method : 'GET',
			url : 'http://127.0.0.1:9420/api/words'
		}).then(function(response){
			dfd.resolve(response.data);
			console.log(response.data);
			var word = response.data[Math.floor(Math.random() * response.data.length)].word;
			console.log(word);
			that.word = word;
			that.answerArray = that.setupAnswerArray(that.word);
			that.remainingLetters = that.word.length;
			that.remainingGuesses = 7;
			that.playAgain = false;
		});
		return dfd.promise;
	};
	
	this.addWord = function(word) {
		if((!word) || (word.length <= 2)) {
		 	this.wordErr = true;
			return;
		}
		$http({
			method: 'POST',
			url : 'http://127.0.0.1:9420/api/words',
			data: {
				"word" : word
			}
		});
	};


	
	this.setupAnswerArray = function(word) {
		console.log('this.setupAnswerArray HIT');
		var answerArray = [];
		for(var i = 0; i < word.length; i++) {
			answerArray[i] = " _";
		}
		console.log(answerArray);
		return answerArray;
	}; // end setupAnswerArray
	
	//GAME STATE CREATION AND GAME EXECUTION//
	
//	this.setupGame = function() {
//		console.log(this.word);
//		this.answerArray = this.setupAnswerArray(this.word);
//		this.remainingLetters = this.word.length;
//		this.playAgain = false;
//	};//end setupGame
	
	this.updateGameState = function(guess, word, answerArray, remGuesses) {
		console.log('this.uGS HIT');
		var count = 0;
		var newWord;
		for(var i = 0; i < word.length; i++) {
			var splitWord = word.split('');
			console.log(splitWord);
			if(guess === word[i]) {
				answerArray[i] = guess;
				splitWord[i] = ' ';
				this.remainingLetters -= 1;
				console.log(this.remainingLetters);
				count +=1;
				remGuesses += count;
				newWord = splitWord.join('')
				if(this.remainingLetters === 0) {
					this.answerArray = "You got it! The answer was " + this.word + "!!";
					this.playAgain = true;
					
				}// end You Win! section
			
			}// end correct guess section
			
		}// end for loop
		if(count > 0) { return };
		return this.remainingGuesses = remGuesses -=1;
		
	};// end updateGameState
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});//end HangularService
{'fraction_non_alphanumeric': 0.16926838442730863, 'fraction_numerical': 0.011284558961820575, 'mean_word_length': 2.782361308677098, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '898161', 'n_tokens_mistral': 2364, 'n_tokens_neox': 1933, 'n_words': 369}