BT17_007.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using System;
  6. using Photon.Pun;
  7. namespace DCGO.CardEffects.BT17
  8. {
  9. public class BT17_007 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternate Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsCardName("Koromon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. #endregion
  26. #region Start of Your Main Phase
  27. if (timing == EffectTiming.OnStartMainPhase)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect(
  31. "Return 1 card with [Garurumon]/[Greymon]/[Omnimon] in its name from your trash to the hand",
  32. CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  34. EffectDescription());
  35. cardEffects.Add(activateClass);
  36. string EffectDescription()
  37. {
  38. return
  39. "[Start of Your Main Phase] If you have a Tamer with [Tai Kamiya] in its name, return 1 card with [Garurumon]/[Greymon]/[Omnimon] in its name from your trash to the hand.";
  40. }
  41. bool CanSelectCardCondition(CardSource cardSource)
  42. {
  43. if (cardSource.IsDigimon)
  44. {
  45. if (cardSource.ContainsCardName("Garurumon") ||
  46. cardSource.HasGreymonName ||
  47. cardSource.ContainsCardName("Omnimon"))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool OwnTamerPermanentCondition(Permanent permanent)
  55. {
  56. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  57. {
  58. if (permanent.IsTamer)
  59. {
  60. if (permanent.TopCard.ContainsCardName("Tai Kamiya") || permanent.TopCard.ContainsCardName("TaiKamiya"))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. if (CardEffectCommons.IsOwnerTurn(card))
  73. {
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.IsExistOnBattleArea(card))
  82. {
  83. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, OwnTamerPermanentCondition))
  84. {
  85. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. return false;
  92. }
  93. IEnumerator ActivateCoroutine(Hashtable hashtable)
  94. {
  95. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, OwnTamerPermanentCondition))
  96. {
  97. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  98. {
  99. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  100. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  101. selectCardEffect.SetUp(
  102. canTargetCondition: CanSelectCardCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. canNoSelect: () => false,
  106. selectCardCoroutine: null,
  107. afterSelectCardCoroutine: null,
  108. message: "Select 1 card to add to your hand.",
  109. maxCount: maxCount,
  110. canEndNotMax: false,
  111. isShowOpponent: true,
  112. mode: SelectCardEffect.Mode.AddHand,
  113. root: SelectCardEffect.Root.Trash,
  114. customRootCardList: null,
  115. canLookReverseCard: true,
  116. selectPlayer: card.Owner,
  117. cardEffect: activateClass);
  118. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  119. }
  120. }
  121. }
  122. }
  123. #endregion
  124. #region End of Your Turn - ESS
  125. if (timing == EffectTiming.OnEndTurn)
  126. {
  127. ActivateClass activateClass = new ActivateClass();
  128. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  130. EffectDescription());
  131. activateClass.SetIsInheritedEffect(true);
  132. cardEffects.Add(activateClass);
  133. string EffectDescription()
  134. {
  135. return
  136. "[End of Your Turn] This Digimon and another of your Digimon may DNA digivolve into a Digimon card in the hand.";
  137. }
  138. bool CanSelectCardCondition(CardSource cardSource)
  139. {
  140. if (cardSource != null)
  141. {
  142. if (cardSource.IsDigimon)
  143. {
  144. if (cardSource.Owner == card.Owner)
  145. {
  146. if (cardSource.CanPlayJogress(true))
  147. {
  148. if (isExistOnField(card))
  149. {
  150. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }
  159. return false;
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. if (isExistOnField(card))
  164. {
  165. return true;
  166. }
  167. return false;
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. if (CardEffectCommons.IsExistOnBattleArea(card))
  172. {
  173. if (CardEffectCommons.IsOwnerTurn(card))
  174. {
  175. if (card.Owner.HandCards.Count >= 1)
  176. {
  177. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card,
  178. (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  179. {
  180. return true;
  181. }
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. if (isExistOnField(card))
  190. {
  191. yield return ContinuousController.instance.StartCoroutine(
  192. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  193. CanSelectCardCondition,
  194. payCost: true,
  195. isHand: true,
  196. activateClass,
  197. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  198. ));
  199. }
  200. }
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }