BT20_074.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT20
  9. {
  10. public class BT20_074 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region DNA Digivolve
  16. if (timing == EffectTiming.None)
  17. {
  18. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  19. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  20. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  21. addJogressConditionClass.SetNotShowUI(true);
  22. cardEffects.Add(addJogressConditionClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return true;
  26. }
  27. JogressCondition GetJogress(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. bool PermanentCondition1(Permanent permanent)
  32. {
  33. if (permanent != null)
  34. {
  35. if (permanent.TopCard != null)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  40. {
  41. if (permanent.Levels_ForJogress(card).Contains(4))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool PermanentCondition2(Permanent permanent)
  52. {
  53. if (permanent != null)
  54. {
  55. if (permanent.TopCard != null)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  58. {
  59. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  60. {
  61. if (permanent.Levels_ForJogress(card).Contains(4))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. JogressConditionElement[] elements = new JogressConditionElement[]
  72. {
  73. new JogressConditionElement(PermanentCondition1, "a level 4 purple Digimon"),
  74. new JogressConditionElement(PermanentCondition2, "a level 4 red Digimon"),
  75. };
  76. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  77. return jogressCondition;
  78. }
  79. return null;
  80. }
  81. }
  82. #endregion
  83. #region On Play
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Return a card from your trash to the hand", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[On Play] You may return 1 Digimon card with [Imperialdramon] in its name or the [Free] trait from your trash to the hand.";
  93. }
  94. bool CanSelectCardCondition(CardSource cardSource){
  95. if (cardSource.EqualsTraits("Free") || cardSource.ContainsCardName("Imperialdramon")){
  96. return true;
  97. }
  98. return false;
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  111. {
  112. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  113. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  114. selectCardEffect.SetUp(
  115. canTargetCondition: CanSelectCardCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. canNoSelect: () => true,
  119. selectCardCoroutine: null,
  120. afterSelectCardCoroutine: null,
  121. message: "Select 1 card to add to your hand.",
  122. maxCount: maxCount,
  123. canEndNotMax: false,
  124. isShowOpponent: true,
  125. mode: SelectCardEffect.Mode.AddHand,
  126. root: SelectCardEffect.Root.Trash,
  127. customRootCardList: null,
  128. canLookReverseCard: true,
  129. selectPlayer: card.Owner,
  130. cardEffect: activateClass);
  131. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  132. }
  133. }
  134. }
  135. #endregion
  136. #region When Digivolving
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Return a card from your trash to the hand", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[When Digivolving] You may return 1 Digimon card with [Imperialdramon] in its name or the [Free] trait from your trash to the hand.";
  146. }
  147. bool CanSelectCardCondition(CardSource cardSource){
  148. if (cardSource.EqualsTraits("Free") || cardSource.ContainsCardName("Imperialdramon")){
  149. return true;
  150. }
  151. return false;
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable,card);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  164. {
  165. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  166. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  167. selectCardEffect.SetUp(
  168. canTargetCondition: CanSelectCardCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. canNoSelect: () => true,
  172. selectCardCoroutine: null,
  173. afterSelectCardCoroutine: null,
  174. message: "Select 1 card to add to your hand.",
  175. maxCount: maxCount,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. mode: SelectCardEffect.Mode.AddHand,
  179. root: SelectCardEffect.Root.Trash,
  180. customRootCardList: null,
  181. canLookReverseCard: true,
  182. selectPlayer: card.Owner,
  183. cardEffect: activateClass);
  184. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  185. }
  186. }
  187. }
  188. #endregion
  189. #region All Turns
  190. if(timing == EffectTiming.WhenReturntoLibraryAnyone || timing == EffectTiming.WhenReturntoHandAnyone ){
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("If returned, DNA Digivolve", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine, -1, true, EffectDiscription());
  194. activateClass.SetHashString("DNA Digivolve into Imperialdramon");
  195. cardEffects.Add(activateClass);
  196. string EffectDiscription(){
  197. return "[All Turns] When any of your [Dinobeemon]/[Paildramon] would be returned to hands or decks, 2 of your Digimon may DNA digivolve into [Imperialdramon: Dragon Mode] in the hand.";
  198. }
  199. bool isPaildramonOrDinoBeemon(Permanent permanent){
  200. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  201. {
  202. if(permanent.TopCard.EqualsCardName("Dinobeemon") || permanent.TopCard.EqualsCardName("Paildramon"))
  203. {
  204. return true;
  205. }
  206. }
  207. return false;
  208. }
  209. bool CanSelectDNACardCondition(CardSource cardSource)
  210. {
  211. if (cardSource.IsDigimon)
  212. {
  213. if (cardSource.CanPlayJogress(true))
  214. {
  215. if (cardSource.EqualsCardName("Imperialdramon: Dragon Mode"))
  216. {
  217. return true;
  218. }
  219. }
  220. }
  221. return false;
  222. }
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  226. }
  227. bool CanActivateCondition1(Hashtable hashtable)
  228. {
  229. if(CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, isPaildramonOrDinoBeemon)){
  230. if (CardEffectCommons.MatchConditionPermanentCount(isPaildramonOrDinoBeemon)>=2){
  231. return true;
  232. }
  233. return false;
  234. }
  235. return false;
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable hashtable)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(
  240. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  241. CanSelectDNACardCondition,
  242. payCost: true,
  243. isHand: true,
  244. activateClass
  245. ));
  246. }
  247. }
  248. #endregion
  249. #region Inherited Effect
  250. if (timing == EffectTiming.None)
  251. {
  252. DisableEffectClass invalidationClass = new DisableEffectClass();
  253. invalidationClass.SetUpICardEffect("Ignore Security Effect", CanUseCondition, card);
  254. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  255. invalidationClass.SetIsInheritedEffect(true);
  256. cardEffects.Add(invalidationClass);
  257. bool CanUseCondition(Hashtable hashtable)
  258. {
  259. return true;
  260. }
  261. bool InvalidateCondition(ICardEffect cardEffect)
  262. {
  263. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card) && cardEffect.EffectSourceCard != null && cardEffect.EffectSourceCard.IsOption && cardEffect.IsSecurityEffect && GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard())
  264. {
  265. return true;
  266. }
  267. return false;
  268. }
  269. }
  270. #endregion
  271. return cardEffects;
  272. }
  273. }
  274. }