BT10_053.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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_053 : 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.OnDeclaration)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Suspend your Digimon to play a Digimon from hand", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  20. activateClass.SetHashString("PlayDigimon_BT10_053");
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[Main][Once Per Turn] By suspending 1 of your green Digimon, you may play 1 Digimon card with [Vegetation], [Plant] or [Fairy] in its traits and 3000 DP or less from your hand without paying its memory cost.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  40. {
  41. if (cardSource.CardDP <= 3000)
  42. {
  43. if (cardSource.IsDigimon)
  44. {
  45. if (cardSource.HasPlantTraits)
  46. {
  47. return true;
  48. }
  49. if (cardSource.HasFairyTraits)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. Permanent selectedPermanent = null;
  72. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. selectedPermanent = permanent;
  91. yield return null;
  92. }
  93. if (selectedPermanent != null)
  94. {
  95. if (selectedPermanent.TopCard != null)
  96. {
  97. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  98. {
  99. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  100. {
  101. Permanent tapPermanent = selectedPermanent;
  102. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { tapPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  103. if (tapPermanent.TopCard != null)
  104. {
  105. if (tapPermanent.IsSuspended)
  106. {
  107. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  108. {
  109. List<CardSource> selectedCards = new List<CardSource>();
  110. maxCount = 1;
  111. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  112. selectHandEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectCardCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: true,
  119. canEndNotMax: false,
  120. isShowOpponent: true,
  121. selectCardCoroutine: SelectCardCoroutine,
  122. afterSelectCardCoroutine: null,
  123. mode: SelectHandEffect.Mode.Custom,
  124. cardEffect: activateClass);
  125. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  126. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  127. yield return StartCoroutine(selectHandEffect.Activate());
  128. IEnumerator SelectCardCoroutine(CardSource cardSource)
  129. {
  130. selectedCards.Add(cardSource);
  131. yield return null;
  132. }
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  134. cardSources: selectedCards,
  135. activateClass: activateClass,
  136. payCost: false,
  137. isTapped: false,
  138. root: SelectCardEffect.Root.Hand,
  139. activateETB: true));
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. if (timing == EffectTiming.OnTappedAnyone)
  150. {
  151. ActivateClass activateClass = new ActivateClass();
  152. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  153. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  154. activateClass.SetIsInheritedEffect(true);
  155. activateClass.SetHashString("Memory+1_BT10_053");
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[Your Turn][Once Per Turn] When an effect suspends one of your Digimon, gain 1 memory.";
  160. }
  161. bool PermanentCondition(Permanent permanent)
  162. {
  163. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.IsExistOnBattleArea(card))
  168. {
  169. if (CardEffectCommons.IsOwnerTurn(card))
  170. {
  171. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  172. {
  173. if (CardEffectCommons.IsByEffect(hashtable, null))
  174. {
  175. return true;
  176. }
  177. }
  178. }
  179. }
  180. return false;
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleArea(card))
  185. {
  186. return true;
  187. }
  188. return false;
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  193. }
  194. }
  195. return cardEffects;
  196. }
  197. }
  198. }