MediaWiki:Ck main.js
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
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 initPool(index) {
if(pools.length > index) {
currPool = pools[index];
} else {
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))
})
$('#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() {
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
var poolIndex = urlParams.get("index") || 0;
initPool(poolIndex)
for(var i = 0; i < pools.length; i ++) {
var poolThis = pools[i];
var $button = $('<div>', {
class: 'btn_change_pool',
text: poolThis.name,
"index": i
}).on('click', function() {
debugger
// var index = $(this).index;
// var url = new URL(window.location.href);
// url.searchParams.set("index", index);
// window.location.href = url.href;
});
$button.attr("data-index",i);
$('.change_pool').append($button);
}
$('#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()