let _Adv_保存変数 = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    _Adv_保存変数.call(this);
    this.L0Mode = _L0Mode.Base; 
    this.L0BaseBtnArr = ["Btn_Town", "Btn_Rest", "Btn_Kunren", "Btn_Work"];
    this.L0TownBtnArr = ["Btn_Kyoten", "Btn_Skill", "Btn_GunShop", "Btn_Item"];
    this.L0TownSelecter = []; 
    this.L1WorkArr = ["Work1", "Work2", "Work3", "Work4", "Work5", "Work6"]; 
    this.L1KunrenArr = ["Kunren1", "Kunren2", "Kunren3"]; 
};
let Adv_Mode = -1; 
let _Adv_Mode = {
    Base: 1,
    仕事: 2,
    訓練: 3,
    街:4
};
let Adv_Layer = 0; 
let Adv_Stop = true; 
let Adv_Stop_flame = 0; 
const VN_訓練割引 = 24;
const VN_武器割引 = 38;
const VN_ショップ割引 = 39;
const VN_スキル割引 = 40;
const VN_治安値 = 19;
const CN_拠点移動時 = 4;
const CN_日付変更 = 10;
const AdvPic = "pictures/Adv/";
const PN_tBack = 2;     
const PN_tBack_Tp = PN_tBack + 4; 
const PN_tBackT = PN_tBack_Tp + 4;    
const PN_tGBase = PN_tBackT + 1;    
const PN_tGage = PN_tGBase + 1;     
const PN_tKTxt = PN_tGage + 2;      
const PN_tGage_s = PN_tKTxt + 2;    
const PN_DayWin = PN_tGage_s + 2;   
const PN_DayTxt = PN_DayWin + 1;
const PN_tGold = PN_DayTxt + 2; 
const PN_AStTxt = PN_tGold + 1; 
const PN_Tian = PN_AStTxt + 6;  
const PN_tSelBtn = 31;   
const PN_Layer1 = 38;
const PN_l1Back = PN_Layer1 + 1;
const PN_SelBack = 42;
const PN_tSelBtnCk = PN_l1Back + 4;  
const PN_tSelIcn = 155; 
const PN_tParWin = PN_tSelBtnCk + 9; 
const PN_tParTxt = PN_tParWin + 9;   
const PN_tJhWin = PN_tParTxt + 9;    
const PN_tJhTxt = PN_tJhWin + 1;     
const PN_tPopTxt = PN_tJhTxt + 10;   
const PN_tSexharaBtn = PN_tPopTxt + 1;   
const PN_WSelectH = PN_Layer1 + 4;
const PN_Wanted = PN_WSelectH + 1;
const PN_WBrake = PN_Wanted + 3;
const PN_KunrenFree = 132;
const PN_KunrenFreeTxt = PN_KunrenFree + 1;
const PN_Layer2 = 88;
const PN_tCkBack = PN_Layer2 + 1;   
const PN_tCkWin = PN_tCkBack + 1;   
const PN_tCkTxt = PN_tCkWin + 1;    
const PN_tWorkBase = PN_tCkTxt + 2;     
const PN_tWorkWin  = PN_tWorkBase + 1;  
const PN_tWorkKek = PN_tWorkWin + 1;    
const PN_twResultBack = PN_tWorkKek + 2; 
const PN_twResGage = PN_twResultBack + 1; 
const PN_twResTxt = PN_twResGage + 6;   
const PN_twResTxt_v = PN_twResTxt + 6;  
const PN_twResTxt_up = PN_twResTxt_v + 6; 
const PN_Layer3 = 124;
const PN_LayerTalk = 137;
const PN_AdvSell = 135; 
const PN_tTatieB = 146; 
const PN_tTatie = PN_tTatieB + 5 
const PN_DyBack = PN_Ensyutu + 10;
const PN_DyTxt = PN_DyBack + 1;
const PN_DyMark = PN_DyTxt + 9;
const PN_EventBar = 490;
const PN_EventTxt = PN_EventBar + 1;
const MN_ADV = 6; 
class _PicSave {
    constructor(_PicNo, _Opi) {
        this._PicNo = _PicNo;   
        this._Opi = _Opi;   
    }
}
let _ADV_PicSaveArr = [];
Game_Interpreter.prototype.ADV_PicOpi_0 = function (_time) {
    _time = typeof _time !== 'undefined' ? _time : 10;
    _ADV_PicSaveArr = [];
    if($gameSwitches.value(SW_奴隷)){
        for (let i = PN_dBtn; i <= PN_mAdvSell; i++) {
            if($gameScreen.PicObjGet(i) != undefined){
                if($gameScreen.PicObjGet(i)._opacity == 0) continue;
                _ADV_PicSaveArr.push(new _PicSave(i, $gameScreen.PicObjGet(i)._opacity));
                this.MovePict( i , true , true , _time , 0 , true , true);
            }
        }
    } else {
        for (let i = PN_tSelBtn; i <= PN_LayerTalk - 1; i++) {
            if($gameScreen.PicObjGet(i) != undefined){
                if($gameScreen.PicObjGet(i)._opacity == 0) continue;
                _ADV_PicSaveArr.push(new _PicSave(i, $gameScreen.PicObjGet(i)._opacity));
                this.MovePict( i , true , true , _time , 0 , true , true);
            }
        }
    }
}
Game_Interpreter.prototype.ADV_PicOpi_Load = function (_time) {
    _time = typeof _time !== 'undefined' ? _time : 10;
    for (let i = 0; i <= _ADV_PicSaveArr.length - 1; i++) {
        let _PicNo = _ADV_PicSaveArr[i]._PicNo;
        let _Opi = _ADV_PicSaveArr[i]._Opi;
        this.MovePict(_PicNo, true, true, _time, _Opi, true, true);
    }
    _ADV_PicSaveArr = [];
}
Game_Interpreter.prototype.ADV_PicOpi_Dell = function () {
    this.DelPictSpan(PN_tSelBtn , PN_LayerTalk - 1);
    _ADV_PicSaveArr = [];
}
let Adv_NUpdate = Game_Interpreter.prototype.NUpdate;
Game_Interpreter.prototype.NUpdate = function () {
    Adv_NUpdate.call(this);
    if(!$gameSwitches.value(SW_奴隷)){
        this.Adv_情報_Update(); 
        if (!Adv_Stop){
            this.Adv_Update();
        }
    } else {
        this.Adv_Dorei_UIUpdate();
        if(!Adv_Stop){
            this.Adv_Dorei_Update();
            Adv_Stop_flame = 0;
        } else {
            Adv_Stop_flame++;
        }
    }
    this.UIAutoUpdate();
}
let nadv_flame = 0;
let _Adv_WaitFlame = 0; 
Game_Interpreter.prototype.Adv_Update = function () {
    if (Adv_Stop) return; 
    if(_Adv_WaitFlame > 0) {
        _Adv_WaitFlame--;
        return;
    }
    if (Rn_LineDrawFlg) return; 
    switch (Adv_Layer) {
        case 0: this.Adv_L0_Update(); break;
        case 1: this.Adv_L1_Update(); break;
        case 2: this.Adv_L2_Update(); break;
    }
    nadv_flame++;
}
let befGold = 0;
Game_Interpreter.prototype.UIAutoUpdate = function () {
    var ckSprite = PicObjGet(PN_tGold);
    if ($gameParty._gold != befGold && ckSprite != null) {
        befGold = $gameParty._gold;
        D_Text_Cng_font = "Makinas"; 
        this.Adv_GoldDraw();
        D_Text_Cng_font = ""; 
    }
}
let L0_NotDrawFlg = false; 
let _L0Mode = { 
    Event:0, 
    Base: 1, 
    Town: 2  
};
let L0_flame = 0;
Game_Interpreter.prototype.Adv_L0_Cng = function (_Mode) {
    _Mode = typeof _Mode !== 'undefined' ? _Mode : $gameSystem.L0Mode;
    if($gameMap._mapId != MN_ADV){
        $gamePlayer.reserveTransfer(MN_ADV, 1, 1, 0, 2);
    }
    $gameSystem.L0Mode = _Mode;
    Adv_Layer = 0; L0_flame = 0;
    switch ($gameSystem.L0Mode) {
        case _L0Mode.Event:
            this.Adv_L0Event_View();
            break;
        case _L0Mode.Base:
            this.Adv_L0Base_View();
            break;
        case _L0Mode.Town:
            this.Adv_L0Town_View();
            break;
    }
    this.Adv_情報_Draw(true);
    for (let i = PN_tSelBtn; i <= PN_LayerTalk - 1; i++) {
        this.MovePict(i, true, true, 10, 0, true, true);
    }
}
let L0_Selecter = 0; 
Game_Interpreter.prototype.Adv_L0_Update = function () {
    if(battleflg) return;
    switch ($gameSystem.L0Mode) {
        case _L0Mode.Base:
            this.Adv_L0Base_Update();
            break;
        case _L0Mode.Town:
            this.Adv_L0Town_Update();
            break;
    }
    if ((Input.isTriggered('escape') || TouchInput.isCancelled()) && L0_flame > 30) { 
        this.Menu_Open(); 
    }
    L0_flame++;
}
Game_Interpreter.prototype.Adv_L0_SelReset = function () {
    this.MovePict(PN_AdvSell, L0BtnPos._x - 15, L0BtnPos._y - (_AdvSellSa * L0_Selecter) + 35, 5); 
}
let _変数範囲内変更 = function (_VarID , _Min , _Max) {
    let _ckVar = $gameVariables.value(_VarID);
    if(_ckVar < _Min) _ckVar = _Min;
    if(_ckVar > _Max) _ckVar = _Max;
    $gameVariables.setValue(_VarID ,_ckVar);
}
let _Bef健康 = 0; 
let _Befやる気 = 0;
let _健康DrawFlg = false; 
Game_Interpreter.prototype.Adv_情報_Draw = function (_SetFlg) {
    _SetFlg = typeof _SetFlg !== 'undefined' ? _SetFlg : false;
    _健康DrawFlg = true;
    _変数範囲内変更(VN_PLKenko , 0 , 100);
    _変数範囲内変更(VN_PLYruki , 0 , 100);
    let _opi = 255;
    if (_SetFlg){
        _opi = 0;
        _Bef健康 = $gameVariables.value(VN_PLKenko);
        _Befやる気 = $gameVariables.value(VN_PLYruki);
    } 
    this.SetPict(PN_tGBase, AdvPic + "PN_tGBase", 0, 0, _opi);
    this.MovePict(PN_tGBase, true, true, 10); 
    this.SetPict(PN_tBackT, AdvPic + "PN_tBackT", 0, 0, _opi);
    this.MovePict(PN_tBackT, true, true, 10); 
    let _健康 = $gameVariables.value(VN_PLKenko);
    this.SetPict(PN_tGage, AdvPic + "PN_tGage", 126, 21, _opi, _健康);
    this.MovePict(PN_tGage, true, true, 10, 255, true);
    this.PicCngColor(PN_tGage, [0,255,0]);
    // if (_健康 <= 50) this.PicCngColor(PN_tGage, [255, 255, 0]);
    // if (_健康 <= 25) this.PicCngColor(PN_tGage, [255, 0, 0]);
    let _やる気 = $gameVariables.value(VN_PLYruki);
    this.SetPict(PN_tGage_s, AdvPic + "PN_tGage_s", 127, 21 + 37, _opi, _やる気);
    this.MovePict(PN_tGage_s, true, true, 10, 255, true);
    this.PicCngColor(PN_tGage_s, [234, 150, 215]);
    D_Text_Cng_font = "Makinas"; 
    this.SetPictFIn(PN_DayWin, AdvPic + "PN_DayWin", 0, 0, 0, 0, 10);
    let _現在日 = $gameVariables.value(VN_日付);
    let _試合日 = $gameVariables.value(VN_試合日);
    let _残り日数 = _試合日 - _現在日;
    this.SetPicStrC(PN_DayTxt + 0, $gameVariables.value(VN_日付), 80, 1364, 83, 0);
    this.SetPicStrC(PN_DayTxt + 1, _残り日数, 24, 1384, 160, 0); 
    this.MovePict(PN_DayTxt + 0, true, true, 10);
    this.MovePict(PN_DayTxt + 1, true, true, 10);
    D_Text_Cng_font = "";
    this.Adv_情報_ステートDraw(_opi);
    this.Adv_情報_MojiDraw();
    let _TianVar = $gameVariables.value(VN_治安値);
    let _TianPic = "PN_Tian_1";
    if(_TianVar <= 80) _TianPic = "PN_Tian_2";
    if(_TianVar <= 60) _TianPic = "PN_Tian_3";
    if(_TianVar <= 40) _TianPic = "PN_Tian_4";
    if(_TianVar <= 20) _TianPic = "PN_Tian_5";
    this.SetPictFIn(PN_Tian, AdvPic + _TianPic, 0, 0, 0, 0, 10);
}
Game_Interpreter.prototype.Adv_情報_ステートDraw = function (_opi) {
    _opi = typeof _opi !== 'undefined' ? _opi : 255;
    if ($gameSwitches.value(SW_奴隷)) return; 
    let _AStTxtPs = new Pos2D(801 , 23);
    D_Text_Cng_font = "Makinas"; 
    let _StArr = PL_StateGet();
    for (let i = 0; i <= _StArr.length - 1; i++) { 
        let _PsX = _AStTxtPs._x + (97 * (i % 3));
        let _PsY = _AStTxtPs._y + (25 * Math.floor(i / 3));
        this.SetPicStr(PN_AStTxt + i , _StArr[i] , 18 , _PsX , _PsY , _opi);
        this.MovePict(PN_AStTxt + i , true , true , 10 , 255);
    }
    D_Text_Cng_font = ""; 
}
Game_Interpreter.prototype.Adv_情報_MojiDraw = function (_健康Txt , _やる気Txt) {
    _健康Txt = typeof _健康Txt !== 'undefined' ? _健康Txt : -1;
    _やる気Txt = typeof _やる気Txt !== 'undefined' ? _やる気Txt : -1;
    D_Text_Cng_font = "Makinas"; 
    let _zrX = 100;
    let _tX = 380; let _ty = 14;
    let _健康 = $gameVariables.value(VN_PLKenko);
    if(_健康Txt != -1){
        _健康 = _健康Txt;
    }
    this.SetPicStrR(PN_tKTxt + 0, " " + String(_健康) + " / 100 ", 22, _tX + _zrX, _ty, 0);
    this.MovePict(PN_tKTxt + 0, true, true, 10);
    let _やる気 = $gameVariables.value(VN_PLYruki);
    if(_やる気Txt != -1){
        _やる気 = _やる気Txt;
    }
    this.SetPicStrR(PN_tKTxt + 1, " " + String(_やる気) + " / 100 ", 22, _tX + _zrX, _ty + 32, 0);
    this.MovePict(PN_tKTxt + 1, true, true, 10);
    this.Adv_GoldDraw();
    D_Text_Cng_font = "";
}
Game_Interpreter.prototype.Adv_GoldDraw = function () {
    let _Gold = $gameParty._gold;
    this.SetPicStrR(PN_tGold, _Gold + "B", 30, 658, 26, 0);
    this.MovePict(PN_tGold, true, true, 10);
}
Game_Interpreter.prototype.Adv_情報_GageDraw = function (_健康変化値 , _やる気変化値) {
    _健康変化値 = typeof _健康変化値 !== 'undefined' ? _健康変化値 : 0;
    _やる気変化値 = typeof _やる気変化値 !== 'undefined' ? _やる気変化値 : 0;
    let _BarXSize = 221;
    let _ggXPos = _BarXSize - (_BarXSize * ((100 - $gameVariables.value(VN_PLKenko)) / 100)) + 1;
    let _SetSizeX = _健康変化値;
    if($gameVariables.value(VN_PLKenko) + _SetSizeX < 0) _SetSizeX = -$gameVariables.value(VN_PLKenko);
    if($gameVariables.value(VN_PLKenko) + _SetSizeX > 100) _SetSizeX = 100 - $gameVariables.value(VN_PLKenko);
    this.SetPict(PN_tGage + 1, AdvPic + "PN_tGage", 127 + _ggXPos, 21, 255, _SetSizeX);
    if(_健康変化値 < 0){
         this.PicCngColor(PN_tGage + 1, [255,0,0]);
    } else {
        this.PicCngColor(PN_tGage + 1, [255,255,0]); 
    }
    _ggXPos = _BarXSize - (_BarXSize * ((100 - $gameVariables.value(VN_PLYruki)) / 100)) + 1;
    _SetSizeX = _やる気変化値;
    if($gameVariables.value(VN_PLYruki) + _SetSizeX < 0) _SetSizeX = -$gameVariables.value(VN_PLYruki);
    if($gameVariables.value(VN_PLYruki) + _SetSizeX > 100) _SetSizeX = 100 - $gameVariables.value(VN_PLYruki);
    this.SetPict(PN_tGage_s + 1, AdvPic + "PN_tGage_s", 127 + _ggXPos, 21 + 37, 255, _SetSizeX);
    if(_やる気変化値 < 0){
         this.PicCngColor(PN_tGage_s + 1, [255,0,0]);
    } else {
         this.PicCngColor(PN_tGage_s + 1, [255,255,0]); 
    }
}
Game_Interpreter.prototype.Adv_情報_Update = function (_SetFlg) {
    if (!_健康DrawFlg) return;
    let _zrX = 100;
    let _tX = 380; let _ty = 14;
    if (_Bef健康 != $gameVariables.value(VN_PLKenko)) {
        D_Text_Cng_font = "Makinas"; 
        this.MovePict(PN_tGage, true, true, 60, 255, $gameVariables.value(VN_PLKenko));
        _Bef健康 = $gameVariables.value(VN_PLKenko);
        this.SetPicStrR(PN_tKTxt + 0, " " + String(_Bef健康) + " / 100 ", 22, _tX + _zrX, _ty, 0);
        this.MovePict(PN_tKTxt + 0, true, true, 10);
        D_Text_Cng_font = ""; 
    }
    if (_Befやる気 != $gameVariables.value(VN_PLYruki)) {
        D_Text_Cng_font = "Makinas"; 
        this.MovePict(PN_tGage_s, true, true, 60, 255, $gameVariables.value(VN_PLYruki));
        _Befやる気 = $gameVariables.value(VN_PLYruki);
        this.SetPicStrR(PN_tKTxt + 1, " " + String(_Befやる気) + " / 100 ", 22, _tX + _zrX, _ty + 32, 0);
        this.MovePict(PN_tKTxt + 1, true, true, 10);
        D_Text_Cng_font = ""; 
    }
}
Game_Interpreter.prototype.Adv_健康_Dell = function () {
    _健康DrawFlg = false;
    this.DelPictSpan(PN_tGBase, PN_Tian); 
}
Game_Interpreter.prototype.Adv_Reset = function () {
    Adv_Layer = 0; 
    this.DelPictSpan(PN_tSelBtnCk + 0, PN_tSelBtnCk + 5); 
    this.Adv_L0_BtnColCng(); 
    this.Adv_L0_SelReset(); 
    this.Adv_PicDel(); 
    this.DelPictSpan(PN_tSelBtn + 0, PN_tSelBtn + 5);
}
Game_Interpreter.prototype.Adv_L0_Back = function () {
    L0_NotDrawFlg = true;
    Adv_Layer = L0_flame = 0;
    L0_flame = 0;
    this.Adv_L1_PicDel(); 
    this.Adv_L2_PicDel(); 
    this.Adv_L0_BtnColCng(); 
    this.Adv_L0_SelReset(); 
}
let L0BtnPos = new Pos2D(60, 630);
let L0_TcPic = []; 
const L0背景Path = "parallaxes/";
let L0EventBackImg = "Back_Base";
Game_Interpreter.prototype.Adv_L0Event_View = function () {
}
Game_Interpreter.prototype.EventBackSet = function (_PicName) {
    _PicName = typeof _PicName !== 'undefined' ? _PicName : "";
    if (_PicName != "") {
        L0EventBackImg = _PicName;
    }
    this.SetPict(PN_tBack, L0背景Path + L0EventBackImg, 0, 0);
}
Game_Interpreter.prototype.EventBackCng = function (_PicName , _time) {
    _time = typeof _time !== 'undefined' ? _time : 15;
    for (let i = 0; i <= 4 - 1; i++) {
        this.PicNoCng( PN_tBack_Tp + i , PN_tBack + i);
    }
    this.SetPict(PN_tBack_Tp, L0背景Path + _PicName, 0, 0 , 0);
    this.MovePict( PN_tBack_Tp , true , true , _time , 255);
}
let _L1Mode = { 
    仕事: 1,
    訓練: 2,
    休憩: 3,
    遊び: 4,
    野試合: 8,
    アイテム: 5,
    ガン: 6,
    スキル: 7
};
let L1Mode = _L1Mode.仕事; 
let L1PicArr = [];  
let EvCngWait = 0;   
let L1_flame = 0;   
Game_Interpreter.prototype.Adv_L1_Cng = function (_Mode) {
    _Mode = typeof _Mode !== 'undefined' ? _Mode : L1Mode;
    L1Mode = _Mode;
    L1_flame = 0;
    switch (L1Mode) {
        case _L1Mode.遊び: this.JN_EventLoad("遊び"); break; 
        case _L1Mode.仕事: this.JN_EventLoad("仕事"); break; 
        case _L1Mode.訓練: this.JN_EventLoad("訓練"); break; 
        case _L1Mode.休憩: this.JN_EventLoad("休憩"); break; 
        case _L1Mode.野試合: this.JN_EventLoad("野試合");  break; 
        case _L1Mode.アイテム: this.JN_EventLoad("アイテム"); break; 
        case _L1Mode.ガン: this.JN_EventLoad("ガン"); break; 
        case _L1Mode.スキル: this.JN_EventLoad("スキル"); break; 
    }
    EvCngWait = 5;
}
let L1_Selecter = 0; 
let L1_KeyStop = 0;
Game_Interpreter.prototype.Adv_L1_Update = function () {
    if(EvCngWait > 0){
        EvCngWait--;
        if(EvCngWait <= 0){
            switch (L1Mode) {
                case _L1Mode.遊び: this.Adv_L1AsobiView(); break; 
                case _L1Mode.仕事: this.Adv_L1Work_View(); break; 
                case _L1Mode.訓練: this.Adv_L1Kunren_View(); break; 
                case _L1Mode.休憩: this.Adv_L1Kyukei_View(); break; 
                case _L1Mode.野試合: this.Adv_L1Battle_View(); break; 
                case _L1Mode.アイテム: this.Adv_L1アイテム_View(); break; 
                case _L1Mode.ガン: this.Adv_L1ガン_View(); break; 
                case _L1Mode.スキル: this.Adv_L1スキル_View(); break; 
            }
            return;
        } else {
            return;
        }
    }
    if (L1_flame > 10) {
        switch (L1Mode) {
            case _L1Mode.遊び: this.Adv_L1Asobi_Update(); break; 
            case _L1Mode.仕事: this.Adv_L1Work_Update(); break; 
            case _L1Mode.訓練: this.Adv_L1Kunren_Update(); break; 
            case _L1Mode.休憩: this.Adv_L1Kyukei_Update(); break; 
            //case _L1Mode.野試合: this.Adv_L1Battle_Update(); break; //野試合
            case _L1Mode.アイテム: this.Adv_L1アイテム_Update(); break; 
            case _L1Mode.ガン: this.Adv_L1ガン_Update(); break; 
            case _L1Mode.スキル: this.Adv_L1スキル_Update(); break; 
        }
    }
    L1_flame++;
}
Game_Interpreter.prototype.Adv_L1_PicDel = function () {
    this.DelPictSpan(PN_Layer1, PN_Layer2 - 1);
}
Game_Interpreter.prototype.Adv_L1_Back = function () {
    Adv_Layer = 1; L1_flame = 0;
    this.Adv_L2_PicDel(); 
}
let Sel6_PicPath = ""; 
let Sel6_BtnArr = []; 
let Sel6_Selecter = 0; 
let Sel6_BtnPos = new Pos2D(268, 192); 
let _Sel6_TcPic = []; 
let _Sel6_StArr = [];
let Sel6_Flame = 0;
const _Sel6SaX = 308;
const _Sel6SaY = 117;
let Sel6IcnPicCnt = 0;
const VN_客引き回数 = 115;
const VN_接客回数 = 116;
Game_Interpreter.prototype.Adv_L1Sel6_View = function (_PicPath, _BtnArr, _SucArr , _StArr) {
    _SucArr = typeof _SucArr !== 'undefined' ? _SucArr : [];
    _StArr = typeof _StArr !== 'undefined' ? _StArr : [];
    Sel6IcnPicCnt = 0;
    Sel6_Selecter = 0;
    Sel6_PicPath = _PicPath;
    Sel6_BtnArr = _BtnArr.slice();
    _Sel6_TcPic = [];
    _Sel6_StArr = [];
    Sel6_Flame = 0;
    let _opi = 0;
    D_Text_Cng_font = "Makinas"; 
    for (let i = 0; i <= Sel6_BtnArr.length - 1; i++) {
        let _PsX = Sel6_BtnPos._x + (_Sel6SaX * (i % 3));
        let _PsY = Sel6_BtnPos._y + (_Sel6SaY * (Math.floor(i / 3)));
        this.SetPict(PN_tSelBtnCk + i, Sel6_PicPath + "Btn_" + Sel6_BtnArr[i], _PsX - 50, _PsY, _opi);
        this.MovePict(PN_tSelBtnCk + i, _PsX, true, 10 + (3 * i)); 
        _Sel6_TcPic.push(PN_tSelBtnCk + i);
        switch (Sel6_BtnArr[i]) {
            case "Work8": 
                if (!CheckWork8()) {
                    this.PicCngColor(PN_tSelBtnCk + i , [-100,-100,-100,0]);
                    continue;
                }
                break;
            case "Work9": 
                if (!CheckWork9()) {
                    this.PicCngColor(PN_tSelBtnCk + i , [-100,-100,-100,0]);
                    continue;
                }
                break;
        }
        for (let j = 0; j <= _StArr[i].length - 1; j++) {
            let _SetImg = "";
            switch(_StArr[i][j]._St){
                case _St.体力: _SetImg = "Icn_UpHp";
                    break;
                case _St.攻撃: _SetImg = "Icn_UpAtk";
                    break;
                case _St.防御: _SetImg = "Icn_UpDef";
                    break;
                case _St.命中: _SetImg = "Icn_UpHit";
                    break;
                case _St.回避: _SetImg = "Icn_UpAgi";
                    break;
                case _St.直感: _SetImg = "Icn_UpJut";
                    break;
                case _St.お金:
                     _SetImg = "Icn_UpMn1";
                     if(_StArr[i][j]._Gold >= 400) _SetImg = "Icn_UpMn2";
                     if(_StArr[i][j]._Gold >= 1000) _SetImg = "Icn_UpMn3";
                    break;
                case _St.淫乱度: _SetImg = "Icn_UpInrn";
                    break;
            }
            let _PsIcnX = _PsX + 224 - (j * 44);
            let _PsIcnY = _PsY + 26;
            this.SetSprite(PN_tSelIcn + Sel6IcnPicCnt, L0BasePic + _SetImg, _PsIcnX - 50, _PsIcnY, 0);
            this.MoveSprite(PN_tSelIcn + Sel6IcnPicCnt, _PsIcnX, true, 10 + (3 * i)); 
            Sel6IcnPicCnt++;
        }
        let _SaveX = _PsX + 157;
        _PsY += 25;
        this.SetPict(PN_tParWin + i, Sel6_PicPath + "RateWin", _SaveX - 50, _PsY - 60, _opi);
        this.MovePict(PN_tParWin + i, _SaveX, true, 10 + (3 * i)); 
        let _成功確率 = _SucArr[i];
        this.SetPicStrR(PN_tParTxt + i, SCol.Blk0 + _成功確率 + " ", 25, _SaveX + 89 + 51, _PsY - 50, _opi);
        this.MovePict(PN_tParTxt + i, _SaveX + 48 + 51, true, 10 + (3 * i)); 
    }
    D_Text_Cng_font = ""; 
    this.MovePict(PN_AdvSell, Sel6_BtnPos._x - 15, Sel6_BtnPos._y + 30, 5); 
}
Game_Interpreter.prototype.Adv_L1Sel6_TcCk = function () {
    return overPointerCkArr(_Sel6_TcPic) != -1;
}
Game_Interpreter.prototype.Adv_L1Sel6_Update = function (_ReFlg) {
    _ReFlg = typeof _ReFlg !== 'undefined' ? _ReFlg : false; 
    let _mvFlg = false;
    if (Input.isTriggered('up')) {
        Sel6_Selecter -= 3; _mvFlg = true;
    }
    if (Input.isTriggered('down')) {
        if (Sel6_Selecter + 3 <= Sel6_BtnArr.length - 1) {
            Sel6_Selecter += 3; _mvFlg = true;
        }
    }
    if (Input.isTriggered('left')) {
        _mvFlg = true;
        if (Sel6_Selecter % 3 > 0) Sel6_Selecter--;
    }
    if (Input.isTriggered('right')) {
        _mvFlg = true;
        if (Sel6_Selecter % 3 < 2) Sel6_Selecter++;
    }
    let _CNo = overPointerCkArr(_Sel6_TcPic);
    if (_CNo != -1){
        if (Sel6_Selecter != _CNo - PN_tSelBtnCk){
            Sel6_Selecter = _CNo - PN_tSelBtnCk;
            _mvFlg = true; 
        }
    }
    if (_ReFlg) _mvFlg = true;
    if (_mvFlg) { 
        SoundManager.playCursor();
        if (Sel6_Selecter < 0) Sel6_Selecter = 0;
        if (Sel6_Selecter >= Sel6_BtnArr.length - 1) Sel6_Selecter = Sel6_BtnArr.length - 1;
        let _PsX = Sel6_BtnPos._x + (_Sel6SaX * (Sel6_Selecter % 3));
        let _PsY = Sel6_BtnPos._y + (_Sel6SaY * (Math.floor(Sel6_Selecter / 3)));
        this.MovePict(PN_AdvSell, _PsX - 15, _PsY + 30, 5);
        return Sel6_BtnArr[Sel6_Selecter];
    }
    Sel6_Flame++;
    return "";
}
Game_Interpreter.prototype.Adv_L1Sel6_ReSell = function () {
    let _PsX = Sel6_BtnPos._x + (_Sel6SaX * (Sel6_Selecter % 3));
    let _PsY = Sel6_BtnPos._y + (_Sel6SaY * (Math.floor(Sel6_Selecter / 3)));
    this.MovePict(PN_AdvSell, _PsX - 15, _PsY + 30, 5);
}
let _L2Mode = { 
    Work: 1,    
    Kunren: 2,   
    Asobi: 3    
};
let L2Mode = _L2Mode.Work; 
let L2PicArr = [];  
let L2_flame = 0;   
let L2Select = 0;
let YNPos = [new Pos2D(455,381), new Pos2D(720,381)];
Game_Interpreter.prototype.Adv_L2_Cng = function (_Mode) {
    L2Mode = _Mode; L2_flame = 0;
    switch (_Mode) {
        case _L2Mode.Work: this.Adv_L2Work_View(); break; 
        case _L2Mode.Kunren: this.Adv_L2Work_View(true); break; 
        case _L2Mode.Asobi: this.Adv_L2Asobi_View(true); break; 
    }
}
let L2_Selecter = 0; 
Game_Interpreter.prototype.Adv_L2_Update = function () {
    switch (L2Mode) {
        case _L2Mode.Work: this.Adv_L2Work_Update(); break; 
        case _L2Mode.Kunren: this.Adv_L2Work_Update(true); break; 
        case _L2Mode.Asobi: this.Adv_L2Asobi_Update(true); break; 
    }
    L2_flame++;
}
Game_Interpreter.prototype.Adv_L2_PicDel = function () {
    this.DelPictSpan(PN_Layer2, PN_Layer3 - 1);
}
let L2Select_Cng = function () {
    if (L2Select == 0) {
        L2Select = 1;
    } else {
        L2Select = 0;
    }
}
const DyCngPic = "pictures/Adv/Day_Cng/";
const DyCngMarkPic = "pictures/Adv/Day_Cng/Mark/";
let _DayArr = [null, null, null, null, null, null, null, null]; 
let _Day = 0;
let _dy_flame = 0;
let Adv_DyCng_Initialize = Game_System.prototype.initialize;
const DayCng_マーク差Y = 110;
Game_System.prototype.initialize = function () { 
    Adv_DyCng_Initialize.call(this);
    this.DayMarkArr = []; 
};
class DayMarkData {
    constructor(day , markPic){
        this.day = day
        this.markPic = markPic;
    }
}
Game_Interpreter.prototype.日付変更マーク設定 = function (day , markPic) {
    $gameSystem.DayMarkArr.push(new DayMarkData(day , markPic));
}
Game_Interpreter.prototype.日付変更マーク設定削除 = function (day) {
    for (let j = 0; j < $gameSystem.DayMarkArr.length; j++) {
        if ($gameSystem.DayMarkArr[j].day == day) {
            $gameSystem.DayMarkArr.splice(j , 1);
        }
    }
}
Game_Interpreter.prototype.Adv_DyCng_View = function () { 
    _dy_flame = 0;
    this.DelPictSpan(PN_rsMovie , PN_rsTop);
    this.DelPict(PN_DyBack);
    this.SetPict(PN_DyBack , DyCngPic + "PN_DyBack" , 0 , 0, 0 , 100 , 100);
    this.MovePict(PN_DyBack , 0 , 0 , 10 , 255 , 100 , 100);
    _Day = $gameVariables.value(VN_日付);
    D_Text_Cng_font = "Makinas"; 
    for (let i = 0; i <= _DayArr.length - 1; i++) {
        _DayArr[i] = _Day - 3 + i;
        if (_DayArr[i] < 0) _DayArr[i] = null;
        if (_DayArr[i] != null) { 
            let _tPos = _dyTxtPos(i);
            let _fontSize = _dyFontSize(i);
            for (let j = 0; j < $gameSystem.DayMarkArr.length; j++) {
                if ($gameSystem.DayMarkArr[j].day == _DayArr[i]) {
                    this.SetPictTC(
                        PN_DyMark + i , DyCngMarkPic + $gameSystem.DayMarkArr[j].markPic ,
                        _tPos._x, _tPos._y + DayCng_マーク差Y , 0 , _fontSize , _fontSize
                    );
                }
            }
            if (_DayArr[i] > 140) _DayArr[i] = "";
            this.SetPicStrC(PN_DyTxt + i, _DayArr[i], 240, _tPos._x, _tPos._y, 0);
            this.MovePict(PN_DyTxt + i, true, true, 1, 0, _fontSize, _fontSize);
        }
    }
    D_Text_Cng_font = ""; 
}
let _dyTxtPos = function (_Cnt) {
    let _kX = 0; 
    let _kY = 0; 
    let _Sa = Math.abs(_Cnt - 3);
    if (_Sa > 0) { _kX += 212; _kY += 34; }
    if (_Sa > 1) { _kX += 174; _kY += 15; }
    if (_Sa > 2) { _kX += 146; _kY += 0; }
    if (_Sa > 3) { _kX += 146; _kY += 0; }
    if (_Cnt - 3 < 0) _kX *= -1;
    let _PosX = 703 + _kX; let _PosY = 429 + _kY;
    return new Pos2D(_PosX, _PosY);
}
let _dyFontSize倍率 = 0.8;
let _dyFontSize = function (_Cnt) {
    let _Sa = Math.abs(_Cnt - 3);
    let _FSize = 100 * _dyFontSize倍率;
    if (_Sa > 0) _FSize = 60 * _dyFontSize倍率;
    if (_Sa > 1) _FSize = 40 * _dyFontSize倍率;
    return _FSize;
}
let _dyFontOpi = function (_Cnt) {
    let _Sa = Math.abs(_Cnt - 3);
    let _FOpi = 255;
    if (_Sa > 1) _FOpi = 200;
    if (_Sa > 2) _FOpi = 100;
    if (_Sa > 3) _FOpi = 0;
    return _FOpi;
}
Game_Interpreter.prototype.Adv_DyCng_Update = function () { 
    var okFlg = Input.isPressed('ok') || TouchInput.isPressed()
    if (okFlg && _dy_flame < 90) _dy_flame = 89;
    if (_dy_flame == 2) {
        for (let i = 0; i <= _DayArr.length - 1; i++) {
            if (_DayArr[i] != null) {
                let _fontOpi = _dyFontOpi(i);
                this.MovePict(PN_DyTxt + i, true, true, 48, _fontOpi, true, true);
                for (let j = 0; j < $gameSystem.DayMarkArr.length; j++) {
                    if ($gameSystem.DayMarkArr[j].day == _DayArr[i]) {
                        this.MovePict(PN_DyMark + i, true, true, 48, _fontOpi, true, true);
                    }
                }
            }
        }
    }
    if (_dy_flame == 90) {
        EasingStr = "easeOutQuad";
        for (let i = 0; i <= _DayArr.length - 1; i++) {
            if (_DayArr[i] != null) {
                let _tPos = _dyTxtPos(i - 1);
                let _fontOpi = _dyFontOpi(i - 1);
                let _fontSize = _dyFontSize(i - 1);
                this.MovePict(PN_DyTxt + i, _tPos._x, _tPos._y, 30, _fontOpi, _fontSize, _fontSize);
                for (let j = 0; j < $gameSystem.DayMarkArr.length; j++) {
                    if ($gameSystem.DayMarkArr[j].day == _DayArr[i]) {
                        this.MovePict(PN_DyMark + i, _tPos._x, _tPos._y + DayCng_マーク差Y,
                            30, _fontOpi, _fontSize, _fontSize);
                    }
                }
            }
        }
        EasingStr = "";
        this.ADV_PicOpi_Dell();
        if (okFlg) _dy_flame = 90 + 30;
    }
    if (_dy_flame == 90 + 60) {
        for (let i = PN_DyBack; i <= PN_DyMark + 8; i++) {
            this.MovePict(i, true, true, 30, 0, 100, 100);
        }
        if(_DayCngBack != ""){
            this.SetPict(PN_tBack_Tp, L0背景Path + _DayCngBack, 0, 0);
        }
    }
    if (_dy_flame == 90 + 60 + 35) {
        this.DelPictSpan(PN_DyBack , PN_DyTxt + 8);
        Adv_Stop = false;
        L0_NotDrawFlg = false;
        return false;
    }
    _dy_flame++;
    return true; 
}
let _DayCngEvent = "";
let _DayCngBack = "";
Game_Interpreter.prototype.DayCngEvent = function () {
    Adv_Stop = false; 
    if(_DayCngEvent != ""){
        this.Adv_L0_Cng(_L0Mode.Event);
        this.JN_EventLoad(_DayCngEvent , true);
    } else {
        this.Adv_L0_Cng(_L0Mode.Base); 
    }
    this.EnFadeOut(30); 
    _DayCngEvent = "";
}
const PN_AsGage_wb_t = 190;
const PN_AsGage_t = PN_AsGage_wb_t + 1;
const PN_AsCBack_t = PN_AsGage_t + 1;
const PN_AsTxt_t = PN_AsCBack_t + 1
let _好感度_flame = 0;
let _Set_Plus = -1; 
 let _好感度CNo = 0;
 let _好感度ViewTxt = 0;
let _好感度Ps = new Pos2D(0,0);
Game_Interpreter.prototype.好感度表示 = function (_CNo , _Plus , _Pos) {
    _Plus = typeof _Plus !== 'undefined' ? _Plus : 0;
    _Pos = typeof _Pos !== 'undefined' ? _Pos : "l";
    _好感度Ps = new Pos2D(0,308);
    _好感度CNo = _CNo;
    _好感度_flame = 1;
    switch(_Pos){
        case "l":
            _好感度Ps._x = 54;
            break;
        case "r":
            _好感度Ps._x = 1312;
            break
    }
    let _posX = _好感度Ps._x;
    let _posY = _好感度Ps._y;
    this.SetPictFIn(PN_AsCBack_t, L1AsobiPic + "PN_AsCBack_" + _好感度CNo, _posX, _posY, 0, 0, 15);
    this.SetPictB(PN_AsGage_wb_t, L1AsobiPic + "PN_AsGage_wb" , _posX + 3, _posY + 394, 0);
    this.MovePict(PN_AsGage_wb_t, true, true, 15, 255, true, true);
    this.SetPictB(PN_AsGage_t, L1AsobiPic + "PN_AsGage", _posX + 3, _posY + 394,
                  0, 100, $gameVariables.value(VN_C好感Flg + (_好感度CNo - 1)));
    this.MovePict(PN_AsGage_t, true, true, 15, 255, true, true);
    let _変数No = VN_C好感Flg + _好感度CNo - 1;
    this.SetPictB(PN_AsGage_t, L1AsobiPic + "PN_AsGage" , _posX + 3, _posY + 394, 0, 100, $gameVariables.value(_変数No));
    this.MovePict(PN_AsGage_t, true, true, 15, 255, true, true);
    let _好感度 = $gameVariables.value(_変数No);
    _Bef好感度 = _好感度;
    _Set_Plus = _好感度 + _Plus;
    $gameVariables.setValue(VN_C好感Flg + _好感度CNo - 1 , _Set_Plus);
    //if(_Set_Plus > 100) _Set_Plus = 100;
    if(_Set_Plus < 0) _Set_Plus = 0;
    this.SetPicStrC(PN_AsTxt_t , " " + _好感度 + " " , 25, _posX + 65, _posY + 369, 0);
    this.MovePict(PN_AsTxt_t , true, true, 15, 255, true, true);
    this.SetPicStrC(PN_AsTxt_t + 1 , " " + _Plus + " " , 25, _posX + 65, _posY + 369 - 60, 0);
    this.MovePict(PN_AsTxt_t + 1 , true, true, 15, 255, true, true);
    _好感度WaitFlg = true;
}
let _好感度WaitFlg = false;
let _好感度DelFlame = 0;
let _Bef好感度 = 0;
let 好感度表示_Update = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    好感度表示_Update.call(this);
    let _posX = _好感度Ps._x;
    let _posY = _好感度Ps._y;
    if(_好感度_flame > 0){
        if(_好感度_flame == 60){ 
            this.MovePict(PN_AsTxt_t + 1 , true, _posY + 369, 15, 0);
        }
        if(_好感度_flame > 60 && _好感度_flame % 5 == 0){
            this.MovePict(PN_AsGage_t, true, true, 30, 255, true, _Set_Plus);
            let _CkVN = _Bef好感度
            if(_CkVN > _Set_Plus){
                _Bef好感度 -= 1;
            }
            if(_CkVN < _Set_Plus){
                _Bef好感度 += 1;
            }
            if(_CkVN == _Set_Plus){
                _Set_Plus = -1;
                _好感度_flame = 0; 
                _好感度DelFlame = 60;
            }
            this.SetPicStrC(PN_AsTxt_t , " " + _Bef好感度 + " " , 25, _posX + 65, _posY + 369);
        }
        if(_好感度_flame != 0) _好感度_flame++;
    }
    if(_好感度_flame == 0 && _好感度DelFlame > 0){
        _好感度DelFlame--;
        if(_好感度DelFlame == 0) {
            this.DelPictSpan(PN_AsGage_wb_t , PN_AsTxt_t + 1);
            _好感度WaitFlg = false;
        }
    }
}
Game_Interpreter.prototype.Adv_PicDel = function () {
    for (let i = 0; i <= 6; i++) {
        this.DelPict(PN_tSelBtn + i);
    }
    this.Adv_L1_PicDel(); 
    this.Adv_L2_PicDel(); 
    this.DelPict(PN_AdvSell);
}
Game_Interpreter.prototype.Adv_SpineEffect_Close = function () {
    this.SpineView(PN_EnSpine,"WinEffect","Close",false,0,0);
}
Game_Interpreter.prototype.Adv_SpineEffect_Open = function () {
    this.SetSpineAnime(PN_EnSpine,"Open",false , 0 , 100);
}
Game_Interpreter.prototype.Adv_SpineEffect_A_Close = function () {
    this.SpineView(PN_EnSpine,"WinEffect","A_Close",false,0,0);
}
Game_Interpreter.prototype.Adv_SpineEffect_A_Open = function () {
    this.SetSpineAnime(PN_EnSpine,"A_Open",false , 0 , 100);
}
