EX4_071.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Ame-no-Ohabari
  6. namespace DCGO.CardEffects.EX4
  7. {
  8. public class EX4_071 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Main
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return "[Main] By deleting 1 of your Digimon, delete 1 of your opponent's Digimon whose level is less than or equal. If one of your Digimon with [Ravemon] in its name was deleted by this effect, at the end of your opponent's turn, play 1 [Ravemon] from your trash without paying the cost.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  27. }
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. if (cardSource.CardNames.Contains("Ravemon"))
  31. {
  32. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  44. {
  45. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  46. {
  47. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  48. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  49. selectPermanentEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: CanSelectPermanentCondition,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: maxCount,
  55. canNoSelect: true,
  56. canEndNotMax: false,
  57. selectPermanentCoroutine: SelectPermanentCoroutine,
  58. afterSelectPermanentCoroutine: null,
  59. mode: SelectPermanentEffect.Mode.Custom,
  60. cardEffect: activateClass);
  61. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  62. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  63. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  66. IEnumerator SuccessProcess()
  67. {
  68. bool CanSelectPermanentCondition1(Permanent permanent1)
  69. {
  70. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent1, card))
  71. {
  72. if (permanent.LevelJustBeforeRemoveField > 0)
  73. {
  74. if (permanent1.Level <= permanent.LevelJustBeforeRemoveField)
  75. {
  76. if (permanent1.TopCard.HasLevel)
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. return false;
  84. }
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  86. {
  87. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition1,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Destroy,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. }
  102. if (permanent.CardNamesJustBeforeRemoveField.Count((cardName) => cardName.Contains("Ravemon")) >= 1)
  103. {
  104. ActivateClass activateClass1 = new ActivateClass();
  105. activateClass1.SetUpICardEffect("Play 1 [Ravemon] from trash", CanUseCondition1, card);
  106. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, 1, false, "");
  107. activateClass1.SetHashString("EX4_071_EoOT");
  108. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
  109. bool CanUseCondition1(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsOpponentTurn(card);
  112. }
  113. bool CanActivateCondition1(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  116. {
  117. return true;
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  122. {
  123. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  124. {
  125. List<CardSource> selectedCards = new List<CardSource>();
  126. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  127. selectCardEffect.SetUp(
  128. canTargetCondition: CanSelectCardCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: () => false,
  132. selectCardCoroutine: null,
  133. afterSelectCardCoroutine: null,
  134. message: "Select 1 [Ravemon] to play.",
  135. maxCount: 1,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. mode: SelectCardEffect.Mode.PlayForFree,
  139. root: SelectCardEffect.Root.Trash,
  140. customRootCardList: null,
  141. canLookReverseCard: true,
  142. selectPlayer: card.Owner,
  143. cardEffect: activateClass1);
  144. yield return StartCoroutine(selectCardEffect.Activate());
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. #endregion
  154. #region Security
  155. if (timing == EffectTiming.SecuritySkill)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect($"Delete 1 Digimon with the lowest level", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  160. activateClass.SetIsSecurityEffect(true);
  161. cardEffects.Add(activateClass);
  162. string EffectDescription()
  163. {
  164. return "[Security] Delete 1 of your opponent's Digimon with the lowest level.";
  165. }
  166. bool CanSelectPermanentCondition(Permanent permanent)
  167. {
  168. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  175. {
  176. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  177. {
  178. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Destroy,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. }
  194. }
  195. }
  196. #endregion
  197. return cardEffects;
  198. }
  199. }
  200. }