BT11_033.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_033 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Return 1 level 5 or lower Digimon to hand or opponent adds the top card of Security", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Digivolving] Return 1 of your opponent's level 5 or lower Digimon to its owner's hand. If no Digimon was returned by this effect, your opponent adds the top card of their security stack to their hand.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.Level <= 5)
  26. {
  27. if (permanent.TopCard.HasLevel)
  28. {
  29. if (permanent.CanSelectBySkill(activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (isExistOnField(card))
  45. {
  46. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  47. {
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. return true;
  51. }
  52. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  61. {
  62. if (isExistOnField(card))
  63. {
  64. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  65. {
  66. List<Permanent> selectedPermanents = new List<Permanent>();
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  81. mode: SelectPermanentEffect.Mode.Bounce,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  85. {
  86. foreach (Permanent permanent in permanents)
  87. {
  88. selectedPermanents.Add(permanent);
  89. }
  90. yield return null;
  91. }
  92. }
  93. bool bounced()
  94. {
  95. foreach (Permanent permanent in selectedPermanents)
  96. {
  97. if (permanent.TopCard == null)
  98. {
  99. if (permanent.willBeRemoveField)
  100. {
  101. if (permanent.HandBounceEffect == activateClass)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. if (!bounced())
  111. {
  112. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  113. {
  114. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  115. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  116. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  117. player: card.Owner.Enemy,
  118. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  119. activateClass).ReduceSecurity());
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. if (timing == EffectTiming.OnAddHand)
  127. {
  128. int count()
  129. {
  130. return card.Owner.Enemy.HandCards.Count / 4;
  131. }
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Gain Memory", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  135. activateClass.SetHashString("GainMemory_BT11_033");
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[All Turns][Once Per Turn] When an effect adds cards to your opponent's hand, gain 1 memory for every 4 cards in your opponent's hand.";
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. if (CardEffectCommons.IsExistOnBattleArea(card))
  144. {
  145. if (CardEffectCommons.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null))
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. if (CardEffectCommons.IsExistOnBattleArea(card))
  155. {
  156. return true;
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(count(), activateClass));
  163. }
  164. }
  165. return cardEffects;
  166. }
  167. }
  168. }