ST21_10.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST21 Gabumon
  4. //Code largely copied from ST21 agumon, if error exists in one card then check the other too
  5. namespace DCGO.CardEffects.ST21
  6. {
  7. public class ST21_10 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return (targetPermanent.TopCard.HasAdventureTraits || targetPermanent.TopCard.EqualsTraits("HERO")) && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Warp Digivolution
  23. if (timing == EffectTiming.None)
  24. {
  25. bool enoughTamerColours()
  26. {
  27. List<CardSource> tamerCards = new List<CardSource>();
  28. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  29. {
  30. if (permanent.IsTamer)
  31. {
  32. tamerCards.Add(permanent.TopCard);
  33. }
  34. }
  35. return Combinations.GetDifferenetColorCardCount(tamerCards) >= 3;
  36. }
  37. bool Condition()
  38. {
  39. if (CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && permanent.HasDP && permanent.DP >= 10000))
  42. {
  43. return true;
  44. }
  45. return enoughTamerColours();
  46. }
  47. return false;
  48. }
  49. bool PermanentCondition(Permanent targetPermanent)
  50. {
  51. return targetPermanent == card.PermanentOfThisCard();
  52. }
  53. bool CardCondition(CardSource cardSource)
  54. {
  55. if (cardSource != null)
  56. {
  57. //compared to the code I was copying from (ST8-04), removed a check that owner matched between cardsource and card, as that should be handled by whose hand the card is in. If this breaks, try putting it back.
  58. if (card.Owner.HandCards.Contains(cardSource))
  59. {
  60. return cardSource.EqualsCardName("MetalGarurumon");
  61. }
  62. }
  63. return false;
  64. }
  65. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: true, card: card, condition: Condition, cardCondition: CardCondition));
  66. }
  67. #endregion
  68. #region draw + trash inherit
  69. if (timing == EffectTiming.OnAllyAttack)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  74. activateClass.SetIsInheritedEffect(true);
  75. activateClass.SetHashString("Draw_ST21_10");
  76. cardEffects.Add(activateClass);
  77. string EffectDiscription()
  78. {
  79. return "[When Attacking][Once Per Turn] <Draw 1>. (Draw 1 card from your deck.) Then, trash 1 card in your hand.";
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  84. }
  85. bool CanActivateCondition(Hashtable hashtable)
  86. {
  87. if (CardEffectCommons.IsExistOnBattleArea(card))
  88. {
  89. return true;
  90. }
  91. return false;
  92. }
  93. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  96. if (card.Owner.HandCards.Count >= 1)
  97. {
  98. int discardCount = 1;
  99. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  100. selectHandEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: (cardSource) => true,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: discardCount,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. isShowOpponent: true,
  109. selectCardCoroutine: null,
  110. afterSelectCardCoroutine: null,
  111. mode: SelectHandEffect.Mode.Discard,
  112. cardEffect: activateClass);
  113. yield return StartCoroutine(selectHandEffect.Activate());
  114. }
  115. }
  116. }
  117. #endregion
  118. return cardEffects;
  119. }
  120. }
  121. }