package com.example.smart119

import kotlin.random.Random

object RandomNumberUtil {

    private var randNumList:List<Int> = mutableListOf()
    private var _num_count_min = 0;
    private var _num_counter = 0;
    private var _num_count_max = 5;

    fun num_increase():Boolean {
        _num_counter++;
        if (_num_counter == _num_count_max) return false
        else return true;
    }

    fun setRandDescending(min: Int, max: Int, count: Int){
        _num_count_min = min;
        _num_count_max = count;
        _num_counter = min;

        require(max >= min) { "max should be greater than or equal to min" }
        require(count > 0) { "count should be greater than 0" }

        // 랜덤 숫자 생성
        val randomNumbers = List(count - 1) { Random.nextInt(min, max + 1) } // count-1개의 랜덤 값 생성

        // 마지막 값을 0으로 추가
        val finalList = randomNumbers + 0

        randNumList = finalList.sortedDescending()
        // 내림차순 정렬
    }

    fun getCurrentNumber():Int {
        return randNumList[_num_counter]
    }

}