sevenLee
4/15/2018 - 7:33 PM

calcBet.ts


    public calcBet = (modifier?: number|string ) => {
        let doIncrease = true;
        let isValid = true;
        let isNumber = false;
        const type = typeof modifier;

        switch(type){
            case 'string':
                doIncrease = (modifier !== '-');
                if(doIncrease && modifier !== '+') { isValid = false }
                break;
            case 'number':
                doIncrease = (modifier > 0);
                isNumber = true;
                break;
            default:
                isValid = false;
                break;
        }

        try{
            if(!isValid) throw new Error(`Expected +, - or number, got '${modifier}'.`);
        }catch(err){
            console.warn(err);
            return
        }

        const diffNumber: number = (doIncrease) ? 1 : -1;
        let targetIndex = (isNumber)? this.activeBetIndex + <number>modifier : this.activeBetIndex + diffNumber;



    }