//ゲージ上昇(all_ratio)
//フィボナッチ数列の上限(max)
//JusticeCriticalボーナスを割る値(bunbo)
//JusticeCriticalのカウント+-(j_critical)
//Justiceのカウント+-(justice)
//Attackのカウント+-(attack)
//missのカウント+-(miss)
//作:yoshilove(@yoshi_yottu)

[EntryPoint]
class Boost : Ability {
  double ratio;
  int jc_count, j_count, a_count, m_count, denominator, fibonacci_max;
  int required_usagi = 0, current_usagi = 0, count;
  int siBoost, siNoBoost;
  SkillIndicators@ skill;

  void Initialize(dictionary@ params, SkillIndicators@ ski) {
    params.get("all_ratio", ratio);
    params.get("j_critical", jc_count);
    params.get("justice", j_count);
    params.get("attack", a_count);
    params.get("miss", m_count);
    params.get("bunbo", denominator);
    params.get("max", fibonacci_max);
    @skill = ski;
    siBoost = skill.AddIndicator("boost.png");
    siNoBoost = skill.AddIndicator("no_boost.png");

  }
  
  void OnStart(Result@ result) {
    
  }
  
  void OnFinish(Result@ result) {
    
  }
  
  void OnJusticeCritical(Result@ result, NoteType type) {
        skill.TriggerIndicator(siNoBoost);
        count = count + jc_count;
        result.BoostGaugeJusticeCritical(ratio);
        skill.TriggerIndicator(siBoost);

        if (count >= fibonacci_max){
        required_usagi = fibonacci_max;
        count = fibonacci_max;
        }

        if (count >= required_usagi){
        required_usagi = current_usagi + count;
        current_usagi = count;
        }
        result.BoostGaugeByValue(current_usagi / denominator);
  }
  
  void OnJustice(Result@ result, NoteType type) {
    result.BoostGaugeJustice(ratio);
    skill.TriggerIndicator(siNoBoost);
        count = count + j_count;
        if (count < 0){
        count = 0;
        }

        if (count >= fibonacci_max){
        required_usagi = fibonacci_max;
        count = fibonacci_max;
        }

        if (count >= required_usagi){
        required_usagi = current_usagi + count;
        current_usagi = count;
        }
  }
  
  void OnAttack(Result@ result, NoteType type) {
    result.BoostGaugeAttack(ratio);
    skill.TriggerIndicator(siNoBoost);
        count = count + a_count;
        if (count < 0){
        count = 0;
        }

        if (count >= fibonacci_max){
        required_usagi = fibonacci_max;
        count = fibonacci_max;
        }

        if (count >= required_usagi){
        required_usagi = current_usagi + count;
        current_usagi = count;
        }
  }
  
  void OnMiss(Result@ result, NoteType type) {
        count = count + m_count;
        if (count < 0){
        count = 0;
        }

        if (count >= fibonacci_max){
        required_usagi = fibonacci_max;
        count = fibonacci_max;
        }

        if (count >= required_usagi){
        required_usagi = current_usagi + count;
        current_usagi = count;
        }
  }
}