/*:
 * @plugindesc 
 * @author ぬぷ竜
 */
const ShopUIPath = "pictures/UI_Shop/"; 
const SE_spBuy = "Shop1"; 
let shop_flame = 0; 
let shop_selfFlm = 0; 
let ShopItemArr = [];   
let shopSelNo = 0; 
let SelfArr = []; 
class SpSelf { 
    constructor(_id, _str1, _str2, _motion) {
        this._id = _id; 
        this._str1 = _str1; 
        this._str2 = _str2; 
        this._motion = _motion;
    }
}
let _spPicArr = []; 
for (let i = 0; i <= 7; i++) {
    _spPicArr.push(PN_spIcon + i); 
}
_spPicArr.push(PN_spItmBuyBtn); 
_spPicArr.push(PN_spItmBuyBtn_5); 
_spPicArr.push(PN_spClose);     
class ShopItem {
    constructor(_id, _zaikoVN, _off , _zaiko) {
        _zaikoVN = typeof _zaikoVN !== 'undefined' ? _zaikoVN : -1;
        _off = typeof _off !== 'undefined' ? _off : 0;
        _zaiko = typeof _zaiko !== 'undefined' ? _zaiko : -1;
        this._id = _id; 
        this._zaikoVN = _zaikoVN; 
        this._off = _off; //割引%(0 ~ 100)
        this._zaiko = _zaiko; 
    }
}
let Shop_Initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    Shop_Initialize.call(this);
    this.ShopSaveDatas = []; 
};
class ShopSaveData {
    constructor(ShopNo) {
        this.ShopNo = ShopNo;
        this.ZaikoCounter = [];
    }
}
class ShopData {
    constructor(setData) {
        this.id = setData.id;
        this.name = setData.name;
        this.live2Dname = setData.live2Dname;
        this.weaponShopFlg = setData.weaponShopFlg; 
        this.shopItems = [];
        setData.shopItems.forEach(setItem => {
            this.shopItems.push(new ZaikoData(setItem , this.weaponShopFlg));
        })
        this.firstSelf = new ShopSelfData(setData.firstSelf);
        this.husokuSelf = new ShopSelfData(setData.husokuSelf);
        this.emptySelf = new ShopSelfData(setData.emptySelf);
        this.buySelf = new ShopSelfData(setData.buySelf);
        this.randSelf1 = new ShopSelfData(setData.randSelf1);
        this.randSelf2 = new ShopSelfData(setData.randSelf2);
        this.randSelf3 = new ShopSelfData(setData.randSelf3);
    }
}
class ZaikoData {
    constructor (setData , weaponFlg = false) {
        this.itemId = setData.itemId;
        if (weaponFlg && this.itemId > 0) {
            this.itemId += 499; 
        }
        this.zaikoVN = setData.zaikoVN;
        this.zaiko = setData.zaiko;
        this.sealPar = setData.sealPar;
        this.cardFlg = setData.cardFlg;
    }
}
class ShopSelfData {
    constructor(setData) {
        this.text = setData.text;
        this.motion = setData.motion;
    }
}
let shopL2DMdl = "";
let shopPicMdl = "";
let ShopModelSet = function (_mdlName) {
    shopL2DMdl = _mdlName;
    shopPicMdl = "";
}
let ShopModelSet_Pic = function (_mdlName) {
    shopL2DMdl = "";
    shopPicMdl = _mdlName;
}
var viewShopId = -1;
let ShopReset = function () {
    ShopItemArr = [];
    SelfArr = [];
    shopL2DMdl = "";
    shopPicMdl = "";
    viewShopId = -1;
}
let spISet = function (_id, _在庫VN, _off , _在庫) {
    _在庫VN = typeof _在庫VN !== 'undefined' ? _在庫VN : -1;
    _off = typeof _off !== 'undefined' ? _off : 0;
    _在庫 = typeof _在庫 !== 'undefined' ? _在庫 : -1;
    ShopItemArr.push(new ShopItem(_id, _在庫VN, _off , _在庫));
}
let PS_Shop_Start = function () {
    shop_flame = 0;
    shop_selfFlm = 0;
}
var GetViewShopData = function () {
    let shopSaveData = null;
    if (viewShopId != -1) {
        for (let i = 0; i < $gameSystem.ShopSaveDatas.length; i++) {
            if ($gameSystem.ShopSaveDatas[i].ShopNo == viewShopId) {
                shopSaveData = $gameSystem.ShopSaveDatas[i];
            }
        }
    }
    return shopSaveData;
}
/** @type {ShopData} */
let ViewShopData = null;
Game_Interpreter.prototype.ShopLoad = function (shopId) {
    ViewShopData = GetShopData(shopId);
    _spSPos = new Pos2D(759, 235); 
    if (ViewShopData.weaponShopFlg) {
        _spSPos = new Pos2D(759, 235 - 120); 
    }
    if (ViewShopData == null) return;
    ShopReset();
    ShopModelSet(ViewShopData.live2Dname);
    var shopAddFlg = true;
    if ($gameSystem.ShopSaveDatas == undefined) $gameSystem.ShopSaveDatas = [];
    for (let i = 0; i < $gameSystem.ShopSaveDatas.length; i++) {
        if ($gameSystem.ShopSaveDatas[i].ShopNo == shopId) {
            shopAddFlg = false;
        }
    }
    if (shopAddFlg) {
        var setShopSaveData = new ShopSaveData();
        setShopSaveData.ShopNo = shopId;
        for (let i = 0; i < ViewShopData.shopItems.length; i++) {
            var setZaikoCount = ViewShopData.shopItems[i].zaiko;
            if (setZaikoCount == 0) setZaikoCount = -1;
            setShopSaveData.ZaikoCounter.push(setZaikoCount);
        }
        $gameSystem.ShopSaveDatas.push(setShopSaveData);
    }
    for (let i = 0; i < ViewShopData.shopItems.length; i++) {
        var shopItem = ViewShopData.shopItems[i];
        if (shopItem.itemId > 0) {
            spISet(shopItem.itemId , shopItem.zaikoVN , shopItem.sealPar , shopItem.zaiko);
        }
    }
    SelfArr.push(new SpSelf("st", ViewShopData.firstSelf.text , "", ViewShopData.firstSelf.motion));
    SelfArr.push(new SpSelf("loss", ViewShopData.husokuSelf.text , "", ViewShopData.husokuSelf.motion));
    SelfArr.push(new SpSelf("sold", ViewShopData.emptySelf.text , "", ViewShopData.emptySelf.motion));
    SelfArr.push(new SpSelf("buy", ViewShopData.buySelf.text , "", ViewShopData.buySelf.motion));
    SelfArr.push(new SpSelf("rnd", ViewShopData.randSelf1.text , "", ViewShopData.randSelf1.motion));
    SelfArr.push(new SpSelf("rnd", ViewShopData.randSelf2.text , "", ViewShopData.randSelf2.motion));
    SelfArr.push(new SpSelf("rnd", ViewShopData.randSelf3.text , "", ViewShopData.randSelf3.motion));
    viewShopId = shopId;
}
let GetShopData = function (shopId) {
    for (let i = 0; i <= $Nupu_PSData.ShopDatas.length - 1; i++) {
        if ($Nupu_PSData.ShopDatas[i].id == shopId) {
            return new ShopData($Nupu_PSData.ShopDatas[i]);
        }
    }
    return null;
}
Game_Interpreter.prototype.PS_Shop_View = function (_ItemNo, _SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    shopSelNo = _ItemNo;
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    let setSpBackImg = "PN_spBack";
    if (ViewShopData.weaponShopFlg) setSpBackImg = "PN_spBack_weapon";
    this.SetPict(PN_spBack, ShopUIPath + setSpBackImg, 0, 0, _opi);
    this.SetPict(PN_spBase, ShopUIPath + "PN_spBase", _spPos._x, _spPos._y, _opi);
    this.MovePict(PN_spBack, true, true, 10);
    this.MovePict(PN_spBase, true, true, 10);
    for (let i = 0; i <= ShopItemArr.length - 1; i++) {
        if (i == 8) break; 
        let _posX = _spIPos._x + 164 * (i % 2);
        let _posY = _spIPos._y + 161 * Math.floor(i / 2);
        this.SetPictC(PN_spIcon + i, ShopUIPath + "PN_spIcon", _posX, _posY, _opi);
        let _ckItem = $dataItems[ShopItemArr[i]._id];
        let _owSet = "\\ow[0]"
        if (ViewShopData.weaponShopFlg) {
            _ckItem = $dataWeapons[ShopItemArr[i]._id];
        }
        this.SetPicStrC(PN_spTxtA + i, _owSet + _ckItem.name, 18, _posX, _posY - 54, _opi);
        this.SetPicStrC(PN_spMIcon + i, "\\I[" + _ckItem.iconIndex + "] ", 25, _posX + 6, _posY + 3, _opi);
        this.MovePict(PN_spMIcon + i, true, true, 0, 255, 150, 150);
        if (ShopItemArr[i]._off > 0) {
            DText_NRZureX = 2;
            this.SetPicStrC(PN_spOffTxt + i, SCol.Yel + SWCol.Blk + ShopItemArr[i]._off + "%OFF！",
                18, _posX + 10, _posY - 54 + 20, _opi);
            DText_NRZureX = 0;
        }
        var viewPrice = Math.round(_ckItem.price * ((100 - ShopItemArr[i]._off) / 100));
        this.SetPicStr(PN_spTxtB + i, _owSet + viewPrice, 18, _posX - 8, _posY + 35, _opi);
        if (shopSelNo == i) {
            this.SetPictC(PN_spHikari, ShopUIPath + "PN_spHikari", _posX, _posY, _opi);
            this.MovePict(PN_spHikari, true, true, 10, 255, true, true);
        }
        this.MovePict(PN_spIcon + i, true, true, 10);
        this.MovePict(PN_spTxtA + i, true, true, 10);
        this.MovePict(PN_spTxtB + i, true, true, 10);
        this.MovePict(PN_spMIcon + i, true, true, 1, 255, 150, 150);
        this.MovePict(PN_spOffTxt + i, true, true, 10);
    }
    this.SetPict(PN_spClose, ShopUIPath + "PN_spClose", 762, 67, _opi);
    this.MovePict(PN_spClose, true, true, 10);
    this.PS_Shop_DtView(_ItemNo, _SetFlg);
    this.PS_Shop_GoldView();
    this.PS_Shop_売切描画(); 
}
let _spPos = new Pos2D(372, 27); 
let _spIPos = new Pos2D(_spPos._x + 119, _spPos._y + 164); 
let _spSPos = new Pos2D(759, 235); 
let _spWait = 0; 
Game_Interpreter.prototype.PS_Shop = function () {
    if (_spWait > 0) {
        _spWait--;
        return true;
    }
    if (shop_flame == 0) {
        this.BLogDell(); 
        if (shopL2DMdl != "") {
            L2dFadeMdl(shopL2DMdl, "lleft", 10, "", null, null, -100);
            L2dIdleStart(shopL2DMdl, "wait"); 
        }
        this.PS_Shop_View(0, true);
        this.PS_Shop_SelfSet("st");
    }
    let shopSaveData = GetViewShopData();
    _spSelfFlame--;
    if (_spSelfFlame <= 0) {
        this.PS_Shop_SelfSet("rnd"); 
    }
    if (shop_flame > 30) { 
        this.PicCngColorArr(_spPicArr); 
        let _ckNo = overPointerCkArr(_spPicArr);
        if (_ckNo != -1) { 
            switch (_ckNo) {
                case PN_spClose: 
                    this.PicCngColor(_ckNo, [100, 100, 100, 0]);
                    if (TouchInput.isTriggered()) {
                        this.PS_Shop_Close();
                        return false; 
                    }
                case PN_spItmBuyBtn: 
                case PN_spItmBuyBtn_5: 
                    this.PicCngColor(_ckNo, [150, 150, 150, 0]);
                    if (TouchInput.isTriggered()) {
                        var zaikoCount = -1;
                        if (ShopItemArr[shopSelNo]._zaikoVN > 0) {
                            zaikoCount = $gameVariables.value(ShopItemArr[shopSelNo]._zaikoVN);
                        }
                        if (shopSaveData != null && ShopItemArr[shopSelNo]._zaikoVN <= 0) {
                            if (shopSaveData.ZaikoCounter[shopSelNo] != -1) {
                                zaikoCount = shopSaveData.ZaikoCounter[shopSelNo];
                            }
                        }
                        if (zaikoCount == 0) {
                            return true;
                        }
                        var nowCnt = $gameParty.numItems($dataItems[ShopItemArr[shopSelNo]._id]);
                        if (ViewShopData.weaponShopFlg) {
                            nowCnt = $gameParty.numItems($dataWeapons[ShopItemArr[shopSelNo]._id]);
                        }
                        if (nowCnt + 1 > 99) return true;
                        if (_ckNo == PN_spItmBuyBtn_5 && nowCnt + 5 > 99) return true;
                        let zaikoCheck = zaikoCount <= 0 || zaikoCount > 0;
                        if (zaikoCheck) { 
                            let itemData = $dataItems[ShopItemArr[shopSelNo]._id];
                            if (ViewShopData.weaponShopFlg) {
                                itemData = $dataWeapons[ShopItemArr[shopSelNo]._id];
                            }
                            var viewPrice = Math.round(itemData.price * ((100 - ShopItemArr[shopSelNo]._off) / 100));
                            if (viewPrice <= $gameParty._gold) {
                                SoundManager.playShop();
                                this.PlayPtcScTop("S_Click", 1253, 505);
                                if (zaikoCount != -1) {
                                    zaikoCount--;
                                    if (_ckNo == PN_spItmBuyBtn_5) zaikoCount -= 4;
                                }
                                if (ShopItemArr[shopSelNo]._zaikoVN != -1) {
                                    $gameVariables.setValue(ShopItemArr[shopSelNo]._zaikoVN, zaikoCount);
                                }
                                if (shopSaveData != null) {
                                    if (shopSaveData.ZaikoCounter[shopSelNo] != -1) {
                                        shopSaveData.ZaikoCounter[shopSelNo] = zaikoCount;
                                    }
                                }
                                $gameParty.gainGold(viewPrice * -1);
                                if (_ckNo == PN_spItmBuyBtn_5) {
                                    for (let i = 0; i <= 4 - 1; i++) {
                                        StacWaitPict(PN_spItmBuyBtn_5 , 3);
                                        StacPlaySePict(PN_spItmBuyBtn_5 ,"Shop1");
                                    }
                                }
                                if (ViewShopData.weaponShopFlg) {
                                    $gameParty.gainItem($dataWeapons[ShopItemArr[shopSelNo]._id], 1); 
                                    if (_ckNo == PN_spItmBuyBtn_5) {
                                        $gameParty.gainGold(viewPrice * -4);
                                        $gameParty.gainItem($dataWeapons[ShopItemArr[shopSelNo]._id], 4); 
                                    }
                                } else {
                                    $gameParty.gainItem($dataItems[ShopItemArr[shopSelNo]._id], 1); 
                                    if (_ckNo == PN_spItmBuyBtn_5) {
                                        $gameParty.gainGold(viewPrice * -4);
                                        $gameParty.gainItem($dataItems[ShopItemArr[shopSelNo]._id], 4); 
                                    }
                                }
                                this.PS_Shop_所持数View(shopSelNo, true); 
                                this.PS_Shop_SelfSet("buy"); 
                                this.PS_Shop_売切描画(); 
                                _spWait = 3;
                            } else {
                                this.PS_Shop_SelfSet("loss"); 
                            }
                            if (zaikoCount < 5 && zaikoCount != -1)
                                this.DelPictSpan(PN_spItmBuyBtn_5 , PN_spItmBuyBtn_5 + 1);
                            if (zaikoCount == 0) {
                                this.SetPict(PN_spSoldOutBtn, ShopUIPath + "PN_spSoldOutBtn",
                                    _spSPos._x + 353, _spSPos._y + 198, 0);
                                this.MovePict(PN_spSoldOutBtn, true, true, 10, 255);
                            }
                            if (zaikoCount == -1 || zaikoCount > 0) {
                                this.DelPict(PN_spSoldOutBtn);
                            }
                            if (viewPrice * 5 > $gameParty._gold)
                                this.DelPictSpan(PN_spItmBuyBtn_5 , PN_spItmKStr_5);
                        } else {
                            this.PS_Shop_SelfSet("sold"); 
                        }
                        this.PS_Shop_GoldView(); 
                        this.PS_Shop_DtView(shopSelNo)
                    }
                    break;
                default: 
                    this.PicCngColor(_ckNo, [100, 100, 100, 0]);
                    if (TouchInput.isTriggered()) {
                        shopSelNo = _ckNo - PN_spIcon;
                        let _posX = _spIPos._x + 164 * (shopSelNo % 2);
                        let _posY = _spIPos._y + 161 * Math.floor(shopSelNo / 2);
                        this.SetPictC(PN_spHikari, ShopUIPath + "PN_spHikari", _posX, _posY, 0);
                        this.MovePict(PN_spHikari, _posX, _posY, 3);
                        this.PS_Shop_View(shopSelNo, false);
                    }
                    break;
            }
        }
        if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
            this.PS_Shop_Close();
            return false; 
        }
    }
    shop_flame++;
    return true; 
}
Game_Interpreter.prototype.PS_Shop_Close = function (_ItemNo) {
    L2D_SetZure(shopL2DMdl);
    for (let i = PN_spBack; i <= PN_spEnd; i++) {
        this.DelPict(i);
    }
    if (ViewShopData.weaponShopFlg) {
        this.DelSpriteArr(de_CSsyosaiPArr);
    }
}
Game_Interpreter.prototype.PS_Shop_売切描画 = function () {
    let shopSaveData = GetViewShopData();
    for (let i = 0; i <= ShopItemArr.length - 1; i++) {
        var zaikoCount = -1;
        if (ShopItemArr[i]._zaikoVN > 0) {
            zaikoCount = $gameVariables.value(ShopItemArr[i]._zaikoVN);
        }
        if (shopSaveData != null) {
            if (ShopItemArr[i]._zaikoVN <= 0) {
                if (shopSaveData.ZaikoCounter[i] != -1) {
                    zaikoCount = shopSaveData.ZaikoCounter[i];
                }
            }
        }
        if (zaikoCount == -1 || zaikoCount > 0) continue; 
        let _posX = _spIPos._x + 164 * (i % 2);
        let _posY = _spIPos._y + 161 * Math.floor(i / 2);
        this.SetPictC(PN_spSoldout + i, ShopUIPath + "PN_spSoldout", _posX, _posY, 255);
    }
}
Game_Interpreter.prototype.PS_Shop_GoldView = function () {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    let _owSet = "\\ow[0]"
    this.SetPict(PN_spMnyWin, ShopUIPath + "PN_spMnyWin", 1197, 14, _opi);
    this.MovePict(PN_spMnyWin, true, true, 10, 255);
    this.SetPicStr(PN_spMnyWin + 1, _owSet + $gameParty._gold, 28, 1286, 36, _opi);
    this.MovePict(PN_spMnyWin + 1, true, true, 10, 255);
}
Game_Interpreter.prototype.PS_Shop_DtView = function (_ItemNo, _SetFlg) {
    shopSelNo = _ItemNo;
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    let _owSet = "\\ow[0]"
    let _ckItem = $dataItems[ShopItemArr[shopSelNo]._id];
    if (ViewShopData.weaponShopFlg) {
        _ckItem = $dataWeapons[ShopItemArr[shopSelNo]._id];
    }
    let _adyStr = "";
    if (BtlItemCheck(ShopItemArr[shopSelNo]._id)) {
        _adyStr = "　（戦闘用）";
    }
    let setViewText = _owSet + _ckItem.name + _adyStr;
    this.SetPict(PN_spItmWin, ShopUIPath + "PN_spItemWin", _spSPos._x, _spSPos._y, _opi);
    this.MovePict(PN_spItmWin, true, true, 10);
    let _SetuAr = _ckItem.description.split("\n");
    this.DelPict(PN_spItmStr + 0);
    this.DelPict(PN_spItmStr + 1);
    this.DelPictSpan(PN_spItmBuyBtn_5 , PN_spItmKStr_5);
    for (let i = 0; i <= _SetuAr.length - 1; i++) {
        this.SetPicStr(PN_spItmStr + i, _owSet + _SetuAr[i], 18,
            _spSPos._x + 202, _spSPos._y + 164 + (31 * i), _opi);
        this.MovePict(PN_spItmStr + i, true, true, 10);
    }
    this.SetPicStrC(PN_spItmIco, "\\I[" + _ckItem.iconIndex + "] ", 25,
        _spSPos._x + 123, _spSPos._y + 180, _opi);
    this.MovePict(PN_spItmIco, true, true, 10, 255, 150, 150);
    let shopSaveData = GetViewShopData();
    var viewPrice = Math.round(_ckItem.price * ((100 - ShopItemArr[shopSelNo]._off) / 100));
    this.SetPicStr(PN_spItmKStr, _owSet + viewPrice, 22, _spSPos._x + 513, _spSPos._y + 254, _opi);
    let fiveBuyBtnViewFlg = false;
    if (viewPrice <= $gameParty._gold) {
        this.SetPict(PN_spItmBuyBtn, ShopUIPath + "PN_spItmBuyBtn" ,
            _spSPos._x + 353, _spSPos._y + 198, _opi);
        this.MovePict(PN_spItmBuyBtn, true, true, 10, 255);
        this.MovePict(PN_spItmKStr, true, true, 10, 255);
        var zaikoCount = -1;
        if (shopSaveData.ZaikoCounter[shopSelNo] >= -1) zaikoCount = shopSaveData.ZaikoCounter[shopSelNo];
        if (ShopItemArr[shopSelNo]._zaikoVN > 0) zaikoCount = $gameVariables.value(ShopItemArr[shopSelNo]._zaikoVN);
        if (zaikoCount >= 0) setViewText += "　残り：" + zaikoCount;
        if ((zaikoCount == -1 || zaikoCount >= 5) && viewPrice * 5 <= $gameParty._gold && _ckItem.name.indexOf("キューブ") != -1) {
            let mvY = 75;
            this.SetPict(PN_spItmBuyBtn_5, ShopUIPath + "PN_spItmBuyBtn_5",_spSPos._x + 353, _spSPos._y + 198 + mvY, _opi);
            this.SetPicStr(PN_spItmKStr_5, _owSet + viewPrice * 5, 22,_spSPos._x + 513, _spSPos._y + 254 + mvY, _opi);
            this.MovePict(PN_spItmBuyBtn_5, true, true, 10, 255);
            this.MovePict(PN_spItmKStr_5, true, true, 10, 255);
            fiveBuyBtnViewFlg = true;
        }
    } else {
        this.SetPict(PN_spItmBuyBtn, ShopUIPath + "PN_spItmBuyBtn_False",
            _spSPos._x + 353, _spSPos._y + 198, _opi);
        this.MovePict(PN_spItmBuyBtn, true, true, 10, 155);
        this.MovePict(PN_spItmKStr, true, true, 10, 155);
    }
    var nowCnt = $gameParty.numItems($dataItems[ShopItemArr[shopSelNo]._id]);
    if (nowCnt + 1 > 99) {
        this.MovePict(PN_spItmBuyBtn, true, true, 10, 155);
    }
    if (fiveBuyBtnViewFlg && nowCnt + 5 > 99) {
        this.MovePict(PN_spItmKStr_5, true, true, 10, 155);
        this.MovePict(PN_spItmBuyBtn_5, true, true, 10, 155);
    }
    this.SetPicStr(PN_spItmName, setViewText, 20, _spSPos._x + 202, _spSPos._y + 125, _opi);
    this.MovePict(PN_spItmName, true, true, 10);
    this.DelPict(PN_spSoldOutBtn);
    zaikoCount = -1;
    if (ShopItemArr[shopSelNo]._zaikoVN > 0) {
        zaikoCount = $gameVariables.value(ShopItemArr[shopSelNo]._zaikoVN);
    } else {
        zaikoCount = shopSaveData.ZaikoCounter[shopSelNo];
    }
    if (zaikoCount <= 0 && zaikoCount != -1) {
        this.SetPict(PN_spSoldOutBtn, ShopUIPath + "PN_spSoldOutBtn",
            _spSPos._x + 353, _spSPos._y + 198, _opi);
        this.MovePict(PN_spSoldOutBtn, true, true, 10, 255);
    } else {
        this.DelPict(PN_spSoldOutBtn);
    }
    this.PS_Shop_所持数View(_ItemNo, _SetFlg);
    if (ViewShopData.weaponShopFlg) {
        this.CardPicDraw(ShopItemArr[shopSelNo]._id, PN_spCard, PN_Cmp,
            _spSPos._x + 66, _spSPos._y + 111, 255, 40, 40);
        this.de_CSyosai(ShopItemArr[shopSelNo]._id , 768 , 425);
    }
}
Game_Interpreter.prototype.PS_Shop_所持数View = function (_ItemNo, _SetFlg) {
    shopSelNo = _ItemNo;
    let _opi = 255;
    if (_SetFlg) _opi = 0;
    let _owSet = "\\ow[0]"
    let _vStr = _owSet + "所持数：" + $gameParty.numItems($dataItems[ShopItemArr[shopSelNo]._id]);
    if (ViewShopData.weaponShopFlg) {
        _vStr = _owSet + "所持数：" + $gameParty.numItems($dataWeapons[ShopItemArr[shopSelNo]._id]);
    }
    this.SetPicStr(PN_spSyojiStr, _vStr, 26, _spSPos._x + 62, _spSPos._y + 254, _opi);
    this.MovePict(PN_spSyojiStr, true, true, 10, 255);
}
let _spSelfFlame = 0; 
let _spSlfRNo = 0; 
let _spSlfPos = new Pos2D(22, 31);
Game_Interpreter.prototype.PS_Shop_SelfSet = function (_id) {
    let _viewSelf = null; 
    let _setMotion = "";
    let _ckRndArr = []; 
    let _ckNo = -1;
    this.SetPict(PN_exFuki + 0, ShopUIPath + "PN_spFuki",
        _spSlfPos._x, _spSlfPos._y, 0);
    for (let i = 0; i <= SelfArr.length - 1; i++) {
        if (SelfArr[i]._id == _id) {
            if (_id == "rnd") {
                _ckRndArr.push(SelfArr[i]);
            } else {
                _viewSelf = SelfArr[i];
                break;
            }
        }
    }
    if (_id == "rnd") { 
        _spSlfRNo++;
        if (_ckRndArr.length == _spSlfRNo) _spSlfRNo = 0;
        if (_ckRndArr.length > 0) _viewSelf = _ckRndArr[_spSlfRNo];
    }
    if (_viewSelf != null) {
        let _owSet = SCol.Blk0;
        this.SetPicStr(PN_exFuki + 1, _owSet + _viewSelf._str1, 18,
            _spSlfPos._x + 20, _spSlfPos._y + 13, 0);
        this.SetPicStr(PN_exFuki + 2, _owSet + _viewSelf._str2, 18,
            _spSlfPos._x + 20, _spSlfPos._y + 38, 0);
        _setMotion = _viewSelf._motion;
        if (shopL2DMdl != "" && _setMotion != "") {
            L2dSetMotion(shopL2DMdl, _setMotion);
        }
    }
    this.MovePict(PN_exFuki + 0, true, true, 10, 255, true, true);
    this.MovePict(PN_exFuki + 1, true, true, 10, 255, true, true);
    this.MovePict(PN_exFuki + 2, true, true, 10, 255, true, true);
    _spSelfFlame = 420;
};
