P_152.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 && permanent.DP <= 3000;
  66. return false;
  67. }
  68. bool HasTamer(Permanent permanent)
  69. {
  70. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  71. return permanent.IsTamer;
  72. return false;
  73. }
  74. bool DigivolutionCondition(CardSource source)
  75. {
  76. return !source.IsDigiEgg &&
  77. source.HasPlayCost &&
  78. source.EqualsTraits("Xros Heart");
  79. }
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  87. }
  88. IEnumerator ActivateCoroutine(Hashtable hashtable)
  89. {
  90. bool addedSource = false;
  91. #region DP reduction
  92. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  93. {
  94. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectPermanentCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to get -2000 DP.", "The opponent is selecting 1 Digimon to get -2000 DP.");
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. }
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. if (permanent == null)
  114. yield break;
  115. yield return ContinuousController.instance.StartCoroutine(
  116. CardEffectCommons.ChangeDigimonDP(
  117. targetPermanent: permanent,
  118. changeValue: -2000,
  119. effectDuration: EffectDuration.UntilEachTurnEnd,
  120. activateClass: activateClass));
  121. }
  122. #endregion
  123. if (card.PermanentOfThisCard().DigivolutionCards.Count(DigivolutionCondition) > 0)
  124. {
  125. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(DigivolutionCondition));
  126. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  127. selectCardEffect.SetUp(
  128. canTargetCondition: DigivolutionCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: () => true,
  132. selectCardCoroutine: SelectDigivolutionCard,
  133. afterSelectCardCoroutine: null,
  134. message: "Select 1 card to place under a tamer.",
  135. maxCount: 1,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. mode: SelectCardEffect.Mode.Custom,
  139. root: SelectCardEffect.Root.Custom,
  140. customRootCardList: card.PermanentOfThisCard().DigivolutionCards.Filter(DigivolutionCondition),
  141. canLookReverseCard: true,
  142. selectPlayer: card.Owner,
  143. cardEffect: activateClass);
  144. selectCardEffect.SetUpCustomMessage(
  145. "Select 1 card to place at the bottom of digivolution cards.",
  146. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  147. selectCardEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  148. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  149. }
  150. IEnumerator SelectDigivolutionCard(CardSource source)
  151. {
  152. if (CardEffectCommons.HasMatchConditionPermanent(HasTamer))
  153. {
  154. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasTamer));
  155. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  156. selectPermanentEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: HasTamer,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: false,
  163. canEndNotMax: false,
  164. selectPermanentCoroutine: SelectTamerCoroutine,
  165. afterSelectPermanentCoroutine: null,
  166. mode: SelectPermanentEffect.Mode.Custom,
  167. cardEffect: activateClass);
  168. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to add bottom source.", "The opponent is selecting 1 Tamer to add bottom source.");
  169. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  170. IEnumerator SelectTamerCoroutine(Permanent permanent)
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(
  173. new List<CardSource>() { source },
  174. activateClass));
  175. addedSource = true;
  176. }
  177. }
  178. }
  179. if (addedSource)
  180. {
  181. if (CardEffectCommons.HasMatchConditionPermanent(DeletionCondition))
  182. {
  183. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(DeletionCondition));
  184. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: DeletionCondition,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. maxCount: maxCount,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: null,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.Destroy,
  196. cardEffect: activateClass);
  197. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. }
  200. }
  201. }
  202. }
  203. #endregion
  204. #region Digi-Xros
  205. if (timing == EffectTiming.None)
  206. {
  207. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  208. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  209. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  210. addDigiXrosConditionClass.SetNotShowUI(true);
  211. cardEffects.Add(addDigiXrosConditionClass);
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return true;
  215. }
  216. DigiXrosCondition GetDigiXros(CardSource cardSource)
  217. {
  218. if (cardSource == card)
  219. {
  220. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Shoutmon");
  221. bool CanSelectCardCondition(CardSource cardSource)
  222. {
  223. if (cardSource != null)
  224. {
  225. if (cardSource.Owner == card.Owner)
  226. {
  227. if (cardSource.IsDigimon)
  228. {
  229. if (cardSource.CardNames_DigiXros.Contains("Shoutmon"))
  230. {
  231. return true;
  232. }
  233. }
  234. }
  235. }
  236. return false;
  237. }
  238. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "Dorulumon");
  239. bool CanSelectCardCondition1(CardSource cardSource)
  240. {
  241. if (cardSource != null)
  242. {
  243. if (cardSource.Owner == card.Owner)
  244. {
  245. if (cardSource.IsDigimon)
  246. {
  247. if (cardSource.CardNames_DigiXros.Contains("Dorulumon"))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  257. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 1);
  258. return digiXrosCondition;
  259. }
  260. return null;
  261. }
  262. }
  263. #endregion
  264. return cardEffects;
  265. }
  266. }
  267. }