BT18_006.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_006 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Deletion - ESS
  12. if (timing == EffectTiming.OnDestroyedAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash cards from the top of your deck", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. activateClass.SetIsInheritedEffect(true);
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[On Deletion] Trash the top card of your deck for each color of your opponent's Digimon and Tamers.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  26. }
  27. int OpponentColorCount()
  28. {
  29. List<CardColor> cardColors = new List<CardColor>();
  30. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents()
  31. .Where(permanent => permanent.IsDigimon || permanent.IsTamer))
  32. {
  33. cardColors.AddRange(permanent.TopCard.CardColors);
  34. }
  35. cardColors = cardColors.Distinct().ToList();
  36. return cardColors.Count;
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. yield return ContinuousController.instance.StartCoroutine(
  45. new IAddTrashCardsFromLibraryTop(OpponentColorCount(), card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  46. }
  47. }
  48. #endregion
  49. return cardEffects;
  50. }
  51. }
  52. }