P_153.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_153 : 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
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardColors.Count == 3 && targetPermanent.TopCard.EqualsCardName("MagnaGarurumon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  20. card: card, condition: null));
  21. }
  22. #endregion
  23. #region Armor Purge
  24. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  25. {
  26. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card: card));
  27. }
  28. #endregion
  29. #region When Digivolving
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Return 1 opponent's level 3, 4, and 5 to hand", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[When Digivolving] Return 1 of your opponent's level 3, level 4 and level 5 Digimon to the hand.";
  39. }
  40. bool OpponentsLevel3(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  43. return permanent.TopCard.HasLevel && permanent.Level == 3;
  44. return false;
  45. }
  46. bool OpponentsLevel4(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  49. return permanent.TopCard.HasLevel && permanent.Level == 4;
  50. return false;
  51. }
  52. bool OpponentsLevel5(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  55. return permanent.TopCard.HasLevel && permanent.Level == 5;
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  61. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsLevel3))
  71. {
  72. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OpponentsLevel3));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: OpponentsLevel3,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: null,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Bounce,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsLevel4))
  90. {
  91. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OpponentsLevel4));
  92. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  93. selectPermanentEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: OpponentsLevel4,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: false,
  100. canEndNotMax: false,
  101. selectPermanentCoroutine: null,
  102. afterSelectPermanentCoroutine: null,
  103. mode: SelectPermanentEffect.Mode.Bounce,
  104. cardEffect: activateClass);
  105. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  106. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  107. }
  108. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsLevel5))
  109. {
  110. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OpponentsLevel5));
  111. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: OpponentsLevel5,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: null,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Bounce,
  123. cardEffect: activateClass);
  124. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  125. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  126. }
  127. }
  128. }
  129. #endregion
  130. #region End of Attack
  131. if (timing == EffectTiming.OnEndAttack)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("Place top card of this digimon as top security to unsuspend", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[End of Attack] By placing this Digimon's top card as your top security card, unsuspend this Digimon or Tamer.";
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  144. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  145. return false;
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  150. && card.PermanentOfThisCard().DigivolutionCards.Count > 0
  151. && card.Owner.CanAddSecurity(activateClass);
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. Permanent selectedPermanent = card.PermanentOfThisCard();
  156. CardSource securityCard = selectedPermanent.TopCard;
  157. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(securityCard));
  158. selectedPermanent.ShowingPermanentCard.ShowPermanentData(true);
  159. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(securityCard, selectedPermanent));
  160. if (!securityCard.IsToken)
  161. {
  162. Player owner = securityCard.Owner;
  163. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(securityCard, true));
  164. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(owner));
  165. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(securityCard).AddSecurity());
  166. selectedPermanent.willBeRemoveField = false;
  167. if (selectedPermanent.ShowingPermanentCard != null)
  168. {
  169. if (selectedPermanent.ShowingPermanentCard.WillBeDeletedObject != null)
  170. {
  171. selectedPermanent.ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  172. }
  173. }
  174. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  175. }
  176. }
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }