BT8_082.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 BT8_082 : 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("Ophanimon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null));
  25. }
  26. if (timing == EffectTiming.OnEnterFieldAnyone)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Delete 1 level 4 or lower Digimon and Recovery +1 (Deck)", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[When Digivolving] If this Digimon has a purple card in its digivolution cards, delete 1 of your opponent's level 4 or lower Digimon. If this Digimon has a yellow card in its digivolution cards, <Recovery +1 (Deck)>. (Place the top card of your deck on top of your security stack.)";
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  39. {
  40. if (permanent.Level <= 4)
  41. {
  42. if (permanent.TopCard.HasLevel)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (card.PermanentOfThisCard().DigivolutionCards.Some((cardSource) => cardSource.HasCardColor(CardColor.Purple)))
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. return true;
  63. }
  64. }
  65. if (card.PermanentOfThisCard().DigivolutionCards.Some((cardSource) => cardSource.HasCardColor(CardColor.Yellow)))
  66. {
  67. if (card.Owner.LibraryCards.Count >= 1)
  68. {
  69. if (card.Owner.CanAddSecurity(activateClass))
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  79. {
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. if (card.PermanentOfThisCard().DigivolutionCards.Some((cardSource) => cardSource.HasCardColor(CardColor.Purple)))
  83. {
  84. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  85. {
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Destroy,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. }
  102. }
  103. }
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (card.PermanentOfThisCard().DigivolutionCards.Some((cardSource) => cardSource.HasCardColor(CardColor.Yellow)))
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  109. }
  110. }
  111. }
  112. }
  113. if (timing == EffectTiming.OnDestroyedAnyone)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon from trash", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  118. cardEffects.Add(activateClass);
  119. string EffectDiscription()
  120. {
  121. return "[On Deletion] You may play 1 purple or yellow level 4 or lower Digimon card from your trash without paying its memory cost.";
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. if (cardSource.IsDigimon)
  126. {
  127. if (cardSource.HasCardColor(CardColor.Purple) || cardSource.HasCardColor(CardColor.Yellow))
  128. {
  129. if (cardSource.Level <= 4)
  130. {
  131. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  132. {
  133. if (cardSource.HasLevel)
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  150. {
  151. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  161. {
  162. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  163. List<CardSource> selectedCards = new List<CardSource>();
  164. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  165. selectCardEffect.SetUp(
  166. canTargetCondition: CanSelectCardCondition,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. canNoSelect: () => true,
  170. selectCardCoroutine: SelectCardCoroutine,
  171. afterSelectCardCoroutine: null,
  172. message: "Select 1 card to play.",
  173. maxCount: maxCount,
  174. canEndNotMax: false,
  175. isShowOpponent: true,
  176. mode: SelectCardEffect.Mode.Custom,
  177. root: SelectCardEffect.Root.Trash,
  178. customRootCardList: null,
  179. canLookReverseCard: true,
  180. selectPlayer: card.Owner,
  181. cardEffect: activateClass);
  182. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  183. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  184. yield return StartCoroutine(selectCardEffect.Activate());
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  191. cardSources: selectedCards,
  192. activateClass: activateClass,
  193. payCost: false,
  194. isTapped: false,
  195. root: SelectCardEffect.Root.Trash,
  196. activateETB: true));
  197. }
  198. }
  199. }
  200. return cardEffects;
  201. }
  202. }