BT15_041.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT15
  7. {
  8. public class BT15_041 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Give opponent's Digimon -6000 DP.", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] 1 of your opponent's Digimon gets -6000 DP until the end of your opponent's turn.";
  23. }
  24. bool CanActivateCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. return true;
  29. }
  30. return false;
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  35. }
  36. bool CanSelectPermanent(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanent))
  47. {
  48. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanent));
  49. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  50. selectPermanentEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: CanSelectPermanent,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: maxCount,
  56. canNoSelect: false,
  57. canEndNotMax: false,
  58. selectPermanentCoroutine: SelectPermanentCoroutine,
  59. afterSelectPermanentCoroutine: null,
  60. mode: SelectPermanentEffect.Mode.Custom,
  61. cardEffect: activateClass);
  62. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -6000.", "The opponent is selecting 1 Digimon that will get DP -6000.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  65. {
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  67. targetPermanent: permanent,
  68. changeValue: -6000,
  69. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  70. activateClass: activateClass));
  71. }
  72. }
  73. }
  74. }
  75. #endregion
  76. #region On Deletion
  77. if (timing == EffectTiming.OnDestroyedAnyone)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("Give opponent's Digimon -6000 DP.", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[On Deletion] 1 of your opponent's Digimon gets -6000 DP until the end of your opponent's turn.";
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanActivateOnDeletion(card);
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  94. }
  95. bool CanSelectPermanent(Permanent permanent)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  98. {
  99. return true;
  100. }
  101. return false;
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  104. {
  105. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanent))
  106. {
  107. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanent));
  108. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  109. selectPermanentEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectPermanent,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: false,
  116. canEndNotMax: false,
  117. selectPermanentCoroutine: SelectPermanentCoroutine,
  118. afterSelectPermanentCoroutine: null,
  119. mode: SelectPermanentEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -6000.", "The opponent is selecting 1 Digimon that will get DP -6000.");
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  124. {
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  126. targetPermanent: permanent,
  127. changeValue: -6000,
  128. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  129. activateClass: activateClass));
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region End of Opponent's Turn
  136. if (timing == EffectTiming.OnEndTurn)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("Delete this Digimon to play [Rosemon] or [Jijimon] from hand.", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  141. activateClass.SetHashString("DeleteAndPlay_BT15_041");
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[End of Opponent�'s Turn] By deleting this Digimon, you may play 1 [Rosemon] or [Jijimon] from your hand without paying the cost. Then activate the [When Digivolving] effect of the Digimon played by this effect.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. if (isExistOnField(card))
  150. {
  151. return true;
  152. }
  153. return false;
  154. }
  155. bool CanSelectCardCondition(CardSource cardSource)
  156. {
  157. if (card.Owner.HandCards.Count >= 1)
  158. {
  159. if (cardSource.CardNames.Contains("Jijimon") || cardSource.CardNames.Contains("Rosemon"))
  160. {
  161. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  162. {
  163. return true;
  164. }
  165. }
  166. }
  167. return false;
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. if (isExistOnField(card))
  172. {
  173. if (CardEffectCommons.IsOpponentTurn(card))
  174. {
  175. if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  186. new List<Permanent>() { card.PermanentOfThisCard() },
  187. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  188. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  189. {
  190. List<CardSource> selectedCards = new List<CardSource>();
  191. int maxCount = 1;
  192. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  193. selectHandEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectCardCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. mode: SelectHandEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  207. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  208. yield return StartCoroutine(selectHandEffect.Activate());
  209. IEnumerator SelectCardCoroutine(CardSource cardSource)
  210. {
  211. selectedCards.Add(cardSource);
  212. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  213. if (selectedCards[0].HasWhenDigivolvingEffect)
  214. {
  215. List<ICardEffect> candidateEffects = cardSource.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  216. .Clone()
  217. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  218. if (candidateEffects.Count >= 1)
  219. {
  220. ICardEffect selectedEffect = null;
  221. if (candidateEffects.Count == 1)
  222. {
  223. selectedEffect = candidateEffects[0];
  224. }
  225. else
  226. {
  227. List<SkillInfo> skillInfos = candidateEffects
  228. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  229. List<CardSource> cardSources = candidateEffects
  230. .Map(cardEffect => cardEffect.EffectSourceCard);
  231. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  232. selectCardEffect.SetUp(
  233. canTargetCondition: (cardSource) => true,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. canNoSelect: () => false,
  237. selectCardCoroutine: null,
  238. afterSelectCardCoroutine: null,
  239. message: "Select 1 effect to activate.",
  240. maxCount: 1,
  241. canEndNotMax: false,
  242. isShowOpponent: false,
  243. mode: SelectCardEffect.Mode.Custom,
  244. root: SelectCardEffect.Root.Custom,
  245. customRootCardList: cardSources,
  246. canLookReverseCard: true,
  247. selectPlayer: card.Owner,
  248. cardEffect: activateClass);
  249. selectCardEffect.SetNotShowCard();
  250. selectCardEffect.SetUpSkillInfos(skillInfos);
  251. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  252. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  253. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  254. {
  255. if (selectedIndexes.Count == 1)
  256. {
  257. selectedEffect = candidateEffects[selectedIndexes[0]];
  258. yield return null;
  259. }
  260. }
  261. }
  262. if (selectedEffect != null)
  263. {
  264. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  265. yield return ContinuousController.instance.StartCoroutine(
  266. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. #endregion
  275. return cardEffects;
  276. }
  277. }
  278. }