EX11_012.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Medusamon
  6. namespace DCGO.CardEffects.EX11
  7. {
  8. public class EX11_012 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Rush
  14. if (timing == EffectTiming.None)
  15. {
  16. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  17. }
  18. #endregion
  19. #region Progress
  20. if (timing == EffectTiming.None)
  21. {
  22. cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null));
  23. }
  24. #endregion
  25. #region Shared WD / EOA
  26. string SharedEffectName = "Delete 1 digimon with equal or less DP. Bot deck 1 card from their trash to make Token";
  27. string SharedEffectDescription(string tag) => $"[{tag}] You may delete 1 of your opponent's Digimon with as much or less DP as this Digimon. Then, by returning 1 card from your opponent's trash to the bottom of the deck, they play 1 [Petrification] Token. (Digimon/White/3000 DP/[Your Turn] This Digimon can't suspend. [On Deletion] Trash your top security card.)";
  28. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  29. bool ValidOpponentDigimon(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  32. && permanent.HasDP
  33. && permanent.DP <= card.PermanentOfThisCard().DP;
  34. }
  35. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  36. {
  37. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, ValidOpponentDigimon))
  38. {
  39. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  40. selectPermanentEffect.SetUp(
  41. selectPlayer: card.Owner,
  42. canTargetCondition: ValidOpponentDigimon,
  43. canTargetCondition_ByPreSelecetedList: null,
  44. canEndSelectCondition: null,
  45. maxCount: 1,
  46. canNoSelect: true,
  47. canEndNotMax: false,
  48. selectPermanentCoroutine: null,
  49. afterSelectPermanentCoroutine: null,
  50. mode: SelectPermanentEffect.Mode.Destroy,
  51. cardEffect: activateClass);
  52. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  53. }
  54. if (card.Owner.Enemy.TrashCards.Count > 0)
  55. {
  56. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  57. selectCardEffect.SetUp(
  58. canTargetCondition: _ => true,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. canNoSelect: () => true,
  62. selectCardCoroutine: SelectCardCoroutine,
  63. afterSelectCardCoroutine: null,
  64. message: "Select card to return to bottom of deck",
  65. maxCount: 1,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. mode: SelectCardEffect.Mode.Custom,
  69. root: SelectCardEffect.Root.Custom,
  70. customRootCardList: card.Owner.Enemy.TrashCards,
  71. canLookReverseCard: true,
  72. selectPlayer: card.Owner,
  73. cardEffect: activateClass);
  74. selectCardEffect.SetUpCustomMessage("Select a card to return to bottom of deck.", "The opponent is selecting a card to return to bottom of deck.");
  75. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  76. IEnumerator SelectCardCoroutine(CardSource cardSource)
  77. {
  78. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(new List<CardSource>() { cardSource }));
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPetrificationToken(activateClass));
  80. }
  81. }
  82. }
  83. #endregion
  84. #region When Digivolving
  85. if (timing == EffectTiming.OnEnterFieldAnyone)
  86. {
  87. ActivateClass activateClass = new ActivateClass();
  88. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  89. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  90. cardEffects.Add(activateClass);
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  94. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  95. }
  96. }
  97. #endregion
  98. #region End of Attack
  99. if (timing == EffectTiming.OnEndAttack)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  103. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("End of Attack"));
  104. cardEffects.Add(activateClass);
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  108. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  109. }
  110. }
  111. #endregion
  112. #region All Turns
  113. if (timing == EffectTiming.WhenRemoveField)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("By deleting a token, this does not leave", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  118. activateClass.SetHashString("EX11_012_WHEN_REMOVED");
  119. cardEffects.Add(activateClass);
  120. string EffectDescription() => "[All Turns] When this Digimon would leave the battle area, by deleting 1 Token, it doesn't leave.";
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleArea(card)
  124. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  125. }
  126. bool CanActivateCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnBattleArea(card)
  129. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  130. }
  131. bool CanSelectPermanentCondition(Permanent permanent) => permanent.IsToken;
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  135. {
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectPermanentCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: 1,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: SelectPermanentCoroutine,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Custom,
  148. cardEffect: activateClass);
  149. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  154. IEnumerator SuccessProcess()
  155. {
  156. Permanent thisPermanent = card.PermanentOfThisCard();
  157. thisPermanent.willBeRemoveField = false;
  158. thisPermanent.HideDeleteEffect();
  159. thisPermanent.HideHandBounceEffect();
  160. thisPermanent.HideDeckBounceEffect();
  161. thisPermanent.HideWillRemoveFieldEffect();
  162. yield return null;
  163. }
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. return cardEffects;
  170. }
  171. }
  172. }