P_110.cs 9.2 KB

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