EX9_049.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Sukamon
  4. namespace DCGO.CardEffects.EX9
  5. {
  6. public class EX9_049 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolution Cost Reduction
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("DM") && targetPermanent.TopCard.IsLevel3;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  19. digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region End of Your Turn
  23. if (timing == EffectTiming.OnEndTurn)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("By placing 3 Ver3 digimon flipped in source, digivolve into a ver3", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  28. activateClass.SetHashString("Digivolve~EX9_049");
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[End of Your Turn] [Once Per Turn] By placing 3 Digimon cards with the [Ver.3] trait from your trash face down as this Digimon's bottom digivolution cards, it may digivolve into a Digimon card with the [Ver.3] trait in the hand or trash.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (cardSource.EqualsTraits("Ver.3"))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanSelectCardCondition1(CardSource cardSource)
  46. {
  47. if (cardSource.EqualsTraits("Ver.3"))
  48. {
  49. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanSelectPermanentHandCondition(Permanent permanent)
  57. {
  58. foreach (CardSource cardSource in card.Owner.HandCards)
  59. {
  60. if (cardSource.EqualsTraits("Ver.3"))
  61. {
  62. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. bool CanSelectPermanentTrashCondition(Permanent permanent)
  71. {
  72. foreach (CardSource cardSource in card.Owner.TrashCards)
  73. {
  74. if (cardSource.EqualsTraits("Ver.3"))
  75. {
  76. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. bool ValidDigivolveIntoHand(CardSource source)
  85. {
  86. return source.EqualsTraits("Ver.3");
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.IsExistOnBattleArea(card))
  91. {
  92. if (CardEffectCommons.IsOwnerTurn(card))
  93. {
  94. return true;
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  104. {
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. IEnumerator ActivateCoroutine(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  113. {
  114. List<CardSource> selectedCards = new List<CardSource>();
  115. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  116. selectCardEffect.SetUp(
  117. canTargetCondition: CanSelectCardCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. canNoSelect: () => true,
  121. selectCardCoroutine: SelectCardCoroutine,
  122. afterSelectCardCoroutine: null,
  123. message: "Select 3 Ver.3 digimon to add as bottom digivolution card",
  124. maxCount: 3,
  125. canEndNotMax: true,
  126. isShowOpponent: false,
  127. mode: SelectCardEffect.Mode.Custom,
  128. root: SelectCardEffect.Root.Trash,
  129. customRootCardList: card.Owner.TrashCards,
  130. canLookReverseCard: true,
  131. selectPlayer: card.Owner,
  132. cardEffect: activateClass
  133. );
  134. selectCardEffect.SetUpCustomMessage("Select 3 cards to add as bottom digivolution card.", "The opponent is selecting 3 cards to add as bottom digivolution card.");
  135. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  136. IEnumerator SelectCardCoroutine(CardSource cardSource)
  137. {
  138. selectedCards.Add(cardSource);
  139. yield return null;
  140. }
  141. if (selectedCards.Count == 3)
  142. {
  143. foreach (var selectedCard in selectedCards)
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  146. selectedCard.SetReverse();
  147. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  148. }
  149. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition1);
  150. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1);
  151. if (canSelectHand || canSelectTrash)
  152. {
  153. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  154. {
  155. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  156. new SelectionElement<bool>(message: $"No ", value : false, spriteIndex: 1),
  157. };
  158. string selectPlayerMessage = "Will you digivolve?";
  159. string notSelectPlayerMessage = "The opponent is choosing to digivolve";
  160. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  161. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  162. bool isDigivolving = GManager.instance.userSelectionManager.SelectedBoolValue;
  163. if (isDigivolving)
  164. {
  165. if (canSelectHand && canSelectTrash)
  166. {
  167. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  168. {
  169. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  170. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  171. };
  172. string selectPlayerMessage1 = "From which area do you select a card?";
  173. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  174. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  175. }
  176. else
  177. {
  178. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  181. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  182. CardSource selectedCard = null;
  183. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  184. {
  185. selectedCard = cardSource;
  186. yield return null;
  187. }
  188. if (fromHand)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  191. targetPermanent: card.PermanentOfThisCard(),
  192. cardCondition: ValidDigivolveIntoHand,
  193. payCost: false,
  194. reduceCostTuple: null,
  195. fixedCostTuple: null,
  196. ignoreDigivolutionRequirementFixedCost: -1,
  197. isHand: fromHand,
  198. activateClass: activateClass,
  199. successProcess: null));
  200. }
  201. else
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  204. targetPermanent: card.PermanentOfThisCard(),
  205. cardCondition: ValidDigivolveIntoHand,
  206. payCost: false,
  207. reduceCostTuple: null,
  208. fixedCostTuple: null,
  209. ignoreDigivolutionRequirementFixedCost: -1,
  210. isHand: fromHand,
  211. activateClass: activateClass,
  212. successProcess: null));
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. #region Blocker - ESS
  222. if (timing == EffectTiming.None)
  223. {
  224. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  225. }
  226. #endregion
  227. return cardEffects;
  228. }
  229. }
  230. }