BT22_015.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. //Omnimon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_015 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel6 &&
  18. targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 5,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region DNA Digivolution - Lv.6 w/Greymon + Lv.6 w/Garurumon: Cost 0
  30. if (timing == EffectTiming.None)
  31. {
  32. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  33. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  34. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  35. addJogressConditionClass.SetNotShowUI(true);
  36. cardEffects.Add(addJogressConditionClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return true;
  40. }
  41. JogressCondition GetJogress(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. bool PermanentCondition1(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.TopCard.HasGreymonName)
  50. {
  51. if (permanent.Levels_ForJogress(card).Contains(6))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool PermanentCondition2(Permanent permanent)
  60. {
  61. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  62. {
  63. if (permanent.TopCard.HasGarurumonName)
  64. {
  65. if (permanent.Levels_ForJogress(card).Contains(6))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. JogressConditionElement[] elements = new JogressConditionElement[]
  74. {
  75. new JogressConditionElement(PermanentCondition1, "a level 6 w/ Greymon in name"),
  76. new JogressConditionElement(PermanentCondition2, "a level 6 w/ Garurumon in name"),
  77. };
  78. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  79. return jogressCondition;
  80. }
  81. return null;
  82. }
  83. }
  84. #endregion
  85. #region Static Effects
  86. //Blocker
  87. if (timing == EffectTiming.None)
  88. {
  89. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  90. isInheritedEffect: false,
  91. card: card,
  92. condition: null));
  93. }
  94. //Decode (Red/Black)
  95. if (timing == EffectTiming.WhenRemoveField)
  96. {
  97. bool SourceCondition(CardSource source)
  98. {
  99. return (source.HasCardColor(CardColor.Red) ||
  100. source.HasCardColor(CardColor.Black)) &&
  101. source.HasLevel && source.IsLevel3;
  102. }
  103. string[] decodeStrings = { "(Red/Black) Lv.3)", "Red/Black Level 3" };
  104. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  105. }
  106. //Decode (Blue/Yellow)
  107. if (timing == EffectTiming.WhenRemoveField)
  108. {
  109. bool SourceCondition(CardSource source)
  110. {
  111. return (source.HasCardColor(CardColor.Blue) ||
  112. source.HasCardColor(CardColor.Yellow)) &&
  113. source.HasLevel && source.IsLevel3;
  114. }
  115. string[] decodeStrings = { "(Blue/Yellow) Lv.3)", "Blue/Yellow Level 3" };
  116. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  117. }
  118. #endregion
  119. #region On Play
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[On Play] Delete 1 of your opponent's Digimon with the lowest DP.";
  129. }
  130. bool IsOpponentsDigimon(Permanent permanent)
  131. {
  132. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  133. CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  138. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  143. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable hashtable)
  146. {
  147. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: IsOpponentsDigimon,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: 1,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: null,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Destroy,
  159. cardEffect: activateClass);
  160. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  161. }
  162. }
  163. #endregion
  164. #region When Attacking
  165. if (timing == EffectTiming.OnAllyAttack)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  170. cardEffects.Add(activateClass);
  171. string EffectDiscription()
  172. {
  173. return "[When Attacking] Delete 1 of your opponent's Digimon with the lowest DP.";
  174. }
  175. bool IsOpponentsDigimon(Permanent permanent)
  176. {
  177. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  178. CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  183. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  188. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: IsOpponentsDigimon,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: null,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Destroy,
  204. cardEffect: activateClass);
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. }
  207. }
  208. #endregion
  209. #region When Digivolving
  210. if (timing == EffectTiming.OnEnterFieldAnyone)
  211. {
  212. ActivateClass activateClass = new ActivateClass();
  213. activateClass.SetUpICardEffect("Return 1 digimon, then attack", CanUseCondition, card);
  214. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  215. cardEffects.Add(activateClass);
  216. string EffectDiscription()
  217. {
  218. return "[When Digivolving] For every 2 same-level cards this Digimon's stack has, return 1 of your opponent's Digimon to the bottom of the deck. Then, this Digimon may attack.";
  219. }
  220. bool OpponentsDigimon(Permanent permanent)
  221. {
  222. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  223. }
  224. bool CanUseCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  227. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  228. }
  229. bool CanActivateCondition(Hashtable hashtable)
  230. {
  231. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable hashtable)
  234. {
  235. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon))
  236. {
  237. Permanent thisPermanent = card.PermanentOfThisCard();
  238. List<int> levelList = new List<int> { 0, 0, 0, 0, 0, 0 };
  239. int targetCount = 0;
  240. thisPermanent.StackCards.ForEach(card =>
  241. {
  242. if (card.HasLevel && !card.IsFlipped)
  243. levelList[card.Level - 2]++;
  244. });
  245. foreach (int count in levelList)
  246. {
  247. targetCount += Mathf.FloorToInt(count / 2);
  248. }
  249. int maxCount = Mathf.Min(targetCount, CardEffectCommons.MatchConditionPermanentCount(OpponentsDigimon));
  250. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  251. selectPermanentEffect.SetUp(
  252. selectPlayer: card.Owner,
  253. canTargetCondition: OpponentsDigimon,
  254. canTargetCondition_ByPreSelecetedList: null,
  255. canEndSelectCondition: null,
  256. maxCount: maxCount,
  257. canNoSelect: false,
  258. canEndNotMax: false,
  259. selectPermanentCoroutine: null,
  260. afterSelectPermanentCoroutine: null,
  261. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  262. cardEffect: activateClass);
  263. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon that will be bottom decked.",
  264. $"The opponent is selecting {maxCount} Digimon that will be bottom decked.");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. }
  267. if (CardEffectCommons.IsExistOnBattleArea(card))
  268. {
  269. if (card.PermanentOfThisCard().CanAttack(activateClass))
  270. {
  271. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  272. selectAttackEffect.SetUp(
  273. attacker: card.PermanentOfThisCard(),
  274. canAttackPlayerCondition: () => true,
  275. defenderCondition: (permanent) => true,
  276. cardEffect: activateClass);
  277. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  278. }
  279. }
  280. }
  281. }
  282. #endregion
  283. return cardEffects;
  284. }
  285. }
  286. }