EX5_027.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class EX5_027 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Frimon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Add 1 card from security to hand", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] Search your security stack. You may add 1 card with [Leomon] in its name among them to the hand. If you added a card, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack). Then, shuffle your security stack.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. return cardSource.ContainsCardName("Leomon");
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (card.Owner.SecurityCards.Count >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count(CanSelectCardCondition));
  53. CardSource selectedCard = null;
  54. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  55. selectCardEffect.SetUp(
  56. canTargetCondition: CanSelectCardCondition,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. canNoSelect: () => true,
  60. selectCardCoroutine: null,
  61. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  62. message: "Select 1 card to add to your hand.",
  63. maxCount: maxCount,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. mode: SelectCardEffect.Mode.AddHand,
  67. root: SelectCardEffect.Root.Security,
  68. customRootCardList: null,
  69. canLookReverseCard: true,
  70. selectPlayer: card.Owner,
  71. cardEffect: activateClass);
  72. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  73. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  74. {
  75. foreach (CardSource cardSource in cardSources)
  76. {
  77. selectedCard = cardSource;
  78. }
  79. if (cardSources.Count >= 1)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  82. player: card.Owner,
  83. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  84. activateClass).ReduceSecurity());
  85. }
  86. yield return null;
  87. }
  88. if (selectedCard != null)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  91. }
  92. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  93. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  94. }
  95. }
  96. if (timing == EffectTiming.OnDestroyedAnyone)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("DP -2000", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  101. activateClass.SetIsInheritedEffect(true);
  102. cardEffects.Add(activateClass);
  103. string EffectDiscription()
  104. {
  105. return "[On Deletion] 1 of your opponent's Digimon gets -2000 DP until the end of their turn.";
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  118. {
  119. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  120. {
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  127. {
  128. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  129. {
  130. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  131. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  132. selectPermanentEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: CanSelectPermanentCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: maxCount,
  138. canNoSelect: false,
  139. canEndNotMax: false,
  140. selectPermanentCoroutine: SelectPermanentCoroutine,
  141. afterSelectPermanentCoroutine: null,
  142. mode: SelectPermanentEffect.Mode.Custom,
  143. cardEffect: activateClass);
  144. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  147. {
  148. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  149. targetPermanent: permanent,
  150. changeValue: -2000,
  151. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  152. activateClass: activateClass));
  153. }
  154. }
  155. }
  156. }
  157. return cardEffects;
  158. }
  159. }