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 = ['EDG','MAD','D K','PSG'];
var secondSeed = ['FPX','GEN','FNC','100T'];
var thirdSeed = ['RNG','T 1','RGE','T L'];
var fourSeed =['LNG','HLE','C 9','BYG'];

var LPL = ['EDG','FPX','RNG','LNG'];
var LCK = ['D K','GEN','T 1','HLE'];
var LCS = ['100T','T L','C 9'];
var LCE = ['MAD','FNC','RGE'];
var LMS = ['PSG','BYG'];
const area = [...LPL,...LCK,...LCS,...LCE,...LMS];  // 通过findIndex
const keyValue = {
    0:LPL,1:LPL,2:LPL,3:LPL,
    4:LCK,5:LCK,6:LCK,7:LCK,
    8:LCS,9:LCS,10:LCS,
    11:LCE,12:LCE,13:LCE,
    14:LMS,15: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);
let fourPool = randomSeed(fourSeed);

// 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);
    fourPool = randomSeed(fourSeed);
}

// 可以先按照“不回避原则”排序,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,item=>_.indexOf(keyValue[oneIndex],item)===-1); // 将二档队伍中第一个不属于一号种子赛区的队伍   二号池子中index
    teamLabel.push(secondPool.splice(two,1)[0]);
    // console.log(two,secondPool[0]);
    const twoIndex=_.indexOf(area,teamLabel[1]);
    const three=_.findIndex(thirdPool,item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1); // 将二档队伍中第一个不属于A组前两队赛区的队伍   二号池子中index
    teamLabel.push(thirdPool.splice(three,1)[0]);
    const threeIndex=_.indexOf(area,teamLabel[2]);
    const four=_.findIndex(fourPool,item=>_.indexOf(keyValue[oneIndex],item)===-1&&_.indexOf(keyValue[twoIndex],item)===-1&&_.indexOf(keyValue[threeIndex],item)===-1); //   三号池子中index
    teamLabel.push(fourPool.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 = ['EDG','MAD','D K','PSG'];
    var secondSeed = ['FPX','GEN','FNC','100T'];
    var thirdSeed = ['RNG','T 1','RGE','T L'];
    var fourSeed =['LNG','HLE','C 9','BYG'];

    var LPL = ['EDG','FPX','RNG','LNG'];
    var LCK = ['D K','GEN','T 1','HLE'];
    var LCS = ['100T','T L','C 9'];
    var LCE = ['MAD','FNC','RGE'];
    var LMS = ['PSG','BYG'];
const area = [...LPL,...LCK,...LCS,...LCE,...LMS];  // 通过findIndex
const keyValue = {
    0:LPL,1:LPL,2:LPL,3:LPL,
    4:LCK,5:LCK,6:LCK,7:LCK,
    8:LCS,9:LCS,10:LCS,
    11:LCE,12:LCE,13:LCE,
    14:LMS,15: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 = '';
};

const  copy=(value, cb)=> {
    // 动态创建 textarea 标签
    const textarea = document.createElement('textarea')
    // 将该 textarea 设为 readonly 防止 iOS 下自动唤起键盘,同时将 textarea 移出可视区域
    textarea.readOnly = 'readonly'
    textarea.style.position = 'absolute'
    textarea.style.left = '-9999px'
    // 将要 copy 的值赋给 textarea 标签的 value 属性
    textarea.value = value
    // 将 textarea 插入到 body 中
    document.body.appendChild(textarea)
    // 选中值并复制
    textarea.select()
    textarea.setSelectionRange(0, textarea.value.length)
    document.execCommand('Copy')
    document.body.removeChild(textarea)
    if (cb && Object.prototype.toString.call(cb) === '[object Function]') {
      cb()
    }
  }

  const copyResult=()=>{
      if( $('A').innerHTML === ''){
          genrate();
          copy(`A:  ${$('A').innerHTML}\r\nB:  ${$('B').innerHTML}\r\nC:  ${$('C').innerHTML}\r\nD:  ${$('D').innerHTML}`)
      }else{
           copy(`A:  ${$('A').innerHTML}\r\nB:  ${$('B').innerHTML}\r\nC:  ${$('C').innerHTML}\r\nD:  ${$('D').innerHTML}`)
      }
  }
<div class="des"> 
    <div class="des">
  <h1>
    LOLS11世界总决赛抽签模拟器——我为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='copyResult() '>复制结果</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.0</td></tr>
   <tr><td> A池队伍:EDG,DK,MAD,PSG</td></tr>
   <tr><td> B池队伍:FPX,GEN,FNC,100T</td></tr>
   <tr><td> C池队伍:RNG,T1,RGE,TL</td></tr>
   <tr><td> 目前暂按LNG,HLE,C9,BYG突围入围赛</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;
}

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