EX5_065.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. public class EX5_065 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnAddDigivolutionCards)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Your Turn] When an effect places the top card of one of your Digimon in a Digimon's digivolution cards, by suspending this Tamer, gain 1 memory.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleArea(card))
  25. {
  26. if (CardEffectCommons.IsOwnerTurn(card))
  27. {
  28. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  29. hashtable: hashtable,
  30. permanentCondition: permanent => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card),
  31. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  32. cardCondition: null))
  33. {
  34. if (CardEffectCommons.IsFromDigimon(hashtable))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  46. {
  47. return true;
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  54. new List<Permanent>() { card.PermanentOfThisCard() },
  55. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  56. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  57. }
  58. }
  59. if (timing == EffectTiming.OnStartTurn)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("Play Digimon from digivolution cards to DNA digivolve", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  64. cardEffects.Add(activateClass);
  65. string EffectDiscription()
  66. {
  67. return "[Start of Opponent's Turn] By playing 1 card with the same level as one of your [Night Claw]/[Light Fang] trait Digimon from that Digimon's digivolution cards withotu paying the cost, 2 of your Digimon may DNA Digivolve into a Digimon card in your hand. At the end of the turn, return the Digimon played by this effect to hand.";
  68. }
  69. bool CanSelectPermanentCondition(Permanent permanent)
  70. {
  71. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  72. {
  73. if (permanent.DigivolutionCards.Count(cardSource => CanSelectCardCondition(cardSource, permanent)) >= 1)
  74. {
  75. if (permanent.TopCard.CardTraits.Contains("Light Fang"))
  76. {
  77. return true;
  78. }
  79. if (permanent.TopCard.CardTraits.Contains("LightFung"))
  80. {
  81. return true;
  82. }
  83. if (permanent.TopCard.CardTraits.Contains("Night Claw"))
  84. {
  85. return true;
  86. }
  87. if (permanent.TopCard.CardTraits.Contains("NightClaw"))
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. return false;
  94. }
  95. bool CanSelectCardCondition(CardSource cardSource, Permanent permanent)
  96. {
  97. if (cardSource.IsDigimon)
  98. {
  99. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  100. {
  101. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  102. {
  103. if (cardSource.HasLevel)
  104. {
  105. if (permanent.TopCard.HasLevel)
  106. {
  107. if (cardSource.Level == permanent.Level)
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. return false;
  117. }
  118. bool CanSelectCardCondition1(CardSource cardSource)
  119. {
  120. if (cardSource.IsDigimon)
  121. {
  122. if (cardSource.CanPlayJogress(true))
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. if (CardEffectCommons.IsExistOnBattleArea(card))
  132. {
  133. if (CardEffectCommons.IsOpponentTurn(card))
  134. {
  135. return true;
  136. }
  137. }
  138. return false;
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnBattleArea(card))
  143. {
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. bool played = false;
  154. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  155. {
  156. Permanent selectedPermanent = null;
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that has digivolution cards.", "The opponent is selecting 1 Digimon that has digivolution cards.");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. selectedPermanent = permanent;
  176. yield return null;
  177. }
  178. if (selectedPermanent != null)
  179. {
  180. if (selectedPermanent.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource, selectedPermanent)) >= 1)
  181. {
  182. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource, selectedPermanent)));
  183. List<CardSource> selectedCards = new List<CardSource>();
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: cardSource => CanSelectCardCondition(cardSource, selectedPermanent),
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => false,
  190. selectCardCoroutine: SelectCardCoroutine,
  191. afterSelectCardCoroutine: null,
  192. message: "Select 1 digivolution card to play.",
  193. maxCount: maxCount,
  194. canEndNotMax: false,
  195. isShowOpponent: true,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.Custom,
  198. customRootCardList: selectedPermanent.DigivolutionCards,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  203. "The opponent is selecting 1 digivolution card to play.");
  204. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  205. yield return StartCoroutine(selectCardEffect.Activate());
  206. IEnumerator SelectCardCoroutine(CardSource cardSource)
  207. {
  208. selectedCards.Add(cardSource);
  209. yield return null;
  210. }
  211. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  212. cardSources: selectedCards,
  213. activateClass: activateClass,
  214. payCost: false,
  215. isTapped: false,
  216. root: SelectCardEffect.Root.DigivolutionCards,
  217. activateETB: true));
  218. foreach (CardSource selectedCard in selectedCards)
  219. {
  220. if (CardEffectCommons.IsExistOnBattleArea(selectedCard))
  221. {
  222. played = true;
  223. Permanent selectedPermanent1 = selectedCard.PermanentOfThisCard();
  224. ActivateClass activateClass1 = new ActivateClass();
  225. activateClass1.SetUpICardEffect("Return the Digimon to hand", CanUseCondition1, card);
  226. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, "");
  227. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnEndTurn);
  228. bool CanUseCondition1(Hashtable hashtable)
  229. {
  230. return true;
  231. }
  232. bool CanActivateCondition1(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent1))
  235. {
  236. if (!selectedPermanent1.CannotReturnToHand(activateClass))
  237. {
  238. if (!selectedPermanent1.TopCard.CanNotBeAffected(activateClass1))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(new List<Permanent>() { selectedPermanent1 }, CardEffectCommons.CardEffectHashtable(activateClass1)).Bounce());
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. if (played)
  256. {
  257. // DNA digivolve
  258. yield return ContinuousController.instance.StartCoroutine(
  259. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  260. CanSelectCardCondition1,
  261. payCost: true,
  262. isHand: true,
  263. activateClass
  264. ));
  265. }
  266. }
  267. }
  268. if (timing == EffectTiming.SecuritySkill)
  269. {
  270. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  271. }
  272. return cardEffects;
  273. }
  274. }