"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var getRandomNum = function getRandomNum(baseNum) {
  return Math.floor(Math.random() * baseNum);
};

var getKrNumberAndMeasurableScore = function getKrNumberAndMeasurableScore(krNum, krMeasurableNums) {
  if (krNum === 0) {
    return 0;
  }

  if (krNum === 1) {
    if (krMeasurableNums === 1) {
      return 25;
    }

    return 20;
  }

  if (krNum === 2) {
    if (krMeasurableNums === 1) {
      return 40;
    }

    if (krMeasurableNums === 2) {
      return 50;
    }

    return 35;
  }

  if (krNum === 3) {
    if (krMeasurableNums === 1) {
      return 50;
    }

    if (krMeasurableNums === 2) {
      return 60;
    }

    if (krMeasurableNums === 3) {
      return 60;
    }

    return 45;
  }

  if (krNum === 4) {
    if (krMeasurableNums === 1) {
      return 50;
    }

    if (krMeasurableNums === 2) {
      return 55;
    }

    if (krMeasurableNums === 3) {
      return 60;
    }

    if (krMeasurableNums === 4) {
      return 70;
    }

    return 45;
  }

  if (krNum === 5) {
    if (krMeasurableNums === 1) {
      return 50;
    }

    if (krMeasurableNums === 2) {
      return 55;
    }

    if (krMeasurableNums === 3) {
      return 60;
    }

    if (krMeasurableNums === 4) {
      return 65;
    }

    if (krMeasurableNums === 5) {
      return 70;
    }

    return 45;
  }

  if (krNum > 5) {
    if (krMeasurableNums === 0) {
      return 40;
    }

    if (krMeasurableNums === 1) {
      return 45;
    }

    if (krMeasurableNums === 2) {
      return 50;
    }

    if (krMeasurableNums === 3) {
      return 55;
    }

    return 60;
  }
}; // 参考 https://doc.weixin.qq.com/txdoc/excel?scode=AOEAFQeYAA0Nbxe0lHABkAGgaGACY&docid=e2_AJcATAaKACYmPDc9BjaSnWjBmFCGo&type=1&tab=BB08J2


var _default = function _default(oNameLength, okrHasWtWords, krNum, krMeasurableNums, krAvarageLength) {
  var totalScore = 0;

  if (okrHasWtWords) {
    totalScore += 5;
  } // 计算目标名称长度


  if (oNameLength < 5) {
    totalScore += 2;
  } else if (oNameLength < 9) {
    totalScore += 15;
  } else if (oNameLength < 31) {
    totalScore += 20;
  } else {
    totalScore += 15;
  }

  totalScore += getKrNumberAndMeasurableScore(krNum, krMeasurableNums);

  if (krAvarageLength < 5) {
    return Number((totalScore * (getRandomNum(5) + 3) / 100).toFixed(1));
  }

  if (krAvarageLength < 9) {
    return Number((totalScore * (getRandomNum(15) + 70) / 100).toFixed(1));
  }

  if (krAvarageLength < 31) {
    return Number((totalScore * (getRandomNum(15) + 90) / 100).toFixed(1));
  }

  return Number((totalScore * (getRandomNum(10) + 80) / 100).toFixed(1));
};

exports["default"] = _default;