EX10_039.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //ChuuChuumon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_039 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place 1 [Bagra Army] digimon under digimon/tamer", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. => "[Start of Your Main Phase] You may place 1 Digimon card with the [Bagra Army] trait from your hand or trash as any of your [Bagra Army] trait Digimon's bottom digivolution cards or under any of your [Bagra Army] trait Tamers.";
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  24. CardEffectCommons.IsOwnerTurn(card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  29. }
  30. bool CanSelectTamerCondition(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  33. && (permanent.IsTamer || permanent.IsDigimon) &&
  34. permanent.TopCard.HasBagraArmyTraits;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource.IsDigimon)
  39. {
  40. if (cardSource.HasBagraArmyTraits)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTamerCondition))
  50. {
  51. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  52. {
  53. SelectCardEffect.Root? rootmode = SelectCardEffect.Root.Hand;
  54. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  55. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  56. if (!canSelectHand && canSelectTrash) rootmode = SelectCardEffect.Root.Trash;
  57. if (canSelectHand && canSelectTrash)
  58. {
  59. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  60. {
  61. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  62. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  63. };
  64. string selectPlayerMessage = "From which area do you select a card?";
  65. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  66. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  67. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  68. rootmode = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  69. }
  70. CardSource selectedCard = null;
  71. if (rootmode == SelectCardEffect.Root.Hand)
  72. {
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectCardCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. mode: SelectHandEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  88. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  89. }
  90. else
  91. {
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectCardCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => true,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select 1 card to add as source.",
  101. maxCount: 1,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: (SelectCardEffect.Root)rootmode!,
  106. customRootCardList: null,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  111. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  112. }
  113. IEnumerator SelectCardCoroutine(CardSource cardSource)
  114. {
  115. selectedCard = cardSource;
  116. yield return null;
  117. }
  118. if (selectedCard != null)
  119. {
  120. Permanent selectedPermanent = null;
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectTamerCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: false,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: SelectPermanentCoroutine,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  137. {
  138. selectedPermanent = permanent;
  139. yield return null;
  140. }
  141. if (selectedPermanent != null)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. #endregion
  151. #region Save
  152. if (timing == EffectTiming.OnDestroyedAnyone)
  153. {
  154. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  155. }
  156. #endregion
  157. #region ESS
  158. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect("<Draw 1>", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  163. activateClass.SetIsInheritedEffect(true);
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "When effects trash this card from a [Bagra Army] trait Digimon's digivolution cards, <Draw 1>";
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  172. return trashedPermanent.TopCard.EqualsTraits("Bagra Army") &&
  173. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnTrash(card);
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable hashtable)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  182. }
  183. }
  184. #endregion
  185. return cardEffects;
  186. }
  187. }
  188. }