EX10_031.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. //DarkKnightmon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_031 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasText("Knightmon") &&
  19. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Digixros
  25. if (timing == EffectTiming.None)
  26. {
  27. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  28. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  29. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  30. addDigiXrosConditionClass.SetNotShowUI(true);
  31. cardEffects.Add(addDigiXrosConditionClass);
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return true;
  35. }
  36. DigiXrosCondition GetDigiXros(CardSource cardSource)
  37. {
  38. if (cardSource == card)
  39. {
  40. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "SkullKnightmon");
  41. bool CanSelectCardCondition(CardSource cardSource)
  42. {
  43. if (cardSource != null)
  44. {
  45. if (cardSource.Owner == card.Owner)
  46. {
  47. if (cardSource.IsDigimon)
  48. {
  49. if (cardSource.CardNames_DigiXros.Contains("SkullKnightmon"))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "DeadlyAxemon");
  59. bool CanSelectCardCondition1(CardSource cardSource)
  60. {
  61. if (cardSource != null)
  62. {
  63. if (cardSource.Owner == card.Owner)
  64. {
  65. if (cardSource.IsDigimon)
  66. {
  67. if (cardSource.CardNames_DigiXros.Contains("DeadlyAxemon"))
  68. {
  69. return true;
  70. }
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  77. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 1);
  78. return digiXrosCondition;
  79. }
  80. return null;
  81. }
  82. }
  83. #endregion
  84. #region Shared OP/WD
  85. bool SharedPermamentCondition(Permanent permanent)
  86. {
  87. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  88. }
  89. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  90. {
  91. if (CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition))
  92. {
  93. Permanent selectedPermament = null;
  94. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  95. selectPermanentEffect.SetUp(
  96. selectPlayer: card.Owner,
  97. canTargetCondition: SharedPermamentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: 1,
  101. canNoSelect: false,
  102. canEndNotMax: false,
  103. selectPermanentCoroutine: SelectPermanentCoroutine,
  104. afterSelectPermanentCoroutine: null,
  105. mode: SelectPermanentEffect.Mode.Custom,
  106. cardEffect: activateClass);
  107. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  108. {
  109. selectedPermament = permanent;
  110. yield return null;
  111. }
  112. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain De-Digivolve immunity & 3K DP", "The opponent is selecting 1 Digimon to gain De-Digivolve immunity & 3K DP");
  113. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  114. if (selectedPermament != null)
  115. {
  116. bool CanUseImmunityCondition(Hashtable hashtable1)
  117. {
  118. return selectedPermament.TopCard != null;
  119. }
  120. bool PermanentImmunityCondition(Permanent permanent)
  121. {
  122. return permanent == selectedPermament;
  123. }
  124. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  125. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition, selectedPermament.TopCard);
  126. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  127. selectedPermament.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  129. targetPermanent: selectedPermament,
  130. changeValue: 3000,
  131. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  132. activateClass: activateClass
  133. ));
  134. }
  135. }
  136. }
  137. #endregion
  138. #region On Play
  139. if (timing == EffectTiming.OnEnterFieldAnyone)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 3k DP", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  144. cardEffects.Add(activateClass);
  145. string EffectDiscription()
  146. {
  147. return "[On Play] Until your opponent's turn ends, their <De-Digivolve> effects don't affect 1 of your Digimon, and it gets +3000 DP.";
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  152. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  153. }
  154. bool CanActivateCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  157. && CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition);
  158. }
  159. }
  160. #endregion
  161. #region When Digivolving
  162. if (timing == EffectTiming.OnEnterFieldAnyone)
  163. {
  164. ActivateClass activateClass = new ActivateClass();
  165. activateClass.SetUpICardEffect("Gain immunity to De-Digivolve & gain 3k DP", CanUseCondition, card);
  166. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  167. cardEffects.Add(activateClass);
  168. string EffectDiscription()
  169. {
  170. return "[When Digivolving] Until your opponent's turn ends, their <De-Digivolve> effects don't affect 1 of your Digimon, and it gets +3000 DP.";
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  175. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  180. && CardEffectCommons.HasMatchConditionPermanent(SharedPermamentCondition);
  181. }
  182. }
  183. #endregion
  184. #region All Turns - OPT
  185. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  186. {
  187. ActivateClass activateClass = new ActivateClass();
  188. activateClass.SetUpICardEffect("Play a Digimon from digivolution cards", CanUseCondition, card);
  189. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  190. activateClass.SetHashString("PlayDigimon_EX10_031");
  191. cardEffects.Add(activateClass);
  192. string EffectDiscription()
  193. {
  194. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, you may play 1 play cost 4 or lower card from its digivolution cards without paying the cost.";
  195. }
  196. bool CanSelectCardCondition(CardSource cardSource)
  197. {
  198. return cardSource.IsDigimon &&
  199. cardSource.HasPlayCost && cardSource.GetCostItself <= 4 &&
  200. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.DigivolutionCards);
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. if (CardEffectCommons.IsExistOnBattleArea(card))
  205. {
  206. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  207. {
  208. return true;
  209. }
  210. }
  211. return false;
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.IsExistOnBattleArea(card))
  216. {
  217. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  225. {
  226. Permanent selectedPermanent = card.PermanentOfThisCard();
  227. List<CardSource> selectedCards = new List<CardSource>();
  228. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  229. selectCardEffect.SetUp(
  230. canTargetCondition: CanSelectCardCondition,
  231. canTargetCondition_ByPreSelecetedList: null,
  232. canEndSelectCondition: null,
  233. canNoSelect: () => true,
  234. selectCardCoroutine: SelectCardCoroutine,
  235. afterSelectCardCoroutine: null,
  236. message: "Select 1 card to play.",
  237. maxCount: 1,
  238. canEndNotMax: false,
  239. isShowOpponent: true,
  240. mode: SelectCardEffect.Mode.Custom,
  241. root: SelectCardEffect.Root.Custom,
  242. customRootCardList: selectedPermanent.DigivolutionCards,
  243. canLookReverseCard: true,
  244. selectPlayer: card.Owner,
  245. cardEffect: activateClass);
  246. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  247. "The opponent is selecting 1 digivolution card to play.");
  248. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  249. yield return StartCoroutine(selectCardEffect.Activate());
  250. IEnumerator SelectCardCoroutine(CardSource cardSource)
  251. {
  252. selectedCards.Add(cardSource);
  253. yield return null;
  254. }
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  256. cardSources: selectedCards,
  257. activateClass: activateClass,
  258. payCost: false,
  259. isTapped: false,
  260. root: SelectCardEffect.Root.DigivolutionCards,
  261. activateETB: true));
  262. }
  263. }
  264. #endregion
  265. #region ESS
  266. if (timing == EffectTiming.OnAllyAttack)
  267. {
  268. ActivateClass activateClass = new ActivateClass();
  269. activateClass.SetUpICardEffect("Change attack target to this card", CanUseCondition, card);
  270. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  271. activateClass.SetHashString("BT22_061_ChangeAttackTarget");
  272. activateClass.SetIsInheritedEffect(true);
  273. cardEffects.Add(activateClass);
  274. string EffectDiscription()
  275. {
  276. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  277. }
  278. bool CanUseCondition(Hashtable hashtable)
  279. {
  280. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  281. }
  282. bool CanActivateCondition(Hashtable hashtable)
  283. {
  284. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  285. && CardEffectCommons.IsOpponentTurn(card)
  286. && CanBeSwitched();
  287. }
  288. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  289. bool CanBeSwitched()
  290. {
  291. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(GManager.instance.attackProcess.AttackingPermanent, card)
  292. && GManager.instance.attackProcess.IsAttacking
  293. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  294. }
  295. IEnumerator ActivateCoroutine(Hashtable hashtable)
  296. {
  297. if (CanBeSwitched()) yield return ContinuousController.instance.StartCoroutine(
  298. GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard()));
  299. }
  300. }
  301. #endregion
  302. return cardEffects;
  303. }
  304. }
  305. }