P_152.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using System.Diagnostics;
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_152 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Rule: Name Change
  14. if (timing == EffectTiming.None)
  15. {
  16. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  17. changeCardNamesClass.SetUpICardEffect("Also treated as [Shoutmon]/[Dorulumon]", CanUseCondition, card);
  18. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  19. cardEffects.Add(changeCardNamesClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  25. {
  26. if (cardSource == card)
  27. {
  28. CardNames.Add("Shoutmon");
  29. CardNames.Add("Dorulumon");
  30. }
  31. return CardNames;
  32. }
  33. }
  34. #endregion
  35. #region Alternate Digivolution Requirement
  36. if (timing == EffectTiming.None)
  37. {
  38. static bool PermanentCondition(Permanent targetPermanent)
  39. {
  40. if(targetPermanent.TopCard.HasPlayCost && targetPermanent.TopCard.GetCostItself <= 4)
  41. return targetPermanent.TopCard.EqualsCardName("Shoutmon") || targetPermanent.TopCard.EqualsCardName("Dorulumon");
  42. return false;
  43. }
  44. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  45. }
  46. #endregion
  47. #region When Attacking
  48. if (timing == EffectTiming.OnAllyAttack)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("One of your opponents Digimon gets -2000 DP for the turn, then delete 1 of their Digimon wiht 3000 DP or less", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  53. cardEffects.Add(activateClass);
  54. string EffectDiscription()
  55. {
  56. return "[When Attacking] 1 of your opponent’s Digimon gets -2000 DP for the turn. Then, by placing 1 Digimon card with the [Xros Heart] trait in this Digimon’s digivolution cards under 1 of your Tamers, delete 1 of their Digimon with 3000 DP or less.";
  57. }
  58. bool CanSelectPermanentCondition(Permanent permanent)
  59. {
  60. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  61. }
  62. bool DeletionCondition(Permanent permanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  65. return permanent.HasDP
  66. && permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass);
  67. return false;
  68. }
  69. bool HasTamer(Permanent permanent)
  70. {
  71. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  72. return permanent.IsTamer;
  73. return false;
  74. }
  75. bool DigivolutionCondition(CardSource source)
  76. {
  77. return !source.IsDigiEgg &&
  78. source.HasPlayCost &&
  79. source.EqualsTraits("Xros Heart");
  80. }
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  84. }
  85. bool CanActivateCondition(Hashtable hashtable)
  86. {
  87. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable hashtable)
  90. {
  91. bool addedSource = false;
  92. #region DP reduction
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  94. {
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: SelectPermanentCoroutine,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to get -2000 DP.", "The opponent is selecting 1 Digimon to get -2000 DP.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. }
  112. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  113. {
  114. if (permanent == null)
  115. yield break;
  116. yield return ContinuousController.instance.StartCoroutine(
  117. CardEffectCommons.ChangeDigimonDP(
  118. targetPermanent: permanent,
  119. changeValue: -2000,
  120. effectDuration: EffectDuration.UntilEachTurnEnd,
  121. activateClass: activateClass));
  122. }
  123. #endregion
  124. if (card.PermanentOfThisCard().DigivolutionCards.Count(DigivolutionCondition) > 0)
  125. {
  126. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(DigivolutionCondition));
  127. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  128. selectCardEffect.SetUp(
  129. canTargetCondition: DigivolutionCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. canNoSelect: () => true,
  133. selectCardCoroutine: SelectDigivolutionCard,
  134. afterSelectCardCoroutine: null,
  135. message: "Select 1 card to place under a tamer.",
  136. maxCount: 1,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. mode: SelectCardEffect.Mode.Custom,
  140. root: SelectCardEffect.Root.Custom,
  141. customRootCardList: card.PermanentOfThisCard().DigivolutionCards.Filter(DigivolutionCondition),
  142. canLookReverseCard: true,
  143. selectPlayer: card.Owner,
  144. cardEffect: activateClass);
  145. selectCardEffect.SetUpCustomMessage(
  146. "Select 1 card to place at the bottom of digivolution cards.",
  147. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  148. selectCardEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  149. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  150. }
  151. IEnumerator SelectDigivolutionCard(CardSource source)
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(HasTamer))
  154. {
  155. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasTamer));
  156. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  157. selectPermanentEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: HasTamer,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: maxCount,
  163. canNoSelect: false,
  164. canEndNotMax: false,
  165. selectPermanentCoroutine: SelectTamerCoroutine,
  166. afterSelectPermanentCoroutine: null,
  167. mode: SelectPermanentEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to add bottom source.", "The opponent is selecting 1 Tamer to add bottom source.");
  170. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  171. IEnumerator SelectTamerCoroutine(Permanent permanent)
  172. {
  173. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(
  174. new List<CardSource>() { source },
  175. activateClass));
  176. addedSource = true;
  177. }
  178. }
  179. }
  180. if (addedSource)
  181. {
  182. if (CardEffectCommons.HasMatchConditionPermanent(DeletionCondition))
  183. {
  184. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(DeletionCondition));
  185. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: DeletionCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: maxCount,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: null,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Destroy,
  197. cardEffect: activateClass);
  198. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. }
  201. }
  202. }
  203. }
  204. #endregion
  205. #region Digi-Xros
  206. if (timing == EffectTiming.None)
  207. {
  208. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  209. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  210. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  211. addDigiXrosConditionClass.SetNotShowUI(true);
  212. cardEffects.Add(addDigiXrosConditionClass);
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. return true;
  216. }
  217. DigiXrosCondition GetDigiXros(CardSource cardSource)
  218. {
  219. if (cardSource == card)
  220. {
  221. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Shoutmon");
  222. bool CanSelectCardCondition(CardSource cardSource)
  223. {
  224. if (cardSource != null)
  225. {
  226. if (cardSource.Owner == card.Owner)
  227. {
  228. if (cardSource.IsDigimon)
  229. {
  230. if (cardSource.CardNames_DigiXros.Contains("Shoutmon"))
  231. {
  232. return true;
  233. }
  234. }
  235. }
  236. }
  237. return false;
  238. }
  239. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Dorulumon");
  240. bool CanSelectCardCondition1(CardSource cardSource)
  241. {
  242. if (cardSource != null)
  243. {
  244. if (cardSource.Owner == card.Owner)
  245. {
  246. if (cardSource.IsDigimon)
  247. {
  248. if (cardSource.CardNames_DigiXros.Contains("Dorulumon"))
  249. {
  250. return true;
  251. }
  252. }
  253. }
  254. }
  255. return false;
  256. }
  257. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  258. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 1);
  259. return digiXrosCondition;
  260. }
  261. return null;
  262. }
  263. }
  264. #endregion
  265. return cardEffects;
  266. }
  267. }
  268. }