EX9_052.cs 11 KB

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