BT19_084.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_084 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of Your Main Phase
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("+1 Memory", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return
  21. "[Start of Your Main Phase] If you have face up security cards, gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return isExistOnField(card) &&
  26. CardEffectCommons.IsOwnerTurn(card);
  27. }
  28. bool HasFaceUpSecurity()
  29. {
  30. return card.Owner.SecurityCards.Count(source => !source.IsFlipped) > 0;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. return isExistOnField(card);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. if(HasFaceUpSecurity())
  39. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  40. }
  41. }
  42. #endregion
  43. #region Your Turn
  44. if (timing == EffectTiming.OnDeclaration)
  45. {
  46. List<CardSource> cards = new List<CardSource>();
  47. CardSource selectedCard = null;
  48. Permanent selectedParmanent = null;
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("One of your Digimon digivolves into Digimon card in security", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  52. cardEffects.Add(activateClass);
  53. string EffectDiscription()
  54. {
  55. return "[Main] By suspending this Tamer, 1 of your Digimon digivolves into a Digimon card in your face up security cards. If this effect digivolved, you may place 1 Digimon card with the [Royal Base] trait from your hand face up as your bottom security card.";
  56. }
  57. bool OwnersDigivolveTarget(Permanent permanent)
  58. {
  59. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  60. {
  61. if(card.Owner.SecurityCards.Count(cardSource =>
  62. !cardSource.IsFlipped &&
  63. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, PayCost: false, activateClass, root: SelectCardEffect.Root.Security)) > 0)
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. bool DigivolveTarget(CardSource cardSource)
  71. {
  72. return !cardSource.IsFlipped &&
  73. cardSource.CanPlayCardTargetFrame(selectedParmanent.PermanentFrame, PayCost: false, activateClass, root: SelectCardEffect.Root.Security);
  74. }
  75. bool IsRoyalBaseDigimon(CardSource cardSource)
  76. {
  77. return cardSource.IsDigimon &&
  78. cardSource.EqualsTraits("Royal Base");
  79. }
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return isExistOnField(card) &&
  83. CardEffectCommons.IsOwnerTurn(card) &&
  84. CardEffectCommons.CanActivateSuspendCostEffect(card);
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. return isExistOnField(card);
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(
  93. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  94. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  95. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, OwnersDigivolveTarget))
  96. {
  97. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  98. selectPermanentEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: OwnersDigivolveTarget,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: 1,
  104. canNoSelect: false,
  105. canEndNotMax: false,
  106. selectPermanentCoroutine: SelectDigivolveTarget,
  107. afterSelectPermanentCoroutine: null,
  108. mode: SelectPermanentEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. }
  112. IEnumerator SelectDigivolveTarget(Permanent permanent)
  113. {
  114. selectedParmanent = permanent;
  115. yield return null;
  116. }
  117. if (selectedParmanent != null)
  118. {
  119. cards = card.Owner.SecurityCards.Filter(source => !source.IsFlipped);
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: DigivolveTarget,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => false,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 card to digivolve.",
  129. maxCount: 1,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.Custom,
  133. root: SelectCardEffect.Root.Custom,
  134. customRootCardList: cards,
  135. canLookReverseCard: false,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  139. IEnumerator SelectCardCoroutine(CardSource cardSource)
  140. {
  141. selectedCard = cardSource;
  142. yield return null;
  143. }
  144. if (selectedCard != null)
  145. {
  146. PlayCardClass playCardClass = new PlayCardClass(
  147. cardSources: new List<CardSource>() { selectedCard },
  148. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  149. payCost: true,
  150. targetPermanent: selectedParmanent,
  151. isTapped: false,
  152. root: SelectCardEffect.Root.Security,
  153. activateETB: true);
  154. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  155. if (CardEffectCommons.IsDigivolvedByTheEffect(selectedParmanent, selectedCard, activateClass))
  156. {
  157. if (card.Owner.CanAddSecurity(activateClass))
  158. {
  159. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  160. selectHandEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: IsRoyalBaseDigimon,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: 1,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. isShowOpponent: true,
  169. selectCardCoroutine: null,
  170. afterSelectCardCoroutine: null,
  171. mode: SelectHandEffect.Mode.PutSecurityBottom,
  172. cardEffect: activateClass);
  173. selectHandEffect.SetIsFaceup();
  174. yield return StartCoroutine(selectHandEffect.Activate());
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. #endregion
  182. #region Security Effect
  183. if (timing == EffectTiming.SecuritySkill)
  184. {
  185. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  186. }
  187. #endregion
  188. return cardEffects;
  189. }
  190. }
  191. }