BT24_065.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Diaboromon (X Antibody)
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_065 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Diaboromon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Overclock
  24. if (timing == EffectTiming.OnEndTurn)
  25. {
  26. cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Unidentified", isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Blocker
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region When Digivolving
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("De-digivolve 1 opponent's Digimon. Delete all their highest play cost Digimon.", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  41. cardEffects.Add(activateClass);
  42. string EffectDescription() => "[When Digivolving] To 1 of your opponent's Digimon, <De-Digivolve 1> for each of your Digimon. Then, delete all of your opponent's Digimon with the highest play cost.";
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleArea(card)
  46. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleArea(card);
  51. }
  52. bool CanSelectPermanentCondition(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  55. }
  56. bool CanDeleteCondition(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsMaxCost(permanent, card.Owner.Enemy, true);
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. int digimonCount = card.Owner.GetBattleAreaDigimons().Count;
  63. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  64. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  65. selectPermanentEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CanSelectPermanentCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: maxCount,
  71. canNoSelect: false,
  72. canEndNotMax: false,
  73. selectPermanentCoroutine: SelectPermanentCoroutine,
  74. afterSelectPermanentCoroutine: null,
  75. mode: SelectPermanentEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. selectPermanentEffect.SetUpCustomMessage($"Select 1 digimon to <De-Digivolve 1> {digimonCount} times", "Opponent is selecting a Digimon to De-Digivolve.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  80. {
  81. if (permanent != null)
  82. {
  83. for (int i = 0; i < digimonCount; i++)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  86. }
  87. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(CanDeleteCondition);
  88. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  89. }
  90. }
  91. }
  92. }
  93. #endregion
  94. #region All Turns OPT
  95. if (timing == EffectTiming.WhenRemoveField)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Play a Diaboromon", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  100. activateClass.SetHashString("BT24_65_AT_Play_Diaboromon");
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[All Turns] [Once Per Turn] When any of your Digimon with [Diaboromon] in their names would leave the battle area, you may play 1 [Diaboromon] from your hand or this Digimon's digivolution cards without paying the cost.";
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  109. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  114. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  115. || card.PermanentOfThisCard().DigivolutionCards.Any(CanSelectCardCondition));
  116. }
  117. bool PermanentCondition(Permanent permanent)
  118. {
  119. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  120. && permanent.TopCard.ContainsCardName("Diaboromon");
  121. }
  122. bool CanSelectCardCondition(CardSource cardSource)
  123. {
  124. return cardSource.EqualsCardName("Diaboromon")
  125. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable hashtable)
  128. {
  129. bool hasInHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  130. bool hasInSources = card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) > 0;
  131. bool selectedRoot = false;
  132. CardSource selectedCard = null;
  133. IEnumerator SelectCardCoroutine(CardSource cardSource)
  134. {
  135. selectedCard = cardSource;
  136. yield return null;
  137. }
  138. if (hasInHand || hasInSources)
  139. {
  140. if (hasInHand && hasInSources)
  141. {
  142. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  143. {
  144. new SelectionElement<bool>(message: $"From This Digimon", value: true, spriteIndex: 0),
  145. new SelectionElement<bool>(message: $"From Hand", value: false, spriteIndex: 1),
  146. };
  147. string selectPlayerMessage = "Choose where to get the Diaboromon from";
  148. string notSelectPlayerMessage = "The opponent is choosing effects.";
  149. GManager.instance.userSelectionManager.SetBoolSelection(
  150. selectionElements: selectionElements, selectPlayer: card.Owner,
  151. selectPlayerMessage: selectPlayerMessage,
  152. notSelectPlayerMessage: notSelectPlayerMessage);
  153. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  154. .userSelectionManager.WaitForEndSelect());
  155. selectedRoot = GManager.instance.userSelectionManager.SelectedBoolValue;
  156. }
  157. else if (hasInSources)
  158. {
  159. selectedRoot = true;
  160. }
  161. if (selectedRoot)
  162. {
  163. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  164. selectCardEffect.SetUp(
  165. canTargetCondition: CanSelectCardCondition,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. canNoSelect: () => true,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. message: "Select 1 card to play.",
  172. maxCount: 1,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. mode: SelectCardEffect.Mode.Custom,
  176. root: SelectCardEffect.Root.Custom,
  177. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  178. canLookReverseCard: true,
  179. selectPlayer: card.Owner,
  180. cardEffect: activateClass);
  181. selectCardEffect.SetUpCustomMessage("Select 1 Diaboromon to play", "The opponent is selecting 1 card to play");
  182. yield return StartCoroutine(selectCardEffect.Activate());
  183. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  184. new List<CardSource>() { selectedCard },
  185. activateClass: activateClass,
  186. payCost: false,
  187. isTapped: false,
  188. root: SelectCardEffect.Root.DigivolutionCards,
  189. activateETB: true));
  190. }
  191. else
  192. {
  193. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  194. selectHandEffect.SetUp(
  195. selectPlayer: card.Owner,
  196. canTargetCondition: CanSelectCardCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. maxCount: 1,
  200. canNoSelect: true,
  201. canEndNotMax: false,
  202. isShowOpponent: true,
  203. selectCardCoroutine: SelectCardCoroutine,
  204. afterSelectCardCoroutine: null,
  205. mode: SelectHandEffect.Mode.Custom,
  206. cardEffect: activateClass);
  207. selectHandEffect.SetUpCustomMessage("Select 1 Diaboromon to play", "The opponent is selecting 1 card to play");
  208. yield return StartCoroutine(selectHandEffect.Activate());
  209. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  210. new List<CardSource>() { selectedCard },
  211. activateClass: activateClass,
  212. payCost: false,
  213. isTapped: false,
  214. root: SelectCardEffect.Root.Hand,
  215. activateETB: true));
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. return cardEffects;
  222. }
  223. }
  224. }