SOURCE

console 命令行工具 X clear

                    
>
console
// 生成器 A1 A2 A3 A4 B1 B2 B3 B4 B5 B6 B7 B8 C1 C2 C3 C4
// var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
// var _ = require('lodash');

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];  // 通过findIndex
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]);
        
        };
    // console.log(result)
    if(max===8){
        // console.log(arr)
        return [result,arr]
    }
    return  result;
}

let firstPool=randomSeed(firstSeed);
let secondPool=randomSeed(secondSeed);
let thirdPool = randomSeed(thirdSeed);

// const change = (arr,currentIndex,goalIndex) =>{
//   let newArr=arr;
//   newArr[currentIndex]=arr[goalIndex];
//   newArr[goalIndex]=arr[currentIndex];
//   return newArr;
// }

restart=()=>{
    firstPool=randomSeed(firstSeed);
    secondPool=randomSeed(secondSeed);
    thirdPool = randomSeed(thirdSeed);
}

// 可以先按照“不回避原则”排序,A组从二三档里按序拿去需要的优先队伍
// A.push(firstPool[0]);
// // console.log(area,A[0]);
// const oneIndex=_.indexOf(area,A[0]); // 一号种子在area中的编号,从而找到对应赛区队伍
// // console.log(first);
// const two=_.findIndex(secondPool[0],item=>_.indexOf(keyValue[oneIndex],item)===-1); // 将二档队伍中第一个不属于一号种子赛区的队伍   二号池子中index
// A.push(secondPool[0].splice(two,1)[0]);
// // console.log(two,secondPool[0]);
// const twoIndex=_.indexOf(area,A[1]);
// const three=_.findIndex(secondPool[1],item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1); // 将二档队伍中第一个不属于A组前两队赛区的队伍   二号池子中index
// A.push(secondPool[1].splice(three,1)[0]);
// const threeIndex=_.indexOf(area,A[2]);
// const four=_.findIndex(thirdPool,item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1&&_.indexOf(keyValue[threeIndex],item)===-1); //   三号池子中index
// A.push(thirdPool.splice(four,1)[0]);
// console.log(A);

const teamPush=(teamLabel,number,label)=>{
    teamLabel.push(firstPool[number]);
    // console.log(area,teamLabel[0]);
    const oneIndex=_.indexOf(area,teamLabel[0]); // 一号种子在area中的编号,从而找到对应赛区队伍
    // console.log(first);
    const two=_.findIndex(secondPool[0],item=>_.indexOf(keyValue[oneIndex],item)===-1); // 将二档队伍中第一个不属于一号种子赛区的队伍   二号池子中index
    teamLabel.push(secondPool[0].splice(two,1)[0]);
    // console.log(two,secondPool[0]);
    const twoIndex=_.indexOf(area,teamLabel[1]);
    const three=_.findIndex(secondPool[1],item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1); // 将二档队伍中第一个不属于A组前两队赛区的队伍   二号池子中index
    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); //   三号池子中index
    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');


  
// console.log(A);
// console.log(B);
// console.log(C);
// console.log(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];  // 通过findIndex
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]); // 一号种子在area中的编号,从而找到对应赛区队伍
    const twoIndex=_.indexOf(area,arr[1]);
    const threeIndex=_.indexOf(area,arr[2]);
    const fourIndex=_.indexOf(area,arr[3]);
    const confirmArr=[oneIndex,twoIndex,threeIndex,fourIndex];
    // console.log(confirmArr,'---')
    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;
}

本项目引用的自定义外部资源