BT21_079.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_079 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Requirement
  14. if(timing == EffectTiming.None)
  15. {
  16. bool DigivolutionCondition(Permanent permanent)
  17. {
  18. return permanent.Level == 5 && permanent.TopCard.ContainsCardName("Growlmon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(DigivolutionCondition, 4, false, card, null));
  21. }
  22. #endregion
  23. #region Security attack
  24. if (timing == EffectTiming.None)
  25. {
  26. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  27. changeValue: 1,
  28. isInheritedEffect: false,
  29. card: card,
  30. condition: null));
  31. }
  32. #endregion
  33. #region Rule Text
  34. if (timing == EffectTiming.None)
  35. {
  36. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  37. changeCardNamesClass.SetUpICardEffect("Also treated as [ChaosGallantmon]", _ => true, card);
  38. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: ChangeCardNames);
  39. cardEffects.Add(changeCardNamesClass);
  40. List<string> ChangeCardNames(CardSource cardSource, List<string> cardNames)
  41. {
  42. if (cardSource == card)
  43. {
  44. cardNames.Add("ChaosGallantmon");
  45. }
  46. return cardNames;
  47. }
  48. }
  49. #endregion
  50. #region End of attack
  51. if (timing == EffectTiming.OnEndAttack)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Delete all digimon", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  56. activateClass.SetHashString("BT21_079 EOA");
  57. cardEffects.Add(activateClass);
  58. string EffectDescription()
  59. {
  60. return "[End of Attack][Once Per Turn] Delete all Digimon.";
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. List<Permanent> DestroyTargetPermanents = GManager.instance.turnStateMachine.gameContext.Players.Map(player => player.GetBattleAreaDigimons()).Flat();
  73. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(DestroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  74. }
  75. }
  76. #endregion
  77. #region On Deletion
  78. if(timing == EffectTiming.OnDestroyedAnyone)
  79. {
  80. ActivateClass activateClass = new ActivateClass();
  81. activateClass.SetUpICardEffect("Play guilmon or growlmon in name", CanUseCondition, card);
  82. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  83. cardEffects.Add(activateClass);
  84. string EffectDescription()
  85. {
  86. return "[On Deletion] You may play 1 play cost 3 or lower Digimon card with [Guilmon] or [Growlmon] in its name from your trash without paying the cost. For every 10 cards in both players' trashes, add 2 to this effect's play cost maximum.";
  87. }
  88. int Count()
  89. {
  90. return Mathf.FloorToInt((card.Owner.TrashCards.Count + card.Owner.Enemy.TrashCards.Count) / 10);
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  95. }
  96. bool CanSelectCardCondition(CardSource card)
  97. {
  98. return card.IsDigimon
  99. && (card.ContainsCardName("Guilmon") || card.ContainsCardName("Growlmon"))
  100. && card.GetCostItself <= 3 + Count() * 2;
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  109. {
  110. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  111. List<CardSource> selectedCards = new List<CardSource>();
  112. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  113. selectCardEffect.SetUp(
  114. canTargetCondition: CanSelectCardCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. canNoSelect: () => true,
  118. selectCardCoroutine: SelectCardCoroutine,
  119. afterSelectCardCoroutine: null,
  120. message: "Select 1 card to play.",
  121. maxCount: maxCount,
  122. canEndNotMax: false,
  123. isShowOpponent: true,
  124. mode: SelectCardEffect.Mode.Custom,
  125. root: SelectCardEffect.Root.Trash,
  126. customRootCardList: null,
  127. canLookReverseCard: true,
  128. selectPlayer: card.Owner,
  129. cardEffect: activateClass);
  130. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  131. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  132. yield return StartCoroutine(selectCardEffect.Activate());
  133. IEnumerator SelectCardCoroutine(CardSource cardSource)
  134. {
  135. selectedCards.Add(cardSource);
  136. yield return null;
  137. }
  138. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  139. cardSources: selectedCards,
  140. activateClass: activateClass,
  141. payCost: false,
  142. isTapped: false,
  143. root: SelectCardEffect.Root.Trash,
  144. activateETB: true));
  145. }
  146. }
  147. }
  148. #endregion
  149. return cardEffects;
  150. }
  151. }
  152. }