BT17_102.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_102 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.ContainsCardName("Agumon"))
  18. {
  19. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3)
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  27. permanentCondition: PermanentCondition,
  28. digivolutionCost: 2,
  29. ignoreDigivolutionRequirement: false,
  30. card: card,
  31. condition: null));
  32. }
  33. #endregion
  34. #region When Digivolving
  35. if (timing == EffectTiming.OnEnterFieldAnyone)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("+3000DP, Delete opponents Digimon", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[When Digivolving] If this Digimon's name is [Koromon], it gains +3000 DP for the turn. Then, delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  44. }
  45. bool IsOpponentsDigimonSelectable(Permanent permanent)
  46. {
  47. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.DP <= card.PermanentOfThisCard().DP)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. if (card.PermanentOfThisCard().TopCard.EqualsCardName("Koromon"))
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  69. targetPermanent: card.PermanentOfThisCard(),
  70. changeValue: 3000,
  71. effectDuration: EffectDuration.UntilEachTurnEnd,
  72. activateClass: activateClass));
  73. }
  74. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimonSelectable))
  75. {
  76. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentsDigimonSelectable));
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: IsOpponentsDigimonSelectable,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: maxCount,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: null,
  87. afterSelectPermanentCoroutine: null,
  88. mode: SelectPermanentEffect.Mode.Destroy,
  89. cardEffect: activateClass);
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. }
  92. }
  93. }
  94. #endregion
  95. #region All Turns
  96. if (timing == EffectTiming.None)
  97. {
  98. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  99. changeCardNamesClass.SetUpICardEffect("This Digimon has all the names of level 3 and lower cards in its digivolution cards", CanUseCondition, card);
  100. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  101. cardEffects.Add(changeCardNamesClass);
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  105. return card.PermanentOfThisCard().TopCard == card;
  106. return false;
  107. }
  108. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  109. {
  110. if (cardSource == card)
  111. {
  112. foreach(CardSource digivolutionCard in card.PermanentOfThisCard().DigivolutionCards)
  113. {
  114. if(digivolutionCard.HasLevel && digivolutionCard.Level <= 3)
  115. CardNames.AddRange(digivolutionCard.CardNames);
  116. }
  117. }
  118. return CardNames;
  119. }
  120. }
  121. #endregion
  122. #region On Deletion
  123. if (timing == EffectTiming.OnDestroyedAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Play 1 Tamer, or Hatch", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  128. cardEffects.Add(activateClass);
  129. string EffectDiscription()
  130. {
  131. return "[On Deletion] You may play 1 Tamer card with [Tai Kamiya] or [Kari Kamiya] in its name from your hand without paying the cost or hatch in your breeding area.";
  132. }
  133. bool CanSelectCardCondition(CardSource cardSource)
  134. {
  135. if (cardSource.IsTamer)
  136. {
  137. if (cardSource.ContainsCardName("Tai Kamiya") || cardSource.ContainsCardName("Kari Kamiya"))
  138. {
  139. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  140. {
  141. return true;
  142. }
  143. }
  144. }
  145. return false;
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  158. {
  159. new SelectionElement<bool>(message: $"Play", value : true, spriteIndex: 0),
  160. new SelectionElement<bool>(message: $"Hatch", value : false, spriteIndex: 1),
  161. };
  162. string selectPlayerMessage = "Will you play 1 Tamer card with [Tai Kamiya] or [Kari Kamiya] in its name from your hand or hatch?";
  163. string notSelectPlayerMessage = "The opponent is choosing whether or not to play a Tamer or hatch.";
  164. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  165. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  166. bool willPlayTamer = GManager.instance.userSelectionManager.SelectedBoolValue;
  167. if (willPlayTamer)
  168. {
  169. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  170. {
  171. List<CardSource> selectedCards = new List<CardSource>();
  172. int maxCount = 1;
  173. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  174. selectHandEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectCardCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: maxCount,
  180. canNoSelect: true,
  181. canEndNotMax: false,
  182. isShowOpponent: true,
  183. selectCardCoroutine: SelectCardCoroutine,
  184. afterSelectCardCoroutine: null,
  185. mode: SelectHandEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  188. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  189. yield return StartCoroutine(selectHandEffect.Activate());
  190. IEnumerator SelectCardCoroutine(CardSource cardSource)
  191. {
  192. selectedCards.Add(cardSource);
  193. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  194. cardSources: selectedCards,
  195. activateClass: activateClass,
  196. payCost: false,
  197. isTapped: false,
  198. root: SelectCardEffect.Root.Hand,
  199. activateETB: true));
  200. }
  201. }
  202. }
  203. else
  204. {
  205. if (card.Owner.CanHatch)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(new HatchDigiEggClass(player: card.Owner, hashtable: CardEffectCommons.CardEffectHashtable(activateClass)).Hatch());
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region On Deletion - ESS
  214. if (timing == EffectTiming.OnDestroyedAnyone)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("Play 1 Tamer, or Hatch", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  219. activateClass.SetIsInheritedEffect(true);
  220. cardEffects.Add(activateClass);
  221. string EffectDiscription()
  222. {
  223. return "[On Deletion] You may play 1 Tamer card with [Tai Kamiya] or [Kari Kamiya] in its name from your hand without paying the cost or hatch in your breeding area.";
  224. }
  225. bool CanSelectCardCondition(CardSource cardSource)
  226. {
  227. if (cardSource.IsTamer)
  228. {
  229. if (cardSource.ContainsCardName("Tai Kamiya") || cardSource.ContainsCardName("Kari Kamiya"))
  230. {
  231. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  232. {
  233. return true;
  234. }
  235. }
  236. }
  237. return false;
  238. }
  239. bool CanUseCondition(Hashtable hashtable)
  240. {
  241. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  246. }
  247. IEnumerator ActivateCoroutine(Hashtable hashtable)
  248. {
  249. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  250. {
  251. new SelectionElement<bool>(message: $"Play", value : true, spriteIndex: 0),
  252. new SelectionElement<bool>(message: $"Hatch", value : false, spriteIndex: 1),
  253. };
  254. string selectPlayerMessage = "Will you play 1 Tamer card with [Tai Kamiya] or [Kari Kamiya] in its name from your hand or hatch?";
  255. string notSelectPlayerMessage = "The opponent is choosing whether or not to play a Tamer or hatch.";
  256. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  257. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  258. bool willPlayTamer = GManager.instance.userSelectionManager.SelectedBoolValue;
  259. if (willPlayTamer)
  260. {
  261. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  262. {
  263. List<CardSource> selectedCards = new List<CardSource>();
  264. int maxCount = 1;
  265. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  266. selectHandEffect.SetUp(
  267. selectPlayer: card.Owner,
  268. canTargetCondition: CanSelectCardCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: null,
  271. maxCount: maxCount,
  272. canNoSelect: true,
  273. canEndNotMax: false,
  274. isShowOpponent: true,
  275. selectCardCoroutine: SelectCardCoroutine,
  276. afterSelectCardCoroutine: null,
  277. mode: SelectHandEffect.Mode.Custom,
  278. cardEffect: activateClass);
  279. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  280. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  281. yield return StartCoroutine(selectHandEffect.Activate());
  282. IEnumerator SelectCardCoroutine(CardSource cardSource)
  283. {
  284. selectedCards.Add(cardSource);
  285. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  286. cardSources: selectedCards,
  287. activateClass: activateClass,
  288. payCost: false,
  289. isTapped: false,
  290. root: SelectCardEffect.Root.Hand,
  291. activateETB: true));
  292. }
  293. }
  294. }
  295. else
  296. {
  297. if (card.Owner.CanHatch)
  298. {
  299. yield return ContinuousController.instance.StartCoroutine(new HatchDigiEggClass(player: card.Owner, hashtable: CardEffectCommons.CardEffectHashtable(activateClass)).Hatch());
  300. }
  301. }
  302. }
  303. }
  304. #endregion
  305. return cardEffects;
  306. }
  307. }
  308. }