console
let firstPool=[];
let secondPool=[];
let thirdPool = [];
let A=[];
let B=[];
let C=[];
let D=[];
function genrateUnNomarl(){
var firstSeed = ['FPX','SKT','G 2','T L'];
var secondSeed = ['RNG','I G','GRF','FNC','C 9','AHQ','J T','GAM'];
var thirdSeed = ['DWG','HKA','C G','SPY']
var LPL = ['FPX','RNG','I G'];
var LCK = ['SKT','GRF','DWG'];
var LCS = ['T L','C 9','C G'];
var LCE = ['G 2','FNC','SPY'];
var LMS = ['J T','AHQ','HKA'];
const area = [...LPL,...LCK,...LCS,...LCE,...LMS];
const keyValue = {
0:LPL,1:LPL,2:LPL,
3:LCK,4:LCK,5:LCK,
6:LCS,7:LCS,8:LCS,
9:LCE,10:LCE,11:LCE,
12:LMS,13:LMS,14:LMS,
}
A=[];
B=[];
C=[];
D=[];
const randomSeed = (arr) =>{
var result = [];
const max=arr.length;
for (var i = 0; i < 4; i++) {
var ran = Math.floor(Math.random() * arr.length);
result.push(arr.splice(ran, 1)[0]);
};
if(max===8){
return [result,arr]
}
return result;
}
let firstPool=randomSeed(firstSeed);
let secondPool=randomSeed(secondSeed);
let thirdPool = randomSeed(thirdSeed);
restart=()=>{
firstPool=randomSeed(firstSeed);
secondPool=randomSeed(secondSeed);
thirdPool = randomSeed(thirdSeed);
}
const teamPush=(teamLabel,number,label)=>{
teamLabel.push(firstPool[number]);
const oneIndex=_.indexOf(area,teamLabel[0]);
const two=_.findIndex(secondPool[0],item=>_.indexOf(keyValue[oneIndex],item)===-1);
teamLabel.push(secondPool[0].splice(two,1)[0]);
const twoIndex=_.indexOf(area,teamLabel[1]);
const three=_.findIndex(secondPool[1],item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1);
teamLabel.push(secondPool[1].splice(three,1)[0]);
const threeIndex=_.indexOf(area,teamLabel[2]);
const four=_.findIndex(thirdPool,item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1&&_.indexOf(keyValue[threeIndex],item)===-1);
teamLabel.push(thirdPool.splice(four,1)[0]);
$(label).innerHTML = JSON.stringify(teamLabel);
}
teamPush(A,0,'A');
teamPush(B,1,'B');
teamPush(C,2,'C');
teamPush(D,3,'D');
}
const check=(arr)=>{
var firstSeed = ['FPX','SKT','G 2','T L'];
var secondSeed = ['RNG','I G','GRF','FNC','C 9','AHQ','J T','GAM'];
var thirdSeed = ['DWG','HKA','C G','SPY']
var LPL = ['FPX','RNG','I G'];
var LCK = ['SKT','GRF','DWG'];
var LCS = ['T L','C 9','C G'];
var LCE = ['G 2','FNC','SPY'];
var LMS = ['J T','AHQ','HKA'];
const area = [...LPL,...LCK,...LCS,...LCE,...LMS];
const keyValue = {
0:LPL,1:LPL,2:LPL,
3:LCK,4:LCK,5:LCK,
6:LCS,7:LCS,8:LCS,
9:LCE,10:LCE,11:LCE,
12:LMS,13:LMS,14:LMS,
}
const oneIndex=_.indexOf(area,arr[0]);
const twoIndex=_.indexOf(area,arr[1]);
const threeIndex=_.indexOf(area,arr[2]);
const fourIndex=_.indexOf(area,arr[3]);
const confirmArr=[oneIndex,twoIndex,threeIndex,fourIndex];
for(i=0;i<4;i++){
for(j=i+1;j<4;j++){
if(keyValue[confirmArr[i]]===keyValue[confirmArr[j]]){
return true
}
}
}
return false;
}
const genrate=()=>{
do{ genrateUnNomarl();
}while(check(A)||check(B)||check(C)||check(D))
}
const clearTeam=()=>{
$('A').innerHTML = '';
$('B').innerHTML = '';
$('C').innerHTML = '';
$('D').innerHTML = '';
};
<div class="des">
<div class="des">
<h1>
LOLS9世界总决赛抽签模拟器——我为LPL抽个好签
</h1>
</div>
<div class="des">
<table>
<tr>
<td>
A:
</td>
<td id="A"/>
</tr>
<tr>
<td>
B:
</td>
<td id="B">
</td>
</tr>
<tr>
<td>
C:
</td>
<td id="C">
</td>
</tr>
<tr>
<td>
D:
</td>
<td id="D">
</td>
</tr>
</table>
<div class="intr">
<button onclick='genrate()'>抽签</button>
<button onclick='clearTeam() '>清空</button>
</div>
</div>
<div id="list">
</div>
<div class="intr">
<img src="https://i.ibb.co/3mQsgV0/myQrcode.jpg" alt="myQrcode" border="0">
<table>
<tr><td>author:Toast不是吐司</td></tr>
<tr><td>如果有bug或好的idea,请联系作者vx:dove859289582</td></tr>
<tr><td>QQ:859289582</td></tr>
</table>
</div>
<div class="des">
<table>
<tr><td>版本:1.0.6</td></tr>
<tr><td> GAM为越南一号种子,二号种子池队伍</td></tr>
<tr><td> FNC为LEC二号种子,SPY为三号种子</td></tr>
<tr><td> 目前暂按四大赛区三号种子突围入围赛</td></tr>
<tr><td> 故三号种子池为DWG,HKA,CG,SPY</td></tr>
</table>
</div>
body {
background: #FFF;
}
button{
clear:both;
display:block;
margin:20px auto;
outline:none;
border-radius:30px;
border:1px solid #eee;
background:#FFF;
padding:10px 40px;
color:#555;
}
img{
width: 6rem;
height:6rem;
}
.des {
font-size: 12px;
color: #aaa;
width:600px;
margin:auto;
}
.intr{
flex-direction: row;
display: flex;
}
td{
border:0;
border-top:1px dashed #eee;
border-left: 1px dashed #eee;
padding:3px 25px;
color:#555;
font-size:12px;
}
td:last-child{
border-right: 1px dashed #eee;
}
table{
margin-top:20px;
width:600px;
margin:auto;
}