BT24_080.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. // Megidramon
  8. public class BT24_080 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Name Rule
  14. if (timing == EffectTiming.None)
  15. {
  16. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  17. changeCardNamesClass.SetUpICardEffect("Also treated as [ChaosGallantmon]", CanUseCondition, card);
  18. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: ChangeCardNames);
  19. cardEffects.Add(changeCardNamesClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. List<string> ChangeCardNames(CardSource cardSource, List<string> CardNames)
  25. {
  26. if (cardSource == card)
  27. {
  28. CardNames.Add("ChaosGallantmon");
  29. }
  30. return CardNames;
  31. }
  32. }
  33. #endregion
  34. #region Trash End of Your Turn
  35. if (timing == EffectTiming.OnEndTurn)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("1 [Dark Dragon] or [Evil Dragon] may digivolve into this", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  40. activateClass.SetIsDigimonEffect(true);
  41. cardEffects.Add(activateClass);
  42. string EffectDescription()
  43. {
  44. return "[Trash] [End of Your Turn] If you have 4 or fewer cards in your hand, 1 of your [Dark Dragon] or [Evil Dragon] trait Digimon may digivolve into this card without paying the cost.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.IsOwnerTurn(card)
  49. && CardEffectCommons.IsExistOnTrash(card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnTrash(card)
  54. && card.Owner.HandCards.Count <= 4;
  55. }
  56. bool CanSelectPermanentCondition(Permanent permanent)
  57. {
  58. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  59. && (permanent.TopCard.EqualsTraits("Dark Dragon")
  60. || permanent.TopCard.EqualsTraits("Evil Dragon"))
  61. && card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage(
  80. "Select 1 Digimon that will digivolve.",
  81. "The opponent is selecting 1 Digimon that will digivolve.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  86. targetPermanent: permanent,
  87. cardCondition: null,
  88. payCost: false,
  89. reduceCostTuple: null,
  90. fixedCostTuple: null,
  91. ignoreDigivolutionRequirementFixedCost: -1,
  92. isHand: false,
  93. activateClass: activateClass,
  94. successProcess: null,
  95. ignoreSelection: true));
  96. }
  97. }
  98. }
  99. #endregion
  100. #region Blocker
  101. if (timing == EffectTiming.None)
  102. {
  103. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  104. }
  105. #endregion
  106. #region Shared OP / WD / OD
  107. string SharedEffectName() => "Delete all opponent's lowest level digimon";
  108. string SharedEffectDescription(string tag) => $"[{tag}] Delete all of your opponent's lowest level Digimon.";
  109. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  110. bool SharedCanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  111. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  112. {
  113. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(SharedCanSelectPermanentCondition);
  114. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  115. }
  116. #endregion
  117. #region On Play
  118. if (timing == EffectTiming.OnEnterFieldAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  122. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  123. cardEffects.Add(activateClass);
  124. bool CanUseCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  127. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  128. }
  129. }
  130. #endregion
  131. #region When Digivolving
  132. if (timing == EffectTiming.OnEnterFieldAnyone)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  136. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  137. cardEffects.Add(activateClass);
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  141. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  142. }
  143. }
  144. #endregion
  145. #region On Deletion
  146. if (timing == EffectTiming.OnDestroyedAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("On Deletion"));
  151. cardEffects.Add(activateClass);
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  159. }
  160. }
  161. #endregion
  162. return cardEffects;
  163. }
  164. }
  165. }