EX10_042.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //GulusGammamon
  4. namespace DCGO.CardEffects.EX10
  5. {
  6. public class EX10_042 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Gammamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Trash 2 cards from deck, then place 1 digimon as bottom source", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Trash the top 2 cards of your deck. Then, you may place 1 Digimon card with [Gammamon] in its name from your trash as this Digimon's bottom digivolution card.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  35. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  40. }
  41. bool CanSelectCardCondition(CardSource cardSource)
  42. {
  43. return cardSource.IsDigimon &&
  44. cardSource.ContainsCardName("Gammamon");
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  47. {
  48. if (card.Owner.LibraryCards.Count >= 1)
  49. {
  50. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(2, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  51. }
  52. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. int maxCount = 1;
  56. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  57. selectCardEffect.SetUp(
  58. canTargetCondition: CanSelectCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. canNoSelect: () => true,
  62. selectCardCoroutine: SelectCardCoroutine,
  63. afterSelectCardCoroutine: null,
  64. message: "Select 1 card to place on bottom of digivolution cards.",
  65. maxCount: maxCount,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. mode: SelectCardEffect.Mode.Custom,
  69. root: SelectCardEffect.Root.Trash,
  70. customRootCardList: null,
  71. canLookReverseCard: true,
  72. selectPlayer: card.Owner,
  73. cardEffect: activateClass);
  74. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  75. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  76. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. if (selectedCards.Count >= 1)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  85. }
  86. }
  87. }
  88. }
  89. #endregion
  90. #region When Digivolving
  91. if (timing == EffectTiming.OnEnterFieldAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Trash 2 cards from deck, then place 1 Digimon as bottom source", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[When Digivolving] Trash the top 2 cards of your deck. Then, you may place 1 Digimon card with [Gammamon] in its name from your trash as this Digimon's bottom digivolution card.";
  100. }
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  104. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  105. }
  106. bool CanActivateCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  109. }
  110. bool CanSelectCardCondition(CardSource cardSource)
  111. {
  112. return cardSource.IsDigimon &&
  113. cardSource.ContainsCardName("Gammamon");
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  116. {
  117. if (card.Owner.LibraryCards.Count >= 1)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(2, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  120. }
  121. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  122. {
  123. List<CardSource> selectedCards = new List<CardSource>();
  124. int maxCount = 1;
  125. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  126. selectCardEffect.SetUp(
  127. canTargetCondition: CanSelectCardCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. canNoSelect: () => true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. message: "Select 1 card to place on bottom of digivolution cards.",
  134. maxCount: maxCount,
  135. canEndNotMax: false,
  136. isShowOpponent: true,
  137. mode: SelectCardEffect.Mode.Custom,
  138. root: SelectCardEffect.Root.Trash,
  139. customRootCardList: null,
  140. canLookReverseCard: true,
  141. selectPlayer: card.Owner,
  142. cardEffect: activateClass);
  143. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  144. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  145. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  146. IEnumerator SelectCardCoroutine(CardSource cardSource)
  147. {
  148. selectedCards.Add(cardSource);
  149. yield return null;
  150. }
  151. if (selectedCards.Count >= 1)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  154. }
  155. }
  156. }
  157. }
  158. #endregion
  159. #region Your Turn - OPT
  160. if (timing == EffectTiming.OnAddDigivolutionCards)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("Digivolve into a [Regulusmon] from hand or trash.", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  165. activateClass.SetHashString("YT_EX10_042");
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[Your Turn] [Once Per Turn] When effects add to this Digimon's digivolution cards, this Digimon may digivolve into [Regulusmon] in the hand or trash with the digivolution cost reduced by 1.";
  170. }
  171. bool CanSelectCardCondition(CardSource cardSource)
  172. {
  173. if (cardSource.IsDigimon)
  174. {
  175. if (cardSource.EqualsCardName("Regulusmon"))
  176. {
  177. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, true, activateClass))
  178. {
  179. return true;
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  188. CardEffectCommons.IsOwnerTurn(card) &&
  189. CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  190. hashtable: hashtable,
  191. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  192. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  193. cardCondition: cardSource => cardSource != null);
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  198. (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition) ||
  199. CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition));
  200. }
  201. IEnumerator ActivateCoroutine(Hashtable hashtable)
  202. {
  203. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  204. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  205. if (canSelectHand || canSelectTrash)
  206. {
  207. if (canSelectHand && canSelectTrash)
  208. {
  209. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  210. {
  211. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  212. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  213. };
  214. string selectPlayerMessage = "From which area do you want to digivolve from?";
  215. string notSelectPlayerMessage = "The opponent is choosing where to digivolve from.";
  216. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  217. }
  218. else
  219. {
  220. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  221. }
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  223. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  224. if (fromHand)
  225. {
  226. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  227. targetPermanent: card.PermanentOfThisCard(),
  228. cardCondition: CanSelectCardCondition,
  229. payCost: true,
  230. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  231. fixedCostTuple: null,
  232. ignoreDigivolutionRequirementFixedCost: -1,
  233. isHand: true,
  234. activateClass: activateClass,
  235. successProcess: null));
  236. }
  237. else
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  240. targetPermanent: card.PermanentOfThisCard(),
  241. cardCondition: CanSelectCardCondition,
  242. payCost: true,
  243. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  244. fixedCostTuple: null,
  245. ignoreDigivolutionRequirementFixedCost: -1,
  246. isHand: false,
  247. activateClass: activateClass,
  248. successProcess: null));
  249. }
  250. }
  251. }
  252. }
  253. #endregion
  254. #region Raid - ESS
  255. if (timing == EffectTiming.OnAllyAttack)
  256. {
  257. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: true, card: card, condition: null));
  258. }
  259. #endregion
  260. return cardEffects;
  261. }
  262. }
  263. }