EX9_072.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // File Island
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_072 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Ignore Color Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  17. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  18. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  19. cardEffects.Add(ignoreColorConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped) == 0;
  23. }
  24. bool CardCondition(CardSource cardSource)
  25. {
  26. return cardSource == card;
  27. }
  28. }
  29. #endregion
  30. #region All Turns - Security
  31. if (timing == EffectTiming.None)
  32. {
  33. bool Condition()
  34. {
  35. return CardEffectCommons.IsExistInSecurity(card, false);
  36. }
  37. bool PermanentCondition(Permanent permanent)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  40. {
  41. if (permanent.TopCard.EqualsTraits("DM"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  49. {
  50. if (Condition() && PermanentCondition(permanent))
  51. {
  52. int dpValue = permanent.DigivolutionCards.Filter(x => x.IsFlipped).Count * 1000;
  53. permanent.AddBoost(new Permanent.DPBoost("EX9_072", dpValue, Condition));
  54. }
  55. else
  56. permanent.RemoveBoost("EX9_072");
  57. }
  58. }
  59. #endregion
  60. #region Main Effect
  61. if (timing == EffectTiming.OptionSkill)
  62. {
  63. cardEffects.Add(CardEffectFactory.ReplaceBottomSecurityWithFaceUpOptionMainEffect(card));
  64. }
  65. #endregion
  66. #region Security Effect
  67. if (timing == EffectTiming.SecuritySkill)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Play 1 5 cost or lower card", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  72. activateClass.SetIsSecurityEffect(true);
  73. cardEffects.Add(activateClass);
  74. string EffectDiscription()
  75. {
  76. return "[Security] You may play 1 play cost 5 or lower card with the [DM] trait from your hand or trash without paying the cost.";
  77. }
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  81. }
  82. bool CanSelectCardCondition(CardSource cardSource)
  83. {
  84. return cardSource.HasPlayCost && cardSource.GetCostItself <= 5 &&
  85. cardSource.EqualsTraits("DM") &&
  86. !cardSource.IsDigiEgg &&
  87. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable hashtable)
  90. {
  91. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  92. {
  93. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  94. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  95. };
  96. string selectPlayerMessage = "From which area do you select a card?";
  97. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  98. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  100. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  101. List<CardSource> selectedCards = new List<CardSource>();
  102. IEnumerator SelectCardCoroutine(CardSource cardSource)
  103. {
  104. selectedCards.Add(cardSource);
  105. yield return null;
  106. }
  107. if (fromHand && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  108. {
  109. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  110. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  111. selectHandEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: CanSelectCardCondition,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: maxCount,
  117. canNoSelect: true,
  118. canEndNotMax: true,
  119. isShowOpponent: true,
  120. selectCardCoroutine: SelectCardCoroutine,
  121. afterSelectCardCoroutine: null,
  122. mode: SelectHandEffect.Mode.Custom,
  123. cardEffect: activateClass);
  124. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  125. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  126. yield return StartCoroutine(selectHandEffect.Activate());
  127. }
  128. if (!fromHand && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  129. {
  130. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  131. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  132. selectCardEffect.SetUp(
  133. canTargetCondition: CanSelectCardCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. canNoSelect: () => true,
  137. selectCardCoroutine: SelectCardCoroutine,
  138. afterSelectCardCoroutine: null,
  139. message: "Select 1 digimon to play.",
  140. maxCount: maxCount,
  141. canEndNotMax: true,
  142. isShowOpponent: true,
  143. mode: SelectCardEffect.Mode.Custom,
  144. root: SelectCardEffect.Root.Trash,
  145. customRootCardList: null,
  146. canLookReverseCard: true,
  147. selectPlayer: card.Owner,
  148. cardEffect: activateClass);
  149. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon to play.");
  150. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  151. yield return StartCoroutine(selectCardEffect.Activate());
  152. }
  153. if (selectedCards.Any())
  154. {
  155. SelectCardEffect.Root root = fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  156. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  157. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  158. root: root, activateETB: true));
  159. }
  160. }
  161. }
  162. #endregion
  163. return cardEffects;
  164. }
  165. }
  166. }