BT22_008.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. // Agumon
  8. namespace DCGO.CardEffects.BT22
  9. {
  10. public class BT22_008 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Alternative Digivolution Condition
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.EqualsCardName("Koromon") || (targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasCSTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 0,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region On Play
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Return a card from trash", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. => "[On Play] You may return 1 Digimon card with [Greymon], [Garurumon] or [Omnimon] in its name from your trash to the hand";
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  47. }
  48. bool CanSelectCardCondition(CardSource cardSource)
  49. {
  50. return cardSource.IsDigimon
  51. && (cardSource.ContainsCardName("Greymon") ||
  52. cardSource.ContainsCardName("Garurumon") ||
  53. cardSource.ContainsCardName("Omnimon"));
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  58. {
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  60. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  61. selectCardEffect.SetUp(
  62. canTargetCondition: CanSelectCardCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. canNoSelect: () => true,
  66. selectCardCoroutine: null,
  67. afterSelectCardCoroutine: null,
  68. message: "Select 1 card to add to your hand.",
  69. maxCount: maxCount,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. mode: SelectCardEffect.Mode.AddHand,
  73. root: SelectCardEffect.Root.Trash,
  74. customRootCardList: null,
  75. canLookReverseCard: true,
  76. selectPlayer: card.Owner,
  77. cardEffect: activateClass);
  78. selectCardEffect.SetUpCustomMessage("Select 1 card to add to your hand.", "The opponent is selecting 1 card to add to their hand.");
  79. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  80. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  81. }
  82. }
  83. }
  84. #endregion
  85. #region ESS
  86. if (timing == EffectTiming.OnEndTurn)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  91. activateClass.SetIsInheritedEffect(true);
  92. cardEffects.Add(activateClass);
  93. string EffectDiscription()
  94. {
  95. return "[End of Your Turn] This Digimon and any of your other Digimon may DNA digivolve into a Digimon card in the hand.";
  96. }
  97. bool CanSelectCardCondition(CardSource cardSource)
  98. {
  99. if (cardSource != null)
  100. {
  101. if (cardSource.IsDigimon)
  102. {
  103. if (cardSource.Owner == card.Owner)
  104. {
  105. if (cardSource.CanPlayJogress(true))
  106. {
  107. if (isExistOnField(card))
  108. {
  109. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. if (isExistOnField(card))
  123. {
  124. return true;
  125. }
  126. return false;
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(card))
  131. {
  132. if (CardEffectCommons.IsOwnerTurn(card))
  133. {
  134. if (card.Owner.HandCards.Count >= 1)
  135. {
  136. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  146. {
  147. if (isExistOnField(card))
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(
  150. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  151. CanSelectCardCondition,
  152. payCost: true,
  153. isHand: true,
  154. activateClass,
  155. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  156. ));
  157. }
  158. }
  159. }
  160. #endregion
  161. return cardEffects;
  162. }
  163. }
  164. }