InvincibleDragonInsectFusion_BT16_092.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using Photon.Pun;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects
  7. {
  8. public class InvincibleDragonInsectFusion_BT16_092 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Main - Option Skill
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play 1 [ExVeemon] or [Stingmon]", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] You may play 1 [ExVeemon] or [Stingmon] from your hand without paying the cost. Then, 2 of your Digimon may DNA digivolve into a Digimon card in your hand. Until the end of your opponent's turn, the Digimon this effect DNA digivolved can't be deleted in battle and gains <Blocker>.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (cardSource.CardNames.Contains("ExVeemon") || cardSource.CardNames.Contains("Stingmon"))
  27. {
  28. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanSelectDNACardCondition(CardSource cardSource)
  36. {
  37. if (cardSource.IsDigimon)
  38. {
  39. if (cardSource.CanPlayJogress(true))
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. int maxCount = 1;
  56. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  57. selectHandEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectCardCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. selectCardCoroutine: SelectCardCoroutine,
  67. afterSelectCardCoroutine: null,
  68. mode: SelectHandEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. selectHandEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play.");
  71. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  72. yield return StartCoroutine(selectHandEffect.Activate());
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. selectedCards.Add(cardSource);
  76. yield return null;
  77. }
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  79. // DNA digivolve
  80. if (card.Owner.GetBattleAreaDigimons().Count >= 2)
  81. {
  82. if (card.Owner.HandCards.Count(CanSelectDNACardCondition) >= 1)
  83. {
  84. List<CardSource> selectedDNACards = new List<CardSource>();
  85. SelectHandEffect selectDNAEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectDNAEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectDNACardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: SelectDNACoroutine,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectDNAEffect.SetUpCustomMessage("Select 1 card to DNA digivolve.", "The opponent is selecting 1 card to DNA digivolve.");
  100. selectDNAEffect.SetNotShowCard();
  101. yield return StartCoroutine(selectDNAEffect.Activate());
  102. IEnumerator SelectDNACoroutine(CardSource cardSource)
  103. {
  104. selectedDNACards.Add(cardSource);
  105. yield return null;
  106. }
  107. if (selectedDNACards.Count >= 1)
  108. {
  109. foreach (CardSource selectedCard in selectedDNACards)
  110. {
  111. if (selectedCard.CanPlayJogress(true))
  112. {
  113. _jogressEvoRootsFrameIDs = new int[0];
  114. yield return GManager.instance.photonWaitController.StartWait("AncientAngelOfSteel_BT16_097");
  115. if (card.Owner.isYou || GManager.instance.IsAI)
  116. {
  117. GManager.instance.selectJogressEffect.SetUp_SelectDigivolutionRoots
  118. (card: selectedCard,
  119. isLocal: true,
  120. isPayCost: true,
  121. canNoSelect: true,
  122. endSelectCoroutine_SelectDigivolutionRoots: EndSelectCoroutine_SelectDigivolutionRoots,
  123. noSelectCoroutine: null);
  124. yield return ContinuousController.instance.StartCoroutine(GManager.instance.selectJogressEffect.SelectDigivolutionRoots());
  125. IEnumerator EndSelectCoroutine_SelectDigivolutionRoots(List<Permanent> permanents)
  126. {
  127. if (permanents.Count == 2)
  128. {
  129. _jogressEvoRootsFrameIDs = permanents.Distinct().ToArray().Map(permanent => permanent.PermanentFrame.FrameID);
  130. }
  131. yield return null;
  132. }
  133. photonView.RPC("SetJogressEvoRootsFrameIDs", RpcTarget.All, _jogressEvoRootsFrameIDs);
  134. }
  135. else
  136. {
  137. GManager.instance.commandText.OpenCommandText("The opponent is choosing a card to DNA digivolve.");
  138. }
  139. yield return new WaitWhile(() => !_endSelect);
  140. _endSelect = false;
  141. GManager.instance.commandText.CloseCommandText();
  142. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  143. if (_jogressEvoRootsFrameIDs.Length == 2)
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(new List<CardSource>() { selectedCard }, "Played Card", true, true));
  146. PlayCardClass playCard = new PlayCardClass(
  147. cardSources: new List<CardSource>() { selectedCard },
  148. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  149. payCost: true,
  150. targetPermanent: null,
  151. isTapped: false,
  152. root: SelectCardEffect.Root.Hand,
  153. activateETB: true);
  154. playCard.SetJogress(_jogressEvoRootsFrameIDs);
  155. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  156. if (CardEffectCommons.IsExistOnBattleArea(selectedCard))
  157. {
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  159. targetPermanent: selectedCard.PermanentOfThisCard(),
  160. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  161. activateClass: activateClass));
  162. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  163. targetPermanent: selectedCard.PermanentOfThisCard(),
  164. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  165. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  166. activateClass: activateClass,
  167. effectName: "Can't be deleted in battle"));
  168. bool CanNotBeDestroyedByBattleCondition(Permanent permanent1, Permanent attackingPermanent, Permanent defendingPermanent, CardSource defendingCard)
  169. {
  170. return permanent1 == attackingPermanent || permanent1 == defendingPermanent;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. #endregion
  183. #region Security Effect
  184. if (timing == EffectTiming.SecuritySkill)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("Play 1 [Veemon] or [Wormmon]", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  189. cardEffects.Add(activateClass);
  190. string EffectDiscription()
  191. {
  192. return "[Main] You may play 1 [Veemon] or [Wormmon] from your hand without paying the cost. Then, 2 of your Digimon may DNA digivolve into a Digimon card in your hand. If DNA digivolved by this effect, <Recovery +1(Deck)>";
  193. }
  194. bool CanSelectCardCondition(CardSource cardSource)
  195. {
  196. if (cardSource.CardNames.Contains("Veemon") || cardSource.CardNames.Contains("Wormmon"))
  197. {
  198. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  199. {
  200. return true;
  201. }
  202. }
  203. return false;
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  208. }
  209. IEnumerator ActivateCoroutine(Hashtable hashtable)
  210. {
  211. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  212. {
  213. List<CardSource> selectedCards = new List<CardSource>();
  214. int maxCount = 1;
  215. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  216. selectHandEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: CanSelectCardCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: maxCount,
  222. canNoSelect: true,
  223. canEndNotMax: false,
  224. isShowOpponent: true,
  225. selectCardCoroutine: SelectCardCoroutine,
  226. afterSelectCardCoroutine: null,
  227. mode: SelectHandEffect.Mode.Custom,
  228. cardEffect: activateClass);
  229. selectHandEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play.");
  230. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  231. yield return StartCoroutine(selectHandEffect.Activate());
  232. IEnumerator SelectCardCoroutine(CardSource cardSource)
  233. {
  234. selectedCards.Add(cardSource);
  235. yield return null;
  236. }
  237. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  238. }
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  240. }
  241. }
  242. #endregion
  243. return cardEffects;
  244. }
  245. private bool _endSelect = false;
  246. private int[] _jogressEvoRootsFrameIDs = new int[0];
  247. [PunRPC]
  248. public void SetJogressEvoRootsFrameIDs(int[] JogressEvoRootsFrameIDs)
  249. {
  250. this._jogressEvoRootsFrameIDs = JogressEvoRootsFrameIDs;
  251. _endSelect = true;
  252. }
  253. }
  254. }