EX7_051.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_051 : 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. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Three Musketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2 || targetPermanent.TopCard.HasText("ThreeMusketeers") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Start of Your Main Phase
  23. if (timing == EffectTiming.OnStartMainPhase)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Place an Option under 1 Digimon's digivolution cards to Draw 1", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[Start of Your Main Phase] By placing 1 Option card with the [Three Musketeers] trait from your hand or trash as 1 of your Digimon's bottom digivolution card, <Draw 1>";
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. if (cardSource.IsOption && cardSource.ContainsTraits("Three Musketeers") || cardSource.IsOption && cardSource.ContainsTraits("ThreeMusketeers"))
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  44. {
  45. if (CardEffectCommons.IsOwnerTurn(card))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanSelectPermanentCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  55. {
  56. if (!permanent.IsToken)
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  66. {
  67. if (card.Owner.HandCards.Count >= 1 || card.Owner.TrashCards.Count >= 1)
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  80. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  81. if (canSelectHand || canSelectTrash)
  82. {
  83. if (canSelectHand && canSelectTrash)
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  86. {
  87. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  88. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "From which area do you select a card?";
  91. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. }
  94. else
  95. {
  96. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  100. List<CardSource> selectedCards = new List<CardSource>();
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. if (fromHand)
  107. {
  108. int maxCount = 1;
  109. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  110. selectHandEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: maxCount,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. mode: SelectHandEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  124. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  125. yield return StartCoroutine(selectHandEffect.Activate());
  126. }
  127. else
  128. {
  129. int maxCount = 1;
  130. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  131. selectCardEffect.SetUp(
  132. canTargetCondition: CanSelectCardCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. canNoSelect: () => true,
  136. selectCardCoroutine: SelectCardCoroutine,
  137. afterSelectCardCoroutine: null,
  138. message: "Select 1 card to place on bottom of digivolution cards.",
  139. maxCount: maxCount,
  140. canEndNotMax: false,
  141. isShowOpponent: true,
  142. mode: SelectCardEffect.Mode.Custom,
  143. root: SelectCardEffect.Root.Trash,
  144. customRootCardList: null,
  145. canLookReverseCard: true,
  146. selectPlayer: card.Owner,
  147. cardEffect: activateClass);
  148. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  149. 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.");
  150. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  151. }
  152. if (selectedCards.Count >= 1)
  153. {
  154. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  155. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  156. selectPermanentEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectPermanentCondition,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: true,
  163. canEndNotMax: false,
  164. selectPermanentCoroutine: SelectPermanentCoroutine,
  165. afterSelectPermanentCoroutine: null,
  166. mode: SelectPermanentEffect.Mode.Custom,
  167. cardEffect: activateClass);
  168. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  169. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  170. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  171. {
  172. Permanent selectedPermanent = permanent;
  173. if (selectedPermanent != null)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCards[0] }, activateClass));
  176. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. #endregion
  184. #region Inherit
  185. if (timing == EffectTiming.OnDestroyedAnyone)
  186. {
  187. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  188. }
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }