BT14_032.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_032 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Add the security top card to hand and place 1 card from hand to security ", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Add the top card of your security stack to the hand. Then, you may place 1 card with [Sukamon] in its name from your hand on top of your security stack.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. return cardSource.ContainsCardName("Sukamon");
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (card.Owner.SecurityCards.Count >= 1)
  35. {
  36. return true;
  37. }
  38. if (card.Owner.HandCards.Count >= 1)
  39. {
  40. if (card.Owner.CanAddSecurity(activateClass))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. if (card.Owner.SecurityCards.Count >= 1)
  51. {
  52. CardSource topCard = card.Owner.SecurityCards[0];
  53. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  54. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  55. player: card.Owner,
  56. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  57. activateClass).ReduceSecurity());
  58. }
  59. if (card.Owner.CanAddSecurity(activateClass))
  60. {
  61. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  62. {
  63. List<CardSource> selectedCards = new List<CardSource>();
  64. int maxCount = 1;
  65. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  66. selectHandEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanSelectCardCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: maxCount,
  72. canNoSelect: true,
  73. canEndNotMax: false,
  74. isShowOpponent: true,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. mode: SelectHandEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectHandEffect.SetUpCustomMessage(
  80. "Select 1 card to place on top of security.",
  81. "The opponent is selecting 1 card to place on top of security.");
  82. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  83. yield return StartCoroutine(selectHandEffect.Activate());
  84. IEnumerator SelectCardCoroutine(CardSource cardSource)
  85. {
  86. selectedCards.Add(cardSource);
  87. yield return null;
  88. }
  89. foreach (CardSource cardSource in selectedCards)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource));
  92. }
  93. }
  94. }
  95. }
  96. }
  97. if (timing == EffectTiming.OnDestroyedAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("DP -3000", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  102. activateClass.SetIsInheritedEffect(true);
  103. cardEffects.Add(activateClass);
  104. string EffectDiscription()
  105. {
  106. return "[On Deletion] 1 of your opponent's Digimon gets -3000 DP for the turn.";
  107. }
  108. bool CanSelectPermanentCondition(Permanent permanent)
  109. {
  110. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  119. {
  120. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  121. {
  122. return true;
  123. }
  124. }
  125. return false;
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  128. {
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  130. {
  131. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: maxCount,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: SelectPermanentCoroutine,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -3000.", "The opponent is selecting 1 Digimon that will get DP -3000.");
  146. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  147. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  150. targetPermanent: permanent,
  151. changeValue: -3000,
  152. effectDuration: EffectDuration.UntilEachTurnEnd,
  153. activateClass: activateClass));
  154. }
  155. }
  156. }
  157. }
  158. return cardEffects;
  159. }
  160. }
  161. }