BT25_100.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Iron Slash
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_100 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Link Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.IsDigimon && targetPermanent.TopCard.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  21. }
  22. #endregion
  23. #region Link
  24. if (timing == EffectTiming.OnDeclaration)
  25. {
  26. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  27. }
  28. #endregion
  29. #region Use Requirement
  30. if (timing == EffectTiming.None)
  31. {
  32. bool CardCondition(CardSource cardSource) => cardSource.HasTSTraits;
  33. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  34. }
  35. #endregion
  36. #region Link Inherit
  37. #region Collision
  38. if (timing == EffectTiming.OnCounterTiming)
  39. {
  40. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null, true));
  41. }
  42. #endregion
  43. #region Piercing
  44. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  45. {
  46. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null, isLinkedEffect: true));
  47. }
  48. #endregion
  49. #endregion
  50. #endregion
  51. #region Main
  52. if (timing == EffectTiming.OptionSkill)
  53. {
  54. ActivateClass activateClass = new ActivateClass();
  55. activateClass.SetUpICardEffect("De-Digi(2) 1 opponent digimon, then may link to 1 of your digimon on the field", CanUseCondition, card);
  56. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  57. cardEffects.Add(activateClass);
  58. string EffectDescription()
  59. => "[Main] <De-Digivolve 2> 1 of your opponent's Digimon. Then, you may link this card to 1 of your Digimon on the field without paying the cost.";
  60. bool CanUseCondition(Hashtable hashtable)
  61. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  62. bool CanSelectOwnerPermamentCondition(Permanent permanent)
  63. {
  64. return CardEffectCommons.IsOwnerPermanent(permanent, card)
  65. && permanent.IsDigimon
  66. && card.CanLinkToTargetPermanent(permanent, false, true);
  67. }
  68. bool CanSelectEnemyPermamentCondition(Permanent permanent)
  69. => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. // De-Digi(2) 1 opponent digimon
  73. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectEnemyPermamentCondition))
  74. {
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectEnemyPermamentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectEnemyPermamentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: null,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Degenerate,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetDegenerationCount(2);
  90. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digi(2)", "The opponent is selecting 1 Digimon to De-Digi(2).");
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. }
  93. // Link to 1 Owner digimon on the field
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermamentCondition, true))
  95. {
  96. Permanent selectedPermament = null;
  97. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  98. selectPermanentEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: CanSelectOwnerPermamentCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: 1,
  104. canNoSelect: true,
  105. canEndNotMax: false,
  106. selectPermanentCoroutine: SelectPermanentCoroutine,
  107. afterSelectPermanentCoroutine: null,
  108. mode: SelectPermanentEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  111. {
  112. selectedPermament = permanent;
  113. yield return null;
  114. }
  115. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link this card to", "The opponent is selecting 1 Digimon to link this card to.");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddLinkCard(
  118. addedLinkCard: card,
  119. cardEffect: activateClass));
  120. }
  121. }
  122. }
  123. #endregion
  124. #region Security
  125. if (timing == EffectTiming.SecuritySkill)
  126. {
  127. string EffectDiscription() => "[Security] Activate this card's [Main] effect.";
  128. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"De-Digi(2) 1 opponent digimon, then may link to 1 digimon on the field", effectDiscription: EffectDiscription());
  129. }
  130. #endregion
  131. return cardEffects;
  132. }
  133. }
  134. }