EX3_058.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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_058 : 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 red 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.Red))
  53. {
  54. if (cardSource.CardTraits.Contains("Free"))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. return true;
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  79. {
  80. new SelectionElement<bool>(message: $"Digivolve into trash Digimon", value : true, spriteIndex: 0),
  81. new SelectionElement<bool>(message: $"DNA Digivolve", value : false, spriteIndex: 1),
  82. };
  83. string selectPlayerMessage = "Which effect will you activate?";
  84. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  85. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  86. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  87. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  88. if (fromTrash)
  89. {
  90. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  91. {
  92. Permanent selectedPermanent = null;
  93. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  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: maxCount,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  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(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  117. targetPermanent: selectedPermanent,
  118. cardCondition: CanSelectCardCondition,
  119. payCost: true,
  120. reduceCostTuple: null,
  121. fixedCostTuple: null,
  122. ignoreDigivolutionRequirementFixedCost: -1,
  123. isHand: false,
  124. activateClass: activateClass,
  125. successProcess: null));
  126. }
  127. }
  128. }
  129. else
  130. {
  131. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(
  134. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  135. CanSelectCardCondition,
  136. payCost: true,
  137. isHand: true,
  138. activateClass,
  139. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  140. ));
  141. }
  142. }
  143. }
  144. }
  145. if (timing == EffectTiming.OnEndTurn)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  150. activateClass.SetIsInheritedEffect(true);
  151. cardEffects.Add(activateClass);
  152. string EffectDiscription()
  153. {
  154. 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.";
  155. }
  156. bool CanSelectCardCondition(CardSource cardSource)
  157. {
  158. if (cardSource != null)
  159. {
  160. if (cardSource.IsDigimon)
  161. {
  162. if (cardSource.Owner == card.Owner)
  163. {
  164. if (cardSource.CanPlayJogress(true))
  165. {
  166. if (isExistOnField(card))
  167. {
  168. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  169. {
  170. return true;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. return false;
  178. }
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. if (isExistOnField(card))
  182. {
  183. return true;
  184. }
  185. return false;
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.IsExistOnBattleArea(card))
  190. {
  191. if (CardEffectCommons.IsOwnerTurn(card))
  192. {
  193. if (card.Owner.HandCards.Count >= 1)
  194. {
  195. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  196. {
  197. return true;
  198. }
  199. }
  200. }
  201. }
  202. return false;
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  205. {
  206. if (isExistOnField(card))
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(
  209. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  210. CanSelectCardCondition,
  211. payCost: true,
  212. isHand: true,
  213. activateClass,
  214. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }
  215. ));
  216. }
  217. }
  218. }
  219. return cardEffects;
  220. }
  221. }
  222. }