public IEnumerator Trap(TriggerType trigger, List <Card> cards, EventBlock block)
    {
        yield return(null);

        Card openTrap = null;

        switch (trigger)
        {
        case TriggerType.TakeAttack:
            AttackBlock atkBlock = block as AttackBlock;
            if (atkBlock == null)
            {
                yield break;
            }
            int damage    = block.GetCaster().AttackPower;
            int needValue = 0;    //必要な最低値
            if (atkBlock.GetTarget().GetComponent <Player>())
            {
                damage -= player.Defence;
                if (damage >= player.Life)
                {
                    needValue = damage - player.Life;
                }
                else if (damage > 0)
                {
                    needValue = 1;
                }
            }
            else
            {
                damage   -= atkBlock.GetTarget().GetComponent <Card>().State.defence;
                needValue = damage + 1;
            }
            foreach (Card c in cards)
            {
                foreach (CardEffect ce in c.State.Effect)
                {
                    foreach (EffectState es in ce.effectState)
                    {
                        if (es.effectType == EffectType.AttackAdd && es.value >= -needValue)
                        {
                            if (openTrap == null || openTrap.State.Cost > c.State.Cost)
                            {
                                openTrap = c;
                            }
                        }
                    }
                }
            }
            break;

        case TriggerType.TakeSkill:
            openTrap = cards[0];
            break;

        case TriggerType.TakeDispCard:
            CardDispBlock disp = block as CardDispBlock;
            if (disp.GetCards()[0].State.cardAligment == player.cardAligment)
            {
                openTrap = cards[0];
            }
            break;

        default:
            openTrap = cards[0];
            break;
        }

        if (openTrap)
        {
            yield return(new WaitForSeconds(0.5f));

            Constants.BATTLE.CardOpen(openTrap);
        }
    }
    /// <summary>
    /// 罠カードの発動待機
    /// </summary>
    /// <param name="trigger">発動できる罠カードの発動条件</param>
    /// <param name="caster">カードの発動権を持つプレイヤー</param>
    /// <returns></returns>
    public IEnumerator TrapPlayTime(TriggerType trigger, Player caster, EventBlock block)
    {
        //Debug.Log("Trap wait... as " + trigger);
        List <Card> cards = caster.GetCanPlayTrapCards(trigger);
        string      text  = "";

        switch (trigger)
        {
        case TriggerType.TakeAttack:
            AttackBlock atkBlock   = block as AttackBlock;
            string      targetName = "";
            GameObject  target     = atkBlock.GetTarget();
            if (target.GetComponent <Player>())
            {
                targetName = "あなた";
            }
            else
            {
                targetName = target.GetComponent <Card>().State.cardName;
            }
            text = "相手が" + targetName + "に攻撃しました";
            break;

        case TriggerType.TakeSkill:
            CardPlayBlock playBlock       = block as CardPlayBlock;
            string        skillName       = playBlock.GetCards()[0].State.cardName;
            string        skillTargetName = "";
            if (playBlock.GetTarget())
            {
                if (playBlock.GetTarget().GetComponent <Player>())
                {
                    skillTargetName = "あなた";
                }
                else
                {
                    skillTargetName = playBlock.GetTarget().GetComponent <Card>().State.cardName;
                }
                skillTargetName += "に";
            }

            text = "相手が" + skillTargetName + skillName + "を発動しました";
            break;

        case TriggerType.DraftStart:
            text = "相手ターン開始時です";
            break;

        case TriggerType.TakeDispCard:
            CardDispBlock dispBlock  = block as CardDispBlock;
            Card          targetCard = dispBlock.GetCards()[0];
            foreach (Card c in cards)
            {
                foreach (CardEffect ce in c.State.Effect)
                {
                    foreach (EffectState es in ce.effectState)
                    {
                        es.SetTarget(targetCard.gameObject);
                    }
                }
            }
            string dispCardName = dispBlock.GetCards()[0].State.cardName;
            text = "相手が" + dispCardName + "を捨てました";
            break;
        }
        text += "\n罠カードを発動しますか?";
        //発動可能なカードがあれば発動確認ウィンドウを出す
        if (cards.Count > 0)
        {
            if (!caster.isAI)
            {
                yield return(StartCoroutine(CardPlayWindow.CPW.CallWindow(text, cards, OnSelectedTrapCard)));
            }
            else
            {
                yield return(StartCoroutine(caster.GetComponent <Scond_AIScript>().Trap(trigger, cards, block)));
            }
        }
    }