SOURCE



//牌的个数
function pkSize(str) {
    //拆分左右手
    let slicePuke = str.split('-');
    let left=slicePuke[0];
    let right=slicePuke[1];
    let leftArr = left.split(' ');
    let rightArr = right.split(' ');

    let MAX = ['joker','JOKER']
    //判断大小王
    if((left[left.length -1]=='r' )&& (right[right.length -1] =='R')){
        console.log(right);
    }else if((left[left.length -1]=='R')&&(right[right.length -1] =='r')){
        console.log(left);
    }//不是大小王的情况
    else{
        //王炸
        if(left=='joker JOKER' || left=='JOKER joker'){
            console.log(left)
        }else if(right=='joker JOKER' || right=='JOKER joker'){
            console.log(right)
        }//炸弹
        //两个都是炸弹       
        else if((leftArr[0]==leftArr[1]&&leftArr.length==4)&&(rightArr[0]==rightArr[1]&&rightArr.length==4)){
            if(leftArr[0]<rightArr[0]){
                console.log(rightArr.toString().split(',').join(' '));
            }else{
                console.log(leftArr.toString().split(',').join(' '));
            }
        }//一方是炸弹
        else if(leftArr[0]==leftArr[1]&&leftArr.length==4){
             console.log(leftArr.toString().split(',').join(' '));
        }else if(rightArr[0]==rightArr[1]&&rightArr.length==4){
            console.log(rightArr.toString().split(',').join(' '));
        }
        //两个是顺子
        else if(leftArr.length==5&&rightArr==5){
            //10 J Q K A
            if(leftArr[leftArr.length - 1] == 'A'){
                console.log(leftArr.toString().split(',').join(' '));
            }else if(rightArr[rightArr.length - 1] == 'A'){
                console.log(rightArr.toString().split(',').join(' '));
            }else if(leftArr[0]=='A'){
                console.log(leftArr.toString().split(',').join(' '));
            }else if(rightArr[0]=='A'){
                console.log(rightArr.toString().split(',').join(' '));
            }else if(leftArr[0]<rightArr[0]){
                console.log(rightArr.toString().split(',').join(' '));
            }else{
                console.log(leftArr.toString().split(',').join(' '));
            }
        }
        //两个都是三个,二个牌
        else if(leftArr.length == 3||(leftArr.length == 2)){
            if(leftArr[0]<rightArr[0]){
                console.log(rightArr.toString().split(',').join(' '));
            }else{
                 console.log(leftArr.toString().split(',').join(' '));
            }
        }
        //两个都是一个牌
        else if(leftArr[leftArr.length - 1]=='r'||leftArr[leftArr.length - 1]=='R'){
             console.log(leftArr.toString().split(',').join(' '));
        }else if(rightArr[rightArr.length - 1]=='r'||rightArr[rightArr.length - 1]=='R'){
            console.log(rightArr.toString().split(',').join(' '));
        }else if(leftArr.length==1&&rightArr.length==1){
            if(leftArr[0]>rightArr[0]){
                console.log(leftArr.toString().split(',').join(' '));
            }else{
                console.log(rightArr.toString().split(',').join(' '));
            }
        }else{
            console.log('ERROR')
        }
    }  
} 
 

//处理正反输入的字符串

function switchStrInput(str){
    let left = str.split('-')[0];
    let right = str.split('-')[1];
    let result = right +'-' +left;
    // console.log(result);
    return result;
}
//处理顺子逆序的情况

let nx='5 4 3 2 A'
function nxstr(arr){
        if(arr[0]<arr[arr.length -1]){
             return arr.toString().split(' ').reverse();
        }else{
            return arr;
        }   
}
// console.log(nxstr(nx))


//王炸的
let input1 = '4 4 4 4-joker JOKER';
let sInput1= switchStrInput(input1);
// pkSize(input1);
// pkSize(sInput1);
let input2 = '5 4 3 2 A-joker JOKER';
let sInput2= switchStrInput(input2);
pkSize(input2);
pkSize(sInput2);
let input3 = '3 3 3-joker JOKER';
let sInput3= switchStrInput(input3);
pkSize(input3);
pkSize(sInput3);
let input4 = '3 3-joker JOKER';
let sInput4= switchStrInput(input4);
pkSize(input4);
pkSize(sInput4);
let input5 = '3-joker JOKER';
let sInput5= switchStrInput(input5);
pkSize(input5);
pkSize(sInput5);
let input6 = 'joker JOKER-4 4 4 4';
let sInput6= switchStrInput(input6);
pkSize(input6);
pkSize(sInput6);
let input7 = 'joker JOKER-5 4 3 2 A';
let sInput7= switchStrInput(input7);
pkSize(input7);
pkSize(sInput7);
let input8 = 'joker JOKER-3 3 3';
let sInput8= switchStrInput(input8);
pkSize(input8);
pkSize(sInput8);
let input9 = 'joker JOKER-3 3';
let sInput9= switchStrInput(input9);
pkSize(input9);
pkSize(sInput9);
let input10 = 'joker JOKER-3';
let sInput10= switchStrInput(input10);
pkSize(input10);
pkSize(sInput10);

let input11 = '5 4 3 2 A-3 3 3 3';
let sInput11= switchStrInput(input11);
pkSize(input11);
pkSize(sInput11);
let input12 = '4 4 4 4-3 3 3 3';
let sInput12= switchStrInput(input12);
pkSize(input12);
pkSize(sInput12);
let input13 = '4 4 4-3 3 3 3';
let sInput13= switchStrInput(input13);
pkSize(input13);
pkSize(sInput13);
let input14 = '4 4-3 3 3 3';
let sInput14= switchStrInput(input14);
pkSize(input14);
pkSize(sInput14);
let input15 = '4-3 3 3 3';
let sInput15= switchStrInput(input15);
pkSize(input15);
pkSize(sInput15);
let input16 = 'A 2 3 3 4-10 J Q K A';
let sInput16= switchStrInput(input16);
pkSize(input16);
pkSize(sInput16);
let input17 = '2 3 4 5 6-10 J Q K A';
let sInput17= switchStrInput(input17);
pkSize(input17);
pkSize(sInput17);
let input18 = '2 3 4 5 6-A 2 3 4 5';
let sInput18= switchStrInput(input18);
pkSize(input18);
pkSize(sInput18);
let input19 = 'A A A-4 4 4';
let sInput19= switchStrInput(input19);
pkSize(input19);
pkSize(sInput19);
let input20 = 'A A-4 4';
let sInput20= switchStrInput(input20);
pkSize(input20);
pkSize(sInput20);
let input21 = 'A-4';
let sInput21= switchStrInput(input21);
pkSize(input21);
pkSize(sInput21);
let input22 = 'A-joker';
let sInput22= switchStrInput(input22);
pkSize(input22);
pkSize(sInput22);
let input23 = 'A-JOKER';
let sInput23= switchStrInput(input23);
pkSize(input23);
pkSize(sInput23);
let input24 = 'joker-JOKER';
let sInput24= switchStrInput(input24);
pkSize(input24);
pkSize(sInput24);
// pkSize(input24);
// pkSize(sInput24);
// console.log(input25)
console 命令行工具 X clear

                    
>
console