BT20_086.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Altea
  6. namespace DCGO.CardEffects.BT20
  7. {
  8. public class BT20_086 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Turn
  14. if (timing == EffectTiming.OnStartTurn)
  15. {
  16. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  17. }
  18. #endregion
  19. #region Start of Main Phase
  20. if (timing == EffectTiming.OnStartMainPhase)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("By placing a card as bottom digivolution source, flip opponents top security face up", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return "[Start of Your Main Phase] By placing 1 play cost 4 or lower black Digimon card with the [Cyborg] or [Machine] trait from your hand or trash as any of your [Cyborg] or [Machine] trait Digimon's bottom digivolution card, flip your opponent's top face-down security card face up.";
  29. }
  30. bool SelectPermanentCard(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  33. (permanent.TopCard.EqualsTraits("Cyborg") || permanent.TopCard.EqualsTraits("Machine"));
  34. }
  35. bool SelectSourceCard(CardSource source)
  36. {
  37. return source.IsDigimon &&
  38. source.HasPlayCost && source.GetCostItself <= 4 &&
  39. source.HasCardColor(CardColor.Black) &&
  40. (source.EqualsTraits("Cyborg") || source.EqualsTraits("Machine"));
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  45. && CardEffectCommons.IsOwnerTurn(card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass) &&
  50. CardEffectCommons.HasMatchConditionPermanent(SelectPermanentCard) &&
  51. (CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SelectSourceCard));
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. Permanent selectedPermanent = null;
  56. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectPermanentCard));
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: SelectPermanentCard,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: maxCount,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: SelectPermanentCoroutine,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return null;
  75. }
  76. if(selectedPermanent != null)
  77. {
  78. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectSourceCard);
  79. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SelectSourceCard);
  80. if (canSelectHand || canSelectTrash)
  81. {
  82. if (canSelectHand && canSelectTrash)
  83. {
  84. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  85. {
  86. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  87. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  88. };
  89. string selectPlayerMessage = "From which area do you select a card?";
  90. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  91. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  92. }
  93. else
  94. {
  95. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  96. }
  97. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  98. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  99. List<CardSource> selectedCards = new List<CardSource>();
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCards.Add(cardSource);
  103. yield return null;
  104. }
  105. if (fromHand)
  106. {
  107. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  108. selectHandEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: SelectSourceCard,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: 1,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. selectCardCoroutine: SelectCardCoroutine,
  118. afterSelectCardCoroutine: null,
  119. mode: SelectHandEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  122. yield return StartCoroutine(selectHandEffect.Activate());
  123. }
  124. else
  125. {
  126. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  127. selectCardEffect.SetUp(
  128. canTargetCondition: SelectSourceCard,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: () => true,
  132. selectCardCoroutine: SelectCardCoroutine,
  133. afterSelectCardCoroutine: null,
  134. message: "Select 1 card to add as source.",
  135. maxCount: 1,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. mode: SelectCardEffect.Mode.Custom,
  139. root: SelectCardEffect.Root.Trash,
  140. customRootCardList: null,
  141. canLookReverseCard: true,
  142. selectPlayer: card.Owner,
  143. cardEffect: activateClass);
  144. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  145. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  146. }
  147. if(selectedCards.Count > 0)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  150. foreach (CardSource source in card.Owner.Enemy.SecurityCards)
  151. {
  152. if (!source.IsFlipped)
  153. continue;
  154. yield return ContinuousController.instance.StartCoroutine(new IFlipSecurity(source).FlipFaceUp());
  155. break;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. #endregion
  163. #region Security Effect
  164. if (timing == EffectTiming.SecuritySkill)
  165. {
  166. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  167. }
  168. #endregion
  169. return cardEffects;
  170. }
  171. }
  172. }