BT22_097.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Music of the Heart
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_097 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool HasAppmonTrait(Permanent permanent)
  20. {
  21. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  22. {
  23. if (permanent.TopCard.EqualsTraits("Appmon"))
  24. {
  25. if (permanent.IsDigimon || permanent.IsTamer)
  26. {
  27. return true;
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.HasMatchConditionPermanent(HasAppmonTrait, true);
  36. }
  37. bool CardCondition(CardSource cardSource)
  38. {
  39. return cardSource == card;
  40. }
  41. }
  42. #endregion
  43. #region Main
  44. if (timing == EffectTiming.OptionSkill)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[Main] <Draw 1> (Draw 1 card from your deck.) Then, place this card in the battle area.";
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  61. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  62. }
  63. }
  64. #endregion
  65. #region All Turns - Delay
  66. if (timing == EffectTiming.OnEnterFieldAnyone)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("Link 1 [Appmon] trait Digimon", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  71. cardEffects.Add(activateClass);
  72. string EffectDiscription()
  73. {
  74. return "[All Turns] When any of your [Appmon] trait Digimon are played, <Delay> (By trashing this card after the placing turn, activate the effect below.)\r\n・You may link 1 [Appmon] trait Digimon card from your hand to 1 of your Digimon without paying the cost.";
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleArea(card)
  79. && CardEffectCommons.CanDeclareOptionDelayEffect(card)
  80. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition);
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleArea(card)
  85. && CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => cardSource.CanLink(false));
  86. }
  87. bool PermanentCondition(Permanent permanent)
  88. {
  89. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  90. && permanent.TopCard.HasAppmonTraits;
  91. }
  92. bool OwnPermamentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  93. bool LinkCardCondition(CardSource cardSource, Permanent targetPermament) => cardSource.IsDigimon && cardSource.HasAppmonTraits && cardSource.CanLinkToTargetPermanent(targetPermament, false);
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. bool delaySuccessful = false;
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  98. IEnumerator SuccessProcess()
  99. {
  100. delaySuccessful = true;
  101. yield return null;
  102. }
  103. if (delaySuccessful)
  104. {
  105. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, OwnPermamentCondition))
  106. {
  107. Permanent selectedDigimon = null;
  108. #region Select Permanent Link Target
  109. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, OwnPermamentCondition));
  110. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectPermanentEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: OwnPermamentCondition,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: maxCount,
  117. canNoSelect: true,
  118. canEndNotMax: false,
  119. selectPermanentCoroutine: SelectPermanentCoroutine,
  120. afterSelectPermanentCoroutine: null,
  121. mode: SelectPermanentEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  124. {
  125. selectedDigimon = permanent;
  126. yield return null;
  127. }
  128. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link to", "The opponent is selecting 1 Digimon to link to");
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. #endregion
  131. if (selectedDigimon != null && CardEffectCommons.HasMatchConditionOwnersHand(card, handCard => LinkCardCondition(handCard, selectedDigimon)))
  132. {
  133. CardSource selectedHandCard = null;
  134. #region Select Hand card
  135. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, handCard => LinkCardCondition(handCard, selectedDigimon)));
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: handCard => LinkCardCondition(handCard, selectedDigimon),
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount1,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. selectCardCoroutine: SelectCardCoroutine,
  147. afterSelectCardCoroutine: null,
  148. mode: SelectHandEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. IEnumerator SelectCardCoroutine(CardSource cardSource)
  151. {
  152. selectedHandCard = cardSource;
  153. yield return null;
  154. }
  155. selectHandEffect.SetUpCustomMessage("Select 1 [Appmon] to link", "The opponent is selecting 1 [Appmon] to link");
  156. selectHandEffect.SetUpCustomMessage_ShowCard("Selected card");
  157. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  158. #endregion
  159. if (selectedHandCard != null) yield return ContinuousController.instance.StartCoroutine(selectedDigimon.AddLinkCard(selectedHandCard, activateClass));
  160. }
  161. }
  162. }
  163. }
  164. }
  165. #endregion
  166. #region Security
  167. if (timing == EffectTiming.SecuritySkill)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("place in battle area", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  172. activateClass.SetIsSecurityEffect(true);
  173. cardEffects.Add(activateClass);
  174. string EffectDescription()
  175. {
  176. return "[Security] place this card in the battle area.";
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable hashtable)
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(
  185. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  186. }
  187. }
  188. #endregion
  189. return cardEffects;
  190. }
  191. }
  192. }