ST22_07.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //ST22_07 Rika Nonaka
  5. namespace DCGO.CardEffects.ST22
  6. {
  7. public class ST22_07 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region SoYMP/OP Shared
  13. string EffectDiscriptionShared(string tag)
  14. {
  15. return $"[{tag}] By placing 1 Option card with the [Onmyōjutsu] or [Plug-In] trait from your hand under this Tamer, <Draw 1> and gain 1 memory.";
  16. }
  17. bool CanSelectCardCondition(CardSource cardSource)
  18. {
  19. return cardSource.IsOption &&
  20. (cardSource.EqualsTraits("Onmyōjutsu") || cardSource.EqualsTraits("Plug-In"));
  21. }
  22. bool CanActivateConditionShared(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleArea(card))
  25. {
  26. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  34. {
  35. bool placed = false;
  36. int maxCount = 1;
  37. List<CardSource> selectedCards = new List<CardSource>();
  38. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  39. selectHandEffect.SetUp(
  40. selectPlayer: card.Owner,
  41. canTargetCondition: CanSelectCardCondition,
  42. canTargetCondition_ByPreSelecetedList: null,
  43. canEndSelectCondition: CanEndSelectCondition,
  44. maxCount: maxCount,
  45. canNoSelect: true,
  46. canEndNotMax: false,
  47. isShowOpponent: true,
  48. selectCardCoroutine: SelectCardCoroutine,
  49. afterSelectCardCoroutine: null,
  50. mode: SelectHandEffect.Mode.Custom,
  51. cardEffect: activateClass);
  52. selectHandEffect.SetUpCustomMessage("Select 1 card to place under Tamer.", "The opponent is selecting 1 card to place under Tamer.");
  53. selectHandEffect.SetNotShowCard();
  54. yield return StartCoroutine(selectHandEffect.Activate());
  55. bool CanEndSelectCondition(List<CardSource> cardSources)
  56. {
  57. if (CardEffectCommons.HasNoElement(cardSources))
  58. {
  59. return false;
  60. }
  61. return true;
  62. }
  63. IEnumerator SelectCardCoroutine(CardSource cardSource)
  64. {
  65. selectedCards.Add(cardSource);
  66. yield return null;
  67. }
  68. if (selectedCards.Count >= 1)
  69. {
  70. if (!card.PermanentOfThisCard().IsToken)
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  73. placed = true;
  74. }
  75. }
  76. if (placed)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  79. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  80. }
  81. }
  82. #endregion
  83. #region Start of main
  84. if (timing == EffectTiming.OnStartMainPhase)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Place 1 Option under this Tamer from hand to Draw 1 and gain 1 mem", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscriptionShared("Start of Your Main Phase"));
  89. cardEffects.Add(activateClass);
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. if (CardEffectCommons.IsOwnerTurn(card))
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. }
  102. #endregion
  103. #region On Play
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Place 1 Option under this Tamer from hand to Draw 1 and gain 1 mem", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscriptionShared("On Play"));
  109. cardEffects.Add(activateClass);
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. }
  122. #endregion
  123. #region Your Turn
  124. if (timing == EffectTiming.OnAllyAttack)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("Use 1 [Onmyōjutsu] or [Plug-In] trait Option card.", CanUseCondition,
  128. card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  130. cardEffects.Add(activateClass);
  131. string EffectDescription()
  132. {
  133. return
  134. "[Your Turn] When one of your Digimon with [Renamon], [Kyubimon], [Taomon] or [Sakuyamon] in its name attacks, by suspending this Tamer, you may use 1 [Onmyōjutsu] or [Plug-In] trait Option card with as high or lower a use cost as that Digimon's level from under this Tamer without paying the cost.";
  135. }
  136. bool AttackingPermanent(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  139. (permanent.TopCard.ContainsCardName("Renamon") ||
  140. permanent.TopCard.ContainsCardName("Kyubimon") ||
  141. permanent.TopCard.ContainsCardName("Taomon") ||
  142. permanent.TopCard.ContainsCardName("Sakuyamon"));
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleArea(card) &&
  147. CardEffectCommons.IsOwnerTurn(card) &&
  148. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleArea(card) &&
  153. CardEffectCommons.CanActivateSuspendCostEffect(card);
  154. }
  155. bool SelectSourceCard(CardSource source)
  156. {
  157. return source.IsOption
  158. && GManager.instance.attackProcess.AttackingPermanent.Level >= source.GetCostItself
  159. && source.HasOnmyoOrPluginTraits
  160. && !source.CanNotPlayThisOption;
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(
  165. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  166. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  167. List<CardSource> selectedCards = new List<CardSource>();
  168. IEnumerator SelectCardCoroutine(CardSource cardSource)
  169. {
  170. selectedCards.Add(cardSource);
  171. yield return null;
  172. }
  173. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  174. selectCardEffect.SetUp(
  175. canTargetCondition: SelectSourceCard,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. canNoSelect: () => true,
  179. selectCardCoroutine: SelectCardCoroutine,
  180. afterSelectCardCoroutine: null,
  181. message: "Select 1 option card to use",
  182. maxCount: 1,
  183. canEndNotMax: false,
  184. isShowOpponent: true,
  185. mode: SelectCardEffect.Mode.Custom,
  186. root: SelectCardEffect.Root.DigivolutionCards,
  187. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  188. canLookReverseCard: true,
  189. selectPlayer: card.Owner,
  190. cardEffect: activateClass);
  191. selectCardEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  192. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  193. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  194. cardSources: selectedCards,
  195. activateClass: activateClass,
  196. payCost: false,
  197. root: SelectCardEffect.Root.DigivolutionCards));
  198. }
  199. }
  200. #endregion
  201. #region Security
  202. if (timing == EffectTiming.SecuritySkill)
  203. {
  204. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  205. }
  206. #endregion
  207. return cardEffects;
  208. }
  209. }
  210. }