BT24_099.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Super Hacking
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_099 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Ignore Color Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  17. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  18. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  19. cardEffects.Add(ignoreColorConditionClass);
  20. bool HasAppmonTrait(Permanent permanent)
  21. {
  22. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  23. {
  24. if (permanent.TopCard.EqualsTraits("Appmon"))
  25. {
  26. if (permanent.IsDigimon || permanent.IsTamer)
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.HasMatchConditionPermanent(HasAppmonTrait, true);
  37. }
  38. bool CardCondition(CardSource cardSource)
  39. {
  40. return cardSource == card;
  41. }
  42. }
  43. #endregion
  44. #region Main
  45. if (timing == EffectTiming.OptionSkill)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("Trash 1, Draw 2", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[Main] By trashing 1 [Appmon] trait card from your hand, <Draw 2>. Then, place this card in the battle area.";
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  58. }
  59. bool CanSelectCardCondition(CardSource cardSource)
  60. {
  61. return cardSource.HasAppmonTraits;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  66. {
  67. bool discarded = false;
  68. int discardCount = 1;
  69. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  70. selectHandEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectCardCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: discardCount,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. selectCardCoroutine: null,
  80. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  81. mode: SelectHandEffect.Mode.Discard,
  82. cardEffect: activateClass);
  83. yield return StartCoroutine(selectHandEffect.Activate());
  84. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  85. {
  86. if (cardSources.Count >= 1)
  87. {
  88. discarded = true;
  89. yield return null;
  90. }
  91. }
  92. if (discarded)
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  95. }
  96. }
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  98. }
  99. }
  100. #endregion
  101. #region All Turns - Delay
  102. if(timing == EffectTiming.OnDestroyedAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Link 1 [Appmon] from trash", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  107. cardEffects.Add(activateClass);
  108. string EffectDescription() => "[All Turns] When Digimon are deleted, <Delay>. You may link 1 [Appmon] trait Digimon card from your trash to 1 of your Digimon without paying the cost.";
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsExistOnBattleArea(card)
  112. && CardEffectCommons.CanDeclareOptionDelayEffect(card)
  113. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermamentCondition, activateClass);
  114. }
  115. bool PermamentCondition(Permanent permanent)
  116. {
  117. return permanent.IsDigimon;
  118. }
  119. bool OwnPermamentCondition(CardSource cardsource, Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && cardsource.CanLinkToTargetPermanent(permanent, false);
  120. bool LinkCardCondition(CardSource cardSource) => cardSource.IsDigimon && cardSource.HasAppmonTraits && cardSource.CanLink(false);
  121. IEnumerator ActivateCoroutine(Hashtable hashtable)
  122. {
  123. bool delaySuccessful = false;
  124. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  125. IEnumerator SuccessProcess()
  126. {
  127. delaySuccessful = true;
  128. yield return null;
  129. }
  130. if (delaySuccessful)
  131. {
  132. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, LinkCardCondition))
  133. {
  134. CardSource selectedTrashCard = null;
  135. #region Select Trash card
  136. int maxCount1 = Math.Min(1, card.Owner.TrashCards.Count(LinkCardCondition));
  137. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  138. selectCardEffect.SetUp(
  139. canTargetCondition: LinkCardCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. canNoSelect: () => true,
  143. selectCardCoroutine: SelectCardCoroutine,
  144. afterSelectCardCoroutine: null,
  145. message: "Select 1 [Appmon] to link",
  146. maxCount: maxCount1,
  147. canEndNotMax: false,
  148. isShowOpponent: true,
  149. mode: SelectCardEffect.Mode.Custom,
  150. root: SelectCardEffect.Root.Trash,
  151. customRootCardList: null,
  152. canLookReverseCard: true,
  153. selectPlayer: card.Owner,
  154. cardEffect: activateClass);
  155. IEnumerator SelectCardCoroutine(CardSource cardSource)
  156. {
  157. selectedTrashCard = cardSource;
  158. yield return null;
  159. }
  160. selectCardEffect.SetUpCustomMessage("Select 1 [Appmon] to link", "The opponent is selecting 1 [Appmon] to link");
  161. selectCardEffect.SetUpCustomMessage_ShowCard("Selected card");
  162. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  163. #endregion
  164. if (selectedTrashCard != null)
  165. {
  166. Permanent selectedDigimon = null;
  167. #region Select Permanent Link Target
  168. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, (permanent) => OwnPermamentCondition(selectedTrashCard, permanent)));
  169. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  170. selectPermanentEffect.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: (permanent) => OwnPermamentCondition(selectedTrashCard, permanent),
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: maxCount,
  176. canNoSelect: true,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: SelectPermanentCoroutine,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Custom,
  181. cardEffect: activateClass);
  182. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  183. {
  184. selectedDigimon = permanent;
  185. yield return null;
  186. }
  187. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link to", "The opponent is selecting 1 Digimon to link to");
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. #endregion
  190. if (selectedDigimon != null) yield return ContinuousController.instance.StartCoroutine(selectedDigimon.AddLinkCard(selectedTrashCard, activateClass));
  191. }
  192. }
  193. }
  194. }
  195. }
  196. #endregion
  197. #region Security
  198. if (timing == EffectTiming.SecuritySkill)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("place in battle area", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  203. activateClass.SetIsSecurityEffect(true);
  204. cardEffects.Add(activateClass);
  205. string EffectDescription()
  206. {
  207. return "[Security] place this card in the battle area.";
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  212. }
  213. IEnumerator ActivateCoroutine(Hashtable hashtable)
  214. {
  215. yield return ContinuousController.instance.StartCoroutine(
  216. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  217. }
  218. }
  219. #endregion
  220. return cardEffects;
  221. }
  222. }
  223. }