<commit_before>/******************************************************************************
 * Game utitilies. 
 * Functions defined on the Game object.
 * These should be of general use across games;
 * Functions unique to a game type will be loaded in a js file 
 * associated with that type in the /admin area of the host program.
 * All game util files should have the same format: $.extend(Game, ...)
 ******************************************************************************/

$.extend(Game, {
	
	everyNthTime: function (n, return_value, default_value) {
		this.i = this.i || 0;
		this.i++;
		if (this.i === n) {
			this.i = 0;
			return return_value;
		} else {
			return default_value;
		}
	},
	
	aboutEveryNTimes: function (n, return_value, default_value) {
		if (Math.trunc(Math.random() * n) % n === 0) {
			return return_value;
		} else {
			return default_value;
		}
	}
});<commit_msg>add cleanup routine to clear cards before looping back to first question in sample game.<commit_after>/******************************************************************************
 * Game utitilies. 
 * Functions defined on the Game object.
 * These should be of general use across games;
 * Functions unique to a game type will be loaded in a js file 
 * associated with that type in the /admin area of the host program.
 * All game util files should have the same format: $.extend(Game, ...)
 ******************************************************************************/

$.extend(Game, {
	
	everyNthTime: function (n, return_value, default_value) {
		this.i = this.i || 0;
		this.i++;
		if (this.i === n) {
			this.i = 0;
			return return_value;
		} else {
			return default_value;
		}
	},
	
	aboutEveryNTimes: function (n, return_value, default_value) {
		if (Math.trunc(Math.random() * n) % n === 0) {
			return return_value;
		} else {
			return default_value;
		}
	},
	
	clearAllCards: function () {
		// tell all dealers to clear their cards from the game.
		try {
			this.prompter.discardAll();
			this.listener.discardAll();
			this.responder.discardAll();
		} catch (e) {
			console.log(e);
		}
		// clear any remaining cards (probably orphaned).
		this.element.find(".card").remove();
	}
});
{'fraction_non_alphanumeric': 0.2471757794848622, 'fraction_numerical': 0.0027112516945323093, 'mean_word_length': 3.8130434782608695, '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': '1324240', 'n_tokens_mistral': 716, 'n_tokens_neox': 620, 'n_words': 214}