BT23_079.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Eri Karan
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_079 : 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 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. List<Permanent> LinkedPermaments = new List<Permanent>();
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Suspend tamer, linked digimon(s) get 3K DP. then 1 digimon may app fuse into a card in hand", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[Your Turn] When any of your Digimon get linked, by suspending this Tamer, those Digimon get +3000 DP until your opponent's turn ends. Then, 1 of your Digimon may app fuse into a Digimon card in the hand.";
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleArea(card)
  34. && CardEffectCommons.CanTriggerWhenLinked(hashtable, IsOwnerPermament, null);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleArea(card)
  39. && CardEffectCommons.CanActivateSuspendCostEffect(card)
  40. && CardEffectCommons.IsOwnerTurn(card);
  41. }
  42. bool IsOwnerPermament(Permanent permanent)
  43. {
  44. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  45. {
  46. LinkedPermaments.Add(permanent);
  47. return true;
  48. }
  49. return false;
  50. }
  51. bool CanSelectPermanent(Permanent permanent)
  52. {
  53. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  54. {
  55. foreach (CardSource hand in card.Owner.HandCards)
  56. {
  57. if (hand.appFusionCondition != null)
  58. {
  59. if (hand.CanAppFusionFromTargetPermanent(permanent, true))
  60. return true;
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanSelectCard(CardSource card, Permanent permanent)
  67. {
  68. if (CardEffectCommons.IsExistOnHand(card))
  69. {
  70. if (card.appFusionCondition != null)
  71. {
  72. if (card.CanAppFusionFromTargetPermanent(permanent, true))
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable hashtable)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  81. new List<Permanent>() { card.PermanentOfThisCard() },
  82. hashtable: hashtable).Tap());
  83. if (LinkedPermaments.Any())
  84. {
  85. foreach (Permanent permanent in LinkedPermaments)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  88. targetPermanent: permanent,
  89. changeValue: 3000,
  90. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  91. activateClass: activateClass));
  92. }
  93. }
  94. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  95. {
  96. Permanent selectedPermanent = null;
  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. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to app fuse", "The opponent is selecting 1 digimon to app fuse");
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  114. {
  115. selectedPermanent = permanent;
  116. yield return null;
  117. }
  118. if (selectedPermanent != null)
  119. {
  120. CardSource selectedCard = null;
  121. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, handCard => CanSelectCard(handCard, selectedPermanent)));
  122. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  123. selectHandEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: handCard => CanSelectCard(handCard, selectedPermanent),
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount1,
  129. canNoSelect: true,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. selectCardCoroutine: SelectCardCoroutine,
  133. afterSelectCardCoroutine: null,
  134. mode: SelectHandEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. selectHandEffect.SetUpCustomMessage("Select digimon to app fuse into.", "The opponent is selecting digimon to app fuse into.");
  137. selectHandEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  138. yield return StartCoroutine(selectHandEffect.Activate());
  139. IEnumerator SelectCardCoroutine(CardSource cardSource)
  140. {
  141. selectedCard = cardSource;
  142. yield return null;
  143. }
  144. if (selectedCard != null && selectedCard.CanAppFusionFromTargetPermanent(selectedPermanent, true))
  145. {
  146. CardSource linkCard = selectedPermanent.LinkedCards.Where(x => selectedCard.appFusionCondition.linkedCondition(selectedPermanent, x)).First();
  147. PlayCardClass playCardClass = new PlayCardClass(new List<CardSource> { selectedCard }, hashtable, true, selectedPermanent, false, SelectCardEffect.Root.Hand, true);
  148. playCardClass.SetAppFusion(new int[] { selectedPermanent.PermanentFrame.FrameID, selectedPermanent.LinkedCards.IndexOf(linkCard) });
  149. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  150. }
  151. }
  152. }
  153. }
  154. }
  155. #endregion
  156. #region Security
  157. if (timing == EffectTiming.SecuritySkill)
  158. {
  159. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  160. }
  161. #endregion
  162. return cardEffects;
  163. }
  164. }
  165. }