const CId_待機 = 200; 
let _DeckMode = {
    デッキ編集: 1, 
    カードトレーダー: 2 
};
let DeckMode = _DeckMode.デッキ編集;
class Deck_Edit {   
    constructor(_CNo, _Cnt, _Opi) {
        _Cnt = typeof _Cnt !== 'undefined' ? _Cnt : 1;
        _Opi = typeof _Opi !== 'undefined' ? _Opi : 255;
        this._CNo = _CNo;   
        this._Cnt = _Cnt;   
        this._Opi = _Opi;   
    }
}
let DE_PicPath = MenuUIPath + "DeckEdit/";
let DE_AbPicPath = DE_PicPath + "Albm/";
let _DE_ViewFlg = false; 
let ADeckArr = [];  
let EDeckArr = [];  
let ItDeckArr = []; 
let _DeckBar; 
let _DeckZure = 0; 
let _Albm_Off = false; 
let EDeckTPArr = []; 
let ItDeckTPArr = []; 
let _editDNo;           
let _junNo = 0;         
let _junRtFlg = false;  
let _siboNo = 0;        
let _siboRtFlg = false; 
let DE_ViewFlg = function () {
    return _DE_ViewFlg;
}
let _DeckBar_CBMap = [[1358, 167, 15, 571]];
let _JunArr = [ 
    [811, 112, 65, 25] ,
    [877, 112, 80, 25] ,
    [960, 112, 117, 25]
];
let _SiboArr = [ 
    [1121, 82, 78, 27],
    [1200, 82, 78, 27],
    [1277, 82, 78, 27],
    [1121, 113, 78, 27],
    [1200, 113, 78, 27],
    [1277, 113, 78, 27]
];
let CardAbmId_SetUpdate = Game_Interpreter.prototype.NUpdateSc;
let abmIdSetFlg = false;
Game_Interpreter.prototype.NUpdateSc = function () {
    CardAbmId_SetUpdate.call(this);
    if (!abmIdSetFlg) {
        abmIdSetFlg = true;
        for (let i = 0; i <= $dataWeapons.length - 1; i++) {
            let _wpnData = $dataWeapons[i];
            if (_wpnData == null) continue;
            let notFlg = true;
            for (let j = 0; j < $Nupu_GameSetting.abmCardDatas.length; j++) {
                if ($Nupu_GameSetting.abmCardDatas[j].id == _wpnData.id) {
                    _wpnData.meta["AbmId"] = $Nupu_GameSetting.abmCardDatas[j].abmId;
                    notFlg = false;
                    break;
                }
            }
            if (notFlg) {
                _wpnData.meta["AbmId"] = null;
            }
        }
    }
}
let dataWeapons_AbmNo = [];
let AbmNoArr_Get = function () {
    dataWeapons_AbmNo = [];
    for (let i = 0; i <= $dataWeapons.length - 1; i++) {
        let _wpnData = $dataWeapons[i];
        if (_wpnData == null) continue;
        if (_wpnData.meta["AbmId"] == null) continue;
        let _abmId = Number(_wpnData.meta["AbmId"]);
        if (_abmId == null) continue;
        let _newFlg = true;
        for (let j = 0; j <= dataWeapons_AbmNo.length - 1; j++) {
            let _ckId = Number(dataWeapons_AbmNo[j].meta["AbmId"]);
            if (_ckId == 0) continue;
            if (_abmId < _ckId) {
                dataWeapons_AbmNo.splice(j, 0, _wpnData);
                _newFlg = false;
                break;
            }
        }
        if (_newFlg) {
            dataWeapons_AbmNo.push(_wpnData);
        }
    }
}
let GetdataWeapons_AbmNo = function (weaponId) {
    for (let i = 0; i < dataWeapons_AbmNo.length; i++) {
        if (dataWeapons_AbmNo[i].id == weaponId) return dataWeapons_AbmNo[i];
    }
}
let RentalDeckSetting = function () {
    if (!$gameSwitches.value(SW_RentalOK)) return;
    for (let i = 0; i <= $Nupu_GameSetting.rentalDecks.length - 1; i++) {
        if ($Nupu_GameSetting.rentalDecks[i].id == $gameVariables.value(VN_RentDeckSelectNo)) {
            $gameSystem.DeckArr[2] = [];
            if ($Nupu_GameSetting.rentalDecks[i].deck != "") {
                var resetArr = $Nupu_GameSetting.rentalDecks[i].deck.split(',');
                for (let i = 0; i < resetArr.length; i++) {
                    if (!$gameSystem._OffAcCard) {
                        $gameSystem.DeckArr[2].push(Number(resetArr[i]));
                    } else {
                        let cardId = Number(resetArr[i]);
                        if (!Check必殺Card($dataWeapons[cardId])) {
                            $gameSystem.DeckArr[2].push(cardId);
                        }
                    }
                }
            }
        }
    }
}
Game_Interpreter.prototype.N_DE_Start = function () {
    _DeckZure = 0; 
    RentalDeckSetting();
    AbmNoArr_Get(); 
    DeckMode = _DeckMode.デッキ編集;
    var setDeckPic = "de_back";
    if (!CheckSexCard所持()) setDeckPic = "de_back_NoSex";
    this.SetSpriteFIn(PN_deBack, DE_PicPath + setDeckPic, 0, 0, 0, 0, 15);
    var _mainBtnAddStr = "";
    if ($gameSwitches.value(SW_RentalOnlyFlg)) {
        _mainBtnAddStr = "c";
        $gameSystem.SelDeck = 2;
    }
    this.SetSpriteFIn(PN_deBtn + 0, DE_PicPath + "de_btn_1" + _mainBtnAddStr, -20, 170 + (67 * 0), 0, 0, 15);
    this.SetSpriteFIn(PN_deBtn + 1, DE_PicPath + "de_btn_2" + _mainBtnAddStr, -20, 170 + (67 * 1), 0, 0, 15);
    if ($gameSwitches.value(SW_RentalOK)) {
        this.SetSpriteFIn(PN_deBtn + 2, DE_PicPath + "de_btn_3", -20, 170 + (67 * 2), 0, 0, 15);
    } else {
        this.DelSprite(PN_deBtn + 2);
    }
    this.SetSpriteFIn(PN_deBtn + 3, DE_PicPath + "de_btn_Close", -20, 170 + (67 * 7) + 30, 0, 0, 15);
    if (!_Albm_Off) this.SetSpriteFIn(PN_AbBtn, DE_PicPath + "de_btn_Albm", -20, 170 + (67 * 6) + 20, 0, 0, 5);
    this.SetSpriteFInC(PN_deUseWn, DE_PicPath + "de_help", 107, 513, 0, 0, 15);
    _editDNo = $gameSystem.SelDeck; 
    this.SetSpriteFIn(PN_deBtn + _editDNo, DE_PicPath + "de_btn_" + (_editDNo + 1) + "b", 0, 170 + (67 * _editDNo), 0, 0, 15);
    this.SetSpriteFIn(PN_deDtitle, DE_PicPath + "dtitle_" + _editDNo, 264, 98, 0, 0, 15);
    _junNo = 0;     
    _siboNo = 0;    
    this.DE_CardAllView(true); 
    this.RdoBtnView();   
    Menu_EditLayer = 2; 
}
Game_Interpreter.prototype.RdoBtnView = function () {
    let _jX = 822;
    let _jY = 124; 
    if (_junNo == 1) _jX = 887;
    if (_junNo == 2) _jX = 973;
    let _sX = 1132;
    let _sY = 95; 
    if (_siboNo == 1) _sX = 1210;
    if (_siboNo == 2) _sX = 1287;
    if (_siboNo == 4) _sX = 1210;
    if (_siboNo == 5) _sX = 1287;
    if (_siboNo >= 3) _sY = 124;
    this.SetSpriteFInC(PN_deRdo + 0, DE_PicPath + "de_rbtn1", _jX, _jY, 0, 0, 2);
    if (_junRtFlg) this.SetSpriteFInC(PN_deRdo + 0, DE_PicPath + "de_rbtn2", _jX, _jY, 0, 0, 2);
    this.SetSpriteFInC(PN_deRdo + 1, DE_PicPath + "de_rbtn1", _sX, _sY, 0, 0, 2);
    if (_siboRtFlg) this.SetSpriteFInC(PN_deRdo + 1, DE_PicPath + "de_rbtn2", _sX, _sY, 0, 0, 2);
}
Game_Interpreter.prototype.DE_CardAllView = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    this.CardPicDell();
    if (DeckMode == _DeckMode.デッキ編集) {
        this.DeckCardView(_SetFlg); 
    }
    this.PoolCardView(_SetFlg); 
    if (_editDNo == 2 && !CTradeFlg) {
        this.SetSpriteFIn(PN_RentalRock, DE_PicPath + "PN_RentalRock", 0, 0, 0, 0, 2);
    } else {
        this.DelSprite(PN_RentalRock);
    }
}
let _Dbg_待機埋めOff = false;
let _UseDeckFlg = false; 
let _AddDcCNo = -1; 
Game_Interpreter.prototype.DeckCardView = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    let _SetOpi = 255;
    if (_SetFlg) _SetOpi = 0;
    EDeckArr = [];
    for (let i = 0; i <= $gameSystem.DeckArr[_editDNo].length - 1; i++) {
        if ($gameSystem.DeckArr[_editDNo][i] == CId_待機) {
            $gameSystem.DeckArr[_editDNo].splice(i, 1);
            i--;
        }
    }
    let _ckDeck = $gameSystem.DeckArr[_editDNo];
    let _dcCnt = _ckDeck.length; 
    let _lcol = ""; 
    if (_dcCnt < 20) {
        _lcol = SCol.Red;
        this.SpriteStr(PN_TyuiTxt + 0, SCol.Red + "※デッキが20枚未満です", 22, 320, 18, 255);
        this.SpriteStr(PN_TyuiTxt + 1, SCol.Red + "足りないカードは『待機』で埋められます。", 22, 320, 45, 255);
    } else {
        this.DelSprite(PN_TyuiTxt);
        this.DelSprite(PN_TyuiTxt + 1);
    }
    if (!_Dbg_待機埋めOff) {
        for (let i = _dcCnt; i <= 20 - 1; i++) {
            $gameSystem.DeckArr[_editDNo].push(CId_待機);
        }
    }
    if (_dcCnt < 10) _dcCnt = " " + _dcCnt;
    this.SpriteStrC(PN_deCdCnt, _lcol + _dcCnt + SCol.Def + "/20", 20, 489, 117, _SetOpi);
    this.MoveSprite(PN_deCdCnt, true, true, 15, 255);
    for (let i = 0; i <= _ckDeck.length - 1; i++) {
        let _nAddFlg = true;
        for (let j = 0; j <= EDeckArr.length - 1; j++) {
            if (EDeckArr[j]._CNo == _ckDeck[i]) {
                _nAddFlg = false;
                EDeckArr[j]._Cnt++;
            }
        }
        if (_nAddFlg) { 
            EDeckArr.push(new Deck_Edit(_ckDeck[i]));
        }
    }
    this.DelSprite(PN_StarMark + 1);
    let _starNo = $gameSystem.StarCardNo[_editDNo];
    EDeckTPArr = []; 
    let _cXPos = 281;
    let _cYPos = 230;
    this.DelSpriteSpan(PN_deDCnt, PN_deDCnt + 19);
    let noStarFlg = true; 
    for (let i = 0; i <= 20 - 1; i++) { 
        let ix = i % 5;
        let iy = Math.floor(i / 5);
        if (EDeckArr.length > i) {
            let _cardNo = EDeckArr[i]._CNo;
            EDeckTPArr.push(PN_deDCd + (i * 3));
            this.CardSpriteSetC(_cardNo, PN_deDCd + (i * 3),
                _cXPos + (ix * 108), _cYPos + (iy * 148), _SetOpi, 40, 40);
            if (EDeckArr[i]._Cnt > 1) {
                let _SetCnt = EDeckArr[i]._Cnt;
                if (_SetCnt >= 10) _SetCnt = 10;
                this.SetSpriteC(PN_deDCnt + i, CardPicPath + "wk_cnt" + _SetCnt,
                    _cXPos + (ix * 108), _cYPos + (iy * 148), _SetOpi, 40, 40);
                this.MoveSprite(PN_deDCnt + i, true, true, 10, 255, true, true);
            }
            this.CardSpriteMove(PN_deDCd + (i * 3), true, true, 10, 255, true, true);
            if (_AddDcCNo == _cardNo) {
                this.PlayPtcScTop("S_Click", _cXPos + (ix * 108), _cYPos + (iy * 148));
            }
            var mStr = MetaChecker($dataWeapons[_cardNo], "MiniIco", "352,");
            var ckmArr = mStr.split(',');
            while (ckmArr.length < 2) ckmArr.push("");
            var mKPos = new Pos2D(291, 265);
            this.SpriteStr(PN_CMiniL + i, "\\I[" + ckmArr[0] + "]", 24, mKPos._x + (ix * 108), mKPos._y + (iy * 148));
            this.SpriteStrR(PN_CMiniLTxt + i, GetWeaponValueData($dataWeapons[_cardNo], ckmArr[1]), 18,
                mKPos._x + 40 + (ix * 108), mKPos._y + 21 + (iy * 148));
            if (_starNo == _cardNo) {
                noStarFlg = false;
                this.SetSpriteC(PN_StarMark + 1, DE_PicPath + "PN_StarMark",
                    _cXPos + 28 + (ix * 108), _cYPos - 24 + (iy * 148));
            }
        } else {
            this.SetSpriteC(PN_deDCd + (i * 3), CardPicPath + "_brank",
                _cXPos + (ix * 108), _cYPos + (iy * 148), _SetOpi, 40, 40);
            this.MoveSprite(PN_deDCd + (i * 3), true, true, 10, 255, true, true);
            this.DelSprite(PN_CMiniL + i);
            this.DelSprite(PN_CMiniLTxt + i);
        }
    }
    if (noStarFlg) {
        $gameSystem.StarCardNo[_editDNo] = -1;
    }
    if (_editDNo != $gameSystem.SelDeck) {
        this.SetSpriteFIn(PN_deUseBtn, DE_PicPath + "use_btn1", 571, 92, 0, 0, 10);
        _UseDeckFlg = false;
    } else {
        this.SetSpriteFIn(PN_deUseBtn, DE_PicPath + "use_btn2", 571, 92, 0, 0, 10);
        _UseDeckFlg = true;
    }
    this.SetSpriteFIn(PN_deResetBtn, DE_PicPath + "PN_deResetBtn", 619, 87 - 13, 0, 0, 10);
    _AddDcCNo = -1;
}
let GetWeaponValueData = function (_weaponData, ckStr) {
    ckStr = ckStr.replace("hp", _weaponData.params[0]);
    ckStr = ckStr.replace("mp", _weaponData.params[1]);
    ckStr = ckStr.replace("atk", _weaponData.params[2]);
    ckStr = ckStr.replace("def", _weaponData.params[3]);
    ckStr = ckStr.replace("mat", _weaponData.params[4]);
    ckStr = ckStr.replace("mdf", _weaponData.params[5]);
    ckStr = ckStr.replace("agi", _weaponData.params[6]);
    ckStr = ckStr.replace("luk", _weaponData.params[7]);
    return ckStr;
}
Game_Interpreter.prototype.DeckCardDell = function () {
    if (DeckMode != _DeckMode.カードトレーダー) {
        for (let i = 0; i <= 20 - 1; i++) {
            this.DelSprite(PN_deDCd + 0 + (i * 3));
            this.DelSprite(PN_deDCd + 1 + (i * 3));
            this.DelSprite(PN_deDCd + 2 + (i * 3));
        }
    }
    this.DelSpriteSpan(PN_deDCnt, PN_deDCnt + 19);
}
let CheckSexCard所持 = function () {
    for (let i = 0; i <= dataWeapons_AbmNo.length - 1; i++) { 
        let _SexFlg = (dataWeapons_AbmNo[i].wtypeId == CType.Sex);
        if (!_SexFlg) continue;
        if ($gameParty.numItems(dataWeapons_AbmNo[i]) > 0)
            return true;
    }
    return false;
}
let _AddPcCNo = -1; 
const SozaiCardArr = [201, 202, 203, 204];
Game_Interpreter.prototype.PoolCardView = function () {
    let _setOpi = 255;
    let SetSetDeckArr = function (cardData) { 
        _setOpi = 255;
        let _必殺Flg = Check必殺Card(cardData);
        let _setCnt = $gameParty.numItems(cardData); 
        for (let j = 0; j <= EDeckArr.length - 1; j++) {
            if (EDeckArr[j]._CNo == cardData.id) {
                _setCnt -= EDeckArr[j]._Cnt; 
                if (DeckMode == _DeckMode.カードトレーダー) continue; 
                let _SetOpi150Flg = false;
                if (EDeckArr[j]._Cnt == 3) _SetOpi150Flg = true;
                var getData = GetdataWeapons_AbmNo(EDeckArr[j]._CNo);
                if (Check必殺Card(getData) && _必殺Flg) _SetOpi150Flg = true;
                if (_SetOpi150Flg) _setOpi = 150;
            }
        }
        if (_setCnt > 0) { 
            SetDeckArr.push(new Deck_Edit(cardData.id, _setCnt, _setOpi));
        }
    }
    let SetDeckArr = []; 
    if (CTradeFlg) {
        for (let i = 0; i < SozaiCardArr.length; i++) {
            SetSetDeckArr($dataWeapons[SozaiCardArr[i]]);
        }
    }
    for (let i = 0; i <= dataWeapons_AbmNo.length - 1; i++) {
        SetSetDeckArr(dataWeapons_AbmNo[i]);
    }
    if (CTradeFlg) {
        for (let i = 0; i <= SetDeckArr.length - 1; i++) {
            var ckData = $dataWeapons[SetDeckArr[i]._CNo];
            if (MetaChecker(ckData, "NCNo", false) != false) {
                if (Number(MetaChecker(ckData, "Rea")) == 3) {
                    SetDeckArr.splice(i, 1);
                    i--;
                }
            }
            if (MetaChecker(ckData, "エロカード", false) != false) {
                SetDeckArr.splice(i, 1);
                i--;
            }
        }
    }
    ItDeckArr = []; 
    for (let i = 0; i <= SetDeckArr.length - 1; i++) {
        let _spliceNo = 0; 
        if (_junRtFlg) _spliceNo = ItDeckArr.length;
        let SCData = $dataWeapons[SetDeckArr[i]._CNo];
        for (let j = 0; j <= ItDeckArr.length - 1; j++) {
            let _brkFlg = false; 
            let ICData = $dataWeapons[ItDeckArr[j]._CNo];
            switch (_junNo) {
                case 0: 
                    _spliceNo = ItDeckArr.length; 
                    if (!_junRtFlg) {
                        for (let k = 0; k <= $gameSystem.NewCard.length - 1; k++) {
                            if (SetDeckArr[i]._CNo == $gameSystem.NewCard[k]) {
                                _spliceNo = 0; 
                            }
                        }
                    } else {
                        _spliceNo = 0; 
                    }
                    break;
                case 1: 
                    let SDCost = 0;
                    if (SCData.meta["Cost"] != "All") {
                        SDCost = Number(SCData.meta["Cost"]);
                    }
                    let IDCost = 0;
                    if (ICData.meta["Cost"] != "All") {
                        IDCost = Number(ICData.meta["Cost"]);
                    }
                    if (_junRtFlg) {
                        if (SDCost >= IDCost) {
                            _spliceNo = j;
                            _brkFlg = true;
                        }
                    } else {
                        if (SDCost <= IDCost) {
                            _spliceNo = j;
                            _brkFlg = true;
                        }
                        if (j == ItDeckArr.length - 1) {
                            if (SDCost >= IDCost) {
                                _spliceNo = ItDeckArr.length;
                            }
                        }
                    }
                    break;
                case 2: 
                    let SDRea = Number(SCData.meta["Rea"]);
                    let IDRea = Number(ICData.meta["Rea"]);
                    if (_junRtFlg) {
                        if (SDRea >= IDRea) {
                            _spliceNo = j;
                            _brkFlg = true;
                        }
                    } else {
                        if (SDRea <= IDRea) {
                            _spliceNo = j;
                            _brkFlg = true;
                        }
                        if (j == ItDeckArr.length - 1) {
                            if (SDRea >= IDRea) {
                                _spliceNo = ItDeckArr.length;
                            }
                        }
                    }
                    break;
            }
            if (_brkFlg) break;
        }
        ItDeckArr.splice(_spliceNo, 0, SetDeckArr[i]);
    }
    for (let i = 0; i <= ItDeckArr.length - 1; i++) {
        let ICData = $dataWeapons[ItDeckArr[i]._CNo];
        if (_siboNo != 0) { 
            if (ICData.wtypeId != _siboNo) {
                let spliceFlg = true;
                if (_siboNo == 4 && Check必殺Card(ICData)) spliceFlg = false;
                if (spliceFlg) {
                    ItDeckArr.splice(i, 1);
                    i--;
                }
            }
        }
    }
    ItDeckTPArr = [];
    let _CSi = _DeckZure * 5; 
    let _dXPos = 861;
    let _dYPos = 230;
    DelSpriteSpan(PN_deACnt, PN_deACnt + 19);
    Alpha0SpriteSpan(PN_deCNew, PN_deCNew + 19);
    for (let i = 0; i <= 20 - 1; i++) { 
        let ix = i % 5;
        let iy = Math.floor(i / 5);
        if (ItDeckArr.length <= i + _CSi) {
            this.DelSprite(PN_deACd + (i * 3));
            this.DelSprite(PN_deACd + (i * 3) + 1);
            this.DelSprite(PN_deACd + (i * 3) + 2);
            this.DelSprite(PN_CMiniR + i);
            this.DelSprite(PN_CMiniRTxt + i);
            this.DelSprite(PN_CMiniL + i);
            this.DelSprite(PN_CMiniLTxt + i);
            this.DelSprite(PN_deACnt + i);
            continue; 
        }
        let _setOpi = ItDeckArr[i + _CSi]._Opi;
        let _cardNo = ItDeckArr[i + _CSi]._CNo;
        ItDeckTPArr.push(PN_deACd + (i * 3));
        this.CardSpriteSetC(_cardNo, PN_deACd + (i * 3), _dXPos + (ix * 108), _dYPos + (iy * 148), _setOpi, 40, 40);
        if (ItDeckArr[i + _CSi]._Cnt > 1) {
            let _SetCnt = ItDeckArr[i + _CSi]._Cnt;
            //ppif (_SetCnt >= 10) _SetCnt = 10;
            if (_SetCnt <= 99) { 
                this.SetSpriteC(PN_deACnt + i, CardPicPath + "wk_cnt" + _SetCnt, _dXPos + (ix * 108), _dYPos + (iy * 148), _setOpi, 40, 40);
            } else { 
                this.SetSpriteC(PN_deACnt + i, CardPicPath + "wk_cnt100", _dXPos + (ix * 108), _dYPos + (iy * 148), _setOpi, 40, 40);
            }
            this.MoveSprite(PN_deACnt + i, true, true, 10, 255, true, true);
        }
        for (let j = 0; j <= $gameSystem.NewCard.length - 1; j++) {
            if (_cardNo == $gameSystem.NewCard[j]) {
                this.SetSpriteC(PN_deCNew + i, CardPicPath + "wk_new", _dXPos + (ix * 108), _dYPos + (iy * 148), 255, 40, 40);
            }
        }
        this.CardSpriteMove(PN_deACd + (i * 3), true, true, 10, _setOpi, true, true);
        if (_AddPcCNo == _cardNo) {
            this.PlayPtcScTop("S_Click", _dXPos + (ix * 108), _dYPos + (iy * 148));
        }
        var mStr = MetaChecker($dataWeapons[_cardNo], "MiniIco", "352,");
        var ckmArr = mStr.split(',');
        while (ckmArr.length < 2) ckmArr.push("");
        var mKPos = new Pos2D(291 + 581, 265);
        this.SpriteStr(PN_CMiniR + i, "\\I[" + ckmArr[0] + "]", 24, mKPos._x + (ix * 108), mKPos._y + (iy * 148));
        this.SpriteStrR(PN_CMiniRTxt + i, GetWeaponValueData($dataWeapons[_cardNo], ckmArr[1]), 18,
            mKPos._x + 40 + (ix * 108), mKPos._y + 21 + (iy * 148));
    }
    _AddPcCNo = -1; 
    let _BarMaxCnt = 4;
    if (ItDeckArr.length > 20) {
        let _ckInt = Math.ceil((ItDeckArr.length - 20) / 5);
        _BarMaxCnt += _ckInt;
    }
    _DeckBar = new N_Scroll(DE_PicPath + "PN_deScBar", 571, PN_deScBar, 1358, 167);
    _DeckBar.ViewCount = 4; 
    _DeckBar.ItemCount = _BarMaxCnt; 
    _DeckBar.ZureAdd(_DeckZure);    
    this.ScrollSpView(_DeckBar, 255); 
};
Game_Interpreter.prototype.PoolCardDell = function () {
    for (let i = 0; i <= 20 - 1; i++) {
        this.DelSprite(PN_deACd + 0 + (i * 3));
        this.DelSprite(PN_deACd + 1 + (i * 3));
        this.DelSprite(PN_deACd + 2 + (i * 3));
    }
    this.DelSpriteSpan(PN_deCNew, PN_deCNew + 19);
    this.DelSpriteSpan(PN_deACnt, PN_deACnt + 19);
};
Game_Interpreter.prototype.CardPicDell = function () {
    this.DeckCardDell(); 
    this.PoolCardDell(); 
};
Game_Interpreter.prototype.Menu_DE_Update = function () {
    switch (Menu_EditLayer) {
        case 2:
            this.Menu_DE_Update_L1();
            break;
        case 3:
            this.Menu_DE_Update_L2();
            break;
    }
    if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
        this.PlayPtcScTop("S_Click", PL_MouseX, PL_MouseY);
    }
}
Game_Interpreter.prototype.DE_BtnView = function () {
    this.SetSpriteFIn(PN_deBtn + 0, DE_PicPath + "de_btn_1", -20, 170 + (67 * 0), 0, 0, 5);
    this.SetSpriteFIn(PN_deBtn + 1, DE_PicPath + "de_btn_2", -20, 170 + (67 * 1), 0, 0, 5);
    if ($gameSwitches.value(SW_RentalOK))
        this.SetSpriteFIn(PN_deBtn + 2, DE_PicPath + "de_btn_3", -20, 170 + (67 * 2), 0, 0, 5);
    this.SetSpriteFIn(PN_deBtn + 3, DE_PicPath + "de_btn_Close", -20, 170 + (67 * 7) + 30, 0, 0, 5);
    if (!_Albm_Off) this.SetSpriteFIn(PN_AbBtn, DE_PicPath + "de_btn_Albm", -20, 170 + (67 * 6) + 30, 0, 0, 5);
    this.SetSpriteFIn(PN_deDtitle, DE_PicPath + "dtitle_" + _editDNo, 264, 98, 0, 0, 15);
    let _SpriteName = GetSpriteData(PN_deBtn + _editDNo)._name + "b";
    this.CngSprite(PN_deBtn + _editDNo, DE_PicPath + _SpriteName);
    this.MoveSprite(PN_deBtn + _editDNo, 0, 170 + (67 * _editDNo), 15);
}
Game_Interpreter.prototype.DktoIt = function (_cId) {
    for (let i = 0; i <= $gameSystem.DeckArr[_editDNo].length - 1; i++) {
        if ($gameSystem.DeckArr[_editDNo][i] == _cId) {
            $gameSystem.DeckArr[_editDNo].splice(i, 1); 
            break;
        }
    }
    _AddDcCNo = _cId;
    this.DE_CardAllView(); 
}
Game_Interpreter.prototype.IttoDk = function (_cId) {
    let _必殺Flg = $dataWeapons[_cId].meta["NCNo"] != undefined;
    let _URFlg = $dataWeapons[_cId].meta["Rea"] == "3";
    let _AddFlg = true;
    let in待機Card = false;
    for (let i = 0; i <= EDeckArr.length - 1; i++) {
        if ($dataWeapons[EDeckArr[i]._CNo].meta["NCNo"] != undefined && _必殺Flg) {
            this.BLogAdd(90, "アクセスカードは1枚まで");
            return; 
        }
        if (EDeckArr[i]._CNo == _cId) {
            if (_URFlg) {
                this.BLogAdd(90, "選択したレアカードはデッキに使用されています");
                return; 
            }
            _AddFlg = false; 
            if (EDeckArr[i]._Cnt >= 3) {
                this.BLogAdd(90, "同じ種類のカードは3枚まで");
                return; 
            }
        }
        if (EDeckArr[i]._CNo == CId_待機) in待機Card = true;
    }
    if (_AddFlg) {
        if (EDeckArr.length >= 20 && !in待機Card) {
            this.BLogAdd(90, "デッキには20種類のカードまで");
            return;
        }
    }
    $gameSystem.DeckArr[_editDNo].push(_cId);
    $gameSystem.DeckArr[_editDNo].sort(function (a, b) {
        return a - b;
    });
    _AddDcCNo = _cId;
    this.DE_CardAllView(); 
}
let _befCOver = -1; 
let _de_Resetflame = 0;
Game_Interpreter.prototype.Menu_DE_Update_L1 = function () {
    if (ClickCkFlg) {
        if (_de_Resetflame > 10) {
            let _CCNo = this.ClickCk_Update();
            if (Input.isTriggered('menu') || TouchInput.isCancelled() || _CCNo == PN_ClickCk_No) {
                this.ClickCk_WinDel();
            }
            if (_CCNo == PN_ClickCk_Yes) {
                SoundManager.playOk(); 
                for (let i = 0; i <= $gameSystem.DeckArr[_editDNo].length - 1; i++) {
                    $gameSystem.DeckArr[_editDNo].splice(i, 1); 
                    i--;
                }
                this.DE_CardAllView(); 
                this.ClickCk_WinDel();
            }
        }
        _de_Resetflame++;
        this.CheckDeckRightClick(); 
        return;
    }
    if (_アルバムFlg) {
        this.Abm_Update();
        return;
    }
    let _ix = _iy = 0;
    let _cXPos = 281;
    let _cYPos = 230;
    Alpha0Sprite(PN_deCdSel);
    let _DkCardNo = -1; 
    this.de_MiniSyosaiDel();
    let _DkCkNo = overPointerSpCkArr(EDeckTPArr);
    if (_DkCkNo != -1) {
        let _ckNo = (_DkCkNo - PN_deDCd) / 3;
        try {
            _DkCardNo = EDeckArr[_ckNo]._CNo;
            let ix = _ckNo % 5;
            let iy = Math.floor(_ckNo / 5);
            this.SetSpriteC(PN_deCdSel, DE_PicPath + "de_sel", _cXPos + (ix * 108), _cYPos + (iy * 148));
            let _SyCardNo = EDeckArr[_ckNo]._CNo;
            let AddX = 107;
            this.de_MiniSyosai(_SyCardNo, (ix * 108) + AddX, (iy * 148) + 70);
        } catch (ex) {
            console.log("Err：" + _DkCardNo);
        }
    } else {
        this.DelSprite(PN_StarMark);
    }
    let _dXPos = 861;
    let _dYPos = 230;
    let _ItCardNo = -1;
    let _ItCkNo = overPointerSpCkArr(ItDeckTPArr);
    if (_ItCkNo != -1) {
        let _ckNo = (_ItCkNo - PN_deACd) / 3;
        let ix = _ckNo % 5;
        let iy = Math.floor(_ckNo / 5);
        this.SetSpriteC(PN_deCdSel, DE_PicPath + "de_sel",
            _dXPos + (ix * 108), _dYPos + (iy * 148));
        _ItCardNo = ItDeckArr[_ckNo + (_DeckZure * 5)]._CNo;
        let AddX2 = 680;
        if (ix == 4) AddX2 -= 100;
        this.de_MiniSyosai(_ItCardNo, (ix * 108) + AddX2, (iy * 148) + 70);
    }
    if (_editDNo != 2 || DeckMode == _DeckMode.カードトレーダー) {
        if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
            let exitMenu = true;
            switch (DeckMode) {
                case _DeckMode.デッキ編集:
                    if (overPointerSpCk(PN_deDtlBase)) { 
                    } else {
                        if (_DkCardNo != -1 && _DkCardNo != CId_待機) {
                            this.DktoIt(_DkCardNo); 
                            this.PlaySe("card");
                            exitMenu = false;
                        }
                        if (_ItCardNo != -1) {
                            this.IttoDk(_ItCardNo); 
                            this.PlaySe("card");
                            exitMenu = false;
                        }
                    }
                    break;
                case _DeckMode.カードトレーダー:
                    exitMenu = false;
                    if (_ItCardNo != -1) {
                        this.CTradeRClick(_ItCardNo); 
                        this.PlaySe("card");
                        exitMenu = false;
                    }
                    break;
            }
            this.CheckDeckRightClick(); 
            if (exitMenu) {
                if ((Tutorial_SetuNo >= 11 && Tutorial_SetuNo <= 12)) return; 
                this.Dc_CloseBtn();
                return; 
            }
            return;
        }
    }
    let _CNo = overSpriteClickable(PN_deBack, _DeckBar_CBMap);
    if (_CNo != -1) {
        console.log("接触Flg");
        if (TouchInput.isPressed()) {
            let _Sc位置Y = _DeckBar_CBMap[0][1];
            let _Sc高さ = _DeckBar_CBMap[0][3];
            let _SetZure = 0;
            let _Y位置割合 = (PL_MouseY - _Sc位置Y) / _Sc高さ; 
            _SetZure = Math.floor(_DeckBar.ItemCount * _Y位置割合 + 1) - 4;
            if (_SetZure < 0) _SetZure = 0;
            if (_DeckZure != _SetZure) {
                _DeckZure = _SetZure;
                this.PoolCardView();
            }
        }
    }
    if (TouchInput.wheelY < 0) { 
        if (_DeckZure > 0) _DeckZure--;
        this.PoolCardView();
        this.CheckDeckRightClick(); 
        return;
    }
    if (TouchInput.wheelY > 0) { 
        if (ItDeckArr.length - 20 - (_DeckZure * 5) > 0) {
            _DeckZure++;
        }
        this.PoolCardView();
        this.CheckDeckRightClick(); 
        return;
    }
    let _CkPicArr = [];
    for (let i = 0; i <= 3; i++) {
        _CkPicArr.push(PN_deBtn + i);
        this.SpriteCngColor(PN_deBtn + i); 
    }
    let _OverNo = overPointerSpCkArr(_CkPicArr);
    if (_OverNo != -1) {
        this.SpriteCngColor(_OverNo, [100, 100, 100, 0]); 
        if (TouchInput.isTriggered()) {
            switch (_OverNo - PN_deBtn) {
                case 0: 
                case 1:
                case 2:
                    if ($gameSwitches.value(SW_RentalOnlyFlg)) return;
                    SoundManager.playOk(); 
                    _editDNo = _OverNo - PN_deBtn;
                    this.DE_BtnView();
                    this.DE_CardAllView(true); 
                    break;
                case 3:
                    this.Dc_CloseBtn();
                    return; 
            }
            this.CheckDeckRightClick(); 
            return;
        }
    }
    this.SpriteCngColor(PN_AbBtn); 
    if (overPointerSpCk(PN_AbBtn)) {
        this.SpriteCngColor(PN_AbBtn, [100, 100, 100, 0]); 
        if (TouchInput.isTriggered()) {
            this.Abm_Draw(); 
            this.CheckDeckRightClick(); 
            return;
        }
    }
    this.SpriteCngColor(PN_deUseBtn, [0, 0, 0, 0]); 
    if (!_UseDeckFlg && overPointerSpCk(PN_deUseBtn)) {
        this.SpriteCngColor(PN_deUseBtn, [80, 80, 80, 0]);
    }
    if (_editDNo != 2) {
        this.SpriteCngColor(PN_deResetBtn, [0, 0, 0, 0]);
        if (overPointerSpCk(PN_deResetBtn)) {
            this.SpriteCngColor(PN_deResetBtn, [80, 80, 80, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk();
                if (menuAutoCloseFlame > 0) {
                    menuAutoCloseFlame = 1;
                    this.CheckDeckRightClick(); 
                    return;
                }
                D_Text_Cng_font = "Makinas";
                this.ClickCk_WinView(["デッキのカードを全て", "所持カード一覧に戻しますか？"]);
                D_Text_Cng_font = "";
                _de_Resetflame = 0;
                this.CheckDeckRightClick(); 
                return;
            }
        }
    } else {
        this.DelSprite(PN_deResetBtn);
    }
    let _ckDkCkNo = overPointerSpCkArr(EDeckTPArr);     
    let _ckItCkNo = overPointerSpCkArr(ItDeckTPArr);    
    if ((_ckDkCkNo == -1 && _ckItCkNo == -1) ||
        (_ckDkCkNo != -1 && _ckDkCkNo != _befCOver) ||
        (_ckItCkNo != -1 && _ckItCkNo != _befCOver)) {
        this.DelSpriteArr(de_CSsyosaiPArr);
        de_CSsyosaiPArr = [];
    }
    if (TouchInput.isTriggered()) {
        if (overPointerSpCk(PN_deDtlBase)) {
            this.DelSpriteArr(de_CSsyosaiPArr);
            de_CSsyosaiPArr = [];
            this.CheckDeckRightClick(); 
            return; 
        }
        let _ClkNo = -1;
        if (_ckDkCkNo != -1) {
            SoundManager.playOk(); 
            try {
                let _ckNo = (_ckDkCkNo - PN_deDCd) / 3;
                let _SyCardNo = EDeckArr[_ckNo]._CNo;
                this.de_CSyosai(_SyCardNo, 787, 13);
                _befCOver = _ckDkCkNo;
                return; 
            } catch (ex) {
            }
        }
        if (_ckItCkNo != -1) {
            SoundManager.playOk(); 
            let _ckNo = (_ckItCkNo - PN_deACd) / 3;
            let _SyCardNo = ItDeckArr[_ckNo + (_DeckZure * 5)]._CNo;
            this.de_CSyosai(_SyCardNo, 143, 13);
            _befCOver = _ckItCkNo;
            this.CheckDeckRightClick(); 
            return; 
        }
        _ClkNo = overSpriteClickable(PN_deBack, _JunArr); 
        if (_ClkNo != -1) {
            _DeckZure = 0; 
            SoundManager.playOk(); 
            if (_junNo == _ClkNo) {
                _junRtFlg = !_junRtFlg; 
            } else {
                _junRtFlg = false;
            }
            _junNo = _ClkNo;
            this.RdoBtnView();   
            this.DE_CardAllView(); 
            this.CheckDeckRightClick(); 
            return; 
        }
        _ClkNo = overSpriteClickable(PN_deBack, _SiboArr);
        if (_ClkNo != -1 && _ClkNo != _siboNo) {
            if (_ClkNo == 5 && !CheckSexCard所持()) return;
            _DeckZure = 0; 
            SoundManager.playOk(); 
            _siboNo = _ClkNo;
            this.RdoBtnView();   
            this.DE_CardAllView(); 
            this.CheckDeckRightClick(); 
            return; 
        }
        if (!_UseDeckFlg) {
            if (overPointerSpCk(PN_deUseBtn)) {
                SoundManager.playOk(); 
                $gameSystem.SelDeck = _editDNo;
                $gameVariables.setValue(VN_UseDeckName , 0); 
                this.SetSpriteFIn(PN_deUseBtn, DE_PicPath + "use_btn2", 571, 92, 0, 0, 10);
                _UseDeckFlg = true;
            }
        }
        this.DelSpriteArr(de_CSsyosaiPArr);
        de_CSsyosaiPArr = [];
    }
    this.CheckDeckRightClick(); 
}
Game_Interpreter.prototype.CheckDeckRightClick = function () {
    if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
        Menu_EditLayer++;
        this.DelSpriteArr(de_CSsyosaiPArr);
        de_CSsyosaiPArr = []
    }
}
let deMiniPictFlg = false;
Game_Interpreter.prototype.de_MiniSyosaiDel = function () {
    let _dArr = [PN_deMnBs, PN_deMCName, PN_deMnTxt + 0, PN_deMnTxt + 1, PN_deMnTxt + 2, PN_deMnTxt + 3];
    Alpha0SpriteArr(_dArr);
    if (deMiniPictFlg) {
        for (let i = PN_deMnBs; i <= PN_deMnTxt + 3; i++) {
            this.MovePict(i, true, true, 1, 0, true, true);
        }
    }
    deMiniPictFlg = false;
}
Game_Interpreter.prototype.de_MiniSyosai = function (_CNo, _XPos, _YPos) {
    D_Text_Cng_font = "Makinas";
    let _cData = $dataWeapons[_CNo];
    let _ckStrArr = this.CardSetuGet(_CNo); 
    if (!deMiniPictFlg)
        this.SpriteStr(PN_deMCName, _cData.name, 17, _XPos + 12, _YPos + 3, 255);
    else
        this.SetPicStr(PN_deMCName, _cData.name, 17, _XPos + 12, _YPos + 3, 255);
    if (Check必殺Card($dataWeapons[_CNo])) {
        _ckStrArr.push(SCol.Yel + "★アクセスカード：デッキに1枚まで")
    }
    for (let i = 0; i <= _ckStrArr.length - 1; i++) {
        if (!deMiniPictFlg)
            this.SpriteStr(PN_deMnTxt + i, _ckStrArr[i], 18,
                _XPos + 11, _YPos + 22 + (19 * i), 255);
        else
            this.SetPicStr(PN_deMnTxt + i, _ckStrArr[i], 18,
                _XPos + 11, _YPos + 22 + (19 * i), 255);
    }
    if (!deMiniPictFlg)
        this.SetSprite(PN_deMnBs, DE_PicPath + "mini_Win", _XPos, _YPos);
    else
        this.SetPict(PN_deMnBs, DE_PicPath + "mini_Win", _XPos, _YPos);
    if (_ckStrArr.length == 4) {
        if (!deMiniPictFlg)
            this.SetSprite(PN_deMnBs, DE_PicPath + "mini_Win_L", _XPos, _YPos);
        else
            this.SetPict(PN_deMnBs, DE_PicPath + "mini_Win_L", _XPos, _YPos);
    }
    D_Text_Cng_font = "";
}
let de_CSsyosaiPArr = [];
Game_Interpreter.prototype.de_CSyosai = function (_CNo, _XPos, _YPos) {
    Alpha0SpriteArr(de_CSsyosaiPArr);
    de_CSsyosaiPArr = []
    ViewSpriteArr_Reset();
    this.SetSpriteFIn(PN_deDtlBase, DE_PicPath + "de_syosai", _XPos, _YPos, 0, 0, 10);
    let _cData = $dataWeapons[_CNo];
    D_Text_Cng_font = "Makinas";
    this.SpriteStr(PN_deDtlTxt + 0, _cData.name, 29, _XPos + 205, _YPos + 34, 0);
    this.SpriteStr(PN_deDtlTxt + 1, "コスト：" + _cData.meta["Cost"], 29, _XPos + 457, _YPos + 34, 0);
    this.SpriteStr(PN_deDtlTxt + 2, _cData.description, 17, _XPos + 205, _YPos + 89, 0);
    this.SpriteStr(PN_deDtlTxt + 3, "効果", 21, _XPos + 205, _YPos + 135, 0);
    let _ckStrArr = this.CardSetuGet(_CNo); 
    for (let i = 0; i <= _ckStrArr.length - 1; i++) {
        this.SpriteStr(PN_deDtlTxt + 4 + i, _ckStrArr[i], 21, _XPos + 205, _YPos + 170 + (35 * i), 0);
    }
    this.CardSpriteSetC(_CNo, PN_deSCard, _XPos + 113, _YPos + 142, 0, 70, 70);
    IjoSetuDraw_下描画Flg = true; 
    let _Ps = new Pos2D(_XPos + 33, _YPos + 365);
    this.IjoSetuDraw(PN_deSetuI, _CardSetuGet_StList, _Ps);
    D_Text_Cng_font = "";
    de_CSsyosaiPArr = CopyArr(ViewSpriteArr);
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
    de_CSsyosaiPArr.push(PN_deSCard);
}
Game_Interpreter.prototype.de_CardMove = function () {
}
Game_Interpreter.prototype.Menu_DE_Update_L2 = function () {
}
Game_Interpreter.prototype.Dc_CloseBtn = function () {
    $gameSystem.NewCard = [];
    this.DeckPicDel(); 
    this.CardPicDell();
    this.MenuMainReset(); 
}
Game_Interpreter.prototype.DeckPicDel = function (_No) { 
    _No = typeof _No !== 'undefined' ? _No : 135;
    for (let i = _No; i <= PN_AbmCloseBtn; i++) {
        this.DelSprite(i);
    }
    this.DelSprite(PN_deScBar);
    this.DelPict(PN_AbScroll);
    this.DelPict(_DeckBar.PicNo);
}
let _Abm_Clickable = []; 
let _ScBar_Clickable = [[720, 172, 23, 570]];
let _アルバムFlg = false;
let _Abm_flame = 0;
let _Abm_ExitFlg = false;
let _Abm_Exitflame = 0;
let _Abm_SelY = 0; 
let _Abm_ZureY = 0; 
let _Abm_ListPicArr = [];
let Abm_Scroll = new N_Scroll(DE_AbPicPath + "PN_AbScroll", 566, PN_AbScroll, 722, 174);
Abm_Scroll.ViewCount = 13; 
let AbmItemCount = function () {
    var cnt = 0;
    for (let i = 1; i <= $dataWeapons.length - 1; i++) {
        if ($dataWeapons[i].meta["AbmId"] == null) continue;
        cnt++;
    }
    return cnt;
}
Game_Interpreter.prototype.Abm_Draw = function () {
    _Abm_所持カードのみ表示Flg = false;
    _Abm_JunNo = 0;     
    _Abm_siboNo = 0;    
    _Abm_SbSelNo = 0;   
    _Abm_SelectCardNo = -1;
    _Abm_Clickable = [];
    Abm_Scroll.ZureNo = 0;
    _Abm_ExitFlg = false;
    _Abm_Exitflame = 0;
    Abm_Scroll.ItemCount = AbmItemCount();
    this.ScrollView(Abm_Scroll, 255);
    D_Text_Cng_font = "Makinas";
    _アルバムFlg = true;
    _Abm_flame = 0;
    var setAbmPic = "PN_AbBase";
    if (!CheckSexCard所持()) setAbmPic = "PN_AbBase_NoSex";
    this.SetSpriteFIn(PN_AbBase, DE_AbPicPath + setAbmPic, 0, 0, 0, 0, 10);
    this.MoveSprite(PN_AbBtn, 0, true, 3);
    this.Abm_CardListDraw();
    _Abm_SelY = 0;
    this.SetSprite(PN_AbCSelH, DE_AbPicPath + "PN_AbCSelH", 248, 175, 255);
    this.SetSpriteFIn(PN_AbmCloseBtn, DE_PicPath + "de_btn_Close", -20, 170 + (67 * 7) + 30, 0, 0, 5);
    D_Text_Cng_font = "";
}
let _Abm_所持カードのみ表示Flg = false;
let _Abm_JunNo = 0; 
let _JunArr_Abm = [ 
    [23, 402, 65, 25],
    [93, 402, 81, 25],
    [23, 430, 116, 25]
];
let _Abm_SbSelNo = 0; 
let _Abm_siboNo = 0; 
let _SiboArr_Abm = [ 
    [23, 489, 67, 27], 
    [23, 489 + 28, 67, 27], 
    [23, 489 + (28 * 2), 67, 27], 
    [23 + 70, 489, 67, 27], 
    [23 + 70, 489 + 28, 67, 27], 
    [23 + 70, 489 + (28 * 2), 67, 27] 
];
Game_Interpreter.prototype.Abm_絞り込みUI描画 = function () {
    let _PosX = _JunArr_Abm[_Abm_JunNo][0];
    let _PosY = _JunArr_Abm[_Abm_JunNo][1];
    this.SetSprite(PN_AbRBtn + 0, DE_AbPicPath + "de_rbtn1", _PosX, _PosY);
    _PosX = _SiboArr_Abm[_Abm_SbSelNo][0];
    _PosY = _SiboArr_Abm[_Abm_SbSelNo][1];
    this.SetSprite(PN_AbSbRBtn + 0, DE_AbPicPath + "de_rbtn1", _PosX, _PosY);
}
function GetCard_IndexCheck(_cardId) {
    return ($gameSystem.GetCard.indexOf(_cardId) != -1);
}
let _Abm_DowScOkFlg = false;
let _Abm_DeckCbmArr = [];
Game_Interpreter.prototype.Abm_CardListDraw = function () {
    this.Abm_絞り込みUI描画();
    _Abm_ListPicArr = [];
    if (_Abm_ZureY > dataWeapons_AbmNo.length - 14) _Abm_ZureY = dataWeapons_AbmNo.length - 13;
    Abm_Scroll.ZureNo = _Abm_ZureY;
    this.ScrollView(Abm_Scroll, 255);
    let _PsAb = new Pos2D(270, 181);
    let _iCnt = 0;
    let _WpnCnt = 0;
    Abm_Scroll.ItemCount = dataWeapons_AbmNo.length;
    for (let i = 0; i <= dataWeapons_AbmNo.length - 1; i++) {
        let SCData = dataWeapons_AbmNo[i];
        if (SCData.wtypeId != _Abm_siboNo && _Abm_siboNo != 0) {
            if (_Abm_siboNo == 4) {
                if (!Check必殺Card(SCData)) continue;
            } else {
                continue;
            }
        }
        if (!GetCard_IndexCheck(dataWeapons_AbmNo[i].id) && _Abm_所持カードのみ表示Flg) continue;
        _WpnCnt++;
    }
    Abm_Scroll.ItemCount = _WpnCnt;
    this.ScrollView(Abm_Scroll, 255);
    let _ViewDeckArr = []; 
    for (let i = 0; i <= dataWeapons_AbmNo.length - 1; i++) {
        let SCData = dataWeapons_AbmNo[i];
        if (_Abm_所持カードのみ表示Flg) {
            if (!GetCard_IndexCheck(dataWeapons_AbmNo[i].id)) {
                continue; 
            }
        }
        if (_Abm_siboNo != 0) {
            if (SCData.wtypeId != _Abm_siboNo) {
                if (_Abm_siboNo == 4) { 
                    if (!Check必殺Card(SCData)) continue;
                } else {
                    continue; 
                }
            }
        }
        let _spliceNo = _ViewDeckArr.length; 
        switch (_Abm_JunNo) {
            case 0: 
                _ViewDeckArr.push(dataWeapons_AbmNo[i]);
                break;
            case 1: 
                let SDCost = 0; 
                if (SCData.meta["Cost"] != "All") {
                    SDCost = Number(SCData.meta["Cost"]);
                } else {
                    SDCost = 99; 
                }
                for (let j = 0; j <= _ViewDeckArr.length - 1; j++) {
                    let ICData = _ViewDeckArr[j];
                    let IDCost = 0;
                    if (ICData.meta["Cost"] != "All") {
                        IDCost = Number(ICData.meta["Cost"]);
                    } else {
                        IDCost = 99; 
                    }
                    if (SDCost > IDCost) {
                        _spliceNo = j;
                        break;
                    }
                }
                _ViewDeckArr.splice(_spliceNo, 0, dataWeapons_AbmNo[i]);
                break;
            case 2: 
                let SDRea = Number(SCData.meta["Rea"]);
                for (let j = 0; j <= _ViewDeckArr.length - 1; j++) {
                    let ICData = _ViewDeckArr[j];
                    let IDRea = Number(ICData.meta["Rea"]);
                    if (SDRea > IDRea) {
                        _spliceNo = j;
                        break;
                    }
                }
                _ViewDeckArr.splice(_spliceNo, 0, dataWeapons_AbmNo[i]);
                break;
        }
    }
    this.DelSprite(PN_AbTopBtn);
    this.DelSprite(PN_AbBtmBtn);
    _Abm_DowScOkFlg = false;
    if (_Abm_ZureY > 0) {
        this.SetSprite(PN_AbTopBtn, DE_AbPicPath + "PN_AbTopBtn", 274, 148);
    }
    _ViewDeckArr.unshift(null); 
    _Abm_DeckCbmArr = _ViewDeckArr.slice();
    this.DelSpriteSpan(PN_AbCNo, PN_AbType + 12);
    _iCnt = 0;
    for (let i = 1 + _Abm_ZureY; i <= _ViewDeckArr.length - 1; i++) {
        _Abm_Clickable.push([254, 179 + (_iCnt * 43), 448, 37]);
        if (_ViewDeckArr[i].meta["AbmId"] == null) continue;
        let _WpNo = Number(_ViewDeckArr[i].meta["AbmId"]);
        let _CNo = ('000' + _WpNo).slice(-3); 
        if (_Abm_SelectCardNo == _ViewDeckArr[i].id) _CNo = SCol.Yel + _CNo;
        this.SpriteStr(PN_AbCNo + _iCnt, _CNo, 25, _PsAb._x, _PsAb._y + 43 * _iCnt);
        let _CardStr = "";
        let _武器TypeStr = "";
        if (GetCard_IndexCheck(_ViewDeckArr[i].id)) {
            _CardStr = "\\I[" + _ViewDeckArr[i].iconIndex + "] " + _ViewDeckArr[i].name;
            let _武器Type = _ViewDeckArr[i].wtypeId;
            switch (_武器Type) {
                case CType.攻撃:
                    _武器TypeStr = "攻撃";
                    break;
                case CType.防御:
                    _武器TypeStr = "防御";
                    break;
                case CType.補助:
                    _武器TypeStr = "補助";
                    break;
                case CType.必殺:
                    _武器TypeStr = "必殺";
                    break;
                case CType.Sex:
                    _武器TypeStr = "Sex";
                    break;
                case CType.異常:
                    _武器TypeStr = "異常";
                    break;
            }
            if (_Abm_SelectCardNo == _ViewDeckArr[i].id) {
                _CardStr = SCol.Yel + _CardStr;
                _武器TypeStr = SCol.Yel + _武器TypeStr;
            }
        } else {
            _CardStr = "\\I[" + 0 + "] " + "？？？？？？？？";
            _武器TypeStr = "？？？";
        }
        this.SpriteStr(PN_AbCStr + _iCnt, _CardStr, 25, _PsAb._x + 62, _PsAb._y + 43 * _iCnt);
        this.SpriteStr(PN_AbType + _iCnt, _武器TypeStr, 25, _PsAb._x + 62 + 294, _PsAb._y + 43 * _iCnt);
        _iCnt++;
        if (_iCnt == 13) {
            if (_WpNo == (dataWeapons_AbmNo.length)) break;
            _Abm_DowScOkFlg = true;
            this.SetSprite(PN_AbBtmBtn, DE_AbPicPath + "PN_AbBtmBtn", 274, 742);
            break;
        }
    }
}
Game_Interpreter.prototype.Abm_Update = function () {
    let _ListUpFlg = false;
    if (_Abm_ExitFlg) {
        _Abm_Exitflame++;
        if (_Abm_Exitflame == 5) this.Abm_Exit();
        return;
    }
    let _CNo = overSpriteClickable(PN_AbBase, _Abm_Clickable);
    if (_CNo != -1) {
        if (_Abm_SelY != _CNo) {
            _Abm_SelY = _CNo;
            if (_Abm_DeckCbmArr.length <= _CNo + 1 + _Abm_ZureY) return;
            this.MoveSprite(PN_AbCSelH, true, 175 + 43 * _CNo, 5);
        }
        if (TouchInput.isTriggered()) {
            if (_Abm_DeckCbmArr.length <= _CNo + 1 + _Abm_ZureY) return;
            this.Abm_DataDraw(_Abm_DeckCbmArr[_CNo + 1 + _Abm_ZureY].id);
        }
    }
    let _CSNo = overSpriteClickable(PN_AbBase, _JunArr_Abm);
    if (_CSNo != -1) {
        if (TouchInput.isTriggered()) {
            _Abm_ZureY = 0;
            _Abm_所持カードのみ表示Flg = true;
            _Abm_JunNo = _CSNo;
            _ListUpFlg = true;
            this.MoveSprite(PN_AbCSelH, true, 175 + 43 * 0, 5);
        }
    }
    let _CJNo = overSpriteClickable(PN_AbBase, _SiboArr_Abm);
    if (_CJNo != -1) {
        if (TouchInput.isTriggered()) {
            if (_CJNo == 3 && !CheckSexCard所持()) return;
            _Abm_ZureY = 0;
            _Abm_所持カードのみ表示Flg = true;
            _Abm_SbSelNo = _CJNo;
            switch (_CJNo) {
                case 0:
                    _Abm_siboNo = 0;
                    break; 
                case 1:
                    _Abm_siboNo = 1;
                    break; 
                case 2:
                    _Abm_siboNo = 3;
                    break; 
                case 3:
                    _Abm_siboNo = 5;
                    break; 
                case 4:
                    _Abm_siboNo = 2;
                    break; 
                case 5:
                    _Abm_siboNo = 4;
                    break; 
            }
            if (_Abm_JunNo == 0 && _Abm_siboNo == 0) {
                _Abm_所持カードのみ表示Flg = false;
            }
            _ListUpFlg = true;
            this.MoveSprite(PN_AbCSelH, true, 175 + 43 * 0, 5);
        }
    }
    this.SpriteCngColor(PN_AbmCloseBtn); 
    if (overPointerSpCk(PN_AbmCloseBtn)) {
        this.SpriteCngColor(PN_AbmCloseBtn, [100, 100, 100, 0]); 
        if (TouchInput.isTriggered()) {
            this.Abm_PicDel();
            _Abm_ExitFlg = true;
            return;
        }
    }
    _CNo = overSpriteClickable(PN_AbBase, _ScBar_Clickable);
    if (_CNo != -1) {
        if (TouchInput.isPressed()) {
            let _SetZure = 0;
            let _Y位置割合 = (PL_MouseY - 172) / 570;
            _SetZure = Math.floor(Abm_Scroll.ItemCount * _Y位置割合 + 1) - 13;
            if (_SetZure < 0) _SetZure = 0;
            if (_Abm_ZureY != _SetZure) {
                _Abm_ZureY = _SetZure;
                _ListUpFlg = true;
            }
        }
    }
    if (TouchInput.wheelY < 0) { 
        _Abm_ZureY--;
        if (_Abm_ZureY < 0) { 
            _Abm_ZureY = 0;
        } else {
            _ListUpFlg = true;
        }
    }
    if (TouchInput.wheelY > 0 && _Abm_DowScOkFlg) { 
        _Abm_ZureY++;
        _ListUpFlg = true;
    }
    if (_ListUpFlg) {
        this.Abm_CardListDraw();
    }
    if (TouchInput.isCancelled()) {
        this.Abm_PicDel();
        _Abm_ExitFlg = true;
    }
    _Abm_flame++;
}
let _Abm_SelectCardNo = -1; 
Game_Interpreter.prototype.Abm_DataDraw = function (_CardNo) {
    if (GetCard_IndexCheck($dataWeapons[_CardNo].id)) {
        _Abm_SelectCardNo = _CardNo; 
        D_Text_Cng_font = "Makinas";
        let _PsAb = new Pos2D(818, 116);
        let DrawNo = Number($dataWeapons[_CardNo].meta["AbmId"]);
        let _CNo = ('000' + (DrawNo)).slice(-3); 
        this.SpriteStr(PN_AbCardTxt + 0, _CNo, 25, _PsAb._x, _PsAb._y);
        let _CardStr = "\\I[" + $dataWeapons[_CardNo].iconIndex + "] " + $dataWeapons[_CardNo].name
        this.SpriteStr(PN_AbCardTxt + 2, _CardStr, 25, _PsAb._x + 62, _PsAb._y);
        let _武器Type = $dataWeapons[_CardNo].wtypeId;
        let _武器TypeStr = "";
        switch (_武器Type) {
            case CType.攻撃:
                _武器TypeStr = "攻撃";
                break;
            case CType.防御:
                _武器TypeStr = "防御";
                break;
            case CType.補助:
                _武器TypeStr = "補助";
                break;
            case CType.必殺:
                _武器TypeStr = "必殺";
                break;
            case CType.Sex:
                _武器TypeStr = "Sex";
                break;
            case CType.異常:
                _武器TypeStr = "異常";
                break;
        }
        this.SpriteStr(PN_AbCardTxt + 3, _武器TypeStr, 25, _PsAb._x + 62 + 294, _PsAb._y);
        this.CardSpriteSet(_CardNo, PN_AbCardPic, 896, 188);
        let _ckStrArr = this.CardSetuGet(_CardNo); 
        this.DelSpriteSpan(PN_AbCardSetu, PN_AbCardSetu + 2);
        for (let i = 0; i <= _ckStrArr.length - 1; i++) {
            this.SpriteStr(PN_AbCardSetu + i, _ckStrArr[i], 22, 810, 597 + (35 * i), 255);
        }
        let IllustStr = MetaChecker($dataWeapons[_CardNo], "Illust", "");
        this.SpriteStr(PN_AbIllust, IllustStr, 24, 1091, 745);
        this.Abm_CardListDraw();
        D_Text_Cng_font = "";
    }
}
Game_Interpreter.prototype.Abm_PicDel = function () {
    this.DelSpriteSpan(PN_AbBack, PN_AbIllust);
    this.DelSprite(PN_AbmCloseBtn);
    if (!_Albm_Off) this.SetSprite(PN_AbBtn, DE_PicPath + "de_btn_Albm", -20, 170 + (67 * 6) + 30);
    this.DelPict(PN_AbScroll);
}
Game_Interpreter.prototype.Abm_Exit = function () {
    _アルバムFlg = false;
}
　
