let _MMode = { 
    Map: 1 ,
    TalkMode: 2 ,
    RdDungeon: 3 ,
    Battle: 3
};
let MenuModeStr = _MMode.Map; 
var NotSaveValue1 = -1;
var NotSaveValue2 = -1;
var NotSaveValue3 = -1;
var NotSaveValue4 = -1;
var NotSaveValue5 = -1;
var NotSaveValue6 = -1;
var NotSaveValue7 = -1;
var NotSaveValue8 = -1;
var NotSaveValue9 = -1;
let BaseDeck = [];
let ResetDeck = [];
DbgPNo = [480]; 
Deck_初期化 = function () {
    ResetDeck.forEach(cardNo => {
        GetCard_CardSet(cardNo);
    });
    $gameSystem.DeckArr[0] = CopyArr(ResetDeck);
    $gameSystem.DeckArr[1] = [];
    $gameSystem.DeckArr[2] = [];
    for (let i = 0; i <= 20 - 1; i++) {
        $gameSystem.DeckArr[1].push(CId_待機);
        $gameSystem.DeckArr[2].push(CId_待機);
    }
    let skipArr = []; 
    for (let i = 1; i <= $dataWeapons.length - 1; i++) { 
        if (i >= 670 && i <= 676) continue; 
        $gameParty.gainItem($dataWeapons[i], -99, true)
    }
    for (let i = 0; i <= ResetDeck.length - 1; i++) {
        let _wpnNo = ResetDeck[i];
        $gameParty.gainItem($dataWeapons[_wpnNo], +1, true)
    }
}
let _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    _Game_System_initialize.call(this);
    var baseArr = $Nupu_GameSetting.prologueDeck.split(',');
    BaseDeck = [];
    for (let i = 0; i < baseArr.length; i++) BaseDeck.push(Number(baseArr[i]));
    var resetArr = $Nupu_GameSetting.resetDeck.split(',');
    ResetDeck = [];
    for (let i = 0; i < resetArr.length; i++) ResetDeck.push(Number(resetArr[i]));
    this.SelDeck = 0; 
    this.NewCard = []; 
    this.GetCard = [];
    BaseDeck.forEach(cardNo => {
        if (this.GetCard.indexOf(cardNo) == -1) {
            this.GetCard.push(cardNo);
        }
    });
    this.DeckArr = [
        CopyArr(BaseDeck), CopyArr(BaseDeck), CopyArr(BaseDeck)
    ];  
    this.StarCardNo = [-1,-1,-1]; 
    this.MasterDeck = [];   
    this._FgetFlg = false;  
    this._GrayKigae = [false, false, false, false, false];
    this._GrayKami = [false, false];
};
let NC_FirstCardSet = Game_Interpreter.prototype.NUpdate;
Game_Interpreter.prototype.NUpdate = function () {
    NC_FirstCardSet.call(this);
    if ($gameSystem.StarCardNo == undefined) $gameSystem.StarCardNo = [-1,-1,-1];
    if (!$gameSystem._FgetFlg) {
        $gameSystem._FgetFlg = true;
        for (let i = 0; i <= BaseDeck.length - 1; i++) {
            $gameParty.gainItem($dataWeapons[BaseDeck[i]], 1, true);
        }
    }
    //スイッチ管理 $gameSwitches.value(34)
    let _IfkCkNo = 34; 
    for (let i = 0; i <= $gameSystem._GrayKigae.length - 1; i++) {
        if (!$gameSystem._GrayKigae[i] && $gameSwitches.value(_IfkCkNo + i)) {
            $gameSystem._GrayKigae[i] = true; 
        }
    }
    let _KamiCkNo = 39;
    for (let i = 0; i <= $gameSystem._GrayKami.length - 1; i++) {
        if (!$gameSystem._GrayKami[i] && $gameSwitches.value(_KamiCkNo + i)) {
            $gameSystem._GrayKami[i] = true; 
        }
    }
}
let MemoryOpenEvent_Counter = 0;
Game_Interpreter.prototype.MemoryOpenEvent = function () {
    MemoryOpenEvent_Frame = 60; 
    MemoryOpenEvent_Counter++;
    if (MemoryOpenEvent_Counter == 10) {
        $gameSwitches.setValue(SW_Nupu全開放 , true);
    }
}
let MemoryOpenEvent_Frame = 0;
let MemoryOpenEvent_NUpdate = Game_Interpreter.prototype.NUpdate;
Game_Interpreter.prototype.NUpdate = function () {
    MemoryOpenEvent_NUpdate.call(this);
    if (MemoryOpenEvent_Frame > 0) {
        MemoryOpenEvent_Frame--;
    } else {
        MemoryOpenEvent_Counter = 0;
    }
}
let NSetUp_NUpdateScFstFlg = false;
let NSetUp_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    NSetUp_NUpdateSc.call(this);
    if (!NSetUp_NUpdateScFstFlg) {
        NSetUp_NUpdateScFstFlg = true;
        if (!$gameTemp.isPlaytest()) {
            const noop = function(){};
            console.log = noop;
            console.info = noop;
            console.debug = noop;
            console.warn = noop;
            console.trace = noop;
        }
    }
}
