BT16_079.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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_079 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Cherubimon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Alliance
  23. if (timing == EffectTiming.OnAllyAttack)
  24. {
  25. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. #endregion
  28. #region When Attacking
  29. if (timing == EffectTiming.OnAllyAttack)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Play a level 4 or lower Digimon from your hand or trash.", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  34. activateClass.SetHashString("PlayDigimon_BT16_079");
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[When Attacking] [Once Per Turn] You may play 1 level 4 or lower yellow or green Digimon from your hand or trash without paying the cost.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. bool CanSelectCardCondition(CardSource cardSource)
  53. {
  54. if (CardEffectCommons.IsExistOnHand(cardSource))
  55. {
  56. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon)
  57. {
  58. return true;
  59. }
  60. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool CanSelectCardCondition1(CardSource cardSource)
  68. {
  69. if (CardEffectCommons.IsExistOnTrash(cardSource))
  70. {
  71. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon)
  72. {
  73. return true;
  74. }
  75. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  76. {
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable hashtable)
  83. {
  84. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  85. bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition1) >= 1;
  86. if (canSelectHand || canSelectTrash)
  87. {
  88. if (canSelectHand && canSelectTrash)
  89. {
  90. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  91. {
  92. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  93. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  94. };
  95. string selectPlayerMessage = "From which area do you play a card?";
  96. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  97. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  98. }
  99. else
  100. {
  101. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  102. }
  103. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  104. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  105. List<CardSource> selectedCards = new List<CardSource>();
  106. IEnumerator SelectCardCoroutine(CardSource cardSource)
  107. {
  108. selectedCards.Add(cardSource);
  109. yield return null;
  110. }
  111. if (fromHand)
  112. {
  113. int maxCount1 = 1;
  114. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  115. selectHandEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectCardCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: maxCount1,
  121. canNoSelect: true,
  122. canEndNotMax: false,
  123. isShowOpponent: true,
  124. selectCardCoroutine: SelectCardCoroutine,
  125. afterSelectCardCoroutine: null,
  126. mode: SelectHandEffect.Mode.Custom,
  127. cardEffect: activateClass);
  128. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  129. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  130. yield return StartCoroutine(selectHandEffect.Activate());
  131. }
  132. else
  133. {
  134. int maxCount1 = 1;
  135. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  136. selectCardEffect.SetUp(
  137. canTargetCondition: CanSelectCardCondition1,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. canNoSelect: () => true,
  141. selectCardCoroutine: SelectCardCoroutine,
  142. afterSelectCardCoroutine: null,
  143. message: "Select 1 card to play.",
  144. maxCount: maxCount1,
  145. canEndNotMax: false,
  146. isShowOpponent: true,
  147. mode: SelectCardEffect.Mode.Custom,
  148. root: SelectCardEffect.Root.Custom,
  149. customRootCardList: card.Owner.TrashCards,
  150. canLookReverseCard: true,
  151. selectPlayer: card.Owner,
  152. cardEffect: activateClass);
  153. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  154. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  155. yield return StartCoroutine(selectCardEffect.Activate());
  156. }
  157. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  158. if (!fromHand)
  159. {
  160. root = SelectCardEffect.Root.Trash;
  161. }
  162. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  163. cardSources: selectedCards,
  164. activateClass: activateClass,
  165. payCost: false,
  166. isTapped: false,
  167. root: root,
  168. activateETB: true));
  169. }
  170. }
  171. }
  172. #endregion
  173. #region When Digivolving
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect("Play a level 4 or lower Digimon from your hand or trash.", CanUseCondition, card);
  178. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  179. activateClass.SetHashString("PlayDigimon_BT16_079");
  180. cardEffects.Add(activateClass);
  181. string EffectDiscription()
  182. {
  183. return "[When Digivolving] [Once Per Turn] You may play 1 level 4 or lower yellow or green Digimon from your hand or trash without paying the cost.";
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleArea(card))
  192. {
  193. return true;
  194. }
  195. return false;
  196. }
  197. bool CanSelectCardCondition(CardSource cardSource)
  198. {
  199. if (CardEffectCommons.IsExistOnHand(cardSource))
  200. {
  201. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon)
  202. {
  203. return true;
  204. }
  205. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  206. {
  207. return true;
  208. }
  209. }
  210. return false;
  211. }
  212. bool CanSelectCardCondition1(CardSource cardSource)
  213. {
  214. if (CardEffectCommons.IsExistOnTrash(cardSource))
  215. {
  216. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon)
  217. {
  218. return true;
  219. }
  220. if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon)
  221. {
  222. return true;
  223. }
  224. }
  225. return false;
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  230. bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition1) >= 1;
  231. if (canSelectHand || canSelectTrash)
  232. {
  233. if (canSelectHand && canSelectTrash)
  234. {
  235. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  236. {
  237. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  238. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  239. };
  240. string selectPlayerMessage = "From which area do you play a card?";
  241. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  242. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  243. }
  244. else
  245. {
  246. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  247. }
  248. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  249. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  250. List<CardSource> selectedCards = new List<CardSource>();
  251. IEnumerator SelectCardCoroutine(CardSource cardSource)
  252. {
  253. selectedCards.Add(cardSource);
  254. yield return null;
  255. }
  256. if (fromHand)
  257. {
  258. int maxCount1 = 1;
  259. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  260. selectHandEffect.SetUp(
  261. selectPlayer: card.Owner,
  262. canTargetCondition: CanSelectCardCondition,
  263. canTargetCondition_ByPreSelecetedList: null,
  264. canEndSelectCondition: null,
  265. maxCount: maxCount1,
  266. canNoSelect: true,
  267. canEndNotMax: false,
  268. isShowOpponent: true,
  269. selectCardCoroutine: SelectCardCoroutine,
  270. afterSelectCardCoroutine: null,
  271. mode: SelectHandEffect.Mode.Custom,
  272. cardEffect: activateClass);
  273. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  274. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  275. yield return StartCoroutine(selectHandEffect.Activate());
  276. }
  277. else
  278. {
  279. int maxCount1 = 1;
  280. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  281. selectCardEffect.SetUp(
  282. canTargetCondition: CanSelectCardCondition1,
  283. canTargetCondition_ByPreSelecetedList: null,
  284. canEndSelectCondition: null,
  285. canNoSelect: () => true,
  286. selectCardCoroutine: SelectCardCoroutine,
  287. afterSelectCardCoroutine: null,
  288. message: "Select 1 card to play.",
  289. maxCount: maxCount1,
  290. canEndNotMax: false,
  291. isShowOpponent: true,
  292. mode: SelectCardEffect.Mode.Custom,
  293. root: SelectCardEffect.Root.Custom,
  294. customRootCardList: card.Owner.TrashCards,
  295. canLookReverseCard: true,
  296. selectPlayer: card.Owner,
  297. cardEffect: activateClass);
  298. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  299. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  300. yield return StartCoroutine(selectCardEffect.Activate());
  301. }
  302. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  303. if (!fromHand)
  304. {
  305. root = SelectCardEffect.Root.Trash;
  306. }
  307. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  308. cardSources: selectedCards,
  309. activateClass: activateClass,
  310. payCost: false,
  311. isTapped: false,
  312. root: root,
  313. activateETB: true));
  314. }
  315. }
  316. }
  317. #endregion
  318. #region End of Your Turn
  319. if (timing == EffectTiming.OnEndTurn)
  320. {
  321. ActivateClass activateClass = new ActivateClass();
  322. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  323. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  324. activateClass.SetHashString("DeleteDigimon_BT16_079");
  325. cardEffects.Add(activateClass);
  326. string EffectDiscription()
  327. {
  328. return "[End of Your Turn] [Once Per Turn] If [Cherubimon] or [X-Antibody] is in this Digimon's digivolution cards, delete 1 of your opponent's level 4 or lower Digimon. For each of your other Digimon, add 1 to the maximum level this effect can choose.";
  329. }
  330. bool CanSelectPermanentCondition(Permanent permanent)
  331. {
  332. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  333. {
  334. int maxCost = 4;
  335. maxCost += 1 * card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  336. if (permanent.TopCard.Level <= maxCost)
  337. {
  338. if (permanent.TopCard.HasLevel)
  339. {
  340. return true;
  341. }
  342. }
  343. }
  344. return false;
  345. }
  346. bool CanUseCondition(Hashtable hashtable)
  347. {
  348. if (CardEffectCommons.IsExistOnBattleArea(card))
  349. {
  350. if (CardEffectCommons.IsOwnerTurn(card))
  351. {
  352. return true;
  353. }
  354. }
  355. return false;
  356. }
  357. bool CanActivateCondition(Hashtable hashtable)
  358. {
  359. if (CardEffectCommons.IsExistOnBattleArea(card))
  360. {
  361. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Cherubimon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  362. {
  363. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  364. {
  365. return true;
  366. }
  367. }
  368. }
  369. return false;
  370. }
  371. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  372. {
  373. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  374. {
  375. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  376. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  377. selectPermanentEffect.SetUp(
  378. selectPlayer: card.Owner,
  379. canTargetCondition: CanSelectPermanentCondition,
  380. canTargetCondition_ByPreSelecetedList: null,
  381. canEndSelectCondition: null,
  382. maxCount: maxCount,
  383. canNoSelect: false,
  384. canEndNotMax: false,
  385. selectPermanentCoroutine: null,
  386. afterSelectPermanentCoroutine: null,
  387. mode: SelectPermanentEffect.Mode.Destroy,
  388. cardEffect: activateClass);
  389. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  390. }
  391. }
  392. }
  393. #endregion
  394. return cardEffects;
  395. }
  396. }
  397. }