<commit_before>/**
 * @author       <NAME>
 * @copyright    2017 <NAME>
 * @license      {@link http://opensource.org/licenses/MIT}
 *
 * Available events:
 * 					rouletteInitialized
 * 					currentPocketChanged
					currentPocketChangedAfterCountDown
					currentPocketChangedBeforeCountDown
					onCompleteSpinReel
					reelCountDownStarted
 */
var rouletteModule = {
	/**
	 * Instances
	 */
	/** rouletteUnits prop contains a Phaser group that holds from lable, disc to needle */
	'rouletteUnits': {},
	/**
	 * Properties
	 */
	/**
	 * Constants
	 */
	'NUMBER_OF_POCKETS': 36,
	'DEGREE_OF_A_POCCKET': 10,
	'LABEL_STYLE': {
		font: "bold 25px Arial",
		fill: "#fff",
		boundsAlignH: "center",
		boundsAlignV: "middle"
	},
	/**
	 * Public Methods
	 */
	 /**
	  * Initialize
	  *
	  * @param      {string}  rouletteID       The roulette id
	  * @param      {array}   pocketBetStrip    The pocket bet strip (optional)
	  */
	init: function (rouletteID,pocketBetStrip) {
		if(!rouletteID) {
			console.log('No ID specified.');
			return false;
		}
		pocketBetStrip = pocketBetStrip || ['2', '6', '2', '4', '10', '2', '4', '6', '0', '4', '8', '2', '6', '2', '4', '2', '10', '2', '6', '4', '2', '6', '2', '8', '2', '4', '0', '30', '2', '8', '4', '2', '10', '2', '4', '8'];
		this._buildRouletteUnit(rouletteID,pocketBetStrip);
		// reset the needle
		this._getCurrentStopID(rouletteID,true);
		// rouletteInitialized
		PCB.event.trigger('rouletteInitialized');
	},
	/**
	 * Spin the roulette disc
	 *
	 * @param      {string}  rouletteID       The roulette id
	 */
	spinRoulette: function (rouletteID) {
		/** _self */
		var _self = this;
		var $_currentRouletteUnit = this.rouletteUnits[rouletteID];

		/** return if the reel is already in motion */
		if($_currentRouletteUnit.isSpinning === true) return;

		/** set the spin state immediately */
		$_currentRouletteUnit.isSpinning = true;

		/** reelSpinStarted event can be used to start playing the sound */
		PCB.event.trigger('reelSpinStarted');

		/** define variables */
		var $_targetDisc = $_currentRouletteUnit.disc;

		/** randomize angle and duration of spinning */
		var _rand_angle = Math.floor(~~(Math.random()*(360)));
		var _rand_time = Math.floor(Math.random() * 2000) - 1000;
		/** using tween to spin the wheel */
		var _tween = Game.add.tween($_targetDisc).to({
			angle: 1080 + _rand_angle
		}, 11000 + _rand_time, function(k) {
			_self._getCurrentStopID(rouletteID);
			if(k > 0.53 && $_currentRouletteUnit.reelCountDownStarted === false) {
				$_currentRouletteUnit.reelCountDownStarted = true;
				PCB.event.trigger('reelCountDownStarted');
			}
			return --k * k * k + 1;
		}, true);

		_tween.onComplete.add(_findFinalResult, this);

		function _findFinalResult() {
			$_currentRouletteUnit.isSpinning = false;
			$_currentRouletteUnit.reelCountDownStarted = false;
			_self._getCurrentStopID(rouletteID,true);
			/** trigger event */
			PCB.event.trigger('onCompleteSpinReel');
		}
	},
	/**
	 * Private methods
	 */
	/**
	 * Sensors
	 */
	/**
	 * Gets the current pocket.
	 *
	 * @param      {string}		rouletteID    The reel id
	 * @param      {bool}  		lastTick  Is the last tick just before finalizing the result?
	 */
	_getCurrentStopID: function (rouletteID,lastTick) {
		// backdoors
		var $_targetUnit = this.rouletteUnits[rouletteID];
		var $_targetDisc = $_targetUnit.disc;
		// props
		_reelCountDownStarted = $_targetUnit.reelCountDownStarted;<commit_msg>math floor is not needed<commit_after>/**
 * @author       <NAME>
 * @copyright    2017 <NAME>
 * @license      {@link http://opensource.org/licenses/MIT}
 *
 * Available events:
 * 					rouletteInitialized
 * 					currentPocketChanged
					currentPocketChangedAfterCountDown
					currentPocketChangedBeforeCountDown
					onCompleteSpinReel
					reelCountDownStarted
 */
var rouletteModule = {
	/**
	 * Instances
	 */
	/** rouletteUnits prop contains a Phaser group that holds from lable, disc to needle */
	'rouletteUnits': {},
	/**
	 * Properties
	 */
	/**
	 * Constants
	 */
	'NUMBER_OF_POCKETS': 36,
	'DEGREE_OF_A_POCCKET': 10,
	'LABEL_STYLE': {
		font: "bold 25px Arial",
		fill: "#fff",
		boundsAlignH: "center",
		boundsAlignV: "middle"
	},
	/**
	 * Public Methods
	 */
	 /**
	  * Initialize
	  *
	  * @param      {string}  rouletteID       The roulette id
	  * @param      {array}   pocketBetStrip    The pocket bet strip (optional)
	  */
	init: function (rouletteID,pocketBetStrip) {
		if(!rouletteID) {
			console.log('No ID specified.');
			return false;
		}
		pocketBetStrip = pocketBetStrip || ['2', '6', '2', '4', '10', '2', '4', '6', '0', '4', '8', '2', '6', '2', '4', '2', '10', '2', '6', '4', '2', '6', '2', '8', '2', '4', '0', '30', '2', '8', '4', '2', '10', '2', '4', '8'];
		this._buildRouletteUnit(rouletteID,pocketBetStrip);
		// reset the needle
		this._getCurrentStopID(rouletteID,true);
		// rouletteInitialized
		PCB.event.trigger('rouletteInitialized');
	},
	/**
	 * Spin the roulette disc
	 *
	 * @param      {string}  rouletteID       The roulette id
	 */
	spinRoulette: function (rouletteID) {
		/** _self */
		var _self = this;
		var $_currentRouletteUnit = this.rouletteUnits[rouletteID];

		/** return if the reel is already in motion */
		if($_currentRouletteUnit.isSpinning === true) return;

		/** set the spin state immediately */
		$_currentRouletteUnit.isSpinning = true;

		/** reelSpinStarted event can be used to start playing the sound */
		PCB.event.trigger('reelSpinStarted');

		/** define variables */
		var $_targetDisc = $_currentRouletteUnit.disc;

		/** randomize angle and duration of spinning */
		var _rand_angle = Math.floor(~~(Math.random()*(360)));
		var _rand_time = Math.floor(Math.random() * 2000) - 1000;
		/** using tween to spin the wheel */
		var _tween = Game.add.tween($_targetDisc).to({
			angle: 1080 + _rand_angle
		}, 11000 + _rand_time, function(k) {
			_self._getCurrentStopID(rouletteID);
			if(k > 0.53 && $_currentRouletteUnit.reelCountDownStarted === false) {
				$_currentRouletteUnit.reelCountDownStarted = true;
				PCB.event.trigger('reelCountDownStarted');
			}
			return --k * k * k + 1;
		}, true);

		_tween.onComplete.add(_findFinalResult, this);

		function _findFinalResult() {
			// reset once to the degree under 360
			$_targetDisc.angle = $_targetDisc.angle % 360;
			$_currentRouletteUnit.isSpinning = false;
			$_currentRouletteUnit.reelCountDownStarted = false;
			_self._getCurrentStopID(rouletteID,true);
			/** trigger event */
			PCB.event.trigger('onCompleteSpinReel');
		}
	},
	/**
	 * Private methods
	 */
	/**
	 * Sensors
	 */
	/**
	 * Gets the current pocket.
	 *
	 * @param      {string}		rouletteID    The reel id
	 * @param      {bool}  		lastTick  Is the last tick just before finalizing the result?
	 */
	_getCurrentStopID: function (rouletteID,lastTick) {
		// backdoors
		var $_targetUnit = this.rouletteUnits[rouletteID];
		var $_targetDisc = $_targetUnit.disc;
		// props
		_reelCountDownStarted = $_targetUnit.reelCountDownStarted;
{'fraction_non_alphanumeric': 0.15130260521042085, 'fraction_numerical': 0.022044088176352707, 'mean_word_length': 3.4165613147914033, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4282983', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2403, 'n_words': 551}