EX9_006.cs 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX9
  5. {
  6. public class EX9_006 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Inherit
  12. if (timing == EffectTiming.OnAllyAttack)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Digivolve in the trash", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  17. activateClass.SetIsInheritedEffect(true);
  18. activateClass.SetHashString("Digivolve_EX9_006");
  19. cardEffects.Add(activateClass);
  20. string EffectDescription() => "[When Attacking][Once Per Turn] By trashing this Digimon's bottom face-down digivolution card, this Digimon may digivolve into a [Ver.5] trait Digimon card in the trash with the digivolution cost reduced by 1.";
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  24. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  25. }
  26. bool CanSelectCardCondition(CardSource cardSource)
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. if (cardSource.ContainsTraits("Ver.5"))
  31. {
  32. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  41. {
  42. return cardSource.IsFlipped && !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  47. card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectTrashSourceCardCondition) >= 1;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. List<CardSource> selectedCards = new List<CardSource>();
  52. CardSource trashTargetCard = card.PermanentOfThisCard().DigivolutionCards.Filter(CanSelectTrashSourceCardCondition)[^1];
  53. selectedCards.Add(trashTargetCard);
  54. if (selectedCards.Count >= 1)
  55. {
  56. yield return ContinuousController.instance.StartCoroutine(
  57. new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  58. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  61. targetPermanent: card.PermanentOfThisCard(),
  62. cardCondition: CanSelectCardCondition,
  63. payCost: true,
  64. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  65. fixedCostTuple: null,
  66. ignoreDigivolutionRequirementFixedCost: -1,
  67. isHand: false,
  68. activateClass: activateClass,
  69. successProcess: null));
  70. }
  71. }
  72. }
  73. }
  74. #endregion
  75. return cardEffects;
  76. }
  77. }
  78. }