P_110.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Shadramon
  6. public class P_110 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.CardNames.Contains("Wormmon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Play 1 [Veemon] or [Wormmon] from trash for free", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return "[When Digivolving] You may play 1 [Veemon]/[Wormmon] from your trash suspended without paying the cost.";
  28. }
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource != null)
  32. {
  33. if (cardSource.Owner == card.Owner)
  34. {
  35. if (cardSource.CardNames.Contains("Veemon") || cardSource.CardNames.Contains("Wormmon"))
  36. {
  37. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnBattleArea(card))
  53. {
  54. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  55. {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. if (isExistOnField(card))
  64. {
  65. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  66. {
  67. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  68. {
  69. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  70. List<CardSource> selectedCards = new List<CardSource>();
  71. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  72. selectCardEffect.SetUp(
  73. canTargetCondition: CanSelectCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. canNoSelect: () => true,
  77. selectCardCoroutine: SelectCardCoroutine,
  78. afterSelectCardCoroutine: null,
  79. message: "Select 1 card to play.",
  80. maxCount: maxCount,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. mode: SelectCardEffect.Mode.Custom,
  84. root: SelectCardEffect.Root.Trash,
  85. customRootCardList: null,
  86. canLookReverseCard: true,
  87. selectPlayer: card.Owner,
  88. cardEffect: activateClass);
  89. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  90. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  91. yield return StartCoroutine(selectCardEffect.Activate());
  92. IEnumerator SelectCardCoroutine(CardSource cardSource)
  93. {
  94. selectedCards.Add(cardSource);
  95. yield return null;
  96. }
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: true, root: SelectCardEffect.Root.Trash, activateETB: true));
  98. }
  99. }
  100. }
  101. }
  102. }
  103. if (timing == EffectTiming.OnDestroyedAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Play 1 [Veemon] or [Wormmon] from hand", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  108. activateClass.SetIsInheritedEffect(true);
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[On Deletion] You may play 1 [Veemon]/[Wormmon] from your hand suspended without paying the cost.";
  113. }
  114. bool CanSelectCardCondition(CardSource cardSource)
  115. {
  116. if (cardSource != null)
  117. {
  118. if (cardSource.Owner == card.Owner)
  119. {
  120. if (cardSource.CardNames.Contains("Veemon") || cardSource.CardNames.Contains("Wormmon"))
  121. {
  122. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  138. {
  139. if (card.Owner.HandCards.Count >= 1)
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  147. {
  148. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  149. {
  150. List<CardSource> selectedCards = new List<CardSource>();
  151. int maxCount = 1;
  152. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  153. selectHandEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectCardCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: true,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. selectCardCoroutine: SelectCardCoroutine,
  163. afterSelectCardCoroutine: null,
  164. mode: SelectHandEffect.Mode.Custom,
  165. cardEffect: activateClass);
  166. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  167. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  168. yield return StartCoroutine(selectHandEffect.Activate());
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: true, root: SelectCardEffect.Root.Hand, activateETB: true));
  175. }
  176. }
  177. }
  178. return cardEffects;
  179. }
  180. }