BT22_092.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Jimmy KEN
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_092 : 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 turn
  13. if (timing == EffectTiming.OnStartTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  16. }
  17. #endregion
  18. #region Your Turn
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Activate 1 [Main] effect. if you do, gain 1 memory", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return "[Your Turn] When your Digimon are played or digivolve, if any of them have the [Flame] or [CS] trait, by suspending this Tamer, activate 1 of those Digimon's [Main] effects. If this activated any effect, gain 1 memory.";
  28. }
  29. bool PermanentConditionNSoEnterField(Permanent permanent)
  30. {
  31. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  32. {
  33. if (permanent.TopCard.EqualsTraits("Flame") || permanent.TopCard.HasCSTraits)
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.IsOwnerTurn(card))
  45. {
  46. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentConditionNSoEnterField))
  47. {
  48. return true;
  49. }
  50. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentConditionNSoEnterField))
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.IsExistOnBattleArea(card) &&
  61. CardEffectCommons.CanActivateSuspendCostEffect(card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  66. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  67. hashtable: _hashtable,
  68. rootCondition: null)
  69. .Filter(HasMainEffect);
  70. bool HasMainEffect(Permanent permanent)
  71. {
  72. foreach (ICardEffect effect in permanent.EffectList(EffectTiming.OnDeclaration))
  73. {
  74. if (effect.EffectDiscription.Contains("[Main]"))
  75. {
  76. return true;
  77. }
  78. }
  79. return false;
  80. }
  81. if (permanents.Count > 0)
  82. {
  83. bool CanSelectPermanentCondition(Permanent permanent)
  84. {
  85. return permanents.Contains(permanent);
  86. }
  87. Permanent selectedPermanent = null;
  88. if (card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition) == 1)
  89. {
  90. selectedPermanent = card.Owner.GetBattleAreaDigimons().Find(CanSelectPermanentCondition);
  91. }
  92. else
  93. {
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: CanSelectPermanentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: 1,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will activate a [Main] effect.", "The opponent is selecting 1 Digimon that will activate a [Main] effect.");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. selectedPermanent = permanent;
  112. yield return null;
  113. }
  114. }
  115. if (selectedPermanent != null)
  116. {
  117. List<ICardEffect> candidateEffects = new List<ICardEffect>();
  118. List<ICardEffect> effects = selectedPermanent.EffectList(EffectTiming.OnDeclaration)
  119. .Clone()
  120. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && cardEffect.EffectDiscription.Contains("[Main]"));
  121. candidateEffects.AddRange(effects);
  122. if (candidateEffects.Count >= 1)
  123. {
  124. ICardEffect selectedEffect = null;
  125. if (candidateEffects.Count == 1)
  126. {
  127. selectedEffect = candidateEffects[0];
  128. }
  129. else
  130. {
  131. List<SkillInfo> skillInfos = candidateEffects
  132. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  133. List<CardSource> cardSources = candidateEffects
  134. .Map(cardEffect => cardEffect.EffectSourceCard);
  135. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  136. selectCardEffect.SetUp(
  137. canTargetCondition: (cardSource) => true,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. canNoSelect: () => false,
  141. selectCardCoroutine: null,
  142. afterSelectCardCoroutine: null,
  143. message: "Select 1 effect to activate.",
  144. maxCount: 1,
  145. canEndNotMax: false,
  146. isShowOpponent: false,
  147. mode: SelectCardEffect.Mode.Custom,
  148. root: SelectCardEffect.Root.Custom,
  149. customRootCardList: cardSources,
  150. canLookReverseCard: true,
  151. selectPlayer: card.Owner,
  152. cardEffect: activateClass);
  153. selectCardEffect.SetNotShowCard();
  154. selectCardEffect.SetUpSkillInfos(skillInfos);
  155. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  156. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  157. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  158. {
  159. if (selectedIndexes.Count == 1)
  160. {
  161. selectedEffect = candidateEffects[selectedIndexes[0]];
  162. yield return null;
  163. }
  164. }
  165. }
  166. if (selectedEffect != null)
  167. {
  168. if (selectedEffect.EffectSourceCard != null)
  169. {
  170. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  171. {
  172. if (selectedEffect.CanUse(null))
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(null));
  175. ((ActivateICardEffect)selectedEffect).AddUse();
  176. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. #endregion
  187. #region Security
  188. if (timing == EffectTiming.SecuritySkill)
  189. {
  190. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  191. }
  192. #endregion
  193. return cardEffects;
  194. }
  195. }
  196. }