BT19_088.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_088 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Start of Your Main Phase] If your opponent has a Digimon, gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.IsOwnerTurn(card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleArea(card) && card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1 && card.Owner.CanAddMemory(activateClass);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  34. }
  35. }
  36. #endregion
  37. #region Main
  38. if (timing == EffectTiming.OnDeclaration)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Suspend this tamer to digivolve from trash or hand", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[Main] If you have 20 or more cards in your trash, by suspending this Tamer, 1 of your [Impmon] may digivolve into [Beelzemon] in the hand or trash for a digivolution cost of 4, ignoring its digivolution requirements.";
  47. }
  48. bool CanSelectOwnPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  51. permanent.TopCard.EqualsCardName("Impmon");
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (card.Owner.TrashCards.Count >= 20)
  58. {
  59. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  60. {
  61. return true;
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  71. {
  72. Permanent selectedPermanent = null;
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectOwnPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  87. "The opponent is selecting 1 Digimon that will digivolve.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. selectedPermanent = permanent;
  92. yield return null;
  93. }
  94. if (selectedPermanent != null)
  95. {
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. return cardSource.EqualsCardName("Beelzemon");
  99. }
  100. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  101. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  102. if (canSelectHand || canSelectTrash)
  103. {
  104. if (canSelectHand && canSelectTrash)
  105. {
  106. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  107. {
  108. new(message: "From hand", value: true, spriteIndex: 0),
  109. new(message: "From trash", value: false, spriteIndex: 1),
  110. };
  111. string selectPlayerMessage = "From which area do you digivolve?";
  112. string notSelectPlayerMessage = "The opponent is choosing from which area to digivolve.";
  113. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  114. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  115. notSelectPlayerMessage: notSelectPlayerMessage);
  116. }
  117. else
  118. {
  119. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  120. }
  121. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  122. .WaitForEndSelect());
  123. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  124. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  125. targetPermanent: selectedPermanent,
  126. cardCondition: CanSelectCardCondition,
  127. payCost: true,
  128. reduceCostTuple: null,
  129. fixedCostTuple: null,
  130. ignoreDigivolutionRequirementFixedCost: 4,
  131. isHand: fromHand,
  132. activateClass: activateClass,
  133. successProcess: null,
  134. ignoreRequirements:CardEffectCommons.IgnoreRequirement.All));
  135. }
  136. }
  137. }
  138. }
  139. }
  140. #endregion
  141. #region Security
  142. if (timing == EffectTiming.SecuritySkill)
  143. {
  144. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  145. }
  146. #endregion
  147. return cardEffects;
  148. }
  149. }
  150. }