BT9_081.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT9_081 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Dorugoramon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Delete opponent's all Digimon with the lowest Level", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[When Digivolving] If this Digimon has [Dorugoramon] in its digivolution cards or is digivolving from the trash, delete all of your opponent's Digimon with the lowest level.";
  30. }
  31. bool PermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  34. }
  35. bool RootCondition(SelectCardEffect.Root root)
  36. {
  37. return root == SelectCardEffect.Root.Trash;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  48. {
  49. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Dorugoramon")) >= 1)
  50. {
  51. return true;
  52. }
  53. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, RootCondition))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  64. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  65. }
  66. }
  67. if (timing == EffectTiming.OnDestroyedAnyone)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Play 1 Digimon from trash", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  72. cardEffects.Add(activateClass);
  73. string EffectDiscription()
  74. {
  75. return "[On Deletion] You may play 1 purple or black level 3 Digimon card from your trash without paying its memory cost. If you have 5 or more cards with [Dex] or [DeathX] in their names in your trash, you may play 1 [DeathXmon] from your trash without paying its memory cost instead.";
  76. }
  77. bool CanSelectCardCondition(CardSource cardSource)
  78. {
  79. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  80. {
  81. if (cardSource.HasCardColor(CardColor.Purple) || cardSource.HasCardColor(CardColor.Black))
  82. {
  83. if (cardSource.Level == 3)
  84. {
  85. if (cardSource.HasLevel)
  86. {
  87. if (cardSource.IsDigimon)
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. }
  94. if (card.Owner.TrashCards.Count((cardSource) => cardSource.ContainsCardName("Dex") || cardSource.ContainsCardName("DeathX")) >= 5)
  95. {
  96. if (cardSource.CardNames.Contains("DeathXmon"))
  97. {
  98. return true;
  99. }
  100. }
  101. }
  102. return false;
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnTrash(card))
  111. {
  112. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  120. {
  121. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  122. {
  123. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  124. List<CardSource> selectedCards = new List<CardSource>();
  125. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  126. selectCardEffect.SetUp(
  127. canTargetCondition: CanSelectCardCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. canNoSelect: () => true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. message: "Select 1 card to play.",
  134. maxCount: maxCount,
  135. canEndNotMax: false,
  136. isShowOpponent: true,
  137. mode: SelectCardEffect.Mode.Custom,
  138. root: SelectCardEffect.Root.Trash,
  139. customRootCardList: null,
  140. canLookReverseCard: true,
  141. selectPlayer: card.Owner,
  142. cardEffect: activateClass);
  143. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  144. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  145. yield return StartCoroutine(selectCardEffect.Activate());
  146. IEnumerator SelectCardCoroutine(CardSource cardSource)
  147. {
  148. selectedCards.Add(cardSource);
  149. yield return null;
  150. }
  151. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  152. }
  153. }
  154. }
  155. return cardEffects;
  156. }
  157. }