Game_Interpreter.prototype.Cng_TurnSetup = function () {
    StateSetup();
    StateSyoriEnd = false;
}
let StateSetup = function () {
    StateUpdateFlame = 0;
    StateSyoriNo = 0;
}
let btlTurnCngFlame = 0;
let enemyTurnFlg = false;
let _即TurnCngFlg = false; 
Game_Interpreter.prototype.ChangePhase_TurnChange = function (_set即TurnCngFlg) { 
    _set即TurnCngFlg = typeof _set即TurnCngFlg !== 'undefined' ? _set即TurnCngFlg : false;
    CardKoukaArr = []; 
    this.CardSelect(-1); 
    BtlData.Mode = EnBtlMode.TurnCheck;
    btlTurnCngFlame = 0;
    _即TurnCngFlg = _set即TurnCngFlg;
    this.DelSprite(PN_SetuWin);
}
let befTurnType; 
let EnBefTurn = {
    Player: 1,
    Enemy: 2,
    Mikata: 3,
    Skill: 4,
    EmSkill: 5
};
let BefTrashHandArr = []; 
let plTurnEndFlg = false; 
let turnEndEffectFlg = false; 
let NextTurnCardMoveSkip = false;
Game_Interpreter.prototype.BtlTurnCheck_Update = function () {
    if (btlTurnCngFlame == 0) {
        EasingStr = ""; 
        this.TurnCngPicDel(); 
        BtlData.Turn++; 
        this.SpriteCngColor(PN_EdBtn); 
        BefTrashHandArr = [];
        plTurnEndFlg = false;
        if (TurnCard[0]._No == -1 && !_即TurnCngFlg) {
            BefTrashHandArr = CardData.slice(); 
            for (let i = 0; i <= CardData.length - 1; i++) {
                let cardData = CardData[i].CardData;
                let keepFlg = false;
                if (CardKoukaCk(cardData, KSkill.手札に保留)) keepFlg = true;
                if (CardKoukaCk(cardData, KSkill.破棄TEnd) || CardKoukaCk(cardData, KSkill.破棄Max)
                    || CardData[i]._一時カード) {
                    keepFlg = true;
                    this.PicTranOut(CardData[i].setPNo, "123", 45);
                    continue;
                }
                if (CardKoukaCk_DType(cardData, DType.TEDmg)) continue;
                if (!keepFlg) { 
                    this.HandCard_TrashMove(CardData[i].setPNo);
                    CardData.splice(i, 1);
                    i--; 
                }
            }
            this.KeepCardMove();
            this.DeckMaisuView(); 
            plTurnEndFlg = true;
            turnEndEffectFlg = false;
        }
    }
    if (btlTurnCngFlame == 2 && !turnEndEffectFlg) { 
        if (plTurnEndFlg) this.TurnEndPlayer();
        turnEndEffectFlg = true; 
    }
    if (btlTurnCngFlame == 3) {
        if ($gameTroop._turnCount == 0) { 
            this.SetSprite(PN_TurnC_Back, "Black", 0, 0, 0);
            this.MoveSprite(PN_TurnC_Back, 0, 0, 15, 100);
            this.SetSprite(PN_TurnC_W, BtlPicPath + "PN_TurnC_W4", 0, 283, 0);
            this.SetSprite(PN_TurnC, BtlPicPath + "PN_TurnC4", -489, 315, 255);
            if (TurnCard[0]._Type == EnemyTCType.EmDoSkill) {
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.Enemy;
                $gameTroop._turnCount++;
            } else if (TurnCard[0]._Type == EnemyTCType.PlSkill) {
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.Skill;
                $gameTroop._turnCount++;
            } else {
                enemyTurnFlg = false;
                befTurnType = EnBefTurn.Player;
            }
            this.MoveSprite(PN_TurnC_W, 0, 283, 15, 255);
            this.MoveSprite(PN_TurnC, 386, 315, 15, 255);
        } else {
            if (!_即TurnCngFlg) { 
                if (!NextTurnCardMoveSkip) this.NextTCSetting(); 
                NextTurnCardMoveSkip = false;
            }
            BtlEnemyCellDmgFlg = false;
            if (TurnCard[0]._Type == EnemyTCType.PlSkill) { 
                btlTurnCngFlame = 75; 
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.Skill;
            } else if (TurnCard[0]._Type == EnemyTCType.EmSkill) { 
                btlTurnCngFlame = 75; 
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.EmSkill;
            } else if (TurnCard[0]._No == -1) { 
                this.SetSprite(PN_TurnC_Back, "Black", 0, 0, 0);
                this.MoveSprite(PN_TurnC_Back, 0, 0, 15, 100);
                this.SetSprite(PN_TurnC_W, BtlPicPath + "PN_TurnC_W", 0, 283, 0);
                this.SetSprite(PN_TurnC, BtlPicPath + "PN_TurnC", -489, 315, 255);
                enemyTurnFlg = false;
                befTurnType = EnBefTurn.Player;
                this.MoveSprite(PN_TurnC_W, 0, 283, 15, 255);
                this.MoveSprite(PN_TurnC, 386, 315, 15, 255);
            } else if (TurnCard[0]._No < -1) { 
                btlTurnCngFlame = 75; 
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.Mikata;
            } else { 
                if (befTurnType == EnBefTurn.Enemy) {
                    btlTurnCngFlame = 75; 
                } else {
                    this.SetSprite(PN_TurnC_Back, "Black", 0, 0, 0);
                    this.MoveSprite(PN_TurnC_Back, 0, 0, 15, 100);
                    this.SetSprite(PN_TurnC_W, BtlPicPath + "PN_TurnC_W2", 0, 283, 0);
                    this.SetSprite(PN_TurnC, BtlPicPath + "PN_TurnC2", -489, 315, 255);
                    this.MoveSprite(PN_TurnC_W, 0, 283, 15, 255);
                    this.MoveSprite(PN_TurnC, 386, 315, 15, 255);
                }
                enemyTurnFlg = true;
                befTurnType = EnBefTurn.Enemy;
            }
        }
    }
    if (btlTurnCngFlame == 15) {
        this.CardSelect(-1); 
        this.MoveSprite(PN_TurnC, 514, 315, 45, 255);
    }
    if (btlTurnCngFlame == 60) {
        this.MoveSprite(PN_TurnC_Back, 0, 0, 15, 0);
        this.MoveSprite(PN_TurnC_W, 0, 283, 15, 0);
        this.MoveSprite(PN_TurnC, 1543, 315, 30, 0);
    }
    if (btlTurnCngFlame == 75) { 
        if (enemyTurnFlg) {
            this.ChangePhase_EnemyTurn();
        } else {
            this.ChangePhase_PlayerTurnSetup();
        }
    }
    btlTurnCngFlame++;
}
let StateSyoriEnd = false; 
let btlターン使用カード枚数 = 0;
let PLSetFlame = 0; 
let drawCardCount = 0;   
Game_Interpreter.prototype.ChangePhase_PlayerTurnSetup = function () {
    if (DefBtnCoolTime > 0) {
        DefBtnCoolTime--;
        this.DefBtn_Draw();
    }
    this.Cng_TurnSetup();
    BtlData.Mode = EnBtlMode.PLTurnSetup;
    PLSetFlame = 0;
    notUseCardFlg = false; 
    for (let i = 0; i <= NEnemy.length - 1; i++) {
        if (NEnemy[i]._hp <= 0 && !NEnemy[i].FstHidden) {
            $gameSwitches._data[BtlEnemy行動Check.SW_EnemyDownNextTurn + i] = (NEnemy[i]._hp <= 0);
            if (NEnemy[i].RebornEmFlg == undefined) NEnemy[i].RebornEmFlg = false;
            if (NEnemy[i].RebornEmFlg) {
                $gameSwitches._data[BtlEnemy行動Check._復活EnemyDownNextTn + i] = (NEnemy[i]._hp <= 0);
            }
        }
    }
}
Game_Interpreter.prototype.PlayerTurnSetup_End = function () {
    let mpDownCounter = 0;
    for (let i = 0; i <= CardData.length - 1; i++) {
        let reDrawMp = false;
        if (CardKoukaCk(CardData[i].CardData, KSkill.常時MP1減)) {
            mpDownCounter++;
            NPlayer[0]._mp--;
            reDrawMp = true;
        }
        if (CardKoukaCk(CardData[i].CardData, KSkill.常時MP2減)) {
            mpDownCounter += 2;
            NPlayer[0]._mp -= 2;
            reDrawMp = true;
        }
        if (NPlayer[0]._mp <= 0) NPlayer[0]._mp = 1; 
        if (reDrawMp) this.MPKaihuku(0);
    }
    if (mpDownCounter > 0) this.TextPopUp_ENo(-1, SCol.Red + "MP-" + mpDownCounter, 24);
}
let Btl最初のドローFlg = false;
let IsPlayerSelect = false;
Game_Interpreter.prototype.BtlPLTurnSetup_Update = function () {
    if (!StateSyoriEnd) {
        this.StateUpdate(-1);
    } else {
        if (PLSetFlame == 0) {
            _手札PopReset = [];
            btlターン使用カード枚数 = 0;
            IsPlayerSelect = true;
            NPlayer[0]._TurnCount++; 
            drawCardCount = GetTurnStartDrawValue(); 
            this.MPKaihuku(GetTurnStartRecoveryMP() , false); 
            if (NPlayer[0]._mp <= GetPlayerMaxMp()) {
                NPlayer[0]._mp = GetPlayerMaxMp();
            }
            if (BtlData.Turn <= 3) { 
                NPlayer[0]._mp += RDBtlSettingData.NextBtl_MpUp; 
                RDBtlSettingData.NextBtl_MpUp = 0;
            }
            NPlayer[0]._mp += RDBtlSettingData.Btl_MpUp; 
            this.TurnEndBtnDraw();
            BefSelectNo = -2;
            this.CardSelect(-1); 
            if (drawCardCount > 0 && CardData.length < BtlStatic._手札最大枚数 && Btl最初のドローFlg) {
                if ($gameSwitches.value(SW_ゴブリンパート)) {
                    this.PVoice("romasha","h1_436_nn");
                } else {
                    this.PRandVoice("romasha",["btl_377_doro","btl_378_doros","btl_379_watas","btl_380_dekki"]);
                }
            }
            Btl最初のドローFlg = true;
            for (let i = 0; i < drawCardCount; i++) {
                AddCardDrawStac();
            }
            for (let i = 0; i < RDBtlSettingData.NextBtl_DrawUp; i++) {
                AddCardDrawStac();
            }
            for (let i = 0; i < RDBtlSettingData.Btl_DrawUp; i++) {
                AddCardDrawStac();
            }
            if (BtlData.Turn == 1) { 
                for (let i = 0; i < RDBtlSettingData.NextBtl_StartDrawUp; i++) {
                    AddCardDrawStac();
                }
            }
            this.SetCmnEvent(BtlStatic.CN_称号処理);
        }
        if (PLSetFlame == 10) {
            this.DefBtn_Draw(); 
            this._ターン開始時レリック効果発動();
            this.PlayerTurnSetup_End();
            this.ChangePhase_CardSelect();
            $gameTroop.increaseTurn(); 
        }
        PLSetFlame++;
    }
}
let EnemyUseSkillId = null; 
let EnemyNomalAnimeId = -1;  
let SetEnemyLogText = "";
let EnemyAtkAnimeId = 1;   
let EnemySkillAnimeId = -1;  
let UseSkillIconStr = ""; 
let EnemyDrawSkillText = ""; 
let EnemyNo毎ターンコモン = -1;
Game_Interpreter.prototype.ChangePhase_EnemyTurn = function () { 
    this.Cng_TurnSetup(); 
    BtlData.Mode = EnBtlMode.EnemyTurn; 
    EmTurnFlame = 0;
    EnemyAtkAnimeId = 0;
    EnemySkillAnimeId = 0;
    CardSkills = []; 
    memoSkillArr = []; 
    UseCard_SkillCounter = 0; 
    cardUseEffTimer = 0;
    cardUseMoveTimer = 0;
    _SWCngFlg = _CmnGoFlg = false;
    let turnENo = TurnCard[0]._No; 
    switch (befTurnType) {
        case EnBefTurn.Mikata:
            turnENo = -turnENo - 1;
            EnemyAtkAnimeId = MetaChecker(NPlayer[turnENo].enemy(), "AtkAnimeNo", 1);
            NPlayer[turnENo]._TurnCount++; 
            EUseSkillPtnId = NPlayer[turnENo]._UsePtnNo; 
            //レーティングが8(一度だけの実行)なら、ワンショットフラグに入れる
            if (GetEnemyData_ENo(TurnCard[0]._No).actions[EUseSkillPtnId].rating == 8) {
                NPlayer[turnENo]._OneSkillNo.push(EUseSkillPtnId);
            }
            GetSkillMemoData(NPlayer[turnENo].enemy(), NPlayer[turnENo]._UsePtnNo);
            var ckCmnStr = MetaChecker(NPlayer[turnENo].enemy(), "毎ターンCmn", "");
            if (ckCmnStr != "") this.Btl毎ターンCmnStart(Number(ckCmnStr));
            break;
        case EnBefTurn.Enemy:
            turnENo = TurnCard[0]._No;
            EnemyAtkAnimeId = MetaChecker(NEnemy[turnENo].enemy(), "AtkAnimeNo", 1);
            if (!NEnemy[turnENo]._FstTn) NEnemy[turnENo]._TurnCount++; 
            NEnemy[turnENo]._FstTn = false; 
            EUseSkillPtnId = NEnemy[turnENo]._UsePtnNo; 
            //レーティングが8(一度だけの実行)なら、ワンショットフラグに入れる
            if (GetEnemyData_ENo(turnENo).actions[EUseSkillPtnId].rating == 8) {
                NEnemy[turnENo]._OneSkillNo.push(EUseSkillPtnId);
            }
            if (TurnCard[0]._Type == EnemyTCType.EmDoSkill) {
                EUseSkillPtnId = -1;
                GetSkillMemoData(NEnemy[turnENo].enemy(), -2);
            } else {
                GetSkillMemoData(NEnemy[turnENo].enemy(), NEnemy[turnENo]._UsePtnNo);
            }
            EnemyNo毎ターンコモン = NEnemy[turnENo].enemy().id;
            var ckCmnStr = MetaChecker(NEnemy[turnENo].enemy(), "毎ターンCmn", "");
            if (ckCmnStr != "") this.Btl毎ターンCmnStart(Number(ckCmnStr));
            break;
        case EnBefTurn.Skill: 
        case EnBefTurn.EmSkill:
            EnemyNomalAnimeId = -1;
            let weaponData = $dataWeapons[TurnCard[0]._No];
            UseCard = new Card(weaponData);
            EnemyAtkAnimeId = weaponData.animationId;
            EnemyDrawSkillText = "\\I[" + weaponData.iconIndex + "] " + weaponData.name;
            for (let i = 0; i <= weaponData.traits.length - 1; i++) {
                if (weaponData.traits[i].code == 43) {
                    let skillData = $dataSkills[weaponData.traits[i].dataId];
                    if (skillData.damage.elementId != DType.TCDelay) { 
                        CardSkills_Add(weaponData.traits[i].dataId); 
                        SetEnemyLogText = "";
                        try {
                            if (skillData.message2 != "" && skillData.message2 != undefined) { 
                                SetEnemyLogText = skillData.message2.replace("%1", skillData.name);
                            }
                        } catch (e) {
                            console.log("No_Btl_message");
                        }
                    }
                }
            }
            return; 
    }
    if (TurnCard[0]._Type == EnemyTCType.EmDoSkill) {
        EnemyUseSkillId = TurnCard[0]._SkillNo;
    } else {
        EnemyUseSkillId = GetEnemyData_ENo(TurnCard[0]._No).actions[EUseSkillPtnId].skillId;
    }
    EnemyNomalAnimeId = $dataSkills[EnemyUseSkillId].animationId;
    EnemySkillAnimeId = MetaChecker(GetEnemyData_ENo(TurnCard[0]._No), "SAni" + (EUseSkillPtnId + 1), -1);
    //EUseSkillId(使用スキルID)から、実際に処理で使う項目を抜き出し
    SetEnemyLogText = "";
    let skillIconIndex = $dataSkills[EnemyUseSkillId].iconIndex;
    let sIconStr = MetaChecker(GetEnemyData_ENo(TurnCard[0]._No), "Sico" + (EUseSkillPtnId + 1), -1);
    if (sIconStr != -1) skillIconIndex = sIconStr;
    let sIconText = "\\I[" + skillIconIndex + "]";
    UseSkillIconStr = sIconText;
    EnemyDrawSkillText = "";
    if ($dataSkills[EnemyUseSkillId].name.indexOf("::") == -1) {
        EnemyDrawSkillText = sIconText + $dataSkills[EnemyUseSkillId].name;
    } else {
        let setEnemySkillText = _以降文字削除($dataSkills[EnemyUseSkillId].name, "::");
        if (memoSkillArr.length > 0) {
            setEnemySkillText = memoSkillArr[0];
        }
        if (setEnemySkillText != "") {
            EnemyDrawSkillText = sIconText + setEnemySkillText;
        }
    }
    try {
        let setMessage1 = $dataSkills[EnemyUseSkillId].message1.replace("%1", $dataSkills[EnemyUseSkillId].name);
        if (setMessage1 != "") {
            if (befTurnType == EnBefTurn.Mikata) {
                SetEnemyLogText = NPlayer[turnENo]._name + setMessage1; 
            } else {
                SetEnemyLogText = NEnemy[turnENo]._name + setMessage1; 
            }
        }
        if ($dataSkills[EnemyUseSkillId].message2 != "" && $dataSkills[EnemyUseSkillId].message2 != undefined) { 
            SetEnemyLogText = $dataSkills[EnemyUseSkillId].message2.replace("%1", $dataSkills[EnemyUseSkillId].name);
        }
    } catch (ex) {
        console.log("No_Btl_message");
    }
    CardSkills_Add(EnemyUseSkillId);
}
let Btl毎ターンCmnPlay中 = false;
Game_Interpreter.prototype.Btl毎ターンCmnStart = function (playCmnNo) {
    Btl毎ターンCmnPlay中 = true;
    this.SetCmnEvent(playCmnNo);
}
Game_Interpreter.prototype.Btl毎ターンCmnEnd = function () {
    Btl毎ターンCmnPlay中 = false;
}
let _SkillOneEffectAnime = null;
class SkillOneEffect {
    constructor() {
        this.AnimeId = -1;
        this.Ptc = "";
        this.ComboFlg = false;
        this.SetX = 0;
        this.SetY = 0;
    }
}
let _Skill吸血Dmg = 0;
let CardSkills_Add = function (skillId) {
    _Skill吸血Dmg = 0;
    _SkillOneEffectAnime = null;
    if (MetaChecker($dataSkills[skillId] , "OneEff" , true) == "") {
        _SkillOneEffectAnime = new SkillOneEffect();
        if ($dataSkills[skillId].animationId == AN_PtcNo || $dataSkills[skillId].animationId == AN_KPtcNo) {
            let ptcMemoStr = "";
            let memoStr = "Ptc";
            if ($dataSkills[skillId].animationId == AN_KPtcNo) {
                memoStr = "KPtc";
                _SkillOneEffectAnime.ComboFlg = true;
            }
            _SkillOneEffectAnime.Ptc = MetaChecker($dataSkills[skillId], memoStr, "");
            let ckArr = ptcMemoStr.split(',');
            if (ckArr.length > 1) { 
                _SkillOneEffectAnime.SetX += Number(ckArr[1]);
            }
            if (ckArr.length > 2) { 
                _SkillOneEffectAnime.SetY += Number(ckArr[2]);
            }
        } else {
            _SkillOneEffectAnime.AnimeId = $dataSkills[skillId].animationId;
        }
    }
    let oneSkillFlg = true;
    for (let i = 0; i <= $dataSkills[skillId].effects.length - 1; i++) {
        if ($dataSkills[skillId].effects[i].code == 43) {
            let setId = $dataSkills[skillId].effects[i].dataId;
            CardSkills.push($dataSkills[setId]);
            oneSkillFlg = false;
        }
    }
    if (oneSkillFlg) CardSkills.push($dataSkills[skillId]);
}
let GetTurnStartRecoveryMP = function () {
    let ckState = NPlayer[0]._NState;  
    let sumValue = GetStateTypeSumValue(ckState, StType.MPRecUp); 
    let recoverMP = $gameSystem.Btl_Chara.回復MP;
    let rtnValue = recoverMP + sumValue;
    if (BtlRomashaFlg) {
        if ($gameActors._data[1].equips()[3] != null) {
            rtnValue += $gameActors._data[1].equips()[3].params[1];
        }
    }
    return rtnValue;
}
let GetPlayerMaxMp = function () {
    let ckState = NPlayer[0]._NState;  
    let cngValue = GetStateTypeSumValue(ckState, StType.MPRecUp); 
    let baseMP = $gameSystem.Btl_Chara.ベースMP;
    let rtnMaxMp = baseMP + cngValue;
    return rtnMaxMp;
}
let GetTurnStartDrawValue = function () {
    let ckNState = NPlayer[0]._NState;  
    let cngValue = GetStateTypeSumValue(ckNState, StType.DrawUp);
    let baseDraw = $gameSystem.Btl_Chara.ドロー枚数;
    if (BtlRomashaFlg) {
        baseDraw = $gameVariables.value(VN_DrowCard);
        if ($gameActors._data[1].equips()[3] != null) {
            baseDraw += $gameActors._data[1].equips()[3].params[6]; //称号(防具)の敏捷はドロー追加
        }
    }
    let rtnDraw = baseDraw + cngValue;
    if (rtnDraw < 0) rtnDraw = 0;
    return rtnDraw;
}
Game_Interpreter.prototype.HandCard_TrashMove = function (cardPicNo) {
    $gameScreen.rotatePicture(cardPicNo, 40);
    EasingStr = "easeOutQuad";
    this.MovePict(cardPicNo, 977, 759, 45, 255, 0, 0);
    EasingStr = "";
}
Game_Interpreter.prototype.TurnCngPicDel = function () {
    for (let i = 0; i <= NEnemy.length - 1; i++) {
        if (NEnemy[i]._hp < 1) {
            continue;
        }
        Alpha0Sprite(PN_RockOn + i);
    }
    for (let i = PN_RockOn; i <= PN_RockOnPL + 3; i++) {
        Alpha0Sprite(i);
    }
    for (let i = 0; i <= 8 - 1; i++) {
        Alpha0Sprite(PN_T_Setu + 3 + i);
    }
    Alpha0SpriteSpan(PN_SetuC, PN_Setu_End);
}
let _手札AtkChange = 0;
let _手札UseDamage = 0;
let _手札UseSexUp = 0;
let _所持3ターン敗北Flg = false;
let _所持3ターン敗北Turn = 0;
let _Turn常時効果ViewArr = [];
Game_Interpreter.prototype._手札PopReset = function () {
    _Turn常時効果ViewArr = [];
}
Game_Interpreter.prototype.TurnEndPlayer = function () {
    this.AdSysCt_CountDown(1); 
    this._手札常在効果確認(); 
    if (_所持3ターン敗北Flg) {
        for (let i = 0; i <= CardData.length - 1; i++) {
            for (let j = 0; j <= CardData[i].CardData.traits.length - 1; j++) {
                if (CardData[i].CardData.traits[j].code == 43) { 
                    let _ckId = CardData[i].CardData.traits[j].dataId;
                    switch (_ckId) {
                        case KSkill.所持3ターン敗北:
                            CardData[i].Cost++;
                            break;
                    }
                }
            }
        }
        _所持3ターン敗北Turn++;
        this._手札PopUp(-1, SCol.Red + "石化：残り" + (3 - _所持3ターン敗北Turn) + "ターン", 24);
        this.AddState_ENo(-1 , STNo_石化中 , (3 - _所持3ターン敗北Turn + 1));
        if (_所持3ターン敗北Turn == 3) {
            LoseSetFlg = true;
            RD_Flg = false; 
            RD_Keep_NPlayer = null; 
            this.DelSpriteSpan(PN_SetuC , PN_Setu_End);
            this.DelPictSpan(PN_SetuC , PN_Setu_End);
            this.PL_石化演出(); 
            this.ChangePhase_EndBtl();
            return; 
        }
    }
    for (let i = 0; i <= CardData.length - 1; i++) { 
        UseCard = CardData[i];
        let card破棄Flg = false;
        let breakFlg = false;
        for (let j = 0; j <= CardData[i].CardData.traits.length - 1; j++) {
            UseCard = CardData[i]; 
            if (UseCard.CardData.traits[j].code == 43) { 
                let skillId = UseCard.CardData.traits[j].dataId;
                let setDamageType = $dataSkills[skillId].damage.elementId;
                if ($dataSkills[skillId].damage.type == 0) setDamageType = -1;
                let calcValue = GetSkillCalcValue(-1, skillId); 
                let animeId = UseCard.CardData.animationId;
                switch (setDamageType) {
                    case DType.TESknCng: 
                        if (animeId > 0) this.PlayAnimeTopBtlChara(-1, animeId);
                        if ($gameVariables._data[VN_Seikan] == undefined) $gameVariables._data[VN_Seikan] = 0;
                        $gameVariables._data[VN_Seikan] = $gameVariables._data[VN_Seikan] + calcValue;
                        this.TextPopUp_ENo(-1, SCol.Red + "性感値上昇+" + calcValue, 24);
                        if ($gameVariables._data[VN_Seikan] < 0) $gameVariables._data[VN_Seikan] = 0;
                        if ($gameVariables._data[VN_Seikan] > 100) $gameVariables._data[VN_Seikan] = 100;
                        break;
                    case DType.TEDmg: 
                        if (animeId > 0) this.PlayAnimeTopBtlChara(-1, animeId);
                        SetEnemyDmgStac(DType.Dmg, -1, 15, calcValue);     
                        break;
                }
                if (CardKoukaCk(CardData[i].CardData, KSkill.破棄TEnd) ||
                    CardKoukaCk(CardData[i].CardData, KSkill.破棄Max) || CardData[i]._一時カード) {
                    card破棄Flg = true;
                }
            }
            if (breakFlg) break;
        }
        if (card破棄Flg) {
            for (let di = 0; di <= BtlDeck.length - 1; di++) {
                if (BtlDeck[di] == UseCard.CardData.id) {
                    BtlDeck.splice(di, 1);
                    break;
                }
            }
        }
        if (!CardKoukaCk(CardData[i].CardData, KSkill.手札に保留)) {
            this.HandCard_TrashMove(CardData[i].setPNo);
            CardData.splice(i, 1); 
            i--; 
        }
    }
    this.SetCmnEvent(CN_StTurnEnd); 
}
BattleManager.isTurnEnd = function() {
    return BtlData.Mode == EnBtlMode.EnemyTurn;
};
