BT10_080.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.BT10
  9. {
  10. public class BT10_080 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnDiscardHand)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Your Digimon can digivolve to trash cards", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "When one of your effects trashes this card in your hand, if it's your turn, 1 of your Digimon may digivolve into 1 purple Digimon card with [Undead] or [Dark Animal] in its traits from your trash for its digivolution cost.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. foreach (CardSource cardSource in card.Owner.TrashCards)
  30. {
  31. if (CanSelectCardCondition(cardSource))
  32. {
  33. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. if (cardSource.IsDigimon)
  45. {
  46. if (cardSource.HasCardColor(CardColor.Purple))
  47. {
  48. if (cardSource.CardTraits.Contains("Undead"))
  49. {
  50. return true;
  51. }
  52. if (cardSource.CardTraits.Contains("Dark Animal"))
  53. {
  54. return true;
  55. }
  56. if (cardSource.CardTraits.Contains("DarkAnimal"))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. bool SkillCondition(ICardEffect cardEffect)
  67. {
  68. if (cardEffect != null)
  69. {
  70. if (cardEffect.EffectSourceCard != null)
  71. {
  72. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. if (CardEffectCommons.CanTriggerOnTrashSelfHand(hashtable, SkillCondition, card))
  81. {
  82. if (CardEffectCommons.IsOwnerTurn(card))
  83. {
  84. return true;
  85. }
  86. }
  87. return false;
  88. }
  89. bool CanActivateCondition(Hashtable hashtable)
  90. {
  91. if (CardEffectCommons.IsExistOnTrash(card))
  92. {
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  94. {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  101. {
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. Permanent selectedPermanent = null;
  105. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: true,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. selectedPermanent = permanent;
  124. yield return null;
  125. }
  126. if (selectedPermanent != null)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  129. targetPermanent: selectedPermanent,
  130. cardCondition: CanSelectCardCondition,
  131. payCost: true,
  132. reduceCostTuple: null,
  133. fixedCostTuple: null,
  134. ignoreDigivolutionRequirementFixedCost: -1,
  135. isHand: false,
  136. activateClass: activateClass,
  137. successProcess: null));
  138. }
  139. }
  140. }
  141. }
  142. if (timing == EffectTiming.OnEnterFieldAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("This Digimon gets effects", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. return "[When Digivolving] If digivolving from the trash, this Digimon gains \"[On Deletion] Delete 1 of your opponent's Digimon.\" until the end of your opponent's turn.";
  151. }
  152. bool CanSelectPermanentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  155. }
  156. bool RootCondition(SelectCardEffect.Root root)
  157. {
  158. return root == SelectCardEffect.Root.Trash;
  159. }
  160. bool CanUseCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, RootCondition);
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleArea(card))
  167. {
  168. return true;
  169. }
  170. return false;
  171. }
  172. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleArea(card))
  175. {
  176. Permanent selectedPermanent = card.PermanentOfThisCard();
  177. if (selectedPermanent != null)
  178. {
  179. ActivateClass activateClass1 = new ActivateClass();
  180. activateClass1.SetUpICardEffect("Delete 1 Digimon", CanUseCondition1, selectedPermanent.TopCard);
  181. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  182. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  183. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
  184. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  185. string EffectDiscription1()
  186. {
  187. return "[On Deletion] Delete 1 of your opponent's Digimon.";
  188. }
  189. bool CanUseCondition1(Hashtable hashtable1)
  190. {
  191. return CardEffectCommons.CanTriggerOnDeletion(hashtable1, card, activateClass1);
  192. }
  193. bool CanActivateCondition1(Hashtable hashtable1)
  194. {
  195. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass1))
  196. {
  197. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  198. {
  199. return true;
  200. }
  201. }
  202. return false;
  203. }
  204. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  205. {
  206. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  207. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  208. selectPermanentEffect.SetUp(
  209. selectPlayer: card.Owner,
  210. canTargetCondition: CanSelectPermanentCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. maxCount: maxCount,
  214. canNoSelect: false,
  215. canEndNotMax: false,
  216. selectPermanentCoroutine: null,
  217. afterSelectPermanentCoroutine: null,
  218. mode: SelectPermanentEffect.Mode.Destroy,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  221. }
  222. }
  223. }
  224. }
  225. }
  226. return cardEffects;
  227. }
  228. }
  229. }