EX12_059.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Machinedramon Ace
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_059 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Cyborg")
  19. || targetPermanent.TopCard.EqualsTraits("ME");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null,
  27. level: 5)
  28. );
  29. }
  30. #endregion
  31. #region Blast Digivolve
  32. if (timing == EffectTiming.OnCounterTiming)
  33. {
  34. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  35. }
  36. #endregion
  37. #region Reboot
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Fragment
  44. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  45. {
  46. string EffectDescription()
  47. {
  48. return "<Fragment <2>> (When this Digimon would be deleted, by trashing any 2 of its digivolution cards, it isn’t deleted.)";
  49. }
  50. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 2, effectName: "Fragment <2>", effectDiscription: EffectDescription()));
  51. }
  52. #endregion
  53. #region Shared OP/WD/WA
  54. string SharedEffectName = "<De-Digivolve 3> 1 of enemy Digimon, then may place 2 lvl 5 or lower [Machine]/[Cyborg]/[ME] from hand or trash under to be immune to trashing until end of enemy turn";
  55. string SharedEffectHash = "EX12_059_OP_WD_WA";
  56. CardEffectFactory.ActivateClassesForSharedEffects
  57. (ref cardEffects, timing, card,
  58. SharedEffectName,
  59. SharedActivateCoroutine,
  60. SharedEffectDescription,
  61. optional: false,
  62. maxCountPerTurn: 1,
  63. hashValue: SharedEffectHash,
  64. onPlay: true,
  65. whenDigivolving: true,
  66. whenAttacking: true);
  67. string SharedEffectDescription(string tag)
  68. {
  69. return $"[{tag}] [Once Per Turn] <De-Digivolve 3> 1 of your opponent's Digimon. Then, by placing 2 level 5 or lower [Machine], [Cyborg] or [ME] trait cards from your hand or trash as this Digimon's bottom digivolution cards, your opponent's effects can't trash any of your Digimon's stacked cards until their turn ends.";
  70. }
  71. bool CanSelectPermanentCondition(Permanent permanent)
  72. {
  73. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  74. }
  75. bool CanSelectCardCondition(CardSource cardSource)
  76. {
  77. return cardSource.HasLevel
  78. && cardSource.Level <= 5
  79. && (cardSource.EqualsTraits("Machine")
  80. || cardSource.EqualsTraits("Cyborg")
  81. || cardSource.EqualsTraits("ME"));
  82. }
  83. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  84. {
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  86. {
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: 1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Degenerate,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetDegenerationCount(3);
  101. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. }
  104. if(card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  105. {
  106. int toSelect = 2;
  107. List<CardSource> selectedCards = new List<CardSource>();
  108. while (toSelect > 0)
  109. {
  110. bool CanSelectFilteredCardCondtion(CardSource cardSource)
  111. {
  112. return CanSelectCardCondition(cardSource)
  113. && !selectedCards.Contains(cardSource);
  114. }
  115. int validHandCardCount = card.Owner.HandCards.Count(CanSelectFilteredCardCondtion);
  116. int validTrashCardCount = card.Owner.TrashCards.Count(CanSelectFilteredCardCondtion);
  117. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  118. if (validHandCardCount > 0)
  119. {
  120. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  121. }
  122. if (validTrashCardCount > 0)
  123. {
  124. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  125. }
  126. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  127. GManager.instance.userSelectionManager.SetIntSelection(
  128. selectionElements: selectionElements,
  129. selectPlayer: card.Owner,
  130. selectPlayerMessage: "From which area will you select a card?",
  131. notSelectPlayerMessage: "The opponent is choosing from which area to select card.");
  132. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  133. if (GManager.instance.userSelectionManager.SelectedIntValue == 3)
  134. {
  135. break;
  136. }
  137. if (GManager.instance.userSelectionManager.SelectedIntValue == 1)
  138. {
  139. int maxCount = Math.Min(toSelect, card.Owner.HandCards.Count(CanSelectCardCondition));
  140. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  141. selectHandEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: CanSelectFilteredCardCondtion,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: maxCount,
  147. canNoSelect: true,
  148. canEndNotMax: true,
  149. isShowOpponent: true,
  150. selectCardCoroutine: SelectCardCoroutine,
  151. afterSelectCardCoroutine: null,
  152. mode: SelectHandEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. string messagePluralize = maxCount > 1 ? "Select one or more cards to place under this Digimon. You will be able to select a second card if you only choose 1." : "Select a card to place under this Digimon.";
  155. selectHandEffect.SetUpCustomMessage(
  156. messagePluralize,
  157. $"The opponent is selecting cards to place.");
  158. yield return StartCoroutine(selectHandEffect.Activate());
  159. }
  160. else
  161. {
  162. int maxCount = Math.Min(toSelect, card.Owner.TrashCards.Count(CanSelectCardCondition));
  163. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  164. selectCardEffect.SetUp(
  165. canTargetCondition: CanSelectFilteredCardCondtion,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. canNoSelect: () => true,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. message: "Select card(s) to place",
  172. maxCount: maxCount,
  173. canEndNotMax: true,
  174. isShowOpponent: true,
  175. mode: SelectCardEffect.Mode.Custom,
  176. root: SelectCardEffect.Root.Trash,
  177. customRootCardList: null,
  178. canLookReverseCard: true,
  179. selectPlayer: card.Owner,
  180. cardEffect: activateClass);
  181. string messagePluralize = maxCount > 1 ? "Select one or more cards to place under this Digimon. You will be able to select a second card if you only choose 1." : "Select a card to place under this Digimon.";
  182. selectCardEffect.SetUpCustomMessage(
  183. messagePluralize,
  184. $"The opponent is selecting cards to place.");
  185. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  186. }
  187. IEnumerator SelectCardCoroutine(CardSource cardSource)
  188. {
  189. if (cardSource != null)
  190. {
  191. selectedCards.Add(cardSource);
  192. toSelect--;
  193. }
  194. yield return null;
  195. }
  196. }
  197. if (selectedCards.Count == 2)
  198. {
  199. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedCards, "Digivolution Cards", true, true));
  200. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  201. bool DigimonCondition(Permanent permanent)
  202. {
  203. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  204. && !permanent.TopCard.CanNotBeAffected(activateClass);
  205. }
  206. ImmuneStackTrashingClass immuneFromStackTrashingClass = new ImmuneStackTrashingClass();
  207. immuneFromStackTrashingClass.SetUpICardEffect("Isn't affected by trashing any stacked card", hashtable => true, card);
  208. immuneFromStackTrashingClass.SetUpImmuneFromStackTrashingClass(PermanentCondition: DigimonCondition, EffectCondition: EffectCondition);
  209. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromStackTrashingClass);
  210. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.StaticAddDetailClass(_ => true, DigimonCondition, "Opponent's effects cannot trash stacked cards", false, activateClass));
  211. bool EffectCondition(ICardEffect cardEffect) => CardEffectCommons.IsOpponentEffect(cardEffect, card);
  212. }
  213. }
  214. }
  215. #endregion
  216. return cardEffects;
  217. }
  218. }
  219. }