EX10_044.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. //Damemon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Place 1 [Bagra Army] digimon under tamer, Then draw 1", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. => "[On Play] By placing 1 [Bagra Army] trait Digimon card from your hand or trash under any of your Tamers, <Draw 1> ";
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  25. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  30. && CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition)
  31. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  32. }
  33. bool CanSelectTamerCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card);
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. return cardSource.IsDigimon
  40. && cardSource.HasBagraArmyTraits;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  45. {
  46. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  47. {
  48. SelectCardEffect.Root? rootmode = null!;
  49. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  50. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  51. if (canSelectHand && !canSelectTrash) rootmode = SelectCardEffect.Root.Hand;
  52. if (!canSelectHand && canSelectTrash) rootmode = SelectCardEffect.Root.Trash;
  53. if (canSelectHand && canSelectTrash)
  54. {
  55. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  56. {
  57. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  58. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  59. };
  60. string selectPlayerMessage = "From which area do you select a card?";
  61. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  62. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  63. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  64. rootmode = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  65. }
  66. if (rootmode != null)
  67. {
  68. CardSource selectedCard = null;
  69. if(rootmode == SelectCardEffect.Root.Hand)
  70. {
  71. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  72. selectHandEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectCardCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: 1,
  78. canNoSelect: true,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. selectCardCoroutine: SelectCardCoroutine,
  82. afterSelectCardCoroutine: null,
  83. mode: SelectHandEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  86. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  87. }
  88. else
  89. {
  90. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  91. selectCardEffect.SetUp(
  92. canTargetCondition: CanSelectCardCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. canNoSelect: () => true,
  96. selectCardCoroutine: SelectCardCoroutine,
  97. afterSelectCardCoroutine: null,
  98. message: "Select 1 card to add as source.",
  99. maxCount: 1,
  100. canEndNotMax: false,
  101. isShowOpponent: true,
  102. mode: SelectCardEffect.Mode.Custom,
  103. root: (SelectCardEffect.Root)rootmode!,
  104. customRootCardList: null,
  105. canLookReverseCard: true,
  106. selectPlayer: card.Owner,
  107. cardEffect: activateClass);
  108. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  109. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  110. }
  111. IEnumerator SelectCardCoroutine(CardSource cardSource)
  112. {
  113. selectedCard = cardSource;
  114. yield return null;
  115. }
  116. if (selectedCard != null)
  117. {
  118. Permanent selectedPermanent = null;
  119. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectTamerCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: maxCount,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: SelectPermanentCoroutine,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. selectedPermanent = permanent;
  137. yield return null;
  138. }
  139. if (selectedPermanent != null)
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  142. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region On Deletion
  152. if (timing == EffectTiming.OnDestroyedAnyone)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Play 1 [Tuwarmon] with a play cost of 7 or less under tamer, then <Save>", CanUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. => "[On Deletion] You may play 1 [Tuwarmon] with a play cost of 7 or less from under your Tamers without paying the cost. Then, <Save>";
  160. bool CanUseCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.CanActivateOnDeletion(card);
  167. }
  168. bool CanSelectTamerCondition(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  171. && permanent.IsTamer;
  172. }
  173. bool TamerHasDigimon(Permanent permanent)
  174. {
  175. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  176. {
  177. if (permanent.IsTamer)
  178. {
  179. if (permanent.DigivolutionCards.Count(IsTuwarmon) >= 1)
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. bool IsTuwarmon(CardSource cardSource)
  188. {
  189. return cardSource.EqualsCardName("Tuwarmon") &&
  190. cardSource.IsDigimon &&
  191. cardSource.HasPlayCost && cardSource.GetCostItself <= 7 &&
  192. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.DigivolutionCards);
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimon))
  197. {
  198. Permanent selectedPermanent = null;
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: TamerHasDigimon,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: 1,
  206. canNoSelect: true,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: SelectPermanentCoroutine,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  215. {
  216. selectedPermanent = permanent;
  217. yield return null;
  218. }
  219. if (selectedPermanent != null)
  220. {
  221. List<CardSource> selectedCards = new List<CardSource>();
  222. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  223. selectCardEffect.SetUp(
  224. canTargetCondition: IsTuwarmon,
  225. canTargetCondition_ByPreSelecetedList: null,
  226. canEndSelectCondition: null,
  227. canNoSelect: () => true,
  228. selectCardCoroutine: SelectCardCoroutine,
  229. afterSelectCardCoroutine: null,
  230. message: "Select 1 digivolution card to play.",
  231. maxCount: 1,
  232. canEndNotMax: false,
  233. isShowOpponent: true,
  234. mode: SelectCardEffect.Mode.Custom,
  235. root: SelectCardEffect.Root.Custom,
  236. customRootCardList: selectedPermanent.DigivolutionCards,
  237. canLookReverseCard: true,
  238. selectPlayer: card.Owner,
  239. cardEffect: activateClass);
  240. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  241. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  242. yield return StartCoroutine(selectCardEffect.Activate());
  243. IEnumerator SelectCardCoroutine(CardSource cardSource)
  244. {
  245. selectedCards.Add(cardSource);
  246. yield return null;
  247. }
  248. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  249. cardSources: selectedCards,
  250. activateClass: activateClass,
  251. payCost: false,
  252. isTapped: false,
  253. root: SelectCardEffect.Root.DigivolutionCards,
  254. activateETB: true));
  255. }
  256. }
  257. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectTamerCondition))
  258. {
  259. yield return ContinuousController.instance.StartCoroutine(
  260. CardEffectCommons.SaveProcess(hashtable, activateClass, card, CanSelectTamerCondition));
  261. }
  262. }
  263. }
  264. #endregion
  265. #region ESS
  266. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  267. {
  268. ActivateClass activateClass = new ActivateClass();
  269. activateClass.SetUpICardEffect("<Draw 1>", CanUseCondition, card);
  270. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  271. activateClass.SetIsInheritedEffect(true);
  272. cardEffects.Add(activateClass);
  273. string EffectDiscription()
  274. {
  275. return "When effects trash this card from a [Bagra Army] trait Digimon's digivolution cards, <Draw 1>";
  276. }
  277. bool CanUseCondition(Hashtable hashtable)
  278. {
  279. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  280. return trashedPermanent.TopCard.EqualsTraits("Bagra Army") &&
  281. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  282. }
  283. bool CanActivateCondition(Hashtable hashtable)
  284. {
  285. return CardEffectCommons.IsExistOnTrash(card);
  286. }
  287. IEnumerator ActivateCoroutine(Hashtable hashtable)
  288. {
  289. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  290. }
  291. }
  292. #endregion
  293. return cardEffects;
  294. }
  295. }
  296. }