EX8_054.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX8
  4. {
  5. public class EX8_054 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution Requirement
  11. if (timing == EffectTiming.None)
  12. {
  13. static bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel6 &&
  16. targetPermanent.TopCard.ContainsCardName("Justimon") &&
  17. !targetPermanent.TopCard.EqualsTraits("X Antibody");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Rush/Piercing/Security A. +1
  23. if (timing == EffectTiming.None)
  24. {
  25. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  26. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  27. }
  28. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  29. {
  30. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  31. }
  32. #endregion
  33. #region When Attacking
  34. if (timing == EffectTiming.OnAllyAttack)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Activate 1 [When Digivolving] effect", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  39. activateClass.SetHashString("Activate_EX8_054");
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[When Attacking] [Once Per Turn] Activate 1 [When Digivolving] effect of 1 Digimon card with [Justimon] in its name in this Digimon's digivolution cards as an effect of this Digimon.";
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. foreach (CardSource source in card.PermanentOfThisCard().DigivolutionCards)
  61. {
  62. if (!source.IsFlipped)
  63. {
  64. if (!source.ContainsCardName("Justimon"))
  65. continue;
  66. List<ICardEffect> effects = source.EffectList(EffectTiming.OnEnterFieldAnyone)
  67. .Clone()
  68. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  69. if (effects.Count == 0)
  70. continue;
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (CardEffectCommons.IsExistOnBattleArea(card))
  80. {
  81. List<ICardEffect> candidateEffects = new List<ICardEffect>();
  82. foreach (CardSource source in card.PermanentOfThisCard().DigivolutionCards)
  83. {
  84. if (!source.ContainsCardName("Justimon") || source.IsFlipped)
  85. continue;
  86. List<ICardEffect> effects = source.EffectList_ForCard(EffectTiming.OnEnterFieldAnyone, card)
  87. .Clone()
  88. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  89. candidateEffects.AddRange(effects);
  90. }
  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(card);
  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. #endregion
  154. #region End of Your Turn
  155. if (timing == EffectTiming.OnEndTurn)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("This Digimon may attack a player", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  160. activateClass.SetHashString("EOT_EX8_054");
  161. cardEffects.Add(activateClass);
  162. string EffectDiscription()
  163. {
  164. return "[End of Your Turn] [Once Per Turn] If your opponent has an unsuspended Digimon, this Digimon may attack a player.";
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. if (CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. if (CardEffectCommons.IsOwnerTurn(card))
  171. {
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  180. CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => permanent.IsDigimon && !permanent.IsSuspended) &&
  181. card.PermanentOfThisCard().CanAttack(activateClass);
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  186. selectAttackEffect.SetUp(
  187. attacker: card.PermanentOfThisCard(),
  188. canAttackPlayerCondition: () => true,
  189. defenderCondition: (permanent) => false,
  190. cardEffect: activateClass);
  191. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  192. }
  193. }
  194. #endregion
  195. return cardEffects;
  196. }
  197. }
  198. }