const CN_GetFot = 897; 
class RD_MapPosSave {
    constructor(_MapId, _X, _Y, _Muki) {
        this._MapId = _MapId;
        this._X = _X;
        this._Y = _Y;
        this._Muki = _Muki;
    }
}
class RD_Card {
    constructor(_Id, _MType) {
        this._Id = _Id;
        this._MType = _MType;
    }
}
class RD_Mass { 
    constructor() {
        this._EvPic = ""; 
        this._MsPic = ""; 
        this._EvCmnNo = -1; 
    }
}
const RD_DotSet = [ 
    [0, 30, "PL_dots_long"],     
    [1, 30, "PL_dotn_long"],     
    [2, 30, "PL_dotc_long"],     
    [3, 30, "PL_dotu_long"],     
    [4, 30, "PL_doth_long"],     
    [0, 0, "PL_dots_pony"],     
    [1, 0, "PL_dotn_pony"],     
    [2, 0, "PL_dotc_pony"],     
    [3, 0, "PL_dotu_pony"],     
    [4, 0, "PL_doth_pony"],     
    [99, 99, ""] 
];
let EnRDMode = {
    PL_Start: 0,    
    PL_Select: 1,   
    PL_Move: 2,     
    Ev_Start: 3,    
    RD_End: 4,      
};
let RD_Mode = EnRDMode.PL_Start;
let EnRDClearMode = {
    On: 0,      
    Clear: 1,   
    Faild: 2,   
    Tettai: 3   
}
let RD_ClearMode = EnRDClearMode.On;
let SW_L2Dローブ = 70;
let RD_PlImg = "";
Game_Interpreter.prototype.RD_PC_ImgSet = function () {
    let kigaeValue = $gameVariables.value(VN_TL2DKigae);
    let kamiValue = $gameVariables.value(VN_TL2DKami);
    if (kigaeValue == -1) {
        kigaeValue = 3;
        if ($gameSwitches.value(SW_BuraOFF) && $gameSwitches.value(SW_PantuOFF)) {
            kigaeValue = 4;
        }
    }
    for (let i = 0; i <= RD_DotSet.length - 1; i++) {
        if (RD_DotSet[i][0] == kigaeValue && RD_DotSet[i][1] == kamiValue) {
            RD_PlImg = RD_DotSet[i][2];
        }
    }
    if ($gameSwitches.value(SW_L2Dローブ)) {
        RD_PlImg = "PL_dotu_Robu";
    }
}
let RDPreLoadImgs = [
    "pictures/E_Black",
    "pictures/UI_Dungeon/Ev/Romasha/_d", "pictures/UI_Dungeon/Ev/Romasha/_l", "pictures/UI_Dungeon/Ev/Romasha/_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_long_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_long_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_long_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_pony_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_pony_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotc_pony_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_doth_long_d", "pictures/UI_Dungeon/Ev/Romasha/PL_doth_long_l", "pictures/UI_Dungeon/Ev/Romasha/PL_doth_long_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_doth_pony_d", "pictures/UI_Dungeon/Ev/Romasha/PL_doth_pony_l", "pictures/UI_Dungeon/Ev/Romasha/PL_doth_pony_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_long_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_long_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_long_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_pony_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_pony_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotn_pony_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dots_long_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dots_long_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dots_long_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dots_pony_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dots_pony_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dots_pony_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_long_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_long_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_long_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_pony_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_pony_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_pony_t",
    "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_Robu_d", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_Robu_l", "pictures/UI_Dungeon/Ev/Romasha/PL_dotu_Robu_t"
];
Game_Interpreter.prototype.RD_相棒設定反映 = function () {
    $gameSystem.Dngn_AiboArr.forEach(aiboData => {
        if (aiboData.DngnNo == dgnSel_RdId) {
            if (aiboData.AiboArr.length > 0) {
                $gameVariables.setValue(BtlStatic.VN_味方No, aiboData.AiboArr[0]);
                this._味方HP_維持開始();
            }
        }
    });
}
let RD_Flame = 0; 
Game_Interpreter.prototype.RD_Update = function () {
    if (RD_Flame == 0) { 
        this.RD_FirstView();
        if ($gameSystem.RD_BaseData.bgmName != "") {
            this.PlayBgm($gameSystem.RD_BaseData.bgmName);
        }
        if ($gameVariables.value(VN_RdKaiso) == 0) {
            this._味方HP_維持開始(); 
        }
    }
    if (GetSpriteData(PN_rdPlayer) != null) {
        RD_PLPosX = GetSpriteData(PN_rdPlayer)._x;
        RD_PLPosY = GetSpriteData(PN_rdPlayer)._y;
    }
    if (RD_EvStop) return; 
    if (RD_Stop) return; 
    switch (RD_Mode) {
        case EnRDMode.PL_Start: 
            this.RD_PLStart_Update();
            break;
        case EnRDMode.PL_Select: 
            this.RD_PL_Select_Update();
            break;
        case EnRDMode.PL_Move: 
            this.OpeUpdate(); 
            this.RD_PLMove_Update();
            break;
        case EnRDMode.Ev_Start: 
            this.OpeUpdate(); 
            if (RD_BtlFlg) break; 
            this.RD_EvStart_Update();
            break;
        case EnRDMode.RD_End: 
            this.RD_RD_End_Update();
            break;
    }
    RD_Flame++;
};
let RericPs = new Pos2D(1385, 662);
let RericY差 = 60;
let Reric拡大 = 150;
let RericPicArr = [];
Game_Interpreter.prototype.RD_レリックDraw = function () {
    if ($gameSystem.Btl_Chara == null) return;
    RericPicArr = [];
    for (let i = 0; i <= $gameSystem.Btl_Chara.RericArr.length - 1; i++) {
        let itemNo = $gameSystem.Btl_Chara.RericArr[i];
        let iconNo = $dataItems[itemNo].iconIndex;
        let iconStr = " " + "\\I[" + iconNo + "] ";
        this.SpriteStrC(PN_Reric + i, iconStr, 25,
            RericPs._x, RericPs._y - (RericY差 * i), 255, Reric拡大, Reric拡大);
        RericPicArr.push(PN_Reric + i);
    }
}
Game_Interpreter.prototype.RD_レリックUpdate = function () {
    if ($gameSystem.Btl_Chara == null) return;
    this.DelPictSpan(PN_BRSetuWaku, PN_BRSetuWaku + 3); 
    if ($gameSystem.Btl_Chara.RericArr.length > 0) {
        this.RD_レリックDraw();
    }
    let ckPicNo = overPointerSpCkArrTm(RericPicArr);
    if (ckPicNo != -1) {
        ckPicNo -= PN_Reric;
        let itemNo = $gameSystem.Btl_Chara.RericArr[ckPicNo];
        this.RD_レリック_説明描画(itemNo, RericPs._x - 487, RericPs._y - 46 - (RericY差 * ckPicNo));
    }
}
Game_Interpreter.prototype.RD_レリック_説明描画 = function (rericId, setX, setY) {
    _STY_SetuPicNo = PN_BRSetuWaku;
    this.SetPict(_STY_SetuPicNo, BtlPicPath + "PN_RericSetuWin", setX, setY);
    let ckArr = $dataItems[rericId].description.split("\n");
    let iconNo = $dataItems[rericId].iconIndex;
    let nameStr = " " + "\\I[" + iconNo + "] " + $dataItems[rericId].name;
    this.SetPicStr(_STY_SetuPicNo + 1, nameStr, 25, setX + 13, setY + 15);
    for (let i = 0; i <= ckArr.length - 1; i++) {
        this.SetPicStr(_STY_SetuPicNo + 2 + i, ckArr[i], 19, setX + 25, setY + 26 + (27 * (i + 1)));
    }
    _STY_SetuPicNo = PN_BCSetuWaku;
}
Game_Interpreter.prototype.RD_Live2D_Draw = function () {
    if (BtlRomashaFlg) {
        L2dAutoFadeOut("romasha_talk", 15);
        if (!$gameSwitches.value(SW_rdNoLive2D)) { 
            L2dFadeMdl(MdlRomashaBattle, "rightin", 15, "batalle_bless");
            L2dIdleStart(MdlRomashaBattle, "batalle_bless");
            L2dTalkTop(MdlRomashaBattle);
            this.SetCmnEvent(CN_romasha_battale);
        }
    } else {
        let RDLive2DScaleX = 1;
        if ($gameSystem.Btl_Chara.反転Flg) {
            RDLive2DScaleX = -1;
        }
        L2dFadeMdl($gameSystem.Btl_Chara.Live2D.Name, "rightin", 30, $gameSystem.Btl_Chara.Live2D.WaitMotion,
            RDLive2DScaleX, null, $gameSystem.Btl_Chara.Live2D.ZureX, $gameSystem.Btl_Chara.Live2D.ZureY);
        L2dIdleStart($gameSystem.Btl_Chara.Live2D.Name, $gameSystem.Btl_Chara.Live2D.WaitMotion);
        L2dTalkTop($gameSystem.Btl_Chara.Live2D.Name);
    }
}
let RD_DMapArr = [];    
let RDMapPosX = 0;
let RDMapPosY = 0;
Game_Interpreter.prototype.RD_MapLineDraw = function (_XFlg, moveValue) {
    _XFlg = typeof _XFlg !== 'undefined' ? _XFlg : true;
    moveValue = typeof moveValue !== 'undefined' ? moveValue : 0;
    RDMapPosX = 250;
    RDMapPosY = 220;
    D_Text_Cng_font = "Makinas";
    let _ux = $gameSystem.RD_LineX;
    let _uy = $gameSystem.RD_LineY;
    this.DelSpriteSpan(PN_rdBase , PN_rbBossBase - 1);
    this.SetSprite(PN_rbGBase, RdnPicPath + "Map_Line", 71, 153);
    let _returnX = 1;
    if (RD_LeftStartFlg) _returnX = -1;
    if (_XFlg) {
        if (moveValue == 1) { 
            $gameSystem.RD_LineX++;
            let fsti = -1;
            if (RD_LeftStartFlg) fsti = 0;
            for (let i = fsti; i <= (7 - 1); i++) {
                let opacity = 255;
                if (i == -1) opacity = 0;
                this.SetSprite(PN_rdBase + (i + 1), RdnPicPath + "Map_LineS",
                    RDMapPosX + (RD_MassSizeX * i), RDMapPosY, opacity);
                opacity = 255;
                if (RD_LeftStartFlg) {
                    if (i == 0) opacity = 0;
                } else {
                    if (i == (7 - 1)) opacity = 0;
                }
                this.MoveSprite(PN_rdBase + (i + 1),
                    RDMapPosX + (RD_MassSizeX * (i + 1 * _returnX)), RDMapPosY, 15, opacity);
            }
        } else {
            for (let i = 0; i <= 7 - 1; i++) {
                this.SetSprite(PN_rdBase + i, RdnPicPath + "Map_LineS", RDMapPosX + (RD_MassSizeX * i), RDMapPosY);
            }
        }
    } else {
        if (moveValue != 0) { 
            $gameSystem.RD_LineY -= moveValue;
            for (let i = -1; i <= 5 - 1; i++) {
                let _opi = 255;
                if (i == -1) _opi = 0;
                this.SetSprite(PN_rdBase + (i + 1), RdnPicPath + "Map_LineT",
                    RDMapPosX, RDMapPosY + (RD_MassSizeY * i));
                _opi = 255;
                if (i == (5 - 1)) _opi = 0;
                this.MoveSprite(PN_rdBase + (i + 1),
                    RDMapPosX, RDMapPosY + (RD_MassSizeY * (i + 1)), 15, _opi);
            }
        } else {
            for (let i = 0; i <= 5 - 1; i++) {
                this.SetSprite(PN_rdBase + i, RdnPicPath + "Map_LineT",
                    RDMapPosX, RDMapPosY + (RD_MassSizeY * i));
            }
        }
    }
    let _Ev_X = RDMapPosX + 578;
    if (RD_LeftStartFlg) _Ev_X -= (6 * RD_MassSizeX);
    let _Ev_Y = RDMapPosY - 5;
    let _SetPLX = _Ev_X - (_RdPlX * RD_MassSizeX);
    if (RD_LeftStartFlg) _SetPLX = _Ev_X + (_RdPlX * RD_MassSizeX);
    let _SetPLY = _Ev_Y + (_RdPlY * RD_MassSizeY);
    let movePicStr = STY_MovePic_l;
    if (RD_LeftStartFlg) movePicStr = STY_MovePic_r;
    this.PlaySpriteAnimeC(PN_rdPlayer, movePicStr, 6, 10, _SetPLX, _SetPLY);
    this.RD_MassPicDel(); 
    this.RD_EventPicDel();
    var KeepRD_DMapArr = RD_DMapArr.slice();
    RD_DMapArr = [];    
    for (let i = 0; i <= 8 - 1; i++) { 
        let _DMapArr = [];  
        for (let j = 0; j <= 7 - 1; j++) { 
            let _ckX = _ux + i;
            let _ckY = _uy + j - 1;
            if ($gameSystem.RD_Map.length <= _ckX) continue;
            let _CkMass = $gameSystem.RD_Map[_ckX][_ckY];
            _DMapArr.push(_CkMass);
        }
        RD_DMapArr.push(_DMapArr);
    }
    if (_XFlg && moveValue == 1) {
        this.MoveSprite(PN_rdPlayer, _SetPLX + RD_MassSizeX * _returnX, _SetPLY, 15);
    }
    if (!_XFlg && moveValue != 0) {
        this.MoveSprite(PN_rdPlayer, _SetPLX, _SetPLY + (moveValue * RD_MassSizeY), 15);
    }
    this.RD_MapMassDraw(_XFlg, moveValue);
    if (!RD_LeftStartFlg) { 
        let _BWPos = new Pos2D(0, 283); 
        let _BossCnt = 0;
        _ux = $gameSystem.RD_LineX;
        let _BossPic = "Boss";
        for (let i = _ux; i <= $gameSystem.RD_Map.length - 1; i++) { 
            if ($gameSystem.RD_Map[i][0] == null) continue;
            if ($gameSystem.RD_Map[i][0].bossFlg) {
                _BossCnt = i - _ux;
                _BossPic = $gameSystem.RD_Map[i][0].image;
            }
        }
        if (_BossCnt > 0) { 
            this.SpriteStrC(PN_rbBossCnt, _BossCnt, 60, _BWPos._x + 127, _BWPos._y + 95);
            this.SetSprite(PN_rbBossBase + 0, RdnPicPath + "Win_Boss", _BWPos._x, _BWPos._y);
            this.SetSpriteBC(PN_rbBossBase + 1, RdnPicPath + "Ev/" + _BossPic, _BWPos._x + 53, _BWPos._y + 173);
        }
        D_Text_Cng_font = "";
        this.RD_DeckMaisuView();
        _ux = $gameSystem.RD_LineX;
        for (let i = 0; i <= 7 - 1; i++) {
            this.SpriteStrC(PN_rdLineStr + i, " " + (i + _ux) + " ", 24,
                _Ev_X - 5 - (i * RD_MassSizeX), _Ev_Y - 15);
        }
    }
    if (_RD_PLMovingFlg) { 
        RD_DMapArr = KeepRD_DMapArr;
    }
}
Game_Interpreter.prototype.RD_DMapArr_Get = function () {
    let _ux = $gameSystem.RD_LineX;
    let _uy = $gameSystem.RD_LineY;
    RD_DMapArr = []; 
    let _Eci = -1;
    let _Ecj = -1;
    for (let i = _ux; i <= $gameSystem.RD_Map.length - 1; i++) { 
        _Eci++;
        if (_Eci == 7) break;
        let _DMapArr = [];
        _Ecj = -1;
        for (let j = _uy; j <= $gameSystem.RD_Map[i].length - 1; j++) {
            _Ecj++;
            if (_Ecj == 5) break;
            _DMapArr.push($gameSystem.RD_Map[i][j]);
        }
        RD_DMapArr.push(_DMapArr);
    }
}
let CkMass_MassPicGet = function (massData) {
    if (massData.massImage == null) massData.massImage = "";
    if (massData.massImage != "") return massData.massImage;
    switch (massData.type) {
        case "Enemy":
            if (massData.bossFlg) return "Boss"
            return "Enemy";
        default:
            return massData.type;
    }
}
let CkMass_EvPicGet = function (massData, _縦No) {
    if (massData.putData == null) return "";
    if (massData.putData.type == "ライン") {
        if (_縦No != 3) return "";
    }
    if (massData.type == "Fotonia") return "Photonia";
    if (massData.massImage == "Fotonia") return "Photonia";
    if (massData.image.indexOf(",") != -1) {
        let evArr = massData.image.split(",");
        let rdmNo = Math.floor(Math.random() * evArr.length);
        massData.image = evArr[rdmNo]; 
    }
    return massData.image;
}
Game_Interpreter.prototype.RD_MassPicDel = function () {
    for (let i = PN_rdMapMass; i <= PN_rdMap_MvM + 5; i++) {
        this.DelPict(i);
        this.DelSprite(i);
    }
}
Game_Interpreter.prototype.RD_EventPicDel = function () {
    for (let i = PN_rdMapEv; i <= PN_rdMapEvView + 6; i++) {
        this.DelPict(i);
        this.DelSprite(i);
    }
}
Game_Interpreter.prototype.RD_DeckMaisuView = function () {
    let _SetX = 15;
    let _SetY = 670;
    let _DeckImgStr = $gameSystem.Btl_Chara.DeckImg;
    if (_DeckImgStr == undefined) _DeckImgStr = "PN_Deck";
    this.SetSprite(PN_Deck, BtlPicPath + "PN_Deck4", _SetX, _SetY);
    if ($gameSystem.RD_MoveDeck.length > 1) this.SetSprite(PN_Deck, BtlPicPath + _DeckImgStr + "3", _SetX, _SetY);
    if ($gameSystem.RD_MoveDeck.length > 7) this.SetSprite(PN_Deck, BtlPicPath + _DeckImgStr + "2", _SetX, _SetY);
    if ($gameSystem.RD_MoveDeck.length > 14) this.SetSprite(PN_Deck, BtlPicPath + _DeckImgStr + "1", _SetX, _SetY);
    setmaisu = " " + String($gameSystem.RD_MoveDeck.length);
    this.SpriteStrC(PN_T_Maisu, setmaisu, 21, _SetX + 111, _SetY + 104);
    //■捨て札の設定(デッキ総数 - デッキ残り枚数 - 手札)：
    let _StX = _SetX + 890;
    let _StY = _SetY + 52;
    let _smaisu = " " + ($gameSystem.RD_MoveDeckBase.length - $gameSystem.RD_MoveDeck.length - $gameSystem.RD_HandCard.length);
    this.SetSprite(PN_Trash, BtlPicPath + "trash", _StX, _StY);
    this.SpriteStrC(PN_Trash + 1, _smaisu, 16, _StX + 68, _StY + 58);
}
Game_Interpreter.prototype.RD_DeckSetting = function () {
    let SetDeck1 = $gameSystem.RD_MoveDeckBase.concat();
    for (let i = 0; i <= $gameSystem.RD_HandCard.length - 1; i++) {
        for (let j = 0; j <= SetDeck1.length - 1; j++) {
            if ($gameSystem.RD_HandCard[i].CardData.id == SetDeck1[j]) {
                SetDeck1.splice(j, 1); 
                break; 
            }
        }
    }
    ShuffleArr(SetDeck1); 
    $gameSystem.RD_MoveDeck = SetDeck1.concat();
};
Game_Interpreter.prototype.RD_CardSetting = function () {
    if ($gameSystem.RD_MoveDeck.length == 0) { 
        SpriteAnimeLoopFlg = false;
        reloadDeckPicDelFlame = 50;
        //this.PlaySpriteAnimeC(PN_DeckReload, BtlPicPath + "BAnime/DeckReload", 18, 2, _SetX, _SetY);//キャラ画像の中心
        this.RD_DeckSetting();
    }
    let _CardId = $gameSystem.RD_MoveDeck[0];
    $gameSystem.RD_MoveDeck.shift(); 
    let nCard = new Card($dataWeapons[_CardId]);
    $gameSystem.RD_HandCard.push(nCard); 
    _seti = $gameSystem.RD_HandCard.length - 1;
    let ccOpi = 200;
    for (let i = 0; i <= BtlStatic._手札最大枚数 - 1; i++) {
        let _sssFlg = true;
        for (let j = 0; j <= $gameSystem.RD_HandCard.length - 1; j++) {
            if ($gameSystem.RD_HandCard[j].setPNo == PN_Card_RD + i) {
                _sssFlg = false; 
            }
        }
        if (_sssFlg) {
            $gameSystem.RD_HandCard[_seti].setPNo = PN_Card_RD + i;
        }
    }
    $gameSystem.RD_HandCard[_seti].XPos = 31;
    $gameSystem.RD_HandCard[_seti].YPos = 643;
    let CardId = $gameSystem.RD_HandCard[_seti].CardData.id;
    _cCostDrawFlg = false;
    this.CardPicDrawC(CardId, $gameSystem.RD_HandCard[_seti].setPNo, PN_Cmp,
        $gameSystem.RD_HandCard[_seti].XPos,
        $gameSystem.RD_HandCard[_seti].YPos,
        ccOpi, 20, 20);
    let _SetMp = 0;
    if ($dataWeapons[CardId].meta["Cost"] == "All") {
        _SetMp = 3;
    } else {
        _SetMp = Number($dataWeapons[CardId].meta["Cost"]);
    }
    if (_SetMp < 3) _SetMp += 1;
    this.RndRootPicCmp(_SetMp, _seti);
    $gameSystem.RD_HandCard[_seti].KeepPicData = this.SpriteObjGet($gameSystem.RD_HandCard[_seti].setPNo);
    $gameScreen.tintPicture($gameSystem.RD_HandCard[_seti].setPNo, [-20, -20, -20, 0], 0);
    this.PlaySe("card");
    this.RD_DeckMaisuView(); 
};
Game_Interpreter.prototype.RD_CardDrawMove = function (_SelNo) {
    _SelNo = typeof _SelNo !== 'undefined' ? _SelNo : -1;
    let _MTime = 15;
    if (_SelNo != -1) {
        _MTime = 1;
    }
    let Cardxset = 174 - (($gameSystem.RD_HandCard.length - 1) * 7);
    let ccOpi = 200;
    for (let i = 0; i <= $gameSystem.RD_HandCard.length - 1; i++) {
        $gameSystem.RD_HandCard[i].XPos = handCardBasePostion._x + (Cardxset * i);
        $gameSystem.RD_HandCard[i].YPos = handCardBasePostion._y;
        if ($gameSystem.RD_HandCard[i].setPNo == _SelNo) {
            $gameSystem.RD_HandCard[i].YPos -= 40;
        }
        this.MovePict($gameSystem.RD_HandCard[i].setPNo,
            $gameSystem.RD_HandCard[i].XPos,
            $gameSystem.RD_HandCard[i].YPos,
            _MTime, ccOpi, Btl_手札拡大率, Btl_手札拡大率);
        $gameScreen.tintPicture($gameSystem.RD_HandCard[i].setPNo, [-20, -20, -20, 0], 0);
        btlWaitFlame = 3; 
        btl操作不能Flame = 15; 
    }
}
Game_Interpreter.prototype.RndRootPicCmp = function (_SetMp, _HandNo) {
    if (TutorialDgn管理No == 1) _SetMp = 1;
    if (TutorialDgn管理No == 3) _SetMp = 1;
    if (TutorialDgn管理No == 4) _SetMp = 1;
    if (TutorialDgn管理No == 5) _SetMp = 1;
    if (TutorialDgn管理No == 6) _SetMp = 2;
    let _rtnInt = 1;
    switch (_SetMp) {
        case 0:
            _rtnInt = 1;
            break;
        case 1:
            _rtnInt = Math.floor(Math.random() * 5) + 1;
            if (TutorialDgn管理No == 1) _rtnInt = 5;
            if (TutorialDgn管理No == 3) _rtnInt = 5;
            if (TutorialDgn管理No == 4) _rtnInt = 5;
            if (TutorialDgn管理No == 5) _rtnInt = 5;
            break;
        case 2:
            _rtnInt = Math.floor(Math.random() * 8) + 1;
            if (TutorialDgn管理No == 6) _rtnInt = 5;
            break;
        case 3:
            _rtnInt = Math.floor(Math.random() * 5) + 1;
            break;
        case 4:
            _rtnInt = Math.floor(Math.random() * 2) + 1;
            break;
    }
    let _SPicStr = CardPicPath + "RD_Root/move" + (_SetMp + 1) + "_" + _rtnInt;
    if (RD_LeftStartFlg) _SPicStr += "r";
    this.SetPict(PN_Cmp, _SPicStr);
    this.CmpPict($gameSystem.RD_HandCard[_HandNo].setPNo, PN_Cmp);
    for (let i = 0; i <= RndRootData.length - 1; i++) {
        if (RndRootData[i]._RtCnt == _SetMp && RndRootData[i]._RtNo == _rtnInt) {
            $gameSystem.RD_HandCard[_HandNo].CardRoot = RndRootData[i]._RData;
        }
    }
}
let RD_ClearFlg = false; 
Game_Interpreter.prototype.RD_ClrUIDraw = function () {
    this._OpeUIDraw();
    let rdClearFlg = $gameVariables.value(VN_BossBrk) >= $gameSystem.RD_BaseData.clearValue;
    if (RD_ClearFlg) {
        rdClearFlg = true; 
        RD_ClearFlg = false;
    }
    this.SetSprite(PN_rbClearWinB, RdnPicPath + "ClearLine_T", 0, 85, 0);
    this.MoveSprite(PN_rbClearWinB, true, true, 15);
    D_Text_Cng_font = "Makinas";
    let _SetY = 85 + 38;
    this.SetSprite(PN_rbClearWin, RdnPicPath + "ClearLine", 0, _SetY, 0);
    this.SpriteStr(PN_rbClearWin + 1, $gameSystem.RD_BaseData.clearTxt, 20, 30, _SetY + 2, 0);
    this.SetSprite(PN_rbClearWin + 2, RdnPicPath + "ClearCkbox_0", 0, _SetY, 0);
    if (rdClearFlg) this.SetSprite(PN_rbClearWin + 2, RdnPicPath + "ClearCkbox_1", 0, _SetY, 0);
    this.MoveSprite(PN_rbClearWin, true, true, 15);
    this.MoveSprite(PN_rbClearWin + 1, true, true, 15);
    this.MoveSprite(PN_rbClearWin + 2, true, true, 15);
    D_Text_Cng_font = "";
    let _RtX = 1215;
    //this.SetSpriteC(PN_rdRtBtn + 0, RdnPicPath + "RtBtn1", _RtX, 45, 0);
    if (!$gameSystem.RD_BaseData.tettaiFlg) {
        this.SetSpriteC(PN_rdRtBtn + 1, RdnPicPath + "RtBtn2", _RtX + 144, 45, 0); 
        this.MoveSprite(PN_rdRtBtn + 0, true, true, 15);
        this.MoveSprite(PN_rdRtBtn + 1, true, true, 15);
    }
    if (rdClearFlg) { 
        RD_ClearMode = EnRDClearMode.Clear;
        this.RD_RDEnd_Cng();
    }
}
Game_Interpreter.prototype.RD_途中撤退禁止 = function () {
    $gameSystem.RD_BaseData._ExitFlg = false;
    this.DelSprite(PN_rdRtBtn + 1);
}
Game_Interpreter.prototype.RD_ClearUIDell = function () {
    for (let i = 0; i <= 6; i++) {
        this.DelPict(PN_rbClearWinB + i); 
        this.DelSprite(PN_rbClearWinB + i); 
    }
    for (let i = PN_rdOpeFace; i <= PN_rdOpeWin + 4; i++) {
        this.DelPict(i); 
        this.DelSprite(PN_rbClearWinB + i); 
    }
}
Game_Interpreter.prototype.RDOpeSet = function (dgnNo, talkNo) {
    var rdData = RD_MasterData_Get(dgnNo);
    let ckDatas = rdData.talkDatas;
    if ($gameSwitches.value(SW_ダンジョン選択４章状態)) {
        if (rdData.naiyoTxtEx != "" && rdData.naiyoTxtEx != null) {
            ckDatas = rdData.talkDatasEx;
        }
    }
    for (let i = 0; i <= ckDatas.length - 1; i++) {
        if (ckDatas[i].id == talkNo) {
            var speachDatas = ckDatas[i].speachDatas;
            this.OpeReset();
            for (let i = 0; i <= speachDatas.length - 1; i++) {
                let setFlame = 0;
                if (i == 0)
                    setFlame = 0;
                else
                    setFlame = speachDatas[i - 1].viewFlame;
                this.OpeSet(speachDatas[i].name, speachDatas[i].text, speachDatas[i].image, setFlame);
            }
            if (ckDatas[i].lastClearFlg) {
                setFlame = speachDatas[speachDatas.length - 1].viewFlame;
                this.OpeSet("", "", "NoData", 300);
            }
        }
    }
}
let OpeSet_Arr = [];
class _OpeSet {
    constructor(_Name, _Str, _Gra, _flame) {
        _flame = typeof _flame !== 'undefined' ? _flame : 0;
        this._Name = _Name;     
        this._Str = _Str;       
        this._Gra = _Gra;       
        this._flame = _flame;   
    }
}
Game_Interpreter.prototype.OpeReset = function () {
    OpeSet_Arr = [];
}
Game_Interpreter.prototype.OpeSet = function (name, text, graphic, flame) {
    graphic = typeof graphic !== 'undefined' ? graphic : "NoData";
    flame = typeof flame !== 'undefined' ? flame : 0;
    if (graphic == "roma") {
        graphic = this.Ope_ロマーシャ髪型確認();
    }
    OpeSet_Arr.push(new _OpeSet(name, text, graphic, flame))
};
Game_Interpreter.prototype.Ope_ロマーシャ髪型確認 = function () {
    if ($gameVariables.value(VN_TL2DKami) == 0) return "roma_p";
    return "roma_l";
}
Game_Interpreter.prototype.OpeUpdate = function () {
    if (OpeSet_Arr.length > 0) {
        if (OpeSet_Arr[0]._flame <= 0) {
            if (OpeSet_Arr[0]._Gra != undefined) {
                OpeGra = OpeSet_Arr[0]._Gra;
            }
            OpeName = OpeSet_Arr[0]._Name;
            OpeStr = OpeSet_Arr[0]._Str;
            this.OpeDraw();     
            OpeSet_Arr.shift(); 
        } else {
            OpeSet_Arr[0]._flame--;
        }
    }
};
let OpeGra = ""; 
let OpeStr = ""; 
let OpeName = ""; 
Game_Interpreter.prototype.OpeDraw = function () {
    D_Text_Cng_font = "Makinas";
    if (OpeGra != "") {
        this.SetSpriteC(PN_rdOpeFace, RdnPicPath + "Ope/" + OpeGra, 490, 45, 255);
    }
    this.SetSpriteC(PN_rdOpeWin, RdnPicPath + "Ope/OpeWin", 906, 41, 255);
    this.SpriteStr(PN_rdOpeWin + 1, OpeStr, 20, 545, 37 - 10, 0);
    this.MoveSprite(PN_rdOpeWin + 1, true, 37, 20);
    this._OpeUIDraw(20);
    if (OpeName != "") {
        this.SpriteStr(PN_rdOpeWin + 4, OpeName, 16, 560, 10, 255);
    } else {
        this.DelSprite(PN_rdOpeWin + 4);
    }
    D_Text_Cng_font = "";
}
Game_Interpreter.prototype._OpeUIDraw = function (setFlame) {
    setFlame = typeof setFlame !== 'undefined' ? setFlame : 0;
    let fAlpha = 0;
    let ckSpriteData = GetSpriteData(PN_rdOpeWin);
    if (ckSpriteData == null) return;
    if (setFlame == 0) fAlpha = 255;
    this.SpriteStrC(PN_rdOpeWin + 2, SCol.Def0 + $gameVariables.value(VN_GetFotn) + " ", 21, 1110 + (75 * 0), 19, fAlpha);
    this.SpriteStrC(PN_rdOpeWin + 3, SCol.Def0 + $gameVariables.value(VN_EmBrk) + " ", 21, 1085 + (75 * 1), 19, fAlpha);
    this.SpriteStrC(PN_rdOpeWin + 5, SCol.Def0 + $gameVariables.value(VN_ThRitu) + " ", 21, 1065 + (75 * 2), 19, fAlpha);
    if (setFlame != 0){
        this.MoveSprite(PN_rdOpeWin + 2, true, true, 20);
        this.MoveSprite(PN_rdOpeWin + 3, true, true, 20);
        this.MoveSprite(PN_rdOpeWin + 5, true, true, 20);
    }
}
let _rd_TalkPicArr = [];
_rd_TalkPicArr.push(PN_rbMapName + 0, PN_rbMapName + 1);
for (let i = PN_rdMapEvCD; i <= (PN_rbStateWin + 3); i++) {
    _rd_TalkPicArr.push(i);
}
for (let i = PN_rdOpeFace; i <= (PN_rdRtBtn + 1); i++) {
    _rd_TalkPicArr.push(i);
}
Game_Interpreter.prototype.rd_TalkUIOpi_0 = function () {
    for (let i = 0; i <= _rd_TalkPicArr.length - 1; i++) {
        this.MoveSprite(_rd_TalkPicArr[i], true, true, 10, 0, true, true);
    }
};
Game_Interpreter.prototype.rd_TalkUIOpi_255 = function () {
    for (let i = 0; i <= _rd_TalkPicArr.length - 1; i++) {
        if (RDOpi0MapPics.indexOf(rd_TalkPicArr2[i]) != -1) continue;
        let _tSkipFlg = false;
        if (rd_TalkPicArr2[i] == PNo_TBack) _tSkipFlg = true;
        if (!_tSkipFlg) {
            this.MoveSprite(_rd_TalkPicArr[i], true, true, 10, 255, true, true);
        }
    }
};
let rd_TalkPicArr2 = []; 
for (let i = PN_DFuti; i <= PN_Card_RD + 10; i++) {
    rd_TalkPicArr2.push(i);
}
for (let i = PN_rdGainWin; i <= PN_rdKoudoCnt + 1; i++) {
    rd_TalkPicArr2.push(i);
}
let RDOpi0MapPics = [];
Game_Interpreter.prototype.rd_TalkUIOpiAll_0 = function () {
    this.rd_TalkUIOpi_0();
    for (let i = 0; i <= rd_TalkPicArr2.length - 1; i++) {
        let picData = this.PicObjGet(rd_TalkPicArr2[i]);
        if (picData != null) if (picData.opacity == 0) RDOpi0MapPics.push(rd_TalkPicArr2[i]);
        this.MovePict(rd_TalkPicArr2[i], true, true, 10, 0, true, true);
        let spData = GetSpriteData(rd_TalkPicArr2[i]);
        if (spData != null) if (spData.opacity == 0) RDOpi0MapPics.push(rd_TalkPicArr2[i]);
        this.MoveSprite(rd_TalkPicArr2[i], true, true, 10, 0, true, true);
    }
}
Game_Interpreter.prototype.rd_Pic_AllDell = function () {
    for (let i = 0; i <= rd_TalkPicArr2.length - 1; i++) {
        this.DelPict(rd_TalkPicArr2[i], true, true, 10, 0, true, true);
    }
}
Game_Interpreter.prototype.rd_TalkUIOpiAll_255 = function () {
    this.DelPictSpan(PN_LoadBase + 0 , PN_dpBar); 
    this.rd_TalkUIOpi_255();
    for (let i = 0; i <= rd_TalkPicArr2.length - 1; i++) {
        if (RDOpi0MapPics.indexOf(rd_TalkPicArr2[i]) != -1) continue;
        let _tSkipFlg = false;
        if (rd_TalkPicArr2[i] == PNo_TBack) _tSkipFlg = true;
        if (!_tSkipFlg) {
            this.MovePict(rd_TalkPicArr2[i], true, true, 10, 255, true, true);
            this.MoveSprite(rd_TalkPicArr2[i], true, true, 10, 255, true, true);
        }
    }
    this.RD_MapLineDraw();
    this.DelPictSpan(PN_MobB + 0, PN_MobT + 5);
    this.DelSpriteSpan(PN_MobB + 0, PN_MobT + 5);
}
Game_Interpreter.prototype.rd_PicTranIn = function (_FileName, _Flame, _PicNo) {
    _PicNo = typeof _PicNo !== 'undefined' ? _PicNo : PN_rdEnsyutu;
    this.SetPict(_PicNo, _FileName, -1884, 0, 255, 100, 100);
    this.MovePict(_PicNo, -222, 0, _Flame);
};
Game_Interpreter.prototype.rd_PicTranOut = function (_Flame, _PicNo) {
    _PicNo = typeof _PicNo !== 'undefined' ? _PicNo : PN_rdEnsyutu;
    this.MovePict(_PicNo, 1884, 0, _Flame);
};
Game_Interpreter.prototype.rd_PicTranFIn = function (_FileName, _Flame) {
    this.SetPict(PN_rdEnsyutu, _FileName, 0, 0, 255, 100, 100);
    this.MovePict(PN_rdEnsyutu, 0, 0, _Flame);
};
Game_Interpreter.prototype.rd_PicTranFOut = function (_Flame) {
    this.MovePict(PN_rdEnsyutu, 0, 0, _Flame, 0);
};
Game_Interpreter.prototype.RD_会話背景表示 = function (_ImgStr) {
    this.SetSpriteFIn(PN_rdBTalkBack, _ImgStr, 0, 0, 0, 0, 15, 255);
}
let RD階層KeepFDeck = [];
Game_Interpreter.prototype.RD_階層登る処理 = function () {
    RD階層KeepFDeck = CopyArr($gameSystem.Btl_Chara.FDeck);
    $gameVariables.setValue(VN_RdKaiso, $gameVariables.value(VN_RdKaiso) + 1);
    RD_Stop = true;
    this.rd_TalkUIOpiAll_0(); 
    this.PS_DngnSel_DgnStart(); 
}
