IEnumerator BattleAction()
    {
        try
        {
            int targetKey = TargetChanger.TargetIndex <= enemies.Count ? TargetChanger.TargetIndex : enemies.Count;
            targetEnemy = new KeyValuePair <int, Character>(targetKey, enemies[targetKey]);
        }
        catch
        {
            targetEnemy = new KeyValuePair <int, Character>(0, enemies[0]);
        }
        while (Card.selectedCards.Count != 0)
        {
            if (targetEnemy.Value == null)
            {
                targetEnemy = new KeyValuePair <int, Character> (0, enemies[0]);
            }
            int damage = DamageCalculator.DamageCalc(Card.selectedCards.Dequeue(), targetEnemy.Value);
            targetEnemy.Value.hp -= damage;
            targetEnemy.Value.Damage(damage);
            if (targetEnemy.Value.hp <= 0)
            {
                Destroy(targetEnemy.Value.transform.gameObject);
                enemies.RemoveAt(targetEnemy.Key);

                if (enemies.Count == 0)
                {
                    StartCoroutine(BattleFinish());
                    yield break;
                }
            }
            yield return(new WaitForSeconds(1));
        }

        while (enemySelectedCards.Count != 0)
        {
            int targetKey = Random.Range(0, servant.Count);

            targetEnemy = new KeyValuePair <int, Character>(targetKey, servant[targetKey]);
            int damage = DamageCalculator.DamageCalc(enemySelectedCards.Dequeue(), targetEnemy.Value);
            targetEnemy.Value.hp -= damage;
            targetEnemy.Value.Damage(damage);
            if (targetEnemy.Value.hp <= 0)
            {
                Destroy(targetEnemy.Value.transform.gameObject);
                servant.RemoveAt(targetEnemy.Key);

                if (servant.Count == 0)
                {
                    StartCoroutine(GameOver());
                    // gameover
                    yield break;
                }
            }

            yield return(new WaitForSeconds(1));
        }

        SetCard();
    }