let STY_BttleSetUp = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    STY_BttleSetUp.call(this);
    this.Btl_Chara = null;      
};
let BtlChara_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    BtlChara_NUpdateSc.call(this);
    if ($gameSystem.Btl_Chara == null) {
        this.BtlCharaSetting("Romasha");
    }
}
class Btl_Live2D {
    constructor(modelName, zureX, zureY, waitMotion) {
        zureX = typeof zureX !== 'undefined' ? zureX : 0;
        zureY = typeof zureY !== 'undefined' ? zureY : 0;
        waitMotion = typeof waitMotion !== 'undefined' ? waitMotion : "wait";
        this.Name = modelName;
        this.ZureX = zureX;
        this.ZureY = zureY;
        this.WaitMotion = waitMotion;
    }
}
class Btl_Chara {
    constructor(name, loadLive2DArr, live2D, btlLive2D, rericArr, maxHp, baseMp, drawCnt, firstDeck, packId) {
        rericArr = typeof rericArr !== 'undefined' ? rericArr : 0;
        maxHp = typeof maxHp !== 'undefined' ? maxHp : 180;
        baseMp = typeof baseMp !== 'undefined' ? baseMp : 4;
        drawCnt = typeof drawCnt !== 'undefined' ? drawCnt : 5;
        firstDeck = typeof firstDeck !== 'undefined' ? firstDeck : [];
        packId = typeof packId !== 'undefined' ? packId : 0;
        this.Name = name;      
        this.LoadLive2DArr = loadLive2DArr;
        this.Live2D = live2D;  
        this.BtlLive2D = btlLive2D; 
        this.RericArr = rericArr;  
        this.MaxHP = maxHp;  
        this.回復MP = baseMp;  
        this.ベースMP = baseMp;  
        this.ドロー枚数 = drawCnt;  
        this.FDeck = firstDeck; 
        this.PackId = packId;
        this.反転Flg = false;   
        this.DeckImg = "PN_Deck";  
        if (name.indexOf("Romasha") != -1) {
            this.Live2D.WaitMotion = "batalle_bless";
        }
    }
}
let Btl_CharaData = []; 
Game_Interpreter.prototype.BtlCharaSetting = function (charaName) {
    for (let i = 0; i <= Btl_CharaData.length - 1; i++) {
        if (Btl_CharaData[i].Name == charaName) {
            $gameSystem.Btl_Chara = Btl_CharaData[i];
        }
    }
    switch ($gameSystem.Btl_Chara.Name) {
        case "Romasha":
            BtlRomashaFlg = true;
            break;
    }
    PlayerBtlChara = $gameSystem.Btl_Chara;
    this.RD_WalkImgSetting(); 
    this.RD_MoveDeck_Setting(); 
}
Game_Interpreter.prototype.Btl_Chara_SetUp = function () {
    switch ($gameSystem.Btl_Chara.Name) {
        case "Romasha": 
            this.Btl_Romasha_SetUp();
            break;
    }
    PlayerBtlChara = $gameSystem.Btl_Chara;
};
let BtlRomashaFlg = false; 
Btl_CharaData.push(
    new Btl_Chara("Romasha", 
        ["romasha_talk", MdlRomashaBattle], 
        new Btl_Live2D(MdlRomashaBattle, 30), 
        new Btl_Live2D(MdlRomashaBattle, -55), 
        [],     
        180,   
        3,     
        5,     
        [],    
        141     
    )
);
Game_Interpreter.prototype.Btl_Romasha_SetUp = function (deckSkipFlg) {
    deckSkipFlg = typeof deckSkipFlg !== 'undefined' ? deckSkipFlg : false;
    let setFlg = false;
    if ($gameSystem.Btl_Chara == null) setFlg = true;
    if ($gameSystem.Btl_Chara != null) {
        if ($gameSystem.Btl_Chara.Name == "Romasha") setFlg = false;
        if ($gameSystem.Btl_Chara.FDeck.length == 0) setFlg = true;
    }
    if (setFlg) {
        this.BtlCharaSetting("Romasha");
        if (!deckSkipFlg) {
            RentalDeckSetting();
            $gameSystem.Btl_Chara.FDeck = CopyArr($gameSystem.DeckArr[$gameSystem.SelDeck]);
            BtlDeck = CopyArr($gameSystem.Btl_Chara.FDeck);
            $gameSystem.MasterDeck = CopyArr($gameSystem.Btl_Chara.FDeck);
            $gameSystem.Btl_Chara.回復MP = $gameVariables.value(VN_MpRpear);
            $gameSystem.Btl_Chara.ベースMP = $gameVariables.value(VN_MpBase);
        }
    }
    $gameSystem.Btl_Chara.RericArr = [];
    for (let i = 0; i <= 19 - 1; i++) {
        if ($gameActors.actor(1).hasArmor($dataArmors[i + 1])) { 
            menu装備No = i + 1;
            let rericNo = MetaChecker($dataArmors[menu装備No], "Reric", -1);
            if (rericNo != -1) {
                $gameSystem.Btl_Chara.RericArr = [Number(rericNo)]; 
            }
        }
    }
    this.BtlRericDraw(); 
    WaitMdl_Reset(); 
    L2dSetMotion(WaitMdlName, "battale_reset");
    L2dIdleStart(WaitMdlName, "battale_reset"); 
}
Game_Interpreter.prototype.Btl_Yudonge_SetUp = function () {
    WaitMdlName = $gameSystem.Btl_Chara.BtlLive2D;
    WaitMotionName = "wait";
    L2dSetMotion(WaitMdlName, "reset");
    L2dIdleStart(WaitMdlName, "reset"); 
}
let _SpinaSet_BtlChara = new Btl_Chara("spina_talk", 
    ["spina_talk"], 
    new Btl_Live2D("spina_talk", 30), 
    new Btl_Live2D("spina_talk", 50), 
    [],     
    170,   
    3,     
    5,     
    [390, 390, 390, 391, 391, 391, 392, 392, 392, 393, 393, 393], 
    143     
);
_SpinaSet_BtlChara.反転Flg = true;
_SpinaSet_BtlChara.DeckImg = "PN_SpDeck";    
Btl_CharaData.push(_SpinaSet_BtlChara);
