BT16_093.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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_093 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.GetBattleAreaDigimons().Count((permanet) => permanet.TopCard.CardColors.Contains(CardColor.Green)) >= 1)
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. #endregion
  37. #region Main
  38. if (timing == EffectTiming.OptionSkill)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  42. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[Main] You may digivolve 1 of your Digimon with [Gargomon] or [Rapidmon] in its name into a Digimon card with [Rapidmon] in its name in your hand, ignoring its digivolution requirements and without paying its memory cost. The Digimon that digivolved with this effect can't have its DP reduced by your opponent's effects until the end of your opponent's turn.";
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  51. {
  52. if (permanent.TopCard.ContainsCardName("Rapidmon") || permanent.TopCard.ContainsCardName("Gargomon"))
  53. {
  54. foreach (CardSource cardSource in card.Owner.HandCards)
  55. {
  56. if (CanSelectCardCondition(cardSource))
  57. {
  58. if (!cardSource.CanNotEvolve(permanent))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. bool CanSelectCardCondition(CardSource cardSource)
  69. {
  70. return cardSource.ContainsCardName("Rapidmon") && cardSource.IsDigimon;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. Permanent selectedPermanent = null;
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermanent = permanent;
  100. yield return null;
  101. }
  102. if (selectedPermanent != null)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  105. targetPermanent: selectedPermanent,
  106. cardCondition: CanSelectCardCondition,
  107. payCost: false,
  108. reduceCostTuple: null,
  109. fixedCostTuple: null,
  110. ignoreDigivolutionRequirementFixedCost: 0,
  111. isHand: true,
  112. activateClass: activateClass,
  113. successProcess: SuccessProcess()));
  114. IEnumerator SuccessProcess()
  115. {
  116. bool CardEffectCondition(ICardEffect cardEffect)
  117. {
  118. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  119. }
  120. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
  121. targetPermanent: selectedPermanent,
  122. cardEffectCondition: CardEffectCondition,
  123. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  124. activateClass: activateClass,
  125. effectName: "Can't have DP reduced by opponent's effects"));
  126. }
  127. }
  128. }
  129. }
  130. }
  131. #endregion
  132. #region Security Skill
  133. if (timing == EffectTiming.SecuritySkill)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect($"Play 1 level 3 Digimon card with [Terriermon] in it's name from your hand or trash", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  138. activateClass.SetIsSecurityEffect(true);
  139. cardEffects.Add(activateClass);
  140. string EffectDiscription()
  141. {
  142. return "[Security] You may play 1 level 3 Digimon card with [Terriermon] in it's name from you hand or trash without paying the cost. Then, add this card to your hand.";
  143. }
  144. bool CanSelectCardCondition(CardSource cardSource)
  145. {
  146. if (cardSource != null)
  147. {
  148. if (cardSource.Owner == card.Owner)
  149. {
  150. if (cardSource.ContainsCardName("Terriermon"))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  163. {
  164. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  165. bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1;
  166. if (canSelectHand || canSelectTrash)
  167. {
  168. if (canSelectHand && canSelectTrash)
  169. {
  170. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  171. {
  172. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  173. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  174. };
  175. string selectPlayerMessage = "From which area do you play a card?";
  176. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  177. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  178. }
  179. else
  180. {
  181. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  182. }
  183. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  184. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. IEnumerator SelectCardCoroutine(CardSource cardSource)
  187. {
  188. selectedCards.Add(cardSource);
  189. yield return null;
  190. }
  191. if (fromHand)
  192. {
  193. int maxCount1 = 1;
  194. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  195. selectHandEffect.SetUp(
  196. selectPlayer: card.Owner,
  197. canTargetCondition: CanSelectCardCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: maxCount1,
  201. canNoSelect: true,
  202. canEndNotMax: false,
  203. isShowOpponent: true,
  204. selectCardCoroutine: SelectCardCoroutine,
  205. afterSelectCardCoroutine: null,
  206. mode: SelectHandEffect.Mode.Custom,
  207. cardEffect: activateClass);
  208. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  209. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  210. yield return StartCoroutine(selectHandEffect.Activate());
  211. }
  212. else
  213. {
  214. int maxCount1 = 1;
  215. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  216. selectCardEffect.SetUp(
  217. canTargetCondition: CanSelectCardCondition,
  218. canTargetCondition_ByPreSelecetedList: null,
  219. canEndSelectCondition: null,
  220. canNoSelect: () => true,
  221. selectCardCoroutine: SelectCardCoroutine,
  222. afterSelectCardCoroutine: null,
  223. message: "Select 1 card to play.",
  224. maxCount: maxCount1,
  225. canEndNotMax: false,
  226. isShowOpponent: true,
  227. mode: SelectCardEffect.Mode.Custom,
  228. root: SelectCardEffect.Root.Custom,
  229. customRootCardList: card.Owner.TrashCards,
  230. canLookReverseCard: true,
  231. selectPlayer: card.Owner,
  232. cardEffect: activateClass);
  233. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  234. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  235. yield return StartCoroutine(selectCardEffect.Activate());
  236. }
  237. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  238. if (!fromHand)
  239. {
  240. root = SelectCardEffect.Root.Trash;
  241. }
  242. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  243. cardSources: selectedCards,
  244. activateClass: activateClass,
  245. payCost: false,
  246. isTapped: false,
  247. root: root,
  248. activateETB: true));
  249. }
  250. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  251. }
  252. }
  253. #endregion
  254. return cardEffects;
  255. }
  256. }
  257. }