BT18_018.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_018 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Takuya Kanbara") &&
  18. targetPermanent.DigivolutionCards.Count(cardSource => cardSource.ContainsTraits("Hybrid")) >= 5;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: true,
  22. card: card, condition: null));
  23. }
  24. #endregion
  25. #region When Digivolving
  26. if (timing == EffectTiming.OnEnterFieldAnyone)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Trash Digivolution cards, suspend opponent's Digimon and attack", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  31. cardEffects.Add(activateClass);
  32. string EffectDescription()
  33. {
  34. return
  35. "[When Digivolving] For each color in this Digimon's digivolution cards, trash any 1 digivolution card from your opponent's Digimon and suspend 1 of their Digimon. Then, this Digimon may attack.";
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanSelectTrashSourcePermanentCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  44. permanent.DigivolutionCards.Some(CanSelectCardCondition);
  45. }
  46. bool CanSelectCardCondition(CardSource cardSource)
  47. {
  48. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  49. }
  50. bool CanSelectSuspendPermanentCondition(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  53. permanent.CanSuspend;
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. #region Amount of colors in this Digimon's digivolution cards
  62. List<CardColor> cardColors = new List<CardColor>();
  63. foreach (CardSource source in card.PermanentOfThisCard().DigivolutionCards)
  64. {
  65. cardColors.AddRange(source.CardColors);
  66. }
  67. cardColors = cardColors.Distinct().ToList();
  68. int colorCount = cardColors.Count;
  69. #endregion
  70. #region Trash Digivolution cards
  71. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  72. permanentCondition: CanSelectTrashSourcePermanentCondition,
  73. cardCondition: CanSelectCardCondition,
  74. maxCount: colorCount,
  75. canNoTrash: false,
  76. isFromOnly1Permanent: false,
  77. activateClass: activateClass
  78. ));
  79. #endregion
  80. #region Suspend Opponent's Digimon
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectSuspendPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: Math.Min(colorCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectSuspendPermanentCondition)),
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: null,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Tap,
  93. cardEffect: activateClass);
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. #endregion
  96. #region Attack
  97. if (card.PermanentOfThisCard().CanAttack(activateClass))
  98. {
  99. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  100. selectAttackEffect.SetUp(
  101. attacker: card.PermanentOfThisCard(),
  102. canAttackPlayerCondition: () => true,
  103. defenderCondition: _ => true,
  104. cardEffect: activateClass);
  105. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  106. }
  107. #endregion
  108. }
  109. }
  110. #endregion
  111. #region Your Turn
  112. if (timing == EffectTiming.OnEndBattle)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Unsuspend", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  117. activateClass.SetHashString("Unsuspend_BT18_018");
  118. cardEffects.Add(activateClass);
  119. string EffectDescription()
  120. {
  121. return
  122. "[Your Turn] (Once Per Turn) When this Digimon deletes your opponent's Digimon in battle, it gains <Security Attack +1> for the turn and unsuspend it.";
  123. }
  124. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  125. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  129. CardEffectCommons.IsOwnerTurn(card) &&
  130. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  131. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  132. }
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable hashtable)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  140. targetPermanent: card.PermanentOfThisCard(),
  141. changeValue: 1,
  142. effectDuration: EffectDuration.UntilEachTurnEnd,
  143. activateClass: activateClass));
  144. yield return ContinuousController.instance.StartCoroutine(
  145. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  146. }
  147. }
  148. #endregion
  149. return cardEffects;
  150. }
  151. }
  152. }