EX7_013.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using Photon.Realtime;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. namespace DCGO.CardEffects.EX7
  7. {
  8. public class EX7_013 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasText("Three Musketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5 || targetPermanent.TopCard.HasText("ThreeMusketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Play 1 Option then Draw", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] You may use 1 Option card with the [Three Musketeers] trait from your hand without paying the cost. Then, draw cards until there are 6 cards in your hand.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.IsOption)
  37. {
  38. if (cardSource.CardTraits.Contains("Three Musketeers") || cardSource.CardTraits.Contains("ThreeMusketeers"))
  39. {
  40. if (cardSource.HasUseCost)
  41. {
  42. if (!cardSource.CanNotPlayThisOption)
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  58. {
  59. return true;
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. List<CardSource> selectedCards = new List<CardSource>();
  66. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  67. {
  68. int maxCount = 1;
  69. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  70. selectHandEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectCardCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. selectCardCoroutine: SelectCardCoroutine,
  80. afterSelectCardCoroutine: null,
  81. mode: SelectHandEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectHandEffect.SetUpCustomMessage(
  84. "Select 1 option card to use.",
  85. "The opponent is selecting 1 option card to use.");
  86. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCards.Add(cardSource);
  91. yield return null;
  92. }
  93. }
  94. if (selectedCards.Count >= 1)
  95. {
  96. yield return ContinuousController.instance.StartCoroutine(
  97. CardEffectCommons.PlayOptionCards(
  98. cardSources: selectedCards,
  99. activateClass: activateClass,
  100. payCost: false,
  101. root: SelectCardEffect.Root.Hand
  102. )
  103. );
  104. }
  105. if (card.Owner.LibraryCards.Count >= 1 && card.Owner.HandCards.Count < 6)
  106. {
  107. while (card.Owner.HandCards.Count < 6)
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  110. }
  111. }
  112. }
  113. }
  114. #endregion
  115. #region When Digivolving
  116. if (timing == EffectTiming.OnEnterFieldAnyone)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Play 1 Option then Draw", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  121. cardEffects.Add(activateClass);
  122. string EffectDiscription()
  123. {
  124. return "[When Digivolving] You may use 1 Option card with the [Three Musketeers] trait from your hand without paying the cost. Then, draw cards until there are 6 cards in your hand.";
  125. }
  126. bool CanSelectCardCondition(CardSource cardSource)
  127. {
  128. if (cardSource.IsOption)
  129. {
  130. if (cardSource.CardTraits.Contains("Three Musketeers") || cardSource.CardTraits.Contains("ThreeMusketeers"))
  131. {
  132. if (cardSource.HasUseCost)
  133. {
  134. if (!cardSource.CanNotPlayThisOption)
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  146. {
  147. if(CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  148. {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanActivateCondition(Hashtable hashtable)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  157. {
  158. return true;
  159. }
  160. return false;
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  163. {
  164. List<CardSource> selectedCards = new List<CardSource>();
  165. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  166. {
  167. int maxCount = 1;
  168. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  169. selectHandEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectCardCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: maxCount,
  175. canNoSelect: true,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. selectCardCoroutine: SelectCardCoroutine,
  179. afterSelectCardCoroutine: null,
  180. mode: SelectHandEffect.Mode.Custom,
  181. cardEffect: activateClass);
  182. selectHandEffect.SetUpCustomMessage(
  183. "Select 1 option card to use.",
  184. "The opponent is selecting 1 option card to use.");
  185. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  186. yield return StartCoroutine(selectHandEffect.Activate());
  187. IEnumerator SelectCardCoroutine(CardSource cardSource)
  188. {
  189. selectedCards.Add(cardSource);
  190. yield return null;
  191. }
  192. }
  193. if (selectedCards.Count >= 1)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(
  196. CardEffectCommons.PlayOptionCards(
  197. cardSources: selectedCards,
  198. activateClass: activateClass,
  199. payCost: false,
  200. root: SelectCardEffect.Root.Hand
  201. )
  202. );
  203. }
  204. if (card.Owner.LibraryCards.Count >= 1 && card.Owner.HandCards.Count < 6)
  205. {
  206. while (card.Owner.HandCards.Count < 6)
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  209. }
  210. }
  211. }
  212. }
  213. #endregion
  214. #region End of Your Turn
  215. if (timing == EffectTiming.OnEndTurn)
  216. {
  217. ActivateClass activateClass = new ActivateClass();
  218. activateClass.SetUpICardEffect("Trash 1 digivolution card to give <Security Atk +1> and attack", CanUseCondition, card);
  219. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  220. activateClass.SetHashString("ReturnOption_EX7-013");
  221. cardEffects.Add(activateClass);
  222. string EffectDiscription()
  223. {
  224. return "[End of Your Turn] [Once Per Turn] By trashing 1 Option card in this Digimon's digivolution card, 1 of your Digimon gains <Security Attack +1> for the turn and that Digimon attacks.";
  225. }
  226. bool CanSelectCardCondition(CardSource cardSource)
  227. {
  228. if (cardSource.IsOption)
  229. {
  230. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  231. {
  232. return true;
  233. }
  234. }
  235. return false;
  236. }
  237. bool CanSelectPermanentCondition(Permanent permanent)
  238. {
  239. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  240. }
  241. bool CanUseCondition(Hashtable hashtable)
  242. {
  243. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  244. {
  245. if (CardEffectCommons.IsOwnerTurn(card))
  246. {
  247. return true;
  248. }
  249. }
  250. return false;
  251. }
  252. bool CanActivateCondition(Hashtable hashtable)
  253. {
  254. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  255. {
  256. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  257. {
  258. return true;
  259. }
  260. }
  261. return false;
  262. }
  263. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  264. {
  265. bool trashed = false;
  266. Permanent selectedPermanent = null;
  267. List<CardSource> selectedCards = new List<CardSource>();
  268. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  269. selectCardEffect.SetUp(
  270. canTargetCondition: CanSelectCardCondition,
  271. canTargetCondition_ByPreSelecetedList: null,
  272. canEndSelectCondition: null,
  273. canNoSelect: () => false,
  274. selectCardCoroutine: SelectCardCoroutine,
  275. afterSelectCardCoroutine: null,
  276. message: "Select 1 Option card to discard.",
  277. maxCount: 1,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. mode: SelectCardEffect.Mode.Custom,
  281. root: SelectCardEffect.Root.Custom,
  282. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  283. canLookReverseCard: true,
  284. selectPlayer: card.Owner,
  285. cardEffect: null);
  286. selectCardEffect.SetUpCustomMessage("Select 1 Option card to discard.", "The opponent is selecting 1 Option card to discard.");
  287. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  288. IEnumerator SelectCardCoroutine(CardSource cardSource)
  289. {
  290. selectedCards.Add(cardSource);
  291. yield return null;
  292. }
  293. if (selectedCards.Count >= 1)
  294. {
  295. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  296. trashed = true;
  297. }
  298. if (trashed)
  299. {
  300. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  301. {
  302. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  303. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  304. selectPermanentEffect.SetUp(
  305. selectPlayer: card.Owner,
  306. canTargetCondition: CanSelectPermanentCondition,
  307. canTargetCondition_ByPreSelecetedList: null,
  308. canEndSelectCondition: null,
  309. maxCount: maxCount,
  310. canNoSelect: false,
  311. canEndNotMax: false,
  312. selectPermanentCoroutine: SelectPermanentCoroutine,
  313. afterSelectPermanentCoroutine: null,
  314. mode: SelectPermanentEffect.Mode.Custom,
  315. cardEffect: activateClass);
  316. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack +1.", "The opponent is selecting 1 Digimon that will get Security Attack +1.");
  317. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  318. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  319. {
  320. selectedPermanent = permanent;
  321. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  322. targetPermanent: permanent,
  323. changeValue: 1,
  324. effectDuration: EffectDuration.UntilEachTurnEnd,
  325. activateClass: activateClass));
  326. }
  327. if(selectedPermanent != null)
  328. {
  329. if (selectedPermanent.CanAttack(activateClass))
  330. {
  331. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  332. selectAttackEffect.SetUp(
  333. attacker: selectedPermanent,
  334. canAttackPlayerCondition: () => true,
  335. defenderCondition: (permanent) => true,
  336. cardEffect: activateClass);
  337. selectAttackEffect.SetCanNotSelectNotAttack();
  338. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. #endregion
  346. return cardEffects;
  347. }
  348. }
  349. }