let a連続PtnArr = [];
class VoicePtnKeep {
    constructor(Id) {
        this.Id = Id;
        this.BefPlayNo = -1;
        this.PlayedNos = [];
    }
}
let GetVoicePtnNo = function (voiceData , MaxCount) {
    if (MaxCount == voiceData.PlayedNos.length) voiceData.PlayedNos = [];
    let getNos = [];
    for (let i = 0; i < MaxCount; i++) {
        getNos.push(i);
    }
    var rtnNo = Math.floor( Math.random() * MaxCount);
    while (voiceData.PlayedNos.indexOf(rtnNo) != -1 || rtnNo == voiceData.BefPlayNo) {
        rtnNo = Math.floor( Math.random() * MaxCount);
    }
    voiceData.BefPlayNo = rtnNo;
    voiceData.PlayedNos.push(rtnNo);
    return rtnNo;
}
let GetVoicePlayNo = function (Id , MaxNo) {
    var ckPtnKeep = null;
    for (let i = 0; i < a連続PtnArr.length; i++) {
        if (a連続PtnArr[i].Id == Id) {
            ckPtnKeep = a連続PtnArr[i];
            break;
        }
    }
    if (ckPtnKeep == null) {
        ckPtnKeep = new VoicePtnKeep(Id);
        a連続PtnArr.push(ckPtnKeep);
    }
    return GetVoicePtnNo(ckPtnKeep , MaxNo);
}
let GetVoicePlayNoSave = function (Id , MaxNo) {
    var ckPtnKeep = null;
    if ($gameSystem.GetVoicePlayDatas == undefined) $gameSystem.GetVoicePlayDatas = [];
    for (let i = 0; i < $gameSystem.GetVoicePlayDatas.length; i++) {
        if ($gameSystem.GetVoicePlayDatas[i].Id == Id) {
            ckPtnKeep = $gameSystem.GetVoicePlayDatas[i];
            if (ckPtnKeep.PlayedNos.length >= MaxNo) {
                ckPtnKeep.PlayedNos = [];
            }
            break;
        }
    }
    if (ckPtnKeep == null) {
        ckPtnKeep = new VoicePtnKeep(Id);
        $gameSystem.GetVoicePlayDatas.push(ckPtnKeep);
    }
    return GetVoicePtnNo(ckPtnKeep , MaxNo);
}
let GetVoicePlayNoSave_Initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    GetVoicePlayNoSave_Initialize.call(this);
    this.GetVoicePlayDatas = []; 
};
let SaveBgmDataIDArr = [];
class SaveBgmData {
    constructor(ID){
        this.ID = ID;
        this.BgmData = null;
    }
}
Game_Interpreter.prototype.SaveBgmDataID = function (id) {
    for (let i = 0; i < SaveBgmDataIDArr.length; i++) {
        if (SaveBgmDataIDArr[i].ID == id) {
            SaveBgmDataIDArr[i].BgmData = AudioManager.saveBgm();
            return
        }
    }
    var saveBgmData = new SaveBgmData(id);
    saveBgmData.BgmData = AudioManager.saveBgm();
    SaveBgmDataIDArr.push(saveBgmData);
}
Game_Interpreter.prototype.SaveBgmPlayID = function (id) {
    for (let i = 0; i < SaveBgmDataIDArr.length; i++) {
        if (SaveBgmDataIDArr[i].ID == id) {
            AudioManager.replayBgm(SaveBgmDataIDArr[i].BgmData);
            return
        }
    }
}
class PlaySEData {
    constructor(file) {
        this.File = file;
        this.flame = 2;
    }
}
let _PlaySeDatas = [];
let AudioPlaySE_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    AudioPlaySE_NUpdateSc.call(this);
    for (let i = 0; i < _PlaySeDatas.length; i++) {
        _PlaySeDatas[i].flame--;
        if (_PlaySeDatas[i].flame <= 0) {
            _PlaySeDatas.splice(i , 1);
            i--;
        }
    }
}
