BT10_110.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_110 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.None)
  16. {
  17. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  18. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  19. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  20. cardEffects.Add(ignoreColorConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. if (card.Owner.GetBattleAreaDigimons().Count((permanet) => permanet.TopCard.HasRoyalKnightTraits) >= 1)
  24. {
  25. return true;
  26. }
  27. return false;
  28. }
  29. bool CardCondition(CardSource cardSource)
  30. {
  31. if (cardSource == card)
  32. {
  33. return true;
  34. }
  35. return false;
  36. }
  37. }
  38. if (timing == EffectTiming.OptionSkill)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  42. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[Main] Unsuspend 1 of your Digimon. Then, if that Digimon is [Jesmon GX], activate 1 of its [When Digivolving] effects.";
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. Permanent selectedPermanent = null;
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: null,
  72. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  73. mode: SelectPermanentEffect.Mode.UnTap,
  74. cardEffect: activateClass);
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  77. {
  78. foreach (Permanent permanent in permanents)
  79. {
  80. selectedPermanent = permanent;
  81. }
  82. yield return null;
  83. }
  84. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  85. {
  86. if (selectedPermanent.TopCard.CardNames.Contains("Jesmon GX") || selectedPermanent.TopCard.CardNames.Contains("JesmonGX"))
  87. {
  88. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  89. .Clone()
  90. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  91. if (candidateEffects.Count >= 1)
  92. {
  93. ICardEffect selectedEffect = null;
  94. if (candidateEffects.Count == 1)
  95. {
  96. selectedEffect = candidateEffects[0];
  97. }
  98. else
  99. {
  100. List<SkillInfo> skillInfos = candidateEffects
  101. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  102. List<CardSource> cardSources = candidateEffects
  103. .Map(cardEffect => cardEffect.EffectSourceCard);
  104. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  105. selectCardEffect.SetUp(
  106. canTargetCondition: (cardSource) => true,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. canNoSelect: () => false,
  110. selectCardCoroutine: null,
  111. afterSelectCardCoroutine: null,
  112. message: "Select 1 effect to activate.",
  113. maxCount: 1,
  114. canEndNotMax: false,
  115. isShowOpponent: false,
  116. mode: SelectCardEffect.Mode.Custom,
  117. root: SelectCardEffect.Root.Custom,
  118. customRootCardList: cardSources,
  119. canLookReverseCard: true,
  120. selectPlayer: card.Owner,
  121. cardEffect: activateClass);
  122. selectCardEffect.SetNotShowCard();
  123. selectCardEffect.SetUpSkillInfos(skillInfos);
  124. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  125. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  126. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  127. {
  128. if (selectedIndexes.Count == 1)
  129. {
  130. selectedEffect = candidateEffects[selectedIndexes[0]];
  131. yield return null;
  132. }
  133. }
  134. }
  135. if (selectedEffect != null)
  136. {
  137. if (selectedEffect.EffectSourceCard != null)
  138. {
  139. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  140. {
  141. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  142. if (selectedEffect.CanUse(effectHashtable))
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. if (timing == EffectTiming.SecuritySkill)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  160. activateClass.SetIsSecurityEffect(true);
  161. cardEffects.Add(activateClass);
  162. string EffectDiscription()
  163. {
  164. return "[Security] Add this card to its owner's hand.";
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  169. }
  170. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  173. }
  174. }
  175. return cardEffects;
  176. }
  177. }
  178. }