BT18_042.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_042 : 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.EqualsCardName("Koji Minamoto") &&
  17. targetPermanent.DigivolutionCards.Count(cardSource => cardSource.ContainsTraits("Hybrid")) >= 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: true,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region When Digivolving/ End of Opponent's Turn Shared
  25. bool CanSelectSourceCardConditionShared(CardSource cardSource)
  26. {
  27. return cardSource.IsDigimon;
  28. }
  29. bool CanActivateConditionShared(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  32. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardConditionShared);
  33. }
  34. #endregion
  35. #region When Digivolving
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect(
  40. "Place Digivolution card as your bottom security card to delete all opponent's same level Digimon",
  41. CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, true, EffectDescription());
  43. activateClass.SetHashString("WDUnsuspend_BT18_042");
  44. cardEffects.Add(activateClass);
  45. string EffectDescription()
  46. {
  47. return
  48. "[When Digivolving] (Once Per Turn) By placing 1 Digimon card from this Digimon's digivolution cards as your bottom security card, delete all of your opponent's Digimon with the same level as the placed card.";
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. int chosenDigimonCardLevel = 0;
  57. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  58. selectCardEffect.SetUp(
  59. canTargetCondition: CanSelectSourceCardConditionShared,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. canNoSelect: () => true,
  63. selectCardCoroutine: SelectCardCoroutine,
  64. afterSelectCardCoroutine: null,
  65. message: "Select 1 digivolution card to place as bottom security card.",
  66. maxCount: 1,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. mode: SelectCardEffect.Mode.Custom,
  70. root: SelectCardEffect.Root.Custom,
  71. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  72. canLookReverseCard: true,
  73. selectPlayer: card.Owner,
  74. cardEffect: activateClass);
  75. selectCardEffect.SetUpCustomMessage(
  76. "Select 1 digivolution card to place as bottom security card.",
  77. "The opponent is selecting 1 digivolution card to place as bottom security card.");
  78. yield return StartCoroutine(selectCardEffect.Activate());
  79. IEnumerator SelectCardCoroutine(CardSource cardSource)
  80. {
  81. if (cardSource.IsACE) yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(new List<CardSource> { cardSource }).Overflow());
  82. yield return ContinuousController.instance.StartCoroutine(
  83. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  84. chosenDigimonCardLevel = cardSource.Level;
  85. }
  86. if (chosenDigimonCardLevel > 0)
  87. {
  88. List<Permanent> destroyTargetPermanents =
  89. card.Owner.Enemy.GetBattleAreaDigimons().Filter(permanent => permanent.Level == chosenDigimonCardLevel);
  90. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  91. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  92. }
  93. }
  94. }
  95. #endregion
  96. #region End of Opponent's Turn
  97. if (timing == EffectTiming.OnEndTurn)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect(
  101. "Place Digivolution card as your bottom security card to delete all opponent's same level Digimon",
  102. CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, 1, true, EffectDescription());
  104. activateClass.SetHashString("EOTUnsuspend_BT18_042");
  105. cardEffects.Add(activateClass);
  106. string EffectDescription()
  107. {
  108. return
  109. "[End of Opponent's Turn] (Once Per Turn) By placing 1 Digimon card from this Digimon's digivolution cards as your bottom security card, delete all of your opponent's Digimon with the same level as the placed card.";
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  114. CardEffectCommons.IsOpponentTurn(card);
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable hashtable)
  117. {
  118. int chosenDigimonCardLevel = 0;
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: CanSelectSourceCardConditionShared,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => true,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 digivolution card to place as bottom security card.",
  128. maxCount: 1,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.Custom,
  133. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. selectCardEffect.SetUpCustomMessage(
  138. "Select 1 digivolution card to place as bottom security card.",
  139. "The opponent is selecting 1 digivolution card to place as bottom security card.");
  140. yield return StartCoroutine(selectCardEffect.Activate());
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. if (cardSource.IsACE) yield return ContinuousController.instance.StartCoroutine(new AceOverflowClass(new List<CardSource> { cardSource }).Overflow());
  144. yield return ContinuousController.instance.StartCoroutine(
  145. CardObjectController.AddSecurityCard(cardSource, toTop: false));
  146. chosenDigimonCardLevel = cardSource.Level;
  147. }
  148. if (chosenDigimonCardLevel > 0)
  149. {
  150. List<Permanent> destroyTargetPermanents =
  151. card.Owner.Enemy.GetBattleAreaDigimons().Filter(permanent => permanent.Level == chosenDigimonCardLevel);
  152. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  153. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  154. }
  155. }
  156. }
  157. #endregion
  158. #region All Turns
  159. if (timing is EffectTiming.OnAllyAttack or EffectTiming.OnCounterTiming)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("By adding the top card of your security stack to the hand, unsuspend this Digimon",
  163. CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  165. activateClass.SetHashString("ATUnsuspend_BT18_042");
  166. cardEffects.Add(activateClass);
  167. string EffectDescription()
  168. {
  169. return
  170. "[All Turns] (Once Per Turn) When a Digimon attacks, by adding the top card of your security stack to the hand, unsuspend this Digimon.";
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  175. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  176. }
  177. bool PermanentCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  184. card.Owner.SecurityCards.Count >= 1;
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. CardSource topCard = card.Owner.SecurityCards[0];
  189. yield return ContinuousController.instance.StartCoroutine(
  190. CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false,
  191. activateClass));
  192. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  193. player: card.Owner,
  194. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  195. activateClass).ReduceSecurity());
  196. yield return ContinuousController.instance.StartCoroutine(
  197. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  198. }
  199. }
  200. #endregion
  201. return cardEffects;
  202. }
  203. }
  204. }