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

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


var currPool = [];
var poolName = "";
var poolRoleTyels = [];
var numStep = [];
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;


// 截取字符串
var percent_up_50 = 0.8;
function extractContentBetweenStrings(text, start, end) {
var percent_up_45 = 0.4;
    var pattern = new RegExp(start + '((.*?)(?=' + end + '))', 'gm');
var percent_other_50 = 0.6;
    var matches = text.match(pattern);
var percent_other_45 = 0.2;
    if (matches) {
var percent_other_2_50 = 0.6;
        return matches[0].replace(start, '');
var percent_other_2_45 = 1.4;
    }
var percent_40 = 96;
    return null;
var percent_35 = 0;
}
var percent_30 = 0;


var arr_star_3 = [
function ringMoveIn(count = 1) {
{ name:'马努埃尔',star:3},
var obj_ring = document.getElementById("ring");
{ name:'伊布林',star:3},
obj_ring.style = "display: block;"
{ name:'哈利',star:3},
setTimeout(()=>{
{ name:'霍尔赫',star:3},
getRoles(count);
{ name:'萨莉亚',star:3},
{ name:'佩妮',star:3},
{ name:'迪艾格',star:3},
{ name:'费丽妮',star:3},
{ name:'比利',star:3},
{ name:'赫塞',star:3},
{ name:'帕尔',star:3},
{ name:'特利',star:3},
{ name:'弗昂',star:3},
{ name:'卡萝尔',star:3},
{ name:'科妮',star:3},
{ name:'古提',star:3},
{ name:'薇薇安',star:3},
{ name:'萨妮',star:3},
{ name:'伍格',star:3},
{ name:'南娜',star:3},
{ name:'梅妮',star:3},
{ name:'弗利欧',star:3},
{ name:'尤妮丝',star:3},
{ name:'多利',star:3},
];
var arr_star_4 = [
{ name:'普利基特',star:4 },
{ name:'洛洛',star:4 },
{ name:'雪娜',star:4 },
{ name:'约伦',star:4 },
{ name:'勒凡',star:4 },
{ name:'波拉',star:4 },
{ name:'艾弗伦',star:4 },
{ name:'肯尼斯',star:4 },
{ name:'科尔尼利亚',star:4 },
{ name:'杜兰',star:4 },
{ name:'纳尔',star:4 },
{ name:'梅贝儿',star:4 },
{ name:'伊利斯',star:4 },
{ name:'法维欧',star:4 },
{ name:'莉塔',star:4 },
{ name:'歇尔薇',star:4 },
{ name:'罗迪恩',star:4 },
{ name:'玛德蕾妮',star:4 },
{ name:'诺艾尔',star:4 },
{ name:'塞德里克',star:4 },
{ name:'梅诺',star:4 },
{ name:'巴拉德',star:4 },
{ name:'贝尔加',star:4 },
{ name:'阿孜莱特',star:4 },
{ name:'卡米拉',star:4 },
{ name:'迈尔斯',star:4 },
{ name:'贝尔特朗',star:4 },
{ name:'洁卡莉特',star:4 },
{ name:'塔希尔',star:4 },
{ name:'特里休',star:4 },
{ name:'阿什兰',star:4 },
{ name:'劳拉',star:4 },
{ name:'佩雷迪尔',star:4 },
{ name:'米娜',star:4 },
{ name:'卢塞塔',star:4 },
{ name:'拉莫纳',star:4 },
{ name:'梅蕾特',star:4 },
{ name:'皮雅',star:4 },
{ name:'哈因茨',star:4 },
{ name:'德文',star:4 },
{ name:'克雷斯',star:4 },
{ name:'卡尔茨',star:4 },
{ name:'温格特',star:4 }
];
var arr_star_5_up = [
{ name:'奥黛特',star:5 },
];
var arr_star_5_other = [
{ name:'多萝德娅',star:5 },
];
var arr_star_5_other_2 = [
{ name:'洁卡莉特Ex',star:5 },
{ name:'亚芬',star:5 },
{ name:'乌·鲁代',star:5 },
{ name:'泰蕾兹',star:5 },
{ name:'莱欧尼尔',star:5 },
{ name:'海茵特',star:5 },
{ name:'普里姆萝洁',star:5 },
{ name:'赛拉斯',star:5 },
{ name:'斯凯亚克罗',star:5 },
{ name:'菲欧儿',star:5 },
{ name:'米罗德',star:5 },
{ name:'薇欧拉',star:5 },
{ name:'莉妮特',star:5 },
{ name:'吉尔德罗伊',star:5 },
{ name:'特欧',star:5 },
{ name:'索菲亚',star:5 },
{ name:'拉斯',star:5 },
{ name:'赛西莉',star:5 },
{ name:'莲见',star:5 },
{ name:'尼兰娜拉',star:5 },
{ name:'欧尔贝克',star:5 },
{ name:'欧菲莉亚',star:5 },
{ name:'希斯柯特',star:5 },
{ name:'哈雷',star:5 },
];
var currPool = [];
var poolName = "";
var poolRoleTyels = [];
var numStep = [];
var arr_result = [];
},3500)
var max_result_level = 3;
}
var step = 0;
function getRoles(count = 1) {
for (var i = 0; i < count; i++) {
cardResult();
}


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();
}
console.log("arr_result",arr_result)


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




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


step = 2;
step = 2;


}
}
function cardResult() {
function cardResult() {


var result_num = Math.floor(Math.random() * 1000) / 10.0;
var result_num = Math.floor(Math.random() * 1000) / 10.0;
debugger
for(var i = 0;i < numStep.length; i ++) {
for(var i = 0;i < numStep.length; i ++) {
var thisStep = numStep[i];
var thisStep = numStep[i];
if(result_num < thisStep) {
if(result_num < thisStep) {
var roleTypeThis = poolRoleTyels[i];
var roleTypeThis = poolRoleTyels[i];
var arrRolesThis = roleTypeThis.roles;
var arrRolesThis = roleTypeThis.roles;
var random_index = Math.floor(Math.random() * arrRolesThis.length);
var random_index = Math.floor(Math.random() * arrRolesThis.length);
var result = JSON.parse(JSON.stringify(arrRolesThis[random_index]));
var result = JSON.parse(JSON.stringify(arrRolesThis[random_index]));
result.maxStar = roleTypeThis.maxStar;
result.maxStar = roleTypeThis.maxStar;
result.thisStar = roleTypeThis.thisStar;
result.thisStar = roleTypeThis.thisStar;
if (max_result_level < roleTypeThis.thisStar) {
if (max_result_level < roleTypeThis.thisStar) {
max_result_level = roleTypeThis.thisStar;
max_result_level = roleTypeThis.thisStar;
}
arr_result.push(result);
break
}
}
}
arr_result.push(result);
return
break
// console.log(result_num)
// var result_role = {};
// var star_curr_num = 3;
// if(result_num < percent_up_50.toFixed(2)) {
// result_role = getRole("up_50");
// } else if(result_num < (percent_up_50 + percent_up_45).toFixed(2)) {
// result_role = getRole("up_45");
// } else if(result_num < (percent_up_50 + percent_up_45 + percent_other_50).toFixed(2)) {
// result_role = getRole("other_50");
// } else if(result_num < (percent_up_50 + percent_up_45 + percent_other_50 + percent_other_45).toFixed(2)) {
// result_role = getRole("other_45");
// } else if(result_num < (percent_up_50 + percent_up_45 + percent_other_50 + percent_other_45 + percent_other_2_50).toFixed(2)) {
// result_role = getRole("other_2_50");
// } else if(result_num < (percent_up_50 + percent_up_45 + percent_other_50 + percent_other_45 + percent_other_2_50 + percent_other_2_45).toFixed(2)) {
// result_role = getRole("other_2_45");
// } else {
// result_role = getRole("40");
// }
 
// if(max_result_level < result_role.star) {
// max_result_level = result_role.star;
// }
// arr_result.push(result_role);
 
}
}
function getRole( str_star = "30") {
}
var thisArr = [];
}
var star_num = 3;
var half = false;
if(str_star == "30") {
thisArr = arr_star_3;
star_num = 3;
half = false;
} else if(str_star == "35") {
thisArr = arr_star_4;
star_num = 3;
half = true;
} else if( str_star == "40") {
thisArr = arr_star_4;
star_num = 4;
half = false;
} else if(str_star == "other_2_45") {
thisArr = arr_star_5_other_2;
other_half_num ++;
star_num = 4;
half = true;
} else if(str_star == "other_2_50") {
thisArr = arr_star_5_other_2;
other_num ++;
star_num = 5;
half = false;
} else if(str_star == "other_45") {
thisArr = arr_star_5_other;
other_half_num ++;
star_num = 4;
half = true;
} else if(str_star == "other_50") {
thisArr = arr_star_5_other;
other_num ++;
star_num = 5;
half = false;
} else if(str_star == "up_45") {
thisArr = arr_star_5_up;
up_half_num ++;
star_num = 4;
half = true;
} else if(str_star == "up_50") {
thisArr = arr_star_5_up;
up_num ++;
star_num = 5;
half = false;
} else {
return { name:"",img:"" }
}


 
function clickWindow() {
var arr_length = thisArr.length;
if(step != 2) return;
var random_num = Math.floor(Math.random() * arr_length);
step = 3;
var result = thisArr[random_num];
result.star = star_num;
var obj_result_area = document.getElementsByClassName("result_area")[0];
result.half = half;
obj_result_area.style = "display:flex;"
console.log(str_star)
console.log(result)
// 正常流程
return result;
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 + "★"
}
}
function clickWindow() {
if(objThis.maxStar > objThis.thisStar) {
if(step != 2) return;
str_html = str_html + ""
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) {
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)
}


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


getRoles(count);
getRoles(count);


}
}


function initFunc() {
function initFunc() {
$(document).ready(function() {
$(document).ready(function() {
console.log("pools->",pools)
console.log("pools->",pools)
currPool = pools[0];
currPool = pools[0];
poolName = currPool.name;
poolName = currPool.name;
poolRoleTyels = currPool.roleType;
poolRoleTyels = currPool.roleType;
numStep = [];
numStep = [];
var numCurr = 0;
var numCurr = 0;
poolRoleTyels.forEach(item => {
poolRoleTyels.forEach(item => {
numCurr = numCurr + item.num;
numCurr = numCurr + item.num;
numStep.push(numCurr.toFixed(2))
numStep.push(numCurr.toFixed(2))
})
})
console.log("numStep",numStep)
console.log("numStep",numStep)
$('#btn_start_1').on("click",function() {
console.log('clickStart(1)');
clickStart(1)
$('#btn_start_1').on("click",function() {
});
console.log('clickStart(1)');
$('#btn_start_2').on("click",()=>{
clickStart(1)
console.log('clickStart(10)');
clickStart(10)
});
});
$('#btn_start_2').on("click",()=>{
$('#window_area').on("click",()=>{
console.log('clickStart(10)');
clickWindow()
clickStart(10)
});
});
});
$('#window_area').on("click",()=>{
clickWindow()
});
});


}
}


initFunc()
initFunc()

2024年9月6日 (五) 11:52的版本

var currPool = [];
var poolName = "";
var poolRoleTyels = [];
var numStep = [];
	


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 = [];
	
	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 initFunc() {
	
	$(document).ready(function() {
		console.log("pools->",pools)
		currPool = pools[0];
		poolName = currPool.name;
		poolRoleTyels = currPool.roleType;
		numStep = [];
		
		var numCurr = 0;
		poolRoleTyels.forEach(item => {
			numCurr = numCurr + item.num;
			numStep.push(numCurr.toFixed(2))
		})
		console.log("numStep",numStep)
	
		$('#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()