BT18_052.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_052 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 &&
  17. targetPermanent.TopCard.EqualsTraits("Royal Base");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region On Play/When Digivolving Shared
  25. bool IsOpponenetsDigimon(Permanent permanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  28. }
  29. bool SharedCanActivateCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  32. return card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped) > 0;
  33. return false;
  34. }
  35. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  36. {
  37. int maxCount = card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped);
  38. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  39. selectPermanentEffect.SetUp(
  40. selectPlayer: card.Owner,
  41. canTargetCondition: IsOpponenetsDigimon,
  42. canTargetCondition_ByPreSelecetedList: null,
  43. canEndSelectCondition: null,
  44. maxCount: 1,
  45. canNoSelect: false,
  46. canEndNotMax: false,
  47. selectPermanentCoroutine: DeDigivolvePermanent,
  48. afterSelectPermanentCoroutine: null,
  49. mode: SelectPermanentEffect.Mode.Custom,
  50. cardEffect: activateClass);
  51. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  52. IEnumerator DeDigivolvePermanent(Permanent permanent)
  53. {
  54. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, maxCount, activateClass, true).Degeneration());
  55. }
  56. }
  57. #endregion
  58. #region On Play
  59. if (timing == EffectTiming.OnEnterFieldAnyone)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("For each of your face up security cards, <De-Digivolve 1> 1 of your opponent's Digimon", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, EffectDiscription());
  64. cardEffects.Add(activateClass);
  65. string EffectDiscription()
  66. {
  67. return "[On Play] For each of your face up security cards, <De-Digivolve 1> 1 of your opponent's Digimon.";
  68. }
  69. bool CanUseCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  72. }
  73. }
  74. #endregion
  75. #region When Digivolving
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("For each of your face up security cards, <De-Digivolve 1> 1 of your opponent's Digimon", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, EffectDiscription());
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[When Digivolving] For each of your face up security cards, <De-Digivolve 1> 1 of your opponent's Digimon.";
  85. }
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  89. }
  90. }
  91. #endregion
  92. #region All Turns - ESS
  93. if (timing == EffectTiming.OnEndBattle)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  98. activateClass.SetIsInheritedEffect(true);
  99. activateClass.SetHashString("TrashSecurity_BT18_052");
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. {
  103. return "[All Turns] [Once Per Turn] When this Digimon deletes an opponent's Digimon in battle, trash the top card of your opponent's security stack.";
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. if (CardEffectCommons.IsExistOnBattleArea(card))
  108. {
  109. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  110. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  111. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false))
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. if (CardEffectCommons.IsExistOnBattleArea(card))
  121. {
  122. return true;
  123. }
  124. return false;
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  129. player: card.Owner.Enemy,
  130. destroySecurityCount: 1,
  131. cardEffect: activateClass,
  132. fromTop: true).DestroySecurity());
  133. }
  134. }
  135. #endregion
  136. #region All Turns - Security
  137. if (timing == EffectTiming.None)
  138. {
  139. bool CanUseCondition()
  140. {
  141. if (CardEffectCommons.IsExistInSecurity(card, false))
  142. {
  143. if (CardEffectCommons.IsOpponentTurn(card))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool PermanentCondition(Permanent permanent)
  151. {
  152. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  153. {
  154. if (permanent.TopCard.EqualsTraits("Royal Base"))
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  162. permanentCondition: PermanentCondition,
  163. isInheritedEffect: false,
  164. card: card,
  165. condition: CanUseCondition));
  166. }
  167. #endregion
  168. return cardEffects;
  169. }
  170. }
  171. }