BT20_016.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT20
  9. {
  10. public class BT20_016 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region DNA Digivolve
  16. if (timing == EffectTiming.None)
  17. {
  18. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  19. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  20. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  21. addJogressConditionClass.SetNotShowUI(true);
  22. cardEffects.Add(addJogressConditionClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return true;
  26. }
  27. JogressCondition GetJogress(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. bool PermanentCondition1(Permanent permanent)
  32. {
  33. if (permanent != null)
  34. {
  35. if (permanent.TopCard != null)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  40. {
  41. if (permanent.Levels_ForJogress(card).Contains(4))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool PermanentCondition2(Permanent permanent)
  52. {
  53. if (permanent != null)
  54. {
  55. if (permanent.TopCard != null)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  58. {
  59. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  60. {
  61. if (permanent.Levels_ForJogress(card).Contains(4))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. JogressConditionElement[] elements = new JogressConditionElement[]
  72. {
  73. new JogressConditionElement(PermanentCondition1, "a level 4 red Digimon"),
  74. new JogressConditionElement(PermanentCondition2, "a level 4 purple Digimon"),
  75. };
  76. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  77. return jogressCondition;
  78. }
  79. return null;
  80. }
  81. }
  82. #endregion
  83. #region On Play
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Piercing and Digivolve into Imperialdramon Dragon Mode", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[On Play] For the turn, 1 of your Digimon gains <Piercing> (When this Digimon attacks and deletes an opponent's Digimon and survives the battle, it performs any security checks it normally would) and gets +4000 DP. Then, this Digimon may attack.";
  93. }
  94. bool CanSelectPermanentCondition(Permanent permanent)
  95. {
  96. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  109. {
  110. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  111. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectPermanentCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: SelectPermanentCoroutine,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Custom,
  123. cardEffect: activateClass);
  124. selectPermanentEffect.SetUpCustomMessage(
  125. "Select 1 Digimon that will gain Pierce and 4000DP.",
  126. "The opponent is selecting 1 Digimon that will gain Pierce and 4000DP.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  131. targetPermanent: permanent,
  132. effectDuration: EffectDuration.UntilEachTurnEnd,
  133. activateClass: activateClass));
  134. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  135. targetPermanent: permanent,
  136. changeValue: 4000,
  137. effectDuration: EffectDuration.UntilEachTurnEnd,
  138. activateClass: activateClass));
  139. }
  140. }
  141. if (card.PermanentOfThisCard().CanAttack(activateClass))
  142. {
  143. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  144. selectAttackEffect.SetUp(
  145. attacker: card.PermanentOfThisCard(),
  146. canAttackPlayerCondition: () => true,
  147. defenderCondition: _ => true,
  148. cardEffect: activateClass);
  149. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  150. }
  151. }
  152. }
  153. #endregion
  154. #region When Digivolving
  155. if (timing == EffectTiming.OnEnterFieldAnyone)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("1 Digimon gains Piercing and 4000DP, then this digimon may attack", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[When Digivolving] For the turn, 1 of your Digimon gains <Piercing> (When this Digimon attacks and deletes an opponent's Digimon and survives the battle, it performs any security checks it normally would) and gets +4000 DP. Then, this Digimon may attack.";
  164. }
  165. bool CanSelectPermanentCondition(Permanent permanent)
  166. {
  167. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  178. {
  179. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  180. {
  181. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: CanSelectPermanentCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: maxCount,
  189. canNoSelect: false,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: SelectPermanentCoroutine,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. selectPermanentEffect.SetUpCustomMessage(
  196. "Select 1 Digimon that will gain Pierce and 4000DP.",
  197. "The opponent is selecting 1 Digimon that will gain Pierce and 4000DP.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  202. targetPermanent: permanent,
  203. effectDuration: EffectDuration.UntilEachTurnEnd,
  204. activateClass: activateClass));
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  206. targetPermanent: permanent,
  207. changeValue: 4000,
  208. effectDuration: EffectDuration.UntilEachTurnEnd,
  209. activateClass: activateClass));
  210. }
  211. }
  212. if (card.PermanentOfThisCard().CanAttack(activateClass))
  213. {
  214. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  215. selectAttackEffect.SetUp(
  216. attacker: card.PermanentOfThisCard(),
  217. canAttackPlayerCondition: () => true,
  218. defenderCondition: _ => true,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  221. }
  222. }
  223. }
  224. #endregion
  225. #region All Turns
  226. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  227. {
  228. ActivateClass activateClass = new ActivateClass();
  229. activateClass.SetUpICardEffect("If would be deleted, DNA Digivolve", CanUseCondition, card);
  230. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  231. activateClass.SetHashString("DNA Digivolve into Imperialdramon Dragon Mode");
  232. cardEffects.Add(activateClass);
  233. string EffectDiscription()
  234. {
  235. return "[All Turns] When any of your [Paildramon]/[Dinobeemon] would be deleted, 2 of your Digimon may DNA digivolve into [Imperialdramon: Dragon Mode] in the hand.";
  236. }
  237. bool isPaildramonOrDinoBeemon(Permanent permanent)
  238. {
  239. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  240. {
  241. if (permanent.TopCard.EqualsCardName("Dinobeemon") || permanent.TopCard.EqualsCardName("Paildramon"))
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, isPaildramonOrDinoBeemon);
  251. }
  252. bool CanSelectDNACardCondition(CardSource cardSource)
  253. {
  254. if (cardSource.IsDigimon)
  255. {
  256. if (cardSource.CanPlayJogress(true))
  257. {
  258. if (cardSource.EqualsCardName("Imperialdramon: Dragon Mode"))
  259. {
  260. return true;
  261. }
  262. }
  263. }
  264. return false;
  265. }
  266. bool CanUseCondition(Hashtable hashtable)
  267. {
  268. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable hashtable)
  271. {
  272. yield return ContinuousController.instance.StartCoroutine(
  273. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  274. CanSelectDNACardCondition,
  275. payCost: true,
  276. isHand: true,
  277. activateClass
  278. ));
  279. }
  280. }
  281. #endregion
  282. #region InheritedEffect
  283. if (timing == EffectTiming.None)
  284. {
  285. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  286. }
  287. #endregion
  288. return cardEffects;
  289. }
  290. }
  291. }