EX12_060.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Chaosdramon
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_060 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region DNA Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  17. addJogressConditionClass.SetUpICardEffect("DNA Digivolution", CanUseCondition, card);
  18. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  19. addJogressConditionClass.SetNotShowUI(true);
  20. cardEffects.Add(addJogressConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return true;
  24. }
  25. JogressCondition GetJogress(CardSource cardSource)
  26. {
  27. if (cardSource == card)
  28. {
  29. bool PermanentCondition1(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  32. && (permanent.TopCard.CardColors.Contains(CardColor.Red)
  33. || permanent.TopCard.CardColors.Contains(CardColor.Black))
  34. && permanent.Levels_ForJogress(card).Contains(6);
  35. }
  36. bool PermanentCondition2(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  39. && (permanent.TopCard.CardColors.Contains(CardColor.Purple)
  40. || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  41. && permanent.Levels_ForJogress(card).Contains(6);
  42. }
  43. JogressConditionElement[] elements = new JogressConditionElement[]
  44. {
  45. new JogressConditionElement(PermanentCondition1, "a level 6 Red or Black Digimon"),
  46. new JogressConditionElement(PermanentCondition2, "a level 6 Purple or Yellow Digimon"),
  47. };
  48. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  49. return jogressCondition;
  50. }
  51. return null;
  52. }
  53. }
  54. #endregion
  55. #region Piercing
  56. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  57. {
  58. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  59. }
  60. #endregion
  61. #region Security A. +1
  62. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  63. #endregion
  64. #region Fragment
  65. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  66. {
  67. string EffectDescription()
  68. {
  69. return "<Fragment <2>> (When this Digimon would be deleted, by trashing any 2 of its digivolution cards, it isn’t deleted.)";
  70. }
  71. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 2, effectName: "Fragment <2>", effectDiscription: EffectDescription()));
  72. }
  73. #endregion
  74. #region Engage
  75. if (timing == EffectTiming.OnEndTurn)
  76. {
  77. cardEffects.Add(CardEffectFactory.EngageSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  78. }
  79. #endregion
  80. #region Shared OP/WD/WA
  81. string SharedEffectName = "<De-Digivolve 2> all enemy Digimon, then may place 2 lvl 5 or lower [Machine]/[Cyborg]/[ME] from hand/trash under to delete 2 enemy Digimon with play cost equal or lower to source count";
  82. string SharedEffectHash = "EX12_060_OP_WD_WA";
  83. CardEffectFactory.ActivateClassesForSharedEffects
  84. (ref cardEffects, timing, card,
  85. SharedEffectName,
  86. SharedActivateCoroutine,
  87. SharedEffectDescription,
  88. optional: false,
  89. maxCountPerTurn: 1,
  90. hashValue: SharedEffectHash,
  91. onPlay: true,
  92. whenDigivolving: true,
  93. whenAttacking: true);
  94. string SharedEffectDescription(string tag)
  95. {
  96. return $"[{tag}] [Once Per Turn] <De-Digivolve 2> all 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, delete 2 of your opponent's Digimon as high or lower a play cost as the number of this Digimon's digivolution cards.";
  97. }
  98. bool CanSelectCardCondition(CardSource cardSource)
  99. {
  100. return cardSource.HasLevel
  101. && cardSource.Level <= 5
  102. && (cardSource.EqualsTraits("Machine")
  103. || cardSource.EqualsTraits("Cyborg")
  104. || cardSource.EqualsTraits("ME"));
  105. }
  106. bool CanSelectPermanentCondition(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  109. && permanent.TopCard.HasPlayCost
  110. && permanent.TopCard.GetCostItself <= card.PermanentOfThisCard().DigivolutionCards.Count;
  111. }
  112. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(new IMassDegeneration(card.Owner.Enemy.GetBattleAreaDigimons(), 2, activateClass).Degeneration());
  115. if (card.Owner.HandCards.Count(CanSelectCardCondition) + card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  116. {
  117. int toSelect = 2;
  118. List<CardSource> selectedCards = new List<CardSource>();
  119. while (toSelect > 0)
  120. {
  121. bool CanSelectFilteredCardCondtion(CardSource cardSource)
  122. {
  123. return CanSelectCardCondition(cardSource)
  124. && !selectedCards.Contains(cardSource);
  125. }
  126. int validHandCardCount = card.Owner.HandCards.Count(CanSelectFilteredCardCondtion);
  127. int validTrashCardCount = card.Owner.TrashCards.Count(CanSelectFilteredCardCondtion);
  128. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  129. if (validHandCardCount > 0)
  130. {
  131. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  132. }
  133. if (validTrashCardCount > 0)
  134. {
  135. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  136. }
  137. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  138. GManager.instance.userSelectionManager.SetIntSelection(
  139. selectionElements: selectionElements,
  140. selectPlayer: card.Owner,
  141. selectPlayerMessage: "From which area will you select a card?",
  142. notSelectPlayerMessage: "The opponent is choosing from which area to select card.");
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  144. if (GManager.instance.userSelectionManager.SelectedIntValue == 3)
  145. {
  146. break;
  147. }
  148. if (GManager.instance.userSelectionManager.SelectedIntValue == 1)
  149. {
  150. int maxCount = Math.Min(toSelect, card.Owner.HandCards.Count(CanSelectCardCondition));
  151. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  152. selectHandEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: CanSelectFilteredCardCondtion,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: maxCount,
  158. canNoSelect: true,
  159. canEndNotMax: true,
  160. isShowOpponent: true,
  161. selectCardCoroutine: SelectCardCoroutine,
  162. afterSelectCardCoroutine: null,
  163. mode: SelectHandEffect.Mode.Custom,
  164. cardEffect: activateClass);
  165. 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.";
  166. selectHandEffect.SetUpCustomMessage(
  167. messagePluralize,
  168. $"The opponent is selecting cards to place.");
  169. yield return StartCoroutine(selectHandEffect.Activate());
  170. }
  171. else
  172. {
  173. int maxCount = Math.Min(toSelect, card.Owner.TrashCards.Count(CanSelectCardCondition));
  174. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  175. selectCardEffect.SetUp(
  176. canTargetCondition: CanSelectFilteredCardCondtion,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. canNoSelect: () => true,
  180. selectCardCoroutine: SelectCardCoroutine,
  181. afterSelectCardCoroutine: null,
  182. message: "Select card(s) to place",
  183. maxCount: maxCount,
  184. canEndNotMax: true,
  185. isShowOpponent: true,
  186. mode: SelectCardEffect.Mode.Custom,
  187. root: SelectCardEffect.Root.Trash,
  188. customRootCardList: null,
  189. canLookReverseCard: true,
  190. selectPlayer: card.Owner,
  191. cardEffect: activateClass);
  192. 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.";
  193. selectCardEffect.SetUpCustomMessage(
  194. messagePluralize,
  195. $"The opponent is selecting cards to place.");
  196. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  197. }
  198. IEnumerator SelectCardCoroutine(CardSource cardSource)
  199. {
  200. if (cardSource != null)
  201. {
  202. selectedCards.Add(cardSource);
  203. toSelect--;
  204. }
  205. yield return null;
  206. }
  207. }
  208. if (selectedCards.Count == 2)
  209. {
  210. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  211. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  212. {
  213. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  214. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  215. selectPermanentEffect.SetUp(
  216. selectPlayer: card.Owner,
  217. canTargetCondition: CanSelectPermanentCondition,
  218. canTargetCondition_ByPreSelecetedList: null,
  219. canEndSelectCondition: null,
  220. maxCount: maxCount,
  221. canNoSelect: false,
  222. canEndNotMax: false,
  223. selectPermanentCoroutine: null,
  224. afterSelectPermanentCoroutine: null,
  225. mode: SelectPermanentEffect.Mode.Destroy,
  226. cardEffect: activateClass);
  227. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  228. }
  229. }
  230. }
  231. }
  232. #endregion
  233. #region Assembly
  234. if (timing == EffectTiming.None)
  235. {
  236. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  237. addAssemblyConditionClass.SetUpICardEffect("Assembly", CanUseCondition, card);
  238. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  239. addAssemblyConditionClass.SetNotShowUI(true);
  240. cardEffects.Add(addAssemblyConditionClass);
  241. bool CanUseCondition(Hashtable hashtable)
  242. {
  243. return true;
  244. }
  245. AssemblyCondition GetAssembly(CardSource cardSource)
  246. {
  247. if (cardSource == card)
  248. {
  249. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  250. bool CanSelectCardCondition(CardSource cardSource)
  251. {
  252. return cardSource != null
  253. && cardSource.Owner == card.Owner
  254. && cardSource.HasLevel
  255. && cardSource.Level <= 6
  256. && (cardSource.EqualsTraits("Machine")
  257. || cardSource.EqualsTraits("Cyborg")
  258. || cardSource.EqualsTraits("ME"));
  259. }
  260. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  261. {
  262. List<CardSource> AllCards = cardSources.Clone();
  263. AllCards.Add(cardSource);
  264. return AllCards.Count == Combinations.GetUniqueNameCardCount(AllCards);
  265. }
  266. AssemblyCondition assemblyCondition = new AssemblyCondition(
  267. element: element,
  268. CanTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  269. selectMessage: "6 Lv.6 or lower [Machine]/[Cyborg]/[ME] trait cards w/different names",
  270. elementCount: 6,
  271. reduceCost: 8);
  272. return assemblyCondition;
  273. }
  274. return null;
  275. }
  276. }
  277. #endregion
  278. return cardEffects;
  279. }
  280. }
  281. }