EX3_008.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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.EX3
  8. {
  9. public class EX3_008 : 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.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Select Effects", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[When Digivolving] Activate 1 of the effects below. - You may digivolve 1 of your other Digimon into a level 4 purple Digimon card with [Free] in its traits from your trash for the cost. - You may DNA digivolve this Digimon and one of your other Digimon in play into a Digimon card in your hand for the cost.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  27. {
  28. if (permanent != card.PermanentOfThisCard())
  29. {
  30. foreach (CardSource cardSource in permanent.TopCard.Owner.TrashCards)
  31. {
  32. if (CanSelectCardCondition(cardSource))
  33. {
  34. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (cardSource.Level == 4)
  49. {
  50. if (cardSource.HasLevel)
  51. {
  52. if (cardSource.HasCardColor(CardColor.Purple))
  53. {
  54. if (cardSource.CardTraits.Contains("Free"))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanSelectCardCondition1(CardSource cardSource)
  65. {
  66. if (cardSource != null)
  67. {
  68. if (cardSource.IsDigimon)
  69. {
  70. if (cardSource.Owner == card.Owner)
  71. {
  72. if (cardSource.CanPlayJogress(true))
  73. {
  74. if (isExistOnField(card))
  75. {
  76. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  90. }
  91. bool CanActivateCondition(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.IsExistOnBattleArea(card))
  94. {
  95. return true;
  96. }
  97. return false;
  98. }
  99. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  100. {
  101. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  102. {
  103. new SelectionElement<bool>(message: $"Digivolve into trash Digimon", value : true, spriteIndex: 0),
  104. new SelectionElement<bool>(message: $"DNA Digivolve", value : false, spriteIndex: 1),
  105. };
  106. string selectPlayerMessage = "Which effect will you activate?";
  107. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  108. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  109. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  110. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  111. if (fromTrash)
  112. {
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  114. {
  115. Permanent selectedPermanent = null;
  116. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  117. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  118. selectPermanentEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectPermanentCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. maxCount: maxCount,
  124. canNoSelect: false,
  125. canEndNotMax: false,
  126. selectPermanentCoroutine: SelectPermanentCoroutine,
  127. afterSelectPermanentCoroutine: null,
  128. mode: SelectPermanentEffect.Mode.Custom,
  129. cardEffect: activateClass);
  130. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  133. {
  134. selectedPermanent = permanent;
  135. yield return null;
  136. }
  137. if (selectedPermanent != null)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  140. targetPermanent: selectedPermanent,
  141. cardCondition: CanSelectCardCondition,
  142. payCost: true,
  143. reduceCostTuple: null,
  144. fixedCostTuple: null,
  145. ignoreDigivolutionRequirementFixedCost: -1,
  146. isHand: false,
  147. activateClass: activateClass,
  148. successProcess: null));
  149. }
  150. }
  151. }
  152. else
  153. {
  154. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  155. {
  156. yield return ContinuousController.instance.StartCoroutine(
  157. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  158. CanSelectCardCondition,
  159. payCost: true,
  160. isHand: true,
  161. activateClass,
  162. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  163. ));
  164. }
  165. }
  166. }
  167. }
  168. if (timing == EffectTiming.OnEndTurn)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  173. activateClass.SetIsInheritedEffect(true);
  174. cardEffects.Add(activateClass);
  175. string EffectDiscription()
  176. {
  177. return "[End of Your Turn] You may DNA digivolve this Digimon and one of your other Digimon in play into a Digimon card in your hand by paying its DNA digivolve cost.";
  178. }
  179. bool CanSelectCardCondition(CardSource cardSource)
  180. {
  181. if (cardSource != null)
  182. {
  183. if (cardSource.IsDigimon)
  184. {
  185. if (cardSource.Owner == card.Owner)
  186. {
  187. if (cardSource.CanPlayJogress(true))
  188. {
  189. if (isExistOnField(card))
  190. {
  191. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. return false;
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. if (isExistOnField(card))
  205. {
  206. return true;
  207. }
  208. return false;
  209. }
  210. bool CanActivateCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleArea(card))
  213. {
  214. if (CardEffectCommons.IsOwnerTurn(card))
  215. {
  216. if (card.Owner.HandCards.Count >= 1)
  217. {
  218. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  219. {
  220. return true;
  221. }
  222. }
  223. }
  224. }
  225. return false;
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  228. {
  229. if (isExistOnField(card))
  230. {
  231. yield return ContinuousController.instance.StartCoroutine(
  232. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  233. CanSelectCardCondition,
  234. payCost: true,
  235. isHand: true,
  236. activateClass,
  237. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  238. ));
  239. }
  240. }
  241. }
  242. return cardEffects;
  243. }
  244. }
  245. }