BT24_098.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Invasion of the Titans
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_098 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Main
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Draw 2, Trash 2", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return "[Main] <Draw 2> and trash 2 cards in your hand. Then, place this card in the battle area.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  27. }
  28. IEnumerator ActivateCoroutine(Hashtable hashtable)
  29. {
  30. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  31. if (card.Owner.HandCards.Count >= 1)
  32. {
  33. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  34. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  35. selectHandEffect.SetUp(
  36. selectPlayer: card.Owner,
  37. canTargetCondition: source => source != null,
  38. canTargetCondition_ByPreSelecetedList: null,
  39. canEndSelectCondition: null,
  40. maxCount: discardCount,
  41. canNoSelect: false,
  42. canEndNotMax: false,
  43. isShowOpponent: true,
  44. selectCardCoroutine: null,
  45. afterSelectCardCoroutine: null,
  46. mode: SelectHandEffect.Mode.Discard,
  47. cardEffect: activateClass);
  48. selectHandEffect.SetUpCustomMessage("Select 2 cards to trash.", "Opponent is selecting 2 cards to trash.");
  49. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  50. }
  51. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  52. }
  53. }
  54. #endregion
  55. #region Your Turns - Delay
  56. if(timing == EffectTiming.OnEnterFieldAnyone)
  57. {
  58. ActivateClass activateClass = new ActivateClass();
  59. activateClass.SetUpICardEffect("If Opp has 5+ memory, Play a 5- [Titan] from trash", CanUseCondition, card);
  60. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  61. cardEffects.Add(activateClass);
  62. string EffectDescription() => "[Your Turn] When any of your [Titan] trait Digimon are played, <Delay>\r\n• If your opponent has 5 or more memory, you may play 1 level 5 or lower Digimon card with the [Titan] trait from your trash without paying the cost.";
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.IsExistOnBattleArea(card)
  66. && CardEffectCommons.IsOwnerTurn(card)
  67. && CardEffectCommons.CanDeclareOptionDelayEffect(card)
  68. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermamentCondition);
  69. }
  70. bool PermamentCondition(Permanent permanent)
  71. {
  72. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  73. && permanent.TopCard.EqualsTraits("Titan");
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleArea(card);
  78. }
  79. bool CanPlayCondition(CardSource cardSource)
  80. {
  81. return cardSource.IsDigimon
  82. && cardSource.HasLevel
  83. && cardSource.Level <= 5
  84. && cardSource.EqualsTraits("Titan")
  85. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable hashtable)
  88. {
  89. bool delaySuccessful = false;
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  91. IEnumerator SuccessProcess()
  92. {
  93. delaySuccessful = true;
  94. yield return null;
  95. }
  96. if (delaySuccessful && card.Owner.MemoryForPlayer <= -5)
  97. {
  98. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanPlayCondition));
  99. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  100. selectCardEffect.SetUp(
  101. canTargetCondition: CanPlayCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. canNoSelect: () => true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. message: "Select digimon to play.",
  108. maxCount: maxCount,
  109. canEndNotMax: true,
  110. isShowOpponent: true,
  111. mode: SelectCardEffect.Mode.Custom,
  112. root: SelectCardEffect.Root.Trash,
  113. customRootCardList: null,
  114. canLookReverseCard: true,
  115. selectPlayer: card.Owner,
  116. cardEffect: activateClass);
  117. selectCardEffect.SetUpCustomMessage("Select digimon to play.", "The opponent is selecting a digimon to play.");
  118. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  119. yield return StartCoroutine(selectCardEffect.Activate());
  120. IEnumerator SelectCardCoroutine(CardSource cardSource)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  123. cardSources: new List<CardSource>() { cardSource },
  124. activateClass: activateClass,
  125. payCost: false,
  126. isTapped: false,
  127. root: SelectCardEffect.Root.Trash,
  128. activateETB: true));
  129. }
  130. }
  131. }
  132. }
  133. #endregion
  134. #region Security
  135. if (timing == EffectTiming.SecuritySkill)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Play a 4- [Titan] and add this to hand", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  140. activateClass.SetIsSecurityEffect(true);
  141. cardEffects.Add(activateClass);
  142. string EffectDescription()
  143. {
  144. return "[Security] You may play 1 level 4 or lower [Titan] trait Digimon card from your hand or trash without paying the cost. Then, add this card to the hand.";
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  149. }
  150. bool CanPlayCondition(CardSource cardSource)
  151. {
  152. return cardSource.IsDigimon
  153. && cardSource.HasLevel
  154. && cardSource.Level <= 4
  155. && cardSource.EqualsTraits("Titan")
  156. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable hashtable)
  159. {
  160. #region Play a Digimon
  161. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCondition);
  162. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayCondition);
  163. if (canSelectHand || canSelectTrash)
  164. {
  165. if (canSelectHand && canSelectTrash)
  166. {
  167. List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
  168. {
  169. new(message: $"From hand", value: 1, spriteIndex: 0),
  170. new(message: $"From trash", value: 2, spriteIndex: 1),
  171. new(message: $"Don't play", value: 3, spriteIndex: 2),
  172. };
  173. string selectPlayerMessage1 = "From which area will you play a card?";
  174. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  175. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  176. }
  177. else
  178. {
  179. GManager.instance.userSelectionManager.SetInt(canSelectHand ? 1 : 2);
  180. }
  181. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  182. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  183. bool fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 2;
  184. List<CardSource> selectedCards = new List<CardSource>();
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. if (fromHand)
  191. {
  192. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  193. selectHandEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanPlayCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. mode: SelectHandEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  207. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  208. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  209. selectedCards,
  210. activateClass: activateClass,
  211. payCost: false,
  212. isTapped: false,
  213. root: SelectCardEffect.Root.Hand,
  214. activateETB: true));
  215. }
  216. if (fromTrash)
  217. {
  218. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  219. selectCardEffect.SetUp(
  220. canTargetCondition: CanPlayCondition,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. canNoSelect: () => true,
  224. selectCardCoroutine: SelectCardCoroutine,
  225. afterSelectCardCoroutine: null,
  226. message: "Select 1 digimon to play",
  227. maxCount: 1,
  228. canEndNotMax: false,
  229. isShowOpponent: true,
  230. mode: SelectCardEffect.Mode.Custom,
  231. root: SelectCardEffect.Root.Trash,
  232. customRootCardList: null,
  233. canLookReverseCard: true,
  234. selectPlayer: card.Owner,
  235. cardEffect: activateClass);
  236. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play", "The opponent is selecting 1 digimon to play");
  237. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Digimon");
  238. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  239. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  240. selectedCards,
  241. activateClass: activateClass,
  242. payCost: false,
  243. isTapped: false,
  244. root: SelectCardEffect.Root.Trash,
  245. activateETB: true));
  246. }
  247. }
  248. #endregion
  249. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  250. }
  251. }
  252. #endregion
  253. return cardEffects;
  254. }
  255. }
  256. }