Regulusmon_LM_017.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class Regulusmon_LM_017 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. //Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. //Blast Digivolve
  22. if (timing == EffectTiming.OnCounterTiming)
  23. {
  24. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  25. }
  26. #region OnPlay/WhenDigivolving
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Trash 1 card from your hand", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  32. cardEffects.Add(activateClass);
  33. string EffectDiscription()
  34. {
  35. return "[On Play] [When Digivolving] Trash 1 card in your hand. Then, you may place 1 card with [Gammamon] in its text from your trash as this Digimon's bottom digivolution card.";
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (CardEffectCommons.IsExistOnTrash(cardSource))
  40. {
  41. return cardSource.HasText("Gammamon");
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerOnPlay(hashtable, card) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(card))
  52. {
  53. if (card.Owner.HandCards.Count >= 1)
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanActivateThenCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.IsExistOnBattleArea(card))
  63. {
  64. if (card.Owner.TrashCards.Count >= 1)
  65. {
  66. if (card.Owner.TrashCards.Any(cardSource => cardSource.HasText("Gammamon")))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. List<CardSource> selectedCards = new List<CardSource>();
  77. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: (cardSource) => true,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: null,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.Discard,
  90. cardEffect: activateClass);
  91. selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash.");
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. yield return StartCoroutine(ActivatePlacingSource());
  94. }
  95. IEnumerator ActivatePlacingSource()
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Place a Card from hand to digivolution cards to get effects", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateThenCondition, ActivateCoroutine, -1, true, EffectDiscription());
  100. cardEffects.Add(activateClass);
  101. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  102. List<CardSource> selectedCards = new List<CardSource>();
  103. selectCardEffect.SetUp(
  104. canTargetCondition: CanSelectCardCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. canNoSelect: () => true,
  108. selectCardCoroutine: SelectCardCoroutine,
  109. afterSelectCardCoroutine: null,
  110. message: "Select 1 card to place at the bottom of digivolution cards.",
  111. maxCount: 1,
  112. canEndNotMax: false,
  113. isShowOpponent: true,
  114. mode: SelectCardEffect.Mode.Custom,
  115. root: SelectCardEffect.Root.Trash,
  116. customRootCardList: null,
  117. canLookReverseCard: true,
  118. selectPlayer: card.Owner,
  119. cardEffect: activateClass);
  120. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  121. yield return StartCoroutine(selectCardEffect.Activate());
  122. IEnumerator SelectCardCoroutine(CardSource cardSource)
  123. {
  124. selectedCards.Add(cardSource);
  125. yield return null;
  126. }
  127. if (selectedCards.Count >= 1)
  128. {
  129. Permanent selectedPermanent = card.PermanentOfThisCard();
  130. if (selectedPermanent != null)
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  133. }
  134. }
  135. }
  136. }
  137. #endregion
  138. #region All Turns
  139. if (timing == EffectTiming.OnAddDigivolutionCards)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("Delete 1 Digimon, Play 1 Digimon", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  144. activateClass.SetHashString("Delete_Play_LM_017");
  145. cardEffects.Add(activateClass);
  146. string EffectDiscription()
  147. {
  148. return "[All Turns] [Once Per Turn] When an effect adds digivolution card to this Digimon, by deleting 1 level 4 or lower Digimon, you may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  149. }
  150. bool CanSelectPermanentCondition(Permanent permanent)
  151. {
  152. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  153. {
  154. return permanent.IsDigimon && permanent.Level <= 4;
  155. }
  156. return false;
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.IsExistOnBattleArea(card))
  161. {
  162. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  163. hashtable: hashtable,
  164. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  165. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  166. cardCondition: null))
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. bool CanActivateCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleArea(card);
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  178. {
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. List<Permanent> selectedCards = new List<Permanent>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectPermanentCondition,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. canNoSelect: true,
  187. selectPermanentCoroutine: SelectPermanentCoroutine,
  188. afterSelectPermanentCoroutine: null,
  189. maxCount: 1,
  190. canEndNotMax: false,
  191. mode: SelectPermanentEffect.Mode.Destroy,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete.", "The opponent is selecting 1 digimon to delete.");
  194. yield return StartCoroutine(selectPermanentEffect.Activate());
  195. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  196. {
  197. selectedCards.Add(permanent);
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: selectedCards, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  199. yield return null;
  200. }
  201. IEnumerator SuccessProcess()
  202. {
  203. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. bool CanSelectCardCondition(CardSource cardSource)
  206. {
  207. if (CardEffectCommons.IsExistOnTrash(cardSource))
  208. {
  209. if (cardSource.Owner == card.Owner)
  210. {
  211. return cardSource.IsDigimon && cardSource.Level <= 4;
  212. }
  213. }
  214. return false;
  215. }
  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 Digimon card to play.",
  224. maxCount: 1,
  225. canEndNotMax: false,
  226. isShowOpponent: true,
  227. mode: SelectCardEffect.Mode.Custom,
  228. root: SelectCardEffect.Root.Trash,
  229. customRootCardList: null,
  230. canLookReverseCard: true,
  231. selectPlayer: card.Owner,
  232. cardEffect: activateClass);
  233. selectCardEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon card to play.");
  234. yield return StartCoroutine(selectCardEffect.Activate());
  235. IEnumerator SelectCardCoroutine(CardSource cardSource)
  236. {
  237. selectedCards.Add(cardSource);
  238. yield return null;
  239. }
  240. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  241. cardSources: selectedCards,
  242. activateClass: activateClass,
  243. payCost: false,
  244. isTapped: false,
  245. root: SelectCardEffect.Root.Trash,
  246. activateETB: true));
  247. }
  248. }
  249. }
  250. #endregion
  251. return cardEffects;
  252. }
  253. }
  254. }