EX11_053.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Omekamon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_053 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Name Rule
  13. if (timing == EffectTiming.None)
  14. {
  15. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  16. changeCardNamesClass.SetUpICardEffect("Also treated as [X Antibody]", CanUseCondition, card);
  17. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  18. cardEffects.Add(changeCardNamesClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  24. {
  25. if (cardSource == card)
  26. {
  27. CardNames.Add("X Antibody");
  28. }
  29. return CardNames;
  30. }
  31. }
  32. #endregion
  33. #region On Play
  34. if (timing == EffectTiming.OnEnterFieldAnyone)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("By placing a [Royal Knight] under any of your [King Drasil_7D6]s, Draw 1", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  39. cardEffects.Add(activateClass);
  40. string EffectDescription()
  41. => "[On Play] By placing 1 [Royal Knight] trait Digimon card from your hand as the bottom digivolution card of any of your [King Drasil_7D6]s on the field, <Draw 1>.";
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleArea(card)
  45. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleArea(card)
  50. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  51. && (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition)
  52. || CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, CanSelectPermanentCondition));
  53. }
  54. bool CanSelectCardCondition(CardSource cardSource)
  55. {
  56. return cardSource.IsDigimon
  57. && cardSource.EqualsTraits("Royal Knight");
  58. }
  59. bool CanSelectPermanentCondition(Permanent permanent)
  60. {
  61. return (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  62. || CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  63. && permanent.IsDigimon
  64. && permanent.TopCard.EqualsCardName("King Drasil_7D6");
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. List<CardSource> selectedCards = new List<CardSource>();
  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: 1,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. selectCardCoroutine: SelectCardCoroutine,
  80. afterSelectCardCoroutine: null,
  81. mode: SelectHandEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectHandEffect.SetUpCustomMessage("Select 1 Royal Knight to place under a King Drasil_7D6.", "The opponent is selecting 1 card to place.");
  84. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  85. yield return StartCoroutine(selectHandEffect.Activate());
  86. IEnumerator SelectCardCoroutine(CardSource cardSource)
  87. {
  88. selectedCards.Add(cardSource);
  89. yield return null;
  90. }
  91. if (selectedCards.Count > 0)
  92. {
  93. Permanent selectedPermanent = null;
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: CanSelectPermanentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: 1,
  101. canNoSelect: true,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add the selected card under.", "The opponent is selecting 1 Digimon to add the selected card under.");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. selectedPermanent = permanent;
  112. yield return null;
  113. }
  114. if (selectedPermanent != null)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  117. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  118. }
  119. }
  120. }
  121. }
  122. #endregion
  123. #region On Deletion
  124. if (timing == EffectTiming.OnDestroyedAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("Play 1 [Omnimon (X Antibody)] and place this card under it.", CanUseCondition, card);
  128. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  129. cardEffects.Add(activateClass);
  130. string EffectDescription()
  131. => "[On Deletion] If you have 1 of fewer security cards, you may 1 play [Omnimon (X Antibody)] from your hand or under your [King Drasil_7D6]s on the field without paying the cost. Then, place this card as the played Digimon's bottom digivolution card.";
  132. bool CanUseCondition(Hashtable hashtable) => CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  136. && card.Owner.SecurityCards.Count <= 1
  137. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  138. || CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition)
  139. || CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, CanSelectPermanentCondition));
  140. }
  141. bool CanSelectCardCondition(CardSource cardSource)
  142. {
  143. return cardSource.HasPlayCost
  144. && cardSource.EqualsCardName("Omnimon (X Antibody)")
  145. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  146. }
  147. bool CanSelectPermanentCondition(Permanent permanent)
  148. {
  149. return (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  150. || CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  151. && permanent.TopCard.EqualsCardName("King Drasil_7D6")
  152. && permanent.DigivolutionCards.Any(CanSelectCardCondition);
  153. }
  154. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  155. {
  156. bool IsValidHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  157. bool IsValidField = CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition)
  158. || CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, CanSelectPermanentCondition);
  159. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  160. if (IsValidHand)
  161. {
  162. selectionElements.Add(new(message: "From hand", value: 0, spriteIndex: 0));
  163. }
  164. if (IsValidField)
  165. {
  166. selectionElements.Add(new(message: "From digivolution cards", value: 1, spriteIndex: 0));
  167. }
  168. selectionElements.Add(new(message: "Do not play", value: 2, spriteIndex: 1));
  169. string selectPlayerMessage = "From which area will you play a Omnimon (X Antibody)?";
  170. string notSelectPlayerMessage = "The opponent is choosing if they will activate their effect.";
  171. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  172. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  173. notSelectPlayerMessage: notSelectPlayerMessage);
  174. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  175. .WaitForEndSelect());
  176. int selection = GManager.instance.userSelectionManager.SelectedIntValue;
  177. if (selection != 2)
  178. {
  179. CardSource selectedCard = null;
  180. IEnumerator SelectCardCoroutine(CardSource cardSource)
  181. {
  182. selectedCard = cardSource;
  183. yield return null;
  184. }
  185. if (selection == 0)
  186. {
  187. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  188. selectHandEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: CanSelectCardCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: 1,
  194. canNoSelect: true,
  195. canEndNotMax: false,
  196. isShowOpponent: true,
  197. selectCardCoroutine: SelectCardCoroutine,
  198. afterSelectCardCoroutine: null,
  199. mode: SelectHandEffect.Mode.Custom,
  200. cardEffect: activateClass);
  201. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  202. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  203. yield return StartCoroutine(selectHandEffect.Activate());
  204. if (selectedCard != null)
  205. {
  206. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  207. new List<CardSource>() { selectedCard },
  208. activateClass: activateClass,
  209. payCost: false,
  210. isTapped: false,
  211. root: SelectCardEffect.Root.Hand,
  212. activateETB: true));
  213. }
  214. }
  215. else
  216. {
  217. Permanent selectedPermanent = null;
  218. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  219. selectPermanentEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: CanSelectPermanentCondition,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: 1,
  225. canNoSelect: true,
  226. canEndNotMax: false,
  227. selectPermanentCoroutine: SelectPermanentCoroutine,
  228. afterSelectPermanentCoroutine: null,
  229. mode: SelectPermanentEffect.Mode.Custom,
  230. cardEffect: activateClass);
  231. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to play a card from.", "The opponent is selecting 1 Digimon to play a card from.");
  232. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  233. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  234. {
  235. selectedPermanent = permanent;
  236. yield return null;
  237. }
  238. if (selectedPermanent != null)
  239. {
  240. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  241. selectCardEffect.SetUp(
  242. canTargetCondition: CanSelectCardCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. canNoSelect: () => true,
  246. selectCardCoroutine: SelectCardCoroutine,
  247. afterSelectCardCoroutine: null,
  248. message: "Select 1 card to play.",
  249. maxCount: 1,
  250. canEndNotMax: false,
  251. isShowOpponent: true,
  252. mode: SelectCardEffect.Mode.Custom,
  253. root: SelectCardEffect.Root.Custom,
  254. customRootCardList: selectedPermanent.DigivolutionCards,
  255. canLookReverseCard: true,
  256. selectPlayer: card.Owner,
  257. cardEffect: activateClass);
  258. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  259. if (selectedCard != null)
  260. {
  261. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  262. new List<CardSource>() { selectedCard },
  263. activateClass: activateClass,
  264. payCost: false,
  265. isTapped: false,
  266. root: SelectCardEffect.Root.DigivolutionCards,
  267. activateETB: true));
  268. }
  269. }
  270. }
  271. if (selectedCard != null)
  272. {
  273. yield return ContinuousController.instance.StartCoroutine(
  274. selectedCard.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  275. }
  276. }
  277. }
  278. }
  279. #endregion
  280. return cardEffects;
  281. }
  282. }
  283. }