BT21_069.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //BT21-069 GulusGammamon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_069 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt digivolution cost
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.EqualsCardName("Gammamon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 2,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null));
  26. }
  27. #endregion
  28. #region Security
  29. if (timing == EffectTiming.SecuritySkill)
  30. {
  31. cardEffects.Add(CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect(card: card));
  32. }
  33. #endregion
  34. #region On-play/When-digivolving shared
  35. bool HasGammamonNameDigimon(CardSource card)
  36. {
  37. return card.IsDigimon && card.ContainsCardName("Gammamon");
  38. }
  39. bool CanActivateShared(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  42. {
  43. return CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasGammamonNameDigimon)
  44. || CardEffectCommons.HasMatchConditionOwnersHand(card, HasGammamonNameDigimon);
  45. }
  46. return false;
  47. }
  48. #endregion
  49. #region On-Play
  50. if(timing == EffectTiming.OnEnterFieldAnyone)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("Tuck gammamon to delete", CanUseEffect, card);
  54. activateClass.SetUpActivateClass(CanActivateShared, ActivateCoroutine, -1, true, EffectDescription());
  55. cardEffects.Add(activateClass);
  56. string EffectDescription()
  57. {
  58. return "[On Play] By placing 1 Digimon card with [Gammamon] in its name from your hand or trash as this Digimon's bottom digivolution card, delete 1 of your opponent's level 4 or lower Digimon.";
  59. }
  60. bool CanUseEffect(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  63. }
  64. bool CanSelectPermanentCondition(Permanent permanent)
  65. {
  66. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  67. {
  68. return permanent.TopCard.HasLevel && permanent.Level <= 4;
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable hashtable)
  73. {
  74. bool canSelectHand = card.Owner.HandCards.Count(HasGammamonNameDigimon) >= 1;
  75. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasGammamonNameDigimon);
  76. if (canSelectHand || canSelectTrash)
  77. {
  78. if (canSelectHand && canSelectTrash)
  79. {
  80. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  81. {
  82. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  83. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  84. };
  85. string selectPlayerMessage = "From which area do you select a card?";
  86. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  87. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  88. }
  89. else
  90. {
  91. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  92. }
  93. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  94. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  95. List<CardSource> selectedCards = new List<CardSource>();
  96. IEnumerator SelectCardCoroutine(CardSource cardSource)
  97. {
  98. selectedCards.Add(cardSource);
  99. yield return null;
  100. }
  101. if (fromHand)
  102. {
  103. int maxCount = 1;
  104. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  105. selectHandEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: HasGammamonNameDigimon,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: maxCount,
  111. canNoSelect: true,
  112. canEndNotMax: false,
  113. isShowOpponent: true,
  114. selectCardCoroutine: SelectCardCoroutine,
  115. afterSelectCardCoroutine: null,
  116. mode: SelectHandEffect.Mode.Custom,
  117. cardEffect: activateClass);
  118. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  119. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  120. yield return StartCoroutine(selectHandEffect.Activate());
  121. }
  122. else
  123. {
  124. int maxCount = 1;
  125. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  126. selectCardEffect.SetUp(
  127. canTargetCondition: HasGammamonNameDigimon,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. canNoSelect: () => true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. message: "Select 1 card to place on bottom of digivolution cards.",
  134. maxCount: maxCount,
  135. canEndNotMax: false,
  136. isShowOpponent: true,
  137. mode: SelectCardEffect.Mode.Custom,
  138. root: SelectCardEffect.Root.Trash,
  139. customRootCardList: null,
  140. canLookReverseCard: true,
  141. selectPlayer: card.Owner,
  142. cardEffect: activateClass);
  143. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  144. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  145. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  146. }
  147. if (selectedCards.Count >= 1)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  150. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  151. {
  152. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectPermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: null,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Destroy,
  165. cardEffect: activateClass);
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. }
  168. }
  169. }
  170. }
  171. }
  172. #endregion
  173. #region When digivolving
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect("Tuck gammamon to delete", CanUseEffect, card);
  178. activateClass.SetUpActivateClass(CanActivateShared, ActivateCoroutine, -1, true, EffectDescription());
  179. cardEffects.Add(activateClass);
  180. string EffectDescription()
  181. {
  182. return "[When Digivolving] By placing 1 Digimon card with [Gammamon] in its name from your hand or trash as this Digimon's bottom digivolution card, delete 1 of your opponent's level 4 or lower Digimon.";
  183. }
  184. bool CanUseEffect(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  187. }
  188. bool CanSelectPermanentCondition(Permanent permanent)
  189. {
  190. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  191. {
  192. return permanent.TopCard.HasLevel && permanent.Level <= 4;
  193. }
  194. return false;
  195. }
  196. IEnumerator ActivateCoroutine(Hashtable hashtable)
  197. {
  198. bool canSelectHand = card.Owner.HandCards.Count(HasGammamonNameDigimon) >= 1;
  199. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasGammamonNameDigimon);
  200. if (canSelectHand || canSelectTrash)
  201. {
  202. if (canSelectHand && canSelectTrash)
  203. {
  204. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  205. {
  206. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  207. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  208. };
  209. string selectPlayerMessage = "From which area do you select a card?";
  210. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  211. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  212. }
  213. else
  214. {
  215. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  216. }
  217. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  218. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  219. List<CardSource> selectedCards = new List<CardSource>();
  220. IEnumerator SelectCardCoroutine(CardSource cardSource)
  221. {
  222. selectedCards.Add(cardSource);
  223. yield return null;
  224. }
  225. if (fromHand)
  226. {
  227. int maxCount = 1;
  228. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  229. selectHandEffect.SetUp(
  230. selectPlayer: card.Owner,
  231. canTargetCondition: HasGammamonNameDigimon,
  232. canTargetCondition_ByPreSelecetedList: null,
  233. canEndSelectCondition: null,
  234. maxCount: maxCount,
  235. canNoSelect: true,
  236. canEndNotMax: false,
  237. isShowOpponent: true,
  238. selectCardCoroutine: SelectCardCoroutine,
  239. afterSelectCardCoroutine: null,
  240. mode: SelectHandEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  243. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  244. yield return StartCoroutine(selectHandEffect.Activate());
  245. }
  246. else
  247. {
  248. int maxCount = 1;
  249. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  250. selectCardEffect.SetUp(
  251. canTargetCondition: HasGammamonNameDigimon,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. canNoSelect: () => true,
  255. selectCardCoroutine: SelectCardCoroutine,
  256. afterSelectCardCoroutine: null,
  257. message: "Select 1 card to place on bottom of digivolution cards.",
  258. maxCount: maxCount,
  259. canEndNotMax: false,
  260. isShowOpponent: true,
  261. mode: SelectCardEffect.Mode.Custom,
  262. root: SelectCardEffect.Root.Trash,
  263. customRootCardList: null,
  264. canLookReverseCard: true,
  265. selectPlayer: card.Owner,
  266. cardEffect: activateClass);
  267. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  268. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  269. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  270. }
  271. if (selectedCards.Count >= 1)
  272. {
  273. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  274. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  275. {
  276. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  277. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  278. selectPermanentEffect.SetUp(
  279. selectPlayer: card.Owner,
  280. canTargetCondition: CanSelectPermanentCondition,
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. maxCount: maxCount,
  284. canNoSelect: false,
  285. canEndNotMax: false,
  286. selectPermanentCoroutine: null,
  287. afterSelectPermanentCoroutine: null,
  288. mode: SelectPermanentEffect.Mode.Destroy,
  289. cardEffect: activateClass);
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. }
  292. }
  293. }
  294. }
  295. }
  296. #endregion
  297. #region Inherit
  298. if (timing == EffectTiming.OnDestroyedAnyone)
  299. {
  300. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  301. }
  302. #endregion
  303. return cardEffects;
  304. }
  305. }
  306. }