BT10_067.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_067 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.ContainsCardName("Justimon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Return 1 digivolution card to delete 1 Digimon with 9 or less Cost", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[When Digivolving] By returning 1 card with [Justimon] in its name other than [Justimon: Critical Arm] from this Digimon's digivolution cards to its owner's hand, delete 1 of your opponent's Digimon with a play cost of 9 or less.";
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. if (!cardSource.CardNames.Contains("Justimon: Critical Arm") && !cardSource.CardNames.Contains("Justimon:CriticalArm"))
  36. {
  37. if (cardSource.ContainsCardName("Justimon"))
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectPermanentCondition(Permanent permanent)
  45. {
  46. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  47. {
  48. if (permanent.TopCard.GetCostItself <= 9)
  49. {
  50. if (permanent.TopCard.HasPlayCost)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. Permanent selectedPermanent = card.PermanentOfThisCard();
  78. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  79. {
  80. bool returned = false;
  81. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: CanSelectCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  90. message: "Select 1 card to add to your hand.",
  91. maxCount: maxCount,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.AddHand,
  95. root: SelectCardEffect.Root.Custom,
  96. customRootCardList: selectedPermanent.DigivolutionCards,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. yield return StartCoroutine(selectCardEffect.Activate());
  101. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  102. {
  103. if (cardSources.Count >= 1)
  104. {
  105. returned = true;
  106. }
  107. yield return null;
  108. }
  109. if (returned)
  110. {
  111. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  112. {
  113. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  114. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  115. selectPermanentEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectPermanentCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: maxCount,
  121. canNoSelect: false,
  122. canEndNotMax: false,
  123. selectPermanentCoroutine: null,
  124. afterSelectPermanentCoroutine: null,
  125. mode: SelectPermanentEffect.Mode.Destroy,
  126. cardEffect: activateClass);
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. if (timing == EffectTiming.OnAllyAttack)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect("Digivolve this Digimon into a card with [Justimon] in its name", CanUseCondition, card);
  138. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  139. cardEffects.Add(activateClass);
  140. string EffectDiscription()
  141. {
  142. return "[When Attacking] If you have a Tamer in play, this Digimon may digivolve into a Digimon card with [Justimon] in its name other than [Justimon: Critical Arm] for a cost of 2, ignoring its digivolution requirements.";
  143. }
  144. bool CanSelectCardCondition(CardSource cardSource)
  145. {
  146. return cardSource.IsDigimon && !cardSource.CardNames.Contains("Justimon: Critical Arm") && !cardSource.CardNames.Contains("Justimon:CriticalArm") && cardSource.ContainsCardName("Justimon");
  147. }
  148. bool CanUseCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleArea(card))
  155. {
  156. if (card.Owner.HandCards.Count >= 1)
  157. {
  158. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  169. targetPermanent: card.PermanentOfThisCard(),
  170. cardCondition: CanSelectCardCondition,
  171. payCost: true,
  172. reduceCostTuple: null,
  173. fixedCostTuple: null,
  174. ignoreDigivolutionRequirementFixedCost: 2,
  175. isHand: true,
  176. activateClass: activateClass,
  177. successProcess: null));
  178. }
  179. }
  180. return cardEffects;
  181. }
  182. }
  183. }