WeiWeiXinNet/Games/game2/js/scripts-old.js

(开头部分) 25KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/** Define variables **/
var jewel_colors = ["blue","green","orange","purple","red","white","yellow"];
var matching_jewels = []; /** Array to hold the total current board matches **/
var matching_jewel_pair = []; /** Array to store the immediate group of matching jewels to be added to the group of total board matches **/
var selected_jewel = "";

/**
 * Randomize array element order in-place.
 * Using Fisher-Yates shuffle algorithm.
 */
function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}


var populate_board = function() {

	$('.column .jewel-wrap').each(function() {
		if ( $(this).children().length == 0 ) {
			//grab a random jewel color
			shuffleArray(jewel_colors);
			var jewel_color = jewel_colors[0];

			$(this).html('<span class="jewel"></span>'); 
			$(this).children().addClass( jewel_color ).attr('data-color',jewel_color);
		}
	});

}

var unmatch_vertical = function(jewel_column, jewel_order, jewel_color) {
	//This function serves to evaluate and change a jewel color to ensure a vertical 3 pair is broken up
	//console.log('unmatch vertical called..');

	//get color of 1 left
	var jewel_left_column = jewel_column - 1;
	var jewel_left_color = $(".column[data-column='"+jewel_left_column+"'] .jewel-wrap[data-order='"+jewel_order+"'] .jewel").attr('data-color'); 
	//get color of 1 right
	var jewel_right_column = jewel_column + 1;
	var jewel_right_color = $(".column[data-column='"+jewel_right_column+"'] .jewel-wrap[data-order='"+jewel_order+"'] .jewel").attr('data-color'); 

	//create an array of available colors to use that excludes the colors immidiately surrounding the central offending jewel
	if ( jewel_right_color == jewel_left_color ) {
		var blocked_colors = [jewel_right_color, jewel_color];
	} else {
		var blocked_colors = [jewel_right_color, jewel_left_color, jewel_color];
	}

	var available_colors = $(jewel_colors).not(blocked_colors).get();

	//shuffle the available colors and assign a random one to the central jewel
	shuffleArray(available_colors);
	//console.log(jewel_colors);
	//console.log(blocked_colors);
后面还有 476 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。