BT24_087.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Rei Katsura
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_087 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Your Main Phase
  14. if (timing == EffectTiming.OnStartMainPhase)
  15. {
  16. cardEffects.Add(CardEffectFactory.Gain1MemoryTamerOpponentDigimonEffect(card));
  17. }
  18. #endregion
  19. #region Your Turn
  20. if (timing == EffectTiming.WhenLinked)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Draw 1, Trash 1, then you may app fuse", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[Your Turn] When any of your Digimon get linked, by suspending this Tamer, <Draw 1> and trash 1 card in your hand. Then, 1 of your Digimon may app fuse into a Digimon card with the [System], [Life] or [Transmutation] trait in the trash.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card)
  33. && CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkPermanentCondition, null)
  34. && CardEffectCommons.IsOwnerTurn(card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleArea(card)
  39. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  40. }
  41. bool LinkPermanentCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  44. }
  45. bool CanSelectPermanent(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. foreach (CardSource trash in card.Owner.TrashCards)
  50. {
  51. if (trash.appFusionCondition != null)
  52. {
  53. if (trash.CanAppFusionFromTargetPermanent(permanent, true, SelectCardEffect.Root.Trash))
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanSelectCard(CardSource cardSource, Permanent permanent)
  61. {
  62. return cardSource.appFusionCondition != null
  63. && cardSource.CanAppFusionFromTargetPermanent(permanent, true, SelectCardEffect.Root.Trash)
  64. && (cardSource.EqualsTraits("System")
  65. || cardSource.EqualsTraits("Life")
  66. || cardSource.EqualsTraits("Transmutation"));
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).Tap());
  71. if (card.PermanentOfThisCard().IsSuspended)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  74. if (card.Owner.HandCards.Count > 0)
  75. {
  76. int discardCount = 1;
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: (cardSource) => true,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: discardCount,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: null,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Discard,
  90. cardEffect: activateClass);
  91. yield return StartCoroutine(selectHandEffect.Activate());
  92. }
  93. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  94. {
  95. Permanent selectedPermanent = null;
  96. #region Select App Fuse Permanent Target
  97. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: CanSelectPermanent,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: maxCount,
  105. canNoSelect: true,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: SelectPermanentCoroutine,
  108. afterSelectPermanentCoroutine: null,
  109. mode: SelectPermanentEffect.Mode.Custom,
  110. cardEffect: activateClass);
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. selectedPermanent = permanent;
  114. yield return null;
  115. }
  116. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to app fuse", "The opponent is selecting 1 digimon to app fuse");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. #endregion
  119. if (selectedPermanent != null)
  120. {
  121. CardSource selectedCard = null;
  122. #region Select App Fusion Hand Target
  123. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, trashCard => CanSelectCard(trashCard, selectedPermanent)));
  124. List<CardSource> selectedCards = new List<CardSource>();
  125. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  126. selectCardEffect.SetUp(
  127. canTargetCondition: trashCard => CanSelectCard(trashCard, selectedPermanent),
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. canNoSelect: () => false,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. message: "Select 1 digivolution card to play.",
  134. maxCount: maxCount1,
  135. canEndNotMax: false,
  136. isShowOpponent: true,
  137. mode: SelectCardEffect.Mode.Custom,
  138. root: SelectCardEffect.Root.Trash,
  139. customRootCardList: null,
  140. canLookReverseCard: true,
  141. selectPlayer: card.Owner,
  142. cardEffect: activateClass);
  143. selectCardEffect.SetUpCustomMessage("Select 1 card to digivolve into.", "The opponent is selecting 1 card to digivolve into.");
  144. yield return StartCoroutine(selectCardEffect.Activate());
  145. IEnumerator SelectCardCoroutine(CardSource cardSource)
  146. {
  147. selectedCard = cardSource;
  148. yield return null;
  149. }
  150. selectCardEffect.SetUpCustomMessage("Select digimon to app fuse into.", "The opponent is selecting digimon to app fuse into.");
  151. selectCardEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  152. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  153. #endregion
  154. if (selectedCard != null && selectedCard.CanAppFusionFromTargetPermanent(selectedPermanent, true))
  155. {
  156. CardSource linkCard = selectedPermanent.LinkedCards.Where(x => selectedCard.appFusionCondition.linkedCondition(selectedPermanent, x)).First();
  157. PlayCardClass playCardClass = new PlayCardClass(new List<CardSource> { selectedCard }, hashtable, true, selectedPermanent, false, SelectCardEffect.Root.Hand, true);
  158. playCardClass.SetAppFusion(new int[] { selectedPermanent.PermanentFrame.FrameID, selectedPermanent.LinkedCards.IndexOf(linkCard) });
  159. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. #region Security
  168. if (timing == EffectTiming.SecuritySkill)
  169. {
  170. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  171. }
  172. #endregion
  173. return cardEffects;
  174. }
  175. }
  176. }