P_140.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.P
  4. {
  5. public class P_140 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Digivolution Condition
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4 && targetPermanent.TopCard.CardTraits.Contains("Insectoid");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. #endregion
  20. #region Evade
  21. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  22. {
  23. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region All Turns
  27. if (timing == EffectTiming.None)
  28. {
  29. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  30. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  31. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  32. cardEffects.Add(canNotAffectedClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (card.PermanentOfThisCard().IsSuspended)
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. bool CardCondition(CardSource cardSource)
  45. {
  46. if (cardSource == card)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (cardSource == card.PermanentOfThisCard().TopCard)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool SkillCondition(ICardEffect cardEffect)
  59. {
  60. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  61. {
  62. if (cardEffect.IsDigimonEffect)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. }
  70. #endregion
  71. #region Inherit
  72. if (timing == EffectTiming.OnEndBattle)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  77. activateClass.SetIsInheritedEffect(true);
  78. activateClass.SetHashString("TrashSecurity_P_140");
  79. cardEffects.Add(activateClass);
  80. string EffectDiscription()
  81. {
  82. return "[Your Turn][Once Per Turn] When this Digimon deletes an opponent's Digimon in battle, trash the top card of your opponent's security stack.";
  83. }
  84. bool CanUseCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleArea(card))
  87. {
  88. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  89. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  90. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(
  91. hashtable: hashtable,
  92. winnerCondition: WinnerCondition,
  93. loserCondition: LoserCondition,
  94. isOnlyWinnerSurvive: false))
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. if (CardEffectCommons.IsExistOnBattleArea(card))
  104. {
  105. return true;
  106. }
  107. return false;
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  112. player: card.Owner.Enemy,
  113. destroySecurityCount: 1,
  114. cardEffect: activateClass,
  115. fromTop: true).DestroySecurity());
  116. }
  117. }
  118. #endregion
  119. return cardEffects;
  120. }
  121. }
  122. }