EX5_046.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX5
  5. {
  6. public class EX5_046 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  14. changeCardNamesClass.SetUpICardEffect("Also treated as having [Etemon] in its name", CanUseCondition, card);
  15. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  16. cardEffects.Add(changeCardNamesClass);
  17. bool CanUseCondition(Hashtable hashtable)
  18. {
  19. return true;
  20. }
  21. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  22. {
  23. if (cardSource == card)
  24. {
  25. CardNames.Add("Etemon_EX5_046");
  26. }
  27. return CardNames;
  28. }
  29. }
  30. if (timing == EffectTiming.None)
  31. {
  32. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  33. changeCardNamesClass.SetUpICardEffect("Also treated as having [Sukamon] in its name", CanUseCondition, card);
  34. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  35. cardEffects.Add(changeCardNamesClass);
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return true;
  39. }
  40. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  41. {
  42. if (cardSource == card)
  43. {
  44. CardNames.Add("Sukamon_EX5_046");
  45. }
  46. return CardNames;
  47. }
  48. }
  49. if (timing == EffectTiming.None)
  50. {
  51. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  52. }
  53. if (timing == EffectTiming.OnDestroyedAnyone)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect("Trash 1 card from hand to return this card to hand", CanUseCondition, card);
  57. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  58. cardEffects.Add(activateClass);
  59. string EffectDiscription()
  60. {
  61. return "[On Deletion] By trashing 1 card with [Etemon]/[Sukamon] in its name in your hand, return this card to the hand.";
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource)
  64. {
  65. if (cardSource.ContainsCardName("Etemon"))
  66. {
  67. return true;
  68. }
  69. if (cardSource.ContainsCardName("Sukamon"))
  70. {
  71. return true;
  72. }
  73. return false;
  74. }
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  82. {
  83. if (card.Owner.HandCards.Count >= 1)
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  93. {
  94. bool discarded = false;
  95. int discardCount = 1;
  96. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  97. selectHandEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: discardCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. isShowOpponent: true,
  106. selectCardCoroutine: null,
  107. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  108. mode: SelectHandEffect.Mode.Discard,
  109. cardEffect: activateClass);
  110. yield return StartCoroutine(selectHandEffect.Activate());
  111. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  112. {
  113. if (cardSources.Count >= 1)
  114. {
  115. discarded = true;
  116. yield return null;
  117. }
  118. }
  119. if (discarded)
  120. {
  121. if (CardEffectCommons.IsExistOnTrash(card))
  122. {
  123. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { card }, "Card returned to hand", true, true));
  124. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { card }, false, activateClass));
  125. }
  126. }
  127. }
  128. }
  129. }
  130. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  135. activateClass.SetIsInheritedEffect(true);
  136. activateClass.SetHashString("Substitute_EX5_046");
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[All Turns] When this Digimon would be deleted, by deleting 1 other Digimon with [Sukamon] in its name, prevent that deletion.";
  141. }
  142. bool CanSelectPermanentCondition(Permanent permanent)
  143. {
  144. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  145. {
  146. if (permanent != card.PermanentOfThisCard())
  147. {
  148. if (permanent.TopCard.ContainsCardName("Sukamon"))
  149. {
  150. return true;
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleArea(card))
  159. {
  160. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnBattleArea(card))
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  181. {
  182. int maxCount = 1;
  183. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  184. selectPermanentEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: CanSelectPermanentCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. maxCount: maxCount,
  190. canNoSelect: true,
  191. canEndNotMax: false,
  192. selectPermanentCoroutine: SelectPermanentCoroutine,
  193. afterSelectPermanentCoroutine: null,
  194. mode: SelectPermanentEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  199. {
  200. Permanent thisCardPermanent = card.PermanentOfThisCard();
  201. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  202. IEnumerator SuccessProcess()
  203. {
  204. if (thisCardPermanent.TopCard != null)
  205. {
  206. thisCardPermanent.willBeRemoveField = false;
  207. thisCardPermanent.HideDeleteEffect();
  208. }
  209. yield return null;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. return cardEffects;
  216. }
  217. }
  218. }