BT16_083.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_083 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Deletion
  13. if (timing == EffectTiming.OnDestroyedAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Return all Tamers, then play a Tamer and [Ukkomon] from your trash.", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Deletion] Return all Tamers to their owner's hands. Then, you may play 1 Tamer card from your hand and 1 [Ukkomon] from your trash without paying the cost.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  26. }
  27. bool PermanentCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  30. {
  31. if (permanent.IsTamer)
  32. {
  33. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  34. {
  35. if (!permanent.CannotReturnToHand(activateClass))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectTamer(CardSource card)
  45. {
  46. if (card.IsTamer)
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. bool CanSelectUkko(CardSource cardSource)
  53. {
  54. if (cardSource != null)
  55. {
  56. if (cardSource.IsDigimon)
  57. {
  58. if (cardSource.Owner == card.Owner)
  59. {
  60. if (cardSource.CardNames.Contains("Ukkomon"))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return true;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. List<Permanent> boounceTargetPermanents =
  76. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  77. .Map(player => player.GetBattleAreaPermanents())
  78. .Flat()
  79. .Filter(PermanentCondition);
  80. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(boounceTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  81. if (card.Owner.HandCards.Count(CanSelectTamer) >= 1)
  82. {
  83. List<CardSource> selectedCards = new List<CardSource>();
  84. int maxCount = 1;
  85. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectHandEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectTamer,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  100. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. IEnumerator SelectCardCoroutine(CardSource cardSource)
  103. {
  104. selectedCards.Add(cardSource);
  105. yield return null;
  106. }
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  108. cardSources: selectedCards,
  109. activateClass: activateClass,
  110. payCost: false,
  111. isTapped: false,
  112. root: SelectCardEffect.Root.Hand,
  113. activateETB: true));
  114. }
  115. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectUkko))
  116. {
  117. int maxCount = 1;
  118. List<CardSource> selectedCards = new List<CardSource>();
  119. IEnumerator SelectCardCoroutine(CardSource cardSource)
  120. {
  121. selectedCards.Add(cardSource);
  122. yield return null;
  123. }
  124. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  125. selectCardEffect.SetUp(
  126. canTargetCondition: CanSelectUkko,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. canNoSelect: () => true,
  130. selectCardCoroutine: SelectCardCoroutine,
  131. afterSelectCardCoroutine: null,
  132. message: "Select 1 card to play.",
  133. maxCount: maxCount,
  134. canEndNotMax: false,
  135. isShowOpponent: true,
  136. mode: SelectCardEffect.Mode.Custom,
  137. root: SelectCardEffect.Root.Trash,
  138. customRootCardList: null,
  139. canLookReverseCard: true,
  140. selectPlayer: card.Owner,
  141. cardEffect: activateClass);
  142. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  143. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  144. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  145. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  147. }
  148. }
  149. }
  150. #endregion
  151. #region End of Your Turn
  152. if (timing == EffectTiming.OnEndTurn)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Return 1 Digi-Egg to delete 1 opponent Digimon with the lowest level and play a level 4 Digimon.", CanUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  157. activateClass.SetHashString("Effect_BT16_083");
  158. cardEffects.Add(activateClass);
  159. string EffectDiscription()
  160. {
  161. return "[End of Your Turn] [Once Per Turn] By returning 1 Digi-Egg card from your trash to the bottom of your Digi-Egg deck, delete 1 of your opponent's Digimon with the lowest level. Then you may play 1 level 4 or lower Digimon card from your hand to the breeding area without paying the cost.";
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleArea(card))
  166. {
  167. if (CardEffectCommons.IsOwnerTurn(card))
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool CanActivateCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleArea(card))
  177. {
  178. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanSelectCardCondition(CardSource cardSource)
  186. {
  187. if (cardSource.IsDigiEgg)
  188. {
  189. return true;
  190. }
  191. return false;
  192. }
  193. bool CanSelectLevel4InHand(CardSource cardSource)
  194. {
  195. if (cardSource.IsDigimon)
  196. {
  197. if (cardSource.HasLevel)
  198. {
  199. if (cardSource.Level <= 4)
  200. {
  201. return true;
  202. }
  203. }
  204. }
  205. return false;
  206. }
  207. bool CanSelectPermanentCondition(Permanent permanent)
  208. {
  209. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  210. }
  211. IEnumerator ActivateCoroutine(Hashtable hashtable)
  212. {
  213. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  214. {
  215. int maxCount = 1;
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => true,
  222. selectCardCoroutine: null,
  223. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  224. message: "Select 1 card to place at the bottom of the Digi-Egg deck.",
  225. maxCount: maxCount,
  226. canEndNotMax: false,
  227. isShowOpponent: false,
  228. mode: SelectCardEffect.Mode.Custom,
  229. root: SelectCardEffect.Root.Custom,
  230. customRootCardList: card.Owner.TrashCards,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. selectCardEffect.SetNotShowCard();
  235. selectCardEffect.SetNotAddLog();
  236. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  237. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  238. {
  239. if (cardSources.Count == 1)
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  242. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Digi-Egg deck Bottom Cards", true, true));
  243. }
  244. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  245. {
  246. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  247. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  248. selectPermanentEffect.SetUp(
  249. selectPlayer: card.Owner,
  250. canTargetCondition: CanSelectPermanentCondition,
  251. canTargetCondition_ByPreSelecetedList: null,
  252. canEndSelectCondition: null,
  253. maxCount: maxCount,
  254. canNoSelect: true,
  255. canEndNotMax: false,
  256. selectPermanentCoroutine: null,
  257. afterSelectPermanentCoroutine: null,
  258. mode: SelectPermanentEffect.Mode.Destroy,
  259. cardEffect: activateClass);
  260. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  262. }
  263. }
  264. }
  265. if (card.Owner.HandCards.Count(CanSelectLevel4InHand) >= 1)
  266. {
  267. List<CardSource> selectedCards = new List<CardSource>();
  268. int maxCount = 1;
  269. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  270. selectHandEffect.SetUp(
  271. selectPlayer: card.Owner,
  272. canTargetCondition: CanSelectLevel4InHand,
  273. canTargetCondition_ByPreSelecetedList: null,
  274. canEndSelectCondition: null,
  275. maxCount: maxCount,
  276. canNoSelect: true,
  277. canEndNotMax: false,
  278. isShowOpponent: true,
  279. selectCardCoroutine: SelectCardCoroutine,
  280. afterSelectCardCoroutine: null,
  281. mode: SelectHandEffect.Mode.Custom,
  282. cardEffect: activateClass);
  283. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  284. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  285. yield return StartCoroutine(selectHandEffect.Activate());
  286. IEnumerator SelectCardCoroutine(CardSource cardSource)
  287. {
  288. selectedCards.Add(cardSource);
  289. yield return null;
  290. }
  291. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  292. cardSources: selectedCards,
  293. activateClass: activateClass,
  294. payCost: false,
  295. isTapped: false,
  296. root: SelectCardEffect.Root.Hand,
  297. activateETB: true,
  298. isBreedingArea: true));
  299. }
  300. }
  301. }
  302. #endregion
  303. return cardEffects;
  304. }
  305. }
  306. }