EX8_052.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_052 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Cyberdramon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region When Digivolving - Place 1 [Device]
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Place 1 [Device] trait Option in battle area", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] If [Cyberdramon] or [X Antibody] is in this Digimon's digivolution cards, you may place 1 [Device] trait Option card from your hand or trash in the battle area.";
  31. }
  32. bool HasCyberdraorXAnti(CardSource source)
  33. {
  34. return source.EqualsCardName("Cyberdramon") || source.EqualsCardName("X Antibody");
  35. }
  36. bool IsDeviceTrait(CardSource source)
  37. {
  38. return source.IsOption &&
  39. source.EqualsTraits("Device");
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  44. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. return card.PermanentOfThisCard().DigivolutionCards.Count(HasCyberdraorXAnti) > 0 &&
  49. (CardEffectCommons.HasMatchConditionOwnersHand(card, IsDeviceTrait) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsDeviceTrait));
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsDeviceTrait);
  54. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsDeviceTrait);
  55. if (canSelectHand || canSelectTrash)
  56. {
  57. if (canSelectHand && canSelectTrash)
  58. {
  59. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  60. {
  61. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  62. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  63. };
  64. string selectPlayerMessage = "From which area do you select a card?";
  65. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  66. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  67. }
  68. else
  69. {
  70. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  71. }
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  74. CardSource selectedCard = null;
  75. IEnumerator SelectCardCoroutine(CardSource cardSource)
  76. {
  77. selectedCard = cardSource;
  78. yield return null;
  79. }
  80. if (fromHand)
  81. {
  82. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  83. selectHandEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: IsDeviceTrait,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: 1,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. mode: SelectHandEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectHandEffect.SetUpCustomMessage(
  97. "Select 1 card to place in battle area.",
  98. "The opponent is selecting 1 card to place in battle area.");
  99. selectHandEffect.SetUpCustomMessage_ShowCard("Place in battle area");
  100. yield return StartCoroutine(selectHandEffect.Activate());
  101. }
  102. else
  103. {
  104. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  105. selectCardEffect.SetUp(
  106. canTargetCondition: IsDeviceTrait,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. canNoSelect: () => true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. message: "Select 1 card to place in battle area.",
  113. maxCount: 1,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. mode: SelectCardEffect.Mode.Custom,
  117. root: SelectCardEffect.Root.Trash,
  118. customRootCardList: null,
  119. canLookReverseCard: true,
  120. selectPlayer: card.Owner,
  121. cardEffect: activateClass);
  122. selectCardEffect.SetUpCustomMessage(
  123. "Select 1 card to place in battle area.",
  124. "The opponent is selecting 1 card to place in battle area.");
  125. selectCardEffect.SetUpCustomMessage_ShowCard("Place in battle area");
  126. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  127. }
  128. if(selectedCard != null)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: selectedCard, cardEffect: activateClass));
  131. }
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving - De-Digivolve 2
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Trash 1 Option card in battle area, De-Digivolve 2 1 opponent's Digimon", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[When Digivolving] By trashing 1 of your Option cards in the battle area, <De-Digivolve 2> 1 of your opponent's Digimon.";
  146. }
  147. bool OpponentsDigimon(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  150. }
  151. bool IsOptionCard(Permanent permanent)
  152. {
  153. return permanent.IsOption &&
  154. CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  159. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.HasMatchConditionPermanent(IsOptionCard);
  164. }
  165. IEnumerator ActivateCoroutine(Hashtable hashtable)
  166. {
  167. Permanent selectedPermanent = null;
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: IsOptionCard,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: 1,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectPermanentEffect.SetUpCustomMessage("Select 1 Option to trash.",
  182. "The opponent is selecting 1 Option to trash.");
  183. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  184. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  185. {
  186. selectedPermanent = permanent;
  187. yield return null;
  188. }
  189. if(selectedPermanent != null)
  190. {
  191. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  192. targetPermanents: new List<Permanent>() { selectedPermanent },
  193. activateClass: activateClass,
  194. successProcess: permanents => SuccessProcess(),
  195. failureProcess: null));
  196. IEnumerator SuccessProcess()
  197. {
  198. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  199. {
  200. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: OpponentsDigimon,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: 1,
  207. canNoSelect: false,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: SelectPermanentCoroutine,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Custom,
  212. cardEffect: activateClass);
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  214. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  215. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  216. {
  217. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 2, activateClass).Degeneration());
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }
  224. #endregion
  225. #region When Attacking - ESS
  226. if (timing == EffectTiming.OnAllyAttack)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("By trashing 1 of your Option cards in the battle area, trash your opponent's top security card", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  231. activateClass.SetIsInheritedEffect(true);
  232. activateClass.SetHashString("WhenAttacking_EX8_052");
  233. cardEffects.Add(activateClass);
  234. string EffectDiscription()
  235. {
  236. return "[When Attacking] [Once Per Turn] By trashing 1 of your Option cards in the battle area, trash your opponent's top security card.";
  237. }
  238. bool IsDeviceTrait(Permanent permanent)
  239. {
  240. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  241. permanent.IsOption;
  242. }
  243. bool CanUseCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  246. }
  247. bool CanActivateCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.HasMatchConditionPermanent(IsDeviceTrait);
  250. }
  251. IEnumerator ActivateCoroutine(Hashtable hashtable)
  252. {
  253. Permanent selectedPermanent = null;
  254. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  255. selectPermanentEffect.SetUp(
  256. selectPlayer: card.Owner,
  257. canTargetCondition: IsDeviceTrait,
  258. canTargetCondition_ByPreSelecetedList: null,
  259. canEndSelectCondition: null,
  260. maxCount: 1,
  261. canNoSelect: false,
  262. canEndNotMax: false,
  263. selectPermanentCoroutine: SelectPermanentCoroutine,
  264. afterSelectPermanentCoroutine: null,
  265. mode: SelectPermanentEffect.Mode.Custom,
  266. cardEffect: activateClass);
  267. selectPermanentEffect.SetUpCustomMessage("Select 1 Option to trash.",
  268. "The opponent is selecting 1 Option to trash.");
  269. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  270. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  271. {
  272. selectedPermanent = permanent;
  273. yield return null;
  274. }
  275. if (selectedPermanent != null)
  276. {
  277. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  278. targetPermanents: new List<Permanent>() { selectedPermanent },
  279. activateClass: activateClass,
  280. successProcess: permanents => SuccessProcess(),
  281. failureProcess: null));
  282. IEnumerator SuccessProcess()
  283. {
  284. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  285. player: card.Owner.Enemy,
  286. destroySecurityCount: 1,
  287. cardEffect: activateClass,
  288. fromTop: true).DestroySecurity());
  289. }
  290. }
  291. }
  292. }
  293. #endregion
  294. return cardEffects;
  295. }
  296. }
  297. }