package com.yonge.cooleshow.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.yonge.toolset.base.enums.BaseEnum;

public enum HardLevelEnum implements BaseEnum<String, HardLevelEnum> {
	/**
	 * 入门级, 振幅阈值, 频率阈值 <br>
	 * 节奏有效范围（1分音符）, 节奏有效范围（2分音符）, 节奏有效范围（4分音符）, 节奏有效范围（8分音符）, 节奏有效范围（16分音符）, 节奏有效范围（32分音符）<br>
	 * 完成度范围, 未演奏的范围
	 */
	//BEGINNER("入门级", 3, 5, 5, 5, 10, 10, 13, 15, 60, 10), 
	BEGINNER("入门级", 3, 5, 12, 18, 23, 28, 75, 25), 
	/**
	 * 进阶级, 振幅阈值, 频率阈值 <br>
	 * 节奏有效范围（1分音符）, 节奏有效范围（2分音符）, 节奏有效范围（4分音符）, 节奏有效范围（8分音符）, 节奏有效范围（16分音符）, 节奏有效范围（32分音符）<br>
	 * 完成度范围, 未演奏的范围
	 */
	ADVANCED("进阶级", 3, 5, 10, 15, 20, 25, 85, 15),
	//ADVANCED("进阶级", 3, 5, 50, 50, 50, 50, 50, 5, 80, 10),
	/**
	 * 大师级, 振幅阈值, 频率阈值 <br>
	 * 节奏有效范围（1分音符）, 节奏有效范围（2分音符）, 节奏有效范围（4分音符）, 节奏有效范围（8分音符）, 节奏有效范围（16分音符）, 节奏有效范围（32分音符）<br>
	 * 完成度范围, 未演奏的范围
	 */
	PERFORMER("大师级", 3, 3, 5, 10, 13, 15, 95, 10);
	@EnumValue
	private String code;

	private String msg;

	private int amplitudeThreshold;

	private int frequencyThreshold;

	private int tempoEffectiveRangeOf1;

	private int tempoEffectiveRangeOf2;

	private int tempoEffectiveRangeOf4;

	private int tempoEffectiveRangeOf8;


	private int integrityRange;

	private int notPlayRange;

	/**
	 * 
	 * @param msg
	 * @param amplitudeThreshold 振幅阈值
	 * @param frequencyThreshold 频率阈值
	 * @param tempoEffectiveRangeOf1 节奏偏移量百分比（在当前范围内节奏才算正确）
	 * @param tempoEffectiveRangeOf2 节奏偏移量百分比（在当前范围内节奏才算正确）
	 * @param tempoEffectiveRangeOf4 节奏偏移量百分比（在当前范围内节奏才算正确）
	 * @param tempoEffectiveRangeOf8 节奏偏移量百分比（在当前范围内节奏才算正确）
	 * @param integrityRange 完成度范围
	 * @param notPlayRange 未演奏的范围
	 */
	HardLevelEnum(String msg, int amplitudeThreshold, int frequencyThreshold, int tempoEffectiveRangeOf1, int tempoEffectiveRangeOf2,
			int tempoEffectiveRangeOf4, int tempoEffectiveRangeOf8, int integrityRange,
			int notPlayRange) {
		this.code = this.name();
		this.msg = msg;
		this.amplitudeThreshold = amplitudeThreshold;
		this.frequencyThreshold = frequencyThreshold;
		this.tempoEffectiveRangeOf1 = tempoEffectiveRangeOf1;
		this.tempoEffectiveRangeOf2 = tempoEffectiveRangeOf2;
		this.tempoEffectiveRangeOf4 = tempoEffectiveRangeOf4;
		this.tempoEffectiveRangeOf8 = tempoEffectiveRangeOf8;
		this.integrityRange = integrityRange;
		this.notPlayRange = notPlayRange;
	}

	public String getMsg() {
		return msg;
	}

	public int getAmplitudeThreshold() {
		return amplitudeThreshold;
	}

	public int getFrequencyThreshold() {
		return frequencyThreshold;
	}
	
	public int getTempoEffectiveRange(int denominator, double duration) {
		
		int tempoEffectiveRange = 0;
		
		if(duration >= 1000){
			tempoEffectiveRange = tempoEffectiveRangeOf1;
		}else if(duration >= 500){
			tempoEffectiveRange = tempoEffectiveRangeOf2;
		}else if(duration >= 200){
			tempoEffectiveRange = tempoEffectiveRangeOf4;
		}else{
			tempoEffectiveRange = tempoEffectiveRangeOf8;
		}
		
		/*switch (denominator) {
		case 1:
			tempoEffectiveRange = tempoEffectiveRangeOf1;
			break;
		case 2:
			tempoEffectiveRange = tempoEffectiveRangeOf2;
			break;
		case 4:
			tempoEffectiveRange = tempoEffectiveRangeOf4;
			break;
		case 8:
			tempoEffectiveRange = tempoEffectiveRangeOf8;
			break;
		case 16:
			tempoEffectiveRange = tempoEffectiveRangeOf16;
			break;
		case 32:
			tempoEffectiveRange = tempoEffectiveRangeOf32;
			break;

		default:
			break;
		}*/
		return tempoEffectiveRange;
	}

	public int getIntegrityRange() {
		return integrityRange;
	}

	public int getNotPlayRange() {
		return notPlayRange;
	}

	@Override
	public String getCode() {
		return this.name();
	}

}
