BT22_071.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Devimon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_071 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel3 && (targetPermanent.TopCard.HasFlameTraits || targetPermanent.TopCard.HasCSTraits);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Play 1 [Jimmy KEN] Tamer", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Jimmy KEN] from your hand without paying the cost.";
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  46. && CardEffectCommons.IsOwnerTurn(card)
  47. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectTamer)
  48. && card.Owner.GetBattleAreaPermanents().Filter(x => x.IsTamer).Count <= 1;
  49. }
  50. bool CanSelectTamer(CardSource cardSource)
  51. {
  52. return cardSource.IsTamer
  53. && cardSource.EqualsCardName("Jimmy KEN")
  54. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectTamer))
  59. {
  60. CardSource selectedCard = null;
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectTamer));
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectTamer,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  77. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator SelectCardCoroutine(CardSource cardSource)
  80. {
  81. selectedCard = cardSource;
  82. yield return null;
  83. }
  84. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  85. }
  86. }
  87. }
  88. #endregion
  89. #region ESS
  90. if (timing == EffectTiming.OnDestroyedAnyone)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Return 1 [Flame]/[CS] digimon from trash to hand", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  95. activateClass.SetIsInheritedEffect(true);
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[On Deletion] You may return 1 Digimon card with the [Flame] or [CS] trait from your trash to the hand.";
  100. }
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  104. }
  105. bool CanActivateCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  108. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  109. }
  110. bool CanSelectCardCondition(CardSource cardSource)
  111. {
  112. return cardSource.IsDigimon
  113. && (cardSource.HasFlameTraits || cardSource.HasCSTraits);
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  118. {
  119. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: CanSelectCardCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => true,
  126. selectCardCoroutine: null,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 digimon card to add to hand.",
  129. maxCount: maxCount,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.AddHand,
  133. root: SelectCardEffect.Root.Trash,
  134. customRootCardList: null,
  135. canLookReverseCard: true,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. selectCardEffect.SetUpCustomMessage("Select 1 digimon card to add to hand.", "The opponent is selecting 1 digimon card to add to hand.");
  139. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  140. yield return StartCoroutine(selectCardEffect.Activate());
  141. }
  142. }
  143. }
  144. #endregion
  145. return cardEffects;
  146. }
  147. }
  148. }