P_152.cs 15 KB

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