EX11_041.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Oblivimon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_041 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 &&
  17. (targetPermanent.TopCard.EqualsTraits("Cyborg") || targetPermanent.TopCard.EqualsTraits("Machine"));
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Security - End of Opponents Turn
  23. if (timing == EffectTiming.OnEndTurn)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Play this card", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "(Security) [End of Opponent's Turn] Play this card without paying the cost.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.IsOpponentTurn(card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistInSecurity(card) &&
  40. CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass,SelectCardEffect.Root.Security);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { card }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Security, activateETB: true));
  45. }
  46. }
  47. #endregion
  48. #region Shared OP / WD
  49. string SharedEffectName = "Flip security card face up, De-digivolve 1. Then Digivolve on their turn";
  50. string SharedEffectDescription(string tag) => $"[{tag}] Flip your opponent's top face-down security card face up and <De-Digivolve 1> 1 of their Digimon. Then, if it's their turn, this Digimon may digivolve into [Invisimon] in the hand without paying the cost.";
  51. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  52. bool OpponentsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  53. bool IsInvisimonCardCondition(CardSource cardSource) => cardSource.EqualsCardName("Invisimon");
  54. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  55. {
  56. foreach (CardSource source in card.Owner.Enemy.SecurityCards)
  57. {
  58. if (!source.IsFlipped)
  59. continue;
  60. yield return ContinuousController.instance.StartCoroutine(new IFlipSecurity(source).FlipFaceUp());
  61. break;
  62. }
  63. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimonCondition))
  64. {
  65. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  66. selectPermanentEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: OpponentsDigimonCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: 1,
  72. canNoSelect: false,
  73. canEndNotMax: false,
  74. selectPermanentCoroutine: SelectPermanentCoroutine,
  75. afterSelectPermanentCoroutine: null,
  76. mode: SelectPermanentEffect.Mode.Custom,
  77. cardEffect: activateClass);
  78. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  81. {
  82. Permanent selectedPermanent = permanent;
  83. if (selectedPermanent != null)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  86. }
  87. yield return null;
  88. }
  89. }
  90. if (CardEffectCommons.IsOpponentTurn(card))
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(
  93. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  94. targetPermanent: card.PermanentOfThisCard(),
  95. cardCondition: IsInvisimonCardCondition,
  96. payCost: false,
  97. null,
  98. null,
  99. -1,
  100. isHand: true,
  101. activateClass,
  102. null
  103. ));
  104. }
  105. yield return null;
  106. }
  107. #endregion
  108. #region On Play
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  113. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
  114. cardEffects.Add(activateClass);
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  118. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  119. }
  120. }
  121. #endregion
  122. #region When Digivolving
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  127. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  128. cardEffects.Add(activateClass);
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  132. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  133. }
  134. }
  135. #endregion
  136. #region Your Turn
  137. if (timing == EffectTiming.OnSecurityCheck)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Place top card face up as bottom security", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[Your Turn] When your Digimon check face-up security cards, you may place this Digimon's top stacked card face up as the bottom security card.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. if(CardEffectCommons.IsOwnerTurn(card))
  150. {
  151. if (!CardEffectCommons.GetCardFromHashtable(hashtable).IsFlipped)
  152. return true;
  153. }
  154. return false;
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  159. card.PermanentOfThisCard().DigivolutionCards.Count > 0;
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. // Place this card face up as the bottom security card
  164. if (card.Owner.CanAddSecurity(activateClass))
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  167. card, toTop: false, faceUp: true));
  168. }
  169. }
  170. }
  171. #endregion
  172. #region Your Turn - ESS
  173. if (timing == EffectTiming.None)
  174. {
  175. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  176. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be switched.", CanUseCondition, card);
  177. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  178. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  179. cardEffects.Add(canNotSwitchAttackTargetClass);
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  183. CardEffectCommons.IsOwnerTurn(card);
  184. }
  185. bool PermanentCondition(Permanent permanent)
  186. {
  187. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  188. }
  189. }
  190. #endregion
  191. return cardEffects;
  192. }
  193. }
  194. }