BT24_058.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. // Blimpmon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_058 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Shared OP/WD
  23. string SharedEffectName() => "Reveal 3, add or place under sources 1, return rest to deck";
  24. string SharedEffectDescription(string tag) => $"[{tag}] Reveal the top 3 cards of your deck. Among them, add 1 [Machine], [Cyborg] or [TS] trait Digimon card or Tamer card to the hand or place it as any of your [Machine], [Cyborg] or [TS] trait Digimon's bottom digivolution card. Return the rest to the top or bottom of the deck.";
  25. bool SharedCanActivateCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  28. }
  29. bool CanSelectCardConditionShared(CardSource cardSource)
  30. {
  31. return (cardSource.IsDigimon
  32. || cardSource.IsTamer)
  33. && (cardSource.EqualsTraits("Machine")
  34. || cardSource.EqualsTraits("Cyborg")
  35. || cardSource.EqualsTraits("TS"));
  36. }
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  40. && (permanent.TopCard.EqualsTraits("Machine")
  41. || permanent.TopCard.EqualsTraits("Cyborg")
  42. || permanent.TopCard.EqualsTraits("TS"));
  43. }
  44. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  45. {
  46. if (card.Owner.LibraryCards.Count > 0)
  47. {
  48. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  49. revealCount: 3,
  50. simplifiedSelectCardConditions:
  51. new SimplifiedSelectCardConditionClass[]
  52. {
  53. new SimplifiedSelectCardConditionClass(
  54. canTargetCondition:CanSelectCardConditionShared,
  55. message: "Select 1 [Machine], [Cyborg] or [TS] trait Digimon card or Tamer card.",
  56. mode: SelectCardEffect.Mode.Custom,
  57. maxCount: 1,
  58. selectCardCoroutine: SelectCardCoroutine),
  59. },
  60. remainingCardsPlace: RemainingCardsPlace.DeckTopOrBottom,
  61. activateClass: activateClass
  62. ));
  63. IEnumerator SelectCardCoroutine(CardSource cardSource)
  64. {
  65. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  66. {
  67. new SelectionElement<bool>(message: $"Add to hand", value : true, spriteIndex: 0),
  68. new SelectionElement<bool>(message: $"Add to digivolution cards", value : false, spriteIndex: 1),
  69. };
  70. string selectPlayerMessage = "To which area do you place the card?";
  71. string notSelectPlayerMessage = "The opponent is choosing to which area to place the card.";
  72. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  73. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  74. bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  75. if (toHand)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { cardSource }, "Added Hand Card", true, true));
  78. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { cardSource }, false, activateClass));
  79. }
  80. else
  81. {
  82. Permanent selectedPermanent = null;
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectPermanentCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. selectedPermanent = permanent;
  101. yield return null;
  102. }
  103. if (selectedPermanent != null)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { cardSource }, "Digivolution Card", true, true));
  106. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { cardSource }, activateClass));
  107. }
  108. }
  109. }
  110. }
  111. }
  112. #endregion
  113. #region On Play
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  118. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  119. cardEffects.Add(activateClass);
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  123. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  124. }
  125. }
  126. #endregion
  127. #region When Digivolving
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  132. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  133. cardEffects.Add(activateClass);
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  137. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  138. }
  139. }
  140. #endregion
  141. #region Reboot - ESS
  142. if (timing == EffectTiming.None)
  143. {
  144. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  145. }
  146. #endregion
  147. return cardEffects;
  148. }
  149. }
  150. }