BT18_079.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_079 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. // Any purple
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.IsTamer && targetPermanent.TopCard.CardColors.Contains(CardColor.Purple);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. // Koichi Kimura
  25. if (timing == EffectTiming.None)
  26. {
  27. bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.EqualsCardName("Koichi Kimura");
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  32. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  33. card: card, condition: null));
  34. }
  35. // Duskmon
  36. if (timing == EffectTiming.None)
  37. {
  38. bool PermanentCondition(Permanent targetPermanent)
  39. {
  40. return targetPermanent.TopCard.EqualsCardName("Duskmon");
  41. }
  42. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  43. permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false,
  44. card: card, condition: null));
  45. }
  46. #endregion
  47. #region On Play/ When Digivolving Shared
  48. int OpponentColorCount()
  49. {
  50. List<CardColor> cardColors = new List<CardColor>();
  51. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents()
  52. .Where(permanent => permanent.IsDigimon || permanent.IsTamer))
  53. {
  54. cardColors.AddRange(permanent.TopCard.CardColors);
  55. }
  56. cardColors = cardColors.Distinct().ToList();
  57. return cardColors.Count;
  58. }
  59. bool CanActivateConditionShared(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  62. }
  63. #endregion
  64. #region On Play
  65. if (timing == EffectTiming.OnEnterFieldAnyone)
  66. {
  67. ActivateClass activateClass = new ActivateClass();
  68. activateClass.SetUpICardEffect("Trash both player's decks and gain +1000 DP for every card trashed", CanUseCondition, card);
  69. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  70. cardEffects.Add(activateClass);
  71. string EffectDescription()
  72. {
  73. return
  74. "[On Play] For each color among your opponent's Digimon and Tamers, trash the top card of both players decks. Then, this Digimon gets +1000 DP for each card trashed by this effect for the turn.";
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  79. }
  80. IEnumerator ActivateCoroutine(Hashtable hashtable)
  81. {
  82. int trashCount = OpponentColorCount();
  83. int ownerTrashed = Math.Min(card.Owner.LibraryCards.Count, trashCount);
  84. int opponentTrashed = Math.Min(card.Owner.Enemy.LibraryCards.Count, trashCount);
  85. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(
  86. trashCount,
  87. card.Owner.Enemy,
  88. activateClass).AddTrashCardsFromLibraryTop());
  89. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(
  90. trashCount,
  91. card.Owner,
  92. activateClass).AddTrashCardsFromLibraryTop());
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  94. targetPermanent: card.PermanentOfThisCard(),
  95. changeValue: 1000 * (ownerTrashed + opponentTrashed),
  96. effectDuration: EffectDuration.UntilEachTurnEnd,
  97. activateClass: activateClass));
  98. }
  99. }
  100. #endregion
  101. #region When Digivolving
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Trash both player's decks and gain +1000 DP for every card trashed", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  107. cardEffects.Add(activateClass);
  108. string EffectDescription()
  109. {
  110. return
  111. "[When Digivolving] For each color among your opponent's Digimon and Tamers, trash the top card of both players decks. Then, this Digimon gets +1000 DP for each card trashed by this effect for the turn.";
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable hashtable)
  118. {
  119. int trashCount = OpponentColorCount();
  120. int ownerTrashed = Math.Min(card.Owner.LibraryCards.Count, trashCount);
  121. int opponentTrashed = Math.Min(card.Owner.Enemy.LibraryCards.Count, trashCount);
  122. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(
  123. trashCount,
  124. card.Owner.Enemy,
  125. activateClass).AddTrashCardsFromLibraryTop());
  126. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(
  127. trashCount,
  128. card.Owner,
  129. activateClass).AddTrashCardsFromLibraryTop());
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  131. targetPermanent: card.PermanentOfThisCard(),
  132. changeValue: 1000 * (ownerTrashed + opponentTrashed),
  133. effectDuration: EffectDuration.UntilEachTurnEnd,
  134. activateClass: activateClass));
  135. }
  136. }
  137. #endregion
  138. #region End of Attack
  139. if (timing == EffectTiming.OnEndAttack)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("Delete 1 Digimon to delete all of your opponent's Digimon with the lowest level",
  143. CanUseCondition, card);
  144. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  145. cardEffects.Add(activateClass);
  146. string EffectDescription()
  147. {
  148. return
  149. "[End of Attack] By deleting 1 level 4 or lower purple Digimon, delete all of your opponent's Digimon with the lowest level.";
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  154. }
  155. bool CanSelectPermanentCondition(Permanent permanent)
  156. {
  157. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  158. permanent.TopCard.HasLevel &&
  159. permanent.Level <= 4 &&
  160. permanent.TopCard.CardColors.Contains(CardColor.Purple);
  161. }
  162. bool OpponentMinLevelPermanentCondition(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  165. CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  170. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable hashtable)
  173. {
  174. Permanent selectedPermanent = null;
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanSelectPermanentCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: 1,
  182. canNoSelect: true,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: SelectPermanentCoroutine,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Custom,
  187. cardEffect: activateClass);
  188. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  189. "The opponent is selecting 1 Digimon to delete.");
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  192. {
  193. selectedPermanent = permanent;
  194. yield return null;
  195. }
  196. if (selectedPermanent != null)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(
  199. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  200. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  201. successProcess: _ => SuccessProcess(), failureProcess: null));
  202. IEnumerator SuccessProcess()
  203. {
  204. List<Permanent> destroyTargetPermanents =
  205. card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  206. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  207. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Retaliation - ESS
  214. if (timing == EffectTiming.OnDestroyedAnyone)
  215. {
  216. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  217. }
  218. #endregion
  219. return cardEffects;
  220. }
  221. }
  222. }