BT18_017.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_017 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Digivolving
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete all opponent's digimon with the lowest DP.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[When Digivolving] Delete all of your opponent's Digimon with the lowest DP.";
  21. }
  22. bool PermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. return false;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.IsExistOnBattleArea(card);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  37. {
  38. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  39. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  40. }
  41. }
  42. #endregion
  43. #region On Play
  44. if (timing == EffectTiming.OnEnterFieldAnyone)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Delete all opponent's digimon with the lowest DP.", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[On Play] Delete all of your opponent's Digimon with the lowest DP.";
  53. }
  54. bool PermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleArea(card);
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  71. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  72. }
  73. }
  74. #endregion
  75. #region All Turns
  76. if (timing == EffectTiming.WhenRemoveField)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Return a Digimon to the hand or play a Digimon from the digivolution sources.", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[All Turns] When this Digimon would leave the battle area, you may return to the hand or play 1 level 4 or lower red Digimon card from this Digimon's digivolution cards without paying the cost.";
  85. }
  86. bool CanSelectCardCondition(CardSource cardSource)
  87. {
  88. if (cardSource != null)
  89. {
  90. if (cardSource.Owner == card.Owner)
  91. {
  92. if (cardSource.IsDigimon)
  93. {
  94. if (cardSource.Level <= 4)
  95. {
  96. if (cardSource.HasCardColor(CardColor.Red))
  97. {
  98. if (cardSource.HasLevel)
  99. {
  100. return true;
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  112. {
  113. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanActivateCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  123. {
  124. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  132. {
  133. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  134. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  135. if (canSelectDigivolutionCards)
  136. {
  137. if (canSelectDigivolutionCards)
  138. {
  139. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  140. {
  141. new SelectionElement<bool>(message: $"Return to hand", value : true, spriteIndex: 0),
  142. new SelectionElement<bool>(message: $"Play a Digimon", value : false, spriteIndex: 1),
  143. };
  144. string selectPlayerMessage = "Do you want to return to hand or play 1 level 4 or lower Digimon from its digivolution sources";
  145. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  146. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  147. }
  148. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  149. bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  150. List<CardSource> selectedCards = new List<CardSource>();
  151. IEnumerator SelectCardCoroutine(CardSource cardSource)
  152. {
  153. selectedCards.Add(cardSource);
  154. yield return null;
  155. }
  156. if (toHand)
  157. {
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: CanSelectCardCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => true,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. message: "Select 1 card to return to hand.",
  167. maxCount: 1,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. mode: SelectCardEffect.Mode.AddHand,
  171. root: SelectCardEffect.Root.Custom,
  172. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  173. canLookReverseCard: true,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. yield return StartCoroutine(selectCardEffect.Activate());
  177. }
  178. else
  179. {
  180. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  181. selectCardEffect.SetUp(
  182. canTargetCondition: CanSelectCardCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. canNoSelect: () => true,
  186. selectCardCoroutine: SelectCardCoroutine,
  187. afterSelectCardCoroutine: null,
  188. message: "Select 1 card to play.",
  189. maxCount: 1,
  190. canEndNotMax: false,
  191. isShowOpponent: true,
  192. mode: SelectCardEffect.Mode.Custom,
  193. root: SelectCardEffect.Root.Custom,
  194. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  195. canLookReverseCard: true,
  196. selectPlayer: card.Owner,
  197. cardEffect: activateClass);
  198. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  199. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  200. yield return StartCoroutine(selectCardEffect.Activate());
  201. }
  202. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  203. if (!toHand)
  204. {
  205. root = SelectCardEffect.Root.DigivolutionCards;
  206. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedCards[0], payCost: false, cardEffect: activateClass))
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  209. cardSources: selectedCards,
  210. activateClass: activateClass,
  211. payCost: false,
  212. isTapped: false,
  213. root: root,
  214. activateETB: true));
  215. }
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. #region DigiXros
  222. if (timing == EffectTiming.None)
  223. {
  224. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  225. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  226. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  227. addDigiXrosConditionClass.SetNotShowUI(true);
  228. cardEffects.Add(addDigiXrosConditionClass);
  229. bool CanUseCondition(Hashtable hashtable)
  230. {
  231. return true;
  232. }
  233. DigiXrosCondition GetDigiXros(CardSource cardSource)
  234. {
  235. if (cardSource == card)
  236. {
  237. DigiXrosConditionElement elementGrumblemon =
  238. new DigiXrosConditionElement(CanSelectCardCondition, "Grumblemon");
  239. bool CanSelectCardCondition(CardSource conditionCardSource)
  240. {
  241. if (conditionCardSource != null)
  242. {
  243. if (conditionCardSource.Owner == card.Owner)
  244. {
  245. if (conditionCardSource.IsDigimon)
  246. {
  247. if (conditionCardSource.CardNames_DigiXros.Contains("Grumblemon"))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. DigiXrosConditionElement elementGigasmon =
  257. new DigiXrosConditionElement(CanSelectCardCondition1, "Gigasmon");
  258. bool CanSelectCardCondition1(CardSource conditionCardSource)
  259. {
  260. if (conditionCardSource != null)
  261. {
  262. if (conditionCardSource.Owner == card.Owner)
  263. {
  264. if (conditionCardSource.IsDigimon)
  265. {
  266. if (conditionCardSource.CardNames_DigiXros.Contains("Gigasmon"))
  267. {
  268. return true;
  269. }
  270. }
  271. }
  272. }
  273. return false;
  274. }
  275. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  276. { elementGrumblemon, elementGigasmon };
  277. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  278. return digiXrosCondition;
  279. }
  280. return null;
  281. }
  282. }
  283. #endregion
  284. return cardEffects;
  285. }
  286. }
  287. }