BT22_087.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Torajiro Asuka
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_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 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("-2K DP, 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, 1 of your opponent's Digimon gets -2000 DP for the turn. Then, 1 of your Digimon may app fuse into a Digimon card in the hand.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card)
  33. && CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkPermanentCondition, null);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && CardEffectCommons.IsOwnerTurn(card)
  39. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  40. }
  41. bool LinkPermanentCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  44. }
  45. bool IsOpponentDigimon(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. bool CanSelectPermanent(Permanent permanent)
  50. {
  51. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  52. {
  53. foreach (CardSource hand in card.Owner.HandCards)
  54. {
  55. if (hand.appFusionCondition != null)
  56. {
  57. if (hand.CanAppFusionFromTargetPermanent(permanent, true))
  58. return true;
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanSelectCard(CardSource card, Permanent permanent)
  65. {
  66. if (CardEffectCommons.IsExistOnHand(card))
  67. {
  68. if (card.appFusionCondition != null)
  69. {
  70. if (card.CanAppFusionFromTargetPermanent(permanent, true))
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).Tap());
  79. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  80. {
  81. Permanent selectedPermament = null;
  82. #region Select Permanent
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: IsOpponentDigimon,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermament = permanent;
  100. yield return null;
  101. }
  102. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -2K DP", "The opponent is selecting 1 Digimon to -2K DP");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. #endregion
  105. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  106. targetPermanent: selectedPermament,
  107. changeValue: -2000,
  108. effectDuration: EffectDuration.UntilEachTurnEnd,
  109. activateClass: activateClass
  110. ));
  111. }
  112. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanent))
  113. {
  114. Permanent selectedPermanent = null;
  115. #region Select App Fuse Permanent Target
  116. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectPermanent));
  117. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  118. selectPermanentEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectPermanent,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. maxCount: maxCount,
  124. canNoSelect: true,
  125. canEndNotMax: false,
  126. selectPermanentCoroutine: SelectPermanentCoroutine,
  127. afterSelectPermanentCoroutine: null,
  128. mode: SelectPermanentEffect.Mode.Custom,
  129. cardEffect: activateClass);
  130. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  131. {
  132. selectedPermanent = permanent;
  133. yield return null;
  134. }
  135. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to app fuse", "The opponent is selecting 1 digimon to app fuse");
  136. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  137. #endregion
  138. if (selectedPermanent != null)
  139. {
  140. CardSource selectedCard = null;
  141. #region Select App Fusion Hand Target
  142. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, handCard => CanSelectCard(handCard, selectedPermanent)));
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: handCard => CanSelectCard(handCard, selectedPermanent),
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: maxCount1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. mode: SelectHandEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. IEnumerator SelectCardCoroutine(CardSource cardSource)
  158. {
  159. selectedCard = cardSource;
  160. yield return null;
  161. }
  162. selectHandEffect.SetUpCustomMessage("Select digimon to app fuse into.", "The opponent is selecting digimon to app fuse into.");
  163. selectHandEffect.SetUpCustomMessage_ShowCard("Selected digimon");
  164. yield return StartCoroutine(selectHandEffect.Activate());
  165. #endregion
  166. if (selectedCard != null && selectedCard.CanAppFusionFromTargetPermanent(selectedPermanent, true))
  167. {
  168. CardSource linkCard = selectedPermanent.LinkedCards.Where(x => selectedCard.appFusionCondition.linkedCondition(selectedPermanent, x)).First();
  169. PlayCardClass playCardClass = new PlayCardClass(new List<CardSource> { selectedCard }, hashtable, true, selectedPermanent, false, SelectCardEffect.Root.Hand, true);
  170. playCardClass.SetAppFusion(new int[] { selectedPermanent.PermanentFrame.FrameID, selectedPermanent.LinkedCards.IndexOf(linkCard) });
  171. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  172. }
  173. }
  174. }
  175. }
  176. }
  177. #endregion
  178. #region Security
  179. if (timing == EffectTiming.SecuritySkill)
  180. {
  181. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  182. }
  183. #endregion
  184. return cardEffects;
  185. }
  186. }
  187. }