MediaWiki:Ck main.js:修订间差异

无编辑摘要
无编辑摘要
第1行: 第1行:


var currPool = [];
var currPool = {};
var poolName = "";
var poolName = "";
var poolRoleTyels = [];
var poolRoleTyels = [];
var numStep = [];
var numStep = [];
 
var stepPoolIndex = 0;


var arr_result = [];
var arr_result = [];
第145行: 第145行:
arr_result = [];
arr_result = [];
total_num = total_num + count;
if(currPool.step) {
var countThis = currPool.stepCount[stepPoolIndex];
total_num = total_num + countThis;
stepPoolIndex = stepPoolIndex + 1;
if(stepPoolIndex > currPool.stepCount.length) {
stepPoolIndex = 0
}
} else {
total_num = total_num + count;
}
setTimeout(function(){
setTimeout(function(){
第166行: 第177行:
poolRoleTyels = currPool.roleType;
poolRoleTyels = currPool.roleType;
numStep = [];
numStep = [];
stepPoolIndex = 0;
var numCurr = 0;
var numCurr = 0;
第174行: 第186行:
console.log("numStep",numStep)
console.log("numStep",numStep)
$('#pool_title').html(poolName)
$('#pool_title').html(poolName);
if(currPool.step) {
$('#btn_start_1').css("display","none")
} else {
$('#btn_start_1').css("display","block")
}
}
}



2024年9月6日 (五) 14:18的版本

var currPool = {};
var poolName = "";
var poolRoleTyels = [];
var numStep = [];
	
var stepPoolIndex = 0;

var arr_result = [];
var max_result_level = 3;
var step = 0;


var total_num = 0;
var up_num = 0;
var up_half_num = 0;
var other_num = 0;
var other_half_num = 0;

// 截取字符串
function extractContentBetweenStrings(text, start, end) {
    var pattern = new RegExp(start + '((.*?)(?=' + end + '))', 'gm');
    var matches = text.match(pattern);
    if (matches) {
        return matches[0].replace(start, '');
    }
    return null;
}

function ringMoveIn(count = 1) {
	var obj_ring = document.getElementById("ring");
	obj_ring.style = "display: block;"
	setTimeout(()=>{
		getRoles(count);
		
	},3500)
}
function getRoles(count = 1) {
	for (var i = 0; i < count; i++) {
		cardResult();
	}


	$("#ring").css("display","none");


	if (max_result_level == 5) {
		$("#ring_2").css("display","block")
	} else if (max_result_level == 4) {
		$("#ring_1").css("display","block")
	} else {
		$("#ring_0").css("display","block")
	}

	step = 2;

}
function cardResult() {
	
	

	var result_num = Math.floor(Math.random() * 1000) / 10.0;
	
	for(var i = 0;i < numStep.length; i ++) {
		var thisStep = numStep[i];
		if(result_num < thisStep) {
			var roleTypeThis = poolRoleTyels[i];
			var arrRolesThis = roleTypeThis.roles;
			var random_index = Math.floor(Math.random() * arrRolesThis.length);
			var result = JSON.parse(JSON.stringify(arrRolesThis[random_index]));
			result.maxStar = roleTypeThis.maxStar;
			result.thisStar = roleTypeThis.thisStar;
			if (max_result_level < roleTypeThis.thisStar) {
				max_result_level = roleTypeThis.thisStar;
			}
			arr_result.push(result);
			break
			
		}
	}
	
}

function clickWindow() {
	if(step != 2) return;
	step = 3;
	
	var obj_result_area = document.getElementsByClassName("result_area")[0];
	obj_result_area.style = "display:flex;"
	
	// 正常流程
	setTimeout(()=>{
		
		obj_result_area.style = "display:flex;background-image: url(https://i.17173cdn.com/g8bz6k/octopathsp/5/58/db_ck_bg.png?20240904091141);background-color:transparent;"
		$(".img_ring").each(function(){
			$(this).css("display","none")
		})
		var obj_all_result = document.getElementsByClassName("all_Result")[0];
		obj_all_result.innerHTML = "<div>" +  "本次抽卡" + total_num + "次,消费" + total_num * 30 + "钻石" + "</div><div>" + "抽到5星当期UP角色" + up_num + "次,4.5星当期UP角色" + up_half_num + "次</div><div>其他5星角色" + other_num  + '次,其他4.5星角色' + other_half_num + '次' + "</div>";
		showResults();
	},2500)
	
	
	
}
function showResults() {
	var str_html = "";
	for (var i = 0; i < arr_result.length; i++) {
		var objThis = arr_result[i];
		str_html = str_html + "<div class='role_area'>" 
			+ "<div class='text'>" + objThis.name + "</div>"
			+ "<div class='text'>";
		for(var j = 0; j < objThis.thisStar ; j ++) {
			str_html = str_html + "★"
		}
		if(objThis.maxStar > objThis.thisStar) {
			str_html = str_html + "☆"
		}
				
		
		var roleData = getRoleDataWithRoleName(objThis.name);
		var img_lh = "https://wiki.17173.com/octopathsp/thumb.php?f=角色立绘-角色编号" + roleData[0] + ".png&width=200x";
		var img_xs = "https://wiki.17173.com/octopathsp/thumb.php?f=" + roleData[2] + ".png&width=100x";
	
		
		str_html = str_html + "</div>" + "<img class='img' src='" + img_lh + "'/>" + "<img class='img_xs' src='" + img_xs + "' />" + "</div>"
	}
	
	
	$(".result_area").each(function(){
		
		$(this).html(str_html).load()
	})
	
	setTimeout(()=>{
		step = 0;
	},1000)
}

function clickStart( count = 1) {

	if(step != 0) return
	step = 1;
	max_result_level = 3;
	arr_result = [];
	
	if(currPool.step) {
		var countThis = currPool.stepCount[stepPoolIndex];
		total_num = total_num + countThis;
		stepPoolIndex = stepPoolIndex + 1;
		if(stepPoolIndex > currPool.stepCount.length) {
			stepPoolIndex = 0
		}
		
	} else {
		total_num = total_num + count;
	}
	
	
	setTimeout(function(){
		$("#window_area").css("background-color","transparent");
	},1000)
	
	var obj_result_area = document.getElementsByClassName("result_area")[0];
	obj_result_area.style = "display:none;background-color:#FFFFFF;"
	obj_result_area.innerHTML = "";
	

	getRoles(count);

}

function changePool(index) {
	console.log("pools->",pools)
	currPool = pools[0];
	poolName = currPool.name;
	poolRoleTyels = currPool.roleType;
	numStep = [];
	stepPoolIndex = 0;
	
	var numCurr = 0;
	poolRoleTyels.forEach(item => {
		numCurr = numCurr + item.num;
		numStep.push(numCurr.toFixed(2))
	})
	console.log("numStep",numStep)
	
	$('#pool_title').html(poolName);
	
	if(currPool.step) {
		$('#btn_start_1').css("display","none")
	} else {
		$('#btn_start_1').css("display","block")
	}
}

function initFunc() {
	
	$(document).ready(function() {
		changePool(0)
		
	
		$('#btn_start_1').on("click",function() {
			console.log('clickStart(1)');
			clickStart(1)
			
		});
		$('#btn_start_2').on("click",()=>{
			console.log('clickStart(10)');
			clickStart(10)
		});
		$('#window_area').on("click",()=>{
			clickWindow()
		});
	});

}

initFunc()