BT10_089.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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.BT10
  9. {
  10. public class BT10_089 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Play 1 [Dorulumon] from hand or under your Tamer", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[On Play] You may play 1 [Dorulumon] from your hand or from under one of your Tamers without paying its memory cost.";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource.CardNames.Contains("Dorulumon"))
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  39. {
  40. if (permanent.IsTamer)
  41. {
  42. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (card.Owner.HandCards.Count >= 1)
  59. {
  60. return true;
  61. }
  62. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1 || card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  72. {
  73. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1 && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  74. {
  75. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  76. {
  77. new SelectionElement<bool>(message: $"Under Tamer", value : false, spriteIndex: 0),
  78. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 1),
  79. };
  80. string selectPlayerMessage = "From which area do you play a card?";
  81. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  82. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  83. }
  84. else if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) == 0 && card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  85. {
  86. GManager.instance.userSelectionManager.SetBool(true);
  87. }
  88. else if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1 && card.Owner.HandCards.Count(CanSelectCardCondition) == 0)
  89. {
  90. GManager.instance.userSelectionManager.SetBool(false);
  91. }
  92. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  93. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  94. if (fromHand)
  95. {
  96. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  97. {
  98. List<CardSource> selectedCards = new List<CardSource>();
  99. int maxCount = 1;
  100. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  101. selectHandEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectCardCondition,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: maxCount,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. mode: SelectHandEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  115. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  116. yield return StartCoroutine(selectHandEffect.Activate());
  117. IEnumerator SelectCardCoroutine(CardSource cardSource)
  118. {
  119. selectedCards.Add(cardSource);
  120. yield return null;
  121. }
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  123. cardSources: selectedCards,
  124. activateClass: activateClass,
  125. payCost: false,
  126. isTapped: false,
  127. root: SelectCardEffect.Root.Hand,
  128. activateETB: true));
  129. }
  130. }
  131. else
  132. {
  133. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  134. {
  135. Permanent selectedPermanent = null;
  136. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  137. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  138. selectPermanentEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: CanSelectPermanentCondition,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: maxCount,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: SelectPermanentCoroutine,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  153. {
  154. selectedPermanent = permanent;
  155. yield return null;
  156. }
  157. if (selectedPermanent != null)
  158. {
  159. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  160. {
  161. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  162. List<CardSource> selectedCards = new List<CardSource>();
  163. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  164. selectCardEffect.SetUp(
  165. canTargetCondition: CanSelectCardCondition,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. canNoSelect: () => false,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. message: "Select 1 digivolution card to play.",
  172. maxCount: maxCount,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. mode: SelectCardEffect.Mode.Custom,
  176. root: SelectCardEffect.Root.Custom,
  177. customRootCardList: selectedPermanent.DigivolutionCards,
  178. canLookReverseCard: true,
  179. selectPlayer: card.Owner,
  180. cardEffect: activateClass);
  181. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  182. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  183. yield return StartCoroutine(selectCardEffect.Activate());
  184. IEnumerator SelectCardCoroutine(CardSource cardSource)
  185. {
  186. selectedCards.Add(cardSource);
  187. yield return null;
  188. }
  189. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  190. cardSources: selectedCards,
  191. activateClass: activateClass,
  192. payCost: false,
  193. isTapped: false,
  194. root: SelectCardEffect.Root.DigivolutionCards,
  195. activateETB: true));
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. if (timing == EffectTiming.OnEnterFieldAnyone)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[Your Turn] When you play a Digimon with [Xros Heart] in its traits, by suspending this Tamer, <Draw 1>. (Draw 1 card from your deck.)";
  212. }
  213. bool PermanentCondition(Permanent permanent)
  214. {
  215. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  216. {
  217. if (permanent.TopCard.CardTraits.Contains("Xros Heart") || permanent.TopCard.CardTraits.Contains("XrosHeart"))
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleArea(card))
  227. {
  228. if (CardEffectCommons.IsOwnerTurn(card))
  229. {
  230. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  231. {
  232. return true;
  233. }
  234. }
  235. }
  236. return false;
  237. }
  238. bool CanActivateCondition(Hashtable hashtable)
  239. {
  240. if (CardEffectCommons.IsExistOnBattleArea(card))
  241. {
  242. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  243. {
  244. return true;
  245. }
  246. }
  247. return false;
  248. }
  249. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  250. {
  251. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  252. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  253. }
  254. }
  255. if (timing == EffectTiming.SecuritySkill)
  256. {
  257. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  258. }
  259. return cardEffects;
  260. }
  261. }
  262. }