BT16_102.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_102 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Armor Purge and Blocker
  12. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  13. {
  14. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card: card));
  15. }
  16. if (timing == EffectTiming.None)
  17. {
  18. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Digivolution Condition
  22. if (timing == EffectTiming.None)
  23. {
  24. bool PermanentCondition(Permanent targetPermanent)
  25. {
  26. if (targetPermanent.TopCard.ContainsCardName("Magnamon") && targetPermanent.TopCard.CardColors.Count == 2)
  27. {
  28. return true;
  29. }
  30. return false;
  31. }
  32. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  33. permanentCondition: PermanentCondition,
  34. digivolutionCost: 5,
  35. ignoreDigivolutionRequirement: true,
  36. card: card,
  37. condition: null));
  38. }
  39. #endregion
  40. #region When Digivolving
  41. if (timing == EffectTiming.OnEnterFieldAnyone)
  42. {
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("Become unaffected by effects, gain DP and unsuspend.", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  46. cardEffects.Add(activateClass);
  47. string EffectDiscription()
  48. {
  49. return "[When Digivolving] If [Magnamon (X-Antibody)] or a card with the [Armor Form] trait is in this Digimon's digivolution cards, this Digimon isn't affected by your opponent's effects and gains +3000 DP until the end of your opponent's turn. Then, unsuspend this Digimon.";
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  54. {
  55. return CardEffectCommons.IsExistOnBattleArea(card);
  56. }
  57. return false;
  58. }
  59. bool CanActivateCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.IsExistOnBattleArea(card))
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. Permanent selectedPermanent = card.PermanentOfThisCard();
  70. if (selectedPermanent != null)
  71. {
  72. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  73. (cardSource.EqualsCardName("Magnamon (X Antibody)") ||
  74. cardSource.ContainsTraits("Armor Form")) &&
  75. !cardSource.IsFlipped)>= 1)
  76. {
  77. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  78. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effects", CanUseCondition1, card);
  79. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  80. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  81. bool CanUseCondition1(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  84. }
  85. bool CardCondition(CardSource cardSource)
  86. {
  87. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  88. {
  89. if (cardSource == selectedPermanent.TopCard)
  90. {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. bool SkillCondition(ICardEffect cardEffect)
  97. {
  98. if (cardEffect != null)
  99. {
  100. if (cardEffect.EffectSourceCard != null)
  101. {
  102. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  103. {
  104. return true;
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  111. targetPermanent: selectedPermanent,
  112. changeValue: 3000,
  113. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  114. activateClass: activateClass));
  115. }
  116. if (CardEffectCommons.CanUnsuspend(selectedPermanent))
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  119. }
  120. }
  121. }
  122. }
  123. #endregion
  124. #region All Turns
  125. if (timing == EffectTiming.OnLoseSecurity)
  126. {
  127. ActivateClass activateClass = new ActivateClass();
  128. activateClass.SetUpICardEffect("Activate one of this Digimon's [When Digivolving] effects.", CanUseCondition, card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  130. activateClass.SetHashString("BT16_102_AllTurns");
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[All Turns][Once per turn] When a card is removed from a security stack, you may activate 1 of this Digimon's [When Digivolving] effects.";
  135. }
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner || player == card.Owner.Enemy))
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner || player == card.Owner.Enemy))
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  161. .Clone()
  162. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  163. if (candidateEffects.Count >= 1)
  164. {
  165. ICardEffect selectedEffect = null;
  166. if (candidateEffects.Count == 1)
  167. {
  168. selectedEffect = candidateEffects[0];
  169. }
  170. else
  171. {
  172. List<SkillInfo> skillInfos = candidateEffects
  173. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  174. List<CardSource> cardSources = candidateEffects
  175. .Map(cardEffect => cardEffect.EffectSourceCard);
  176. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  177. selectCardEffect.SetUp(
  178. canTargetCondition: (cardSource) => true,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. canNoSelect: () => false,
  182. selectCardCoroutine: null,
  183. afterSelectCardCoroutine: null,
  184. message: "Select 1 effect to activate.",
  185. maxCount: 1,
  186. canEndNotMax: false,
  187. isShowOpponent: false,
  188. mode: SelectCardEffect.Mode.Custom,
  189. root: SelectCardEffect.Root.Custom,
  190. customRootCardList: cardSources,
  191. canLookReverseCard: true,
  192. selectPlayer: card.Owner,
  193. cardEffect: activateClass);
  194. selectCardEffect.SetNotShowCard();
  195. selectCardEffect.SetUpSkillInfos(skillInfos);
  196. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  197. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  198. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  199. {
  200. if (selectedIndexes.Count == 1)
  201. {
  202. selectedEffect = candidateEffects[selectedIndexes[0]];
  203. yield return null;
  204. }
  205. }
  206. }
  207. if (selectedEffect != null)
  208. {
  209. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  210. if (!selectedEffect.IsDisabled)
  211. {
  212. yield return ContinuousController.instance.StartCoroutine(
  213. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  214. }
  215. }
  216. }
  217. }
  218. }
  219. #endregion
  220. return cardEffects;
  221. }
  222. }
  223. }