EX4_051.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX4
  8. {
  9. public class EX4_051 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.CardNames.Contains("MetalGreymon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] Activate 1 of the effects below. - <De-Digivolve 1> 3 of your opponent's Digimon. - 1 of your other Digimon digivolves into a level 6 or lower Digimon card with [Garurumon] in its name in your hand without paying the cost. -This Digimon and one of your other Digimon may DNA digivolve into a Digimon card in your hand for the cost.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. if (isExistOnField(card))
  47. {
  48. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  49. {
  50. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  51. {
  52. new SelectionElement<int>(message: $"De-Digivolve", value : 0, spriteIndex: 0),
  53. new SelectionElement<int>(message: $"Your other 1 Digimon digivolves", value : 1, spriteIndex: 0),
  54. new SelectionElement<int>(message: $"DNA Digivolution", value : 2, spriteIndex: 0),
  55. };
  56. string selectPlayerMessage = "Which effect will you activate?";
  57. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  58. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  59. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  60. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  61. switch (actionID)
  62. {
  63. case 0:
  64. bool CanSelectPermanentCondition(Permanent permanent)
  65. {
  66. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  67. {
  68. if (permanent.CanSelectBySkill(activateClass))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  76. {
  77. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: CanEndSelectCondition,
  84. maxCount: maxCount,
  85. canNoSelect: false,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectPermanentEffect.SetUpCustomMessage("Select Digimon to De-Digivolve.", "The opponent is selecting Digimon to De-Digivolve.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. bool CanEndSelectCondition(List<Permanent> permanents)
  94. {
  95. if (permanents.Count <= 0)
  96. {
  97. return false;
  98. }
  99. return true;
  100. }
  101. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  102. {
  103. Permanent selectedPermanent = permanent;
  104. if (selectedPermanent != null)
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  107. }
  108. yield return null;
  109. }
  110. }
  111. break;
  112. case 1:
  113. bool CanSelectPermanentCondition1(Permanent permanent)
  114. {
  115. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  116. {
  117. if (permanent != card.PermanentOfThisCard())
  118. {
  119. foreach (CardSource cardSource in card.Owner.HandCards)
  120. {
  121. if (CanSelectCardCondition(cardSource))
  122. {
  123. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanSelectCardCondition(CardSource cardSource)
  134. {
  135. return cardSource.IsDigimon && cardSource.HasGarurumonName && cardSource.Level <= 6 && cardSource.HasLevel;
  136. }
  137. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  138. {
  139. Permanent selectedPermanent = null;
  140. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  141. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectPermanentEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectPermanentCondition1,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: maxCount,
  148. canNoSelect: true,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: SelectPermanentCoroutine,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  155. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  156. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  157. {
  158. selectedPermanent = permanent;
  159. yield return null;
  160. }
  161. if (selectedPermanent != null)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  164. targetPermanent: selectedPermanent,
  165. cardCondition: CanSelectCardCondition,
  166. payCost: false,
  167. reduceCostTuple: null,
  168. fixedCostTuple: null,
  169. ignoreDigivolutionRequirementFixedCost: -1,
  170. isHand: true,
  171. activateClass: activateClass,
  172. successProcess: null));
  173. }
  174. }
  175. break;
  176. case 2:
  177. bool CanSelectCardCondition1(CardSource cardSource)
  178. {
  179. if (cardSource != null)
  180. {
  181. if (cardSource.IsDigimon)
  182. {
  183. if (cardSource.Owner == card.Owner)
  184. {
  185. if (cardSource.CanPlayJogress(true))
  186. {
  187. if (isExistOnField(card))
  188. {
  189. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  190. {
  191. return true;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(
  203. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  204. CanSelectCardCondition1,
  205. payCost: true,
  206. isHand: true,
  207. activateClass,
  208. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }));
  209. }
  210. break;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. if (timing == EffectTiming.OnAllyAttack)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  221. activateClass.SetIsInheritedEffect(true);
  222. activateClass.SetHashString("TrashSecurity_EX4_051");
  223. cardEffects.Add(activateClass);
  224. string EffectDiscription()
  225. {
  226. return "[When Attacking][Once Per Turn] If this Digimon has [Omnimon] in its name, trash the top card of your opponent's security stack.";
  227. }
  228. bool CanUseCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  231. }
  232. bool CanActivateCondition(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  237. {
  238. return true;
  239. }
  240. }
  241. return false;
  242. }
  243. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  244. {
  245. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  246. player: card.Owner.Enemy,
  247. destroySecurityCount: 1,
  248. cardEffect: activateClass,
  249. fromTop: true).DestroySecurity());
  250. }
  251. }
  252. return cardEffects;
  253. }
  254. }
  255. }