EX6_052.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.EX6
  9. {
  10. public class EX6_052 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Scapegoat
  16. if(timing == EffectTiming.WhenPermanentWouldBeDeleted)
  17. {
  18. string EffectDiscription()
  19. {
  20. return "<Scapegoat> (When this Digimon would be deleted other than by your own effects, by deleting 1 of your other Digimon, prevent that deletion.)";
  21. }
  22. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: EffectDiscription()));
  23. }
  24. #endregion
  25. #region When Digivolving
  26. if (timing == EffectTiming.OnEnterFieldAnyone)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Play 1 level 3 purple Digimon from your trash", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[When Digivolving] You may play 1 purple level 3 Digimon from your trash without paying the cost.";
  35. }
  36. bool CanSelectCardInTrash(CardSource cardSource)
  37. {
  38. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  39. {
  40. if (cardSource.HasCardColor(CardColor.Purple))
  41. {
  42. if (cardSource.IsDigimon)
  43. {
  44. if (cardSource.Level == 3)
  45. {
  46. if (cardSource.HasLevel)
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable,card);
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.IsExistOnBattleArea(card))
  63. {
  64. if (card.Owner.TrashCards.Count >= 1)
  65. {
  66. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable hashtable)
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  77. {
  78. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  79. List<CardSource> selectedCards = new List<CardSource>();
  80. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  81. selectCardEffect.SetUp(
  82. canTargetCondition: CanSelectCardInTrash,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. canNoSelect: () => true,
  86. selectCardCoroutine: SelectCardCoroutine,
  87. afterSelectCardCoroutine: null,
  88. message: "Select 1 card to play.",
  89. maxCount: maxCount,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. mode: SelectCardEffect.Mode.Custom,
  93. root: SelectCardEffect.Root.Trash,
  94. customRootCardList: null,
  95. canLookReverseCard: true,
  96. selectPlayer: card.Owner,
  97. cardEffect: activateClass);
  98. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  99. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  100. yield return StartCoroutine(selectCardEffect.Activate());
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  107. cardSources: selectedCards,
  108. activateClass: activateClass,
  109. payCost: false,
  110. isTapped: false,
  111. root: SelectCardEffect.Root.Trash,
  112. activateETB: true));
  113. }
  114. }
  115. }
  116. #endregion
  117. #region Inherit
  118. if (timing == EffectTiming.OnDestroyedAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("Play 1 level 4 or lower purple Digimon from your trash", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  123. activateClass.SetHashString("PlayLevel4_EX6_052");
  124. activateClass.SetIsInheritedEffect(true);
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[Opponent's Turn] [Once per turn] When an opponent's Digimon is deleted, you may play 1 purple level 4 or lower Digimon from your trash without paying the cost.";
  129. }
  130. bool CanSelectCardInTrash(CardSource cardSource)
  131. {
  132. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  133. {
  134. if (cardSource.HasCardColor(CardColor.Purple))
  135. {
  136. if (cardSource.IsDigimon)
  137. {
  138. if (cardSource.Level <= 4)
  139. {
  140. if (cardSource.HasLevel)
  141. {
  142. return true;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. return false;
  149. }
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. if (CardEffectCommons.IsOpponentTurn(card))
  155. {
  156. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  157. {
  158. return true;
  159. }
  160. }
  161. }
  162. return false;
  163. }
  164. bool PermanentCondition(Permanent permanent)
  165. {
  166. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  167. {
  168. if (permanent.IsDigimon)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardInTrash(cardSource)))
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. IEnumerator ActivateCoroutine(Hashtable hashtable)
  187. {
  188. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  189. {
  190. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  191. List<CardSource> selectedCards = new List<CardSource>();
  192. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  193. selectCardEffect.SetUp(
  194. canTargetCondition: CanSelectCardInTrash,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. canNoSelect: () => true,
  198. selectCardCoroutine: SelectCardCoroutine,
  199. afterSelectCardCoroutine: null,
  200. message: "Select 1 card to play.",
  201. maxCount: maxCount,
  202. canEndNotMax: false,
  203. isShowOpponent: true,
  204. mode: SelectCardEffect.Mode.Custom,
  205. root: SelectCardEffect.Root.Trash,
  206. customRootCardList: null,
  207. canLookReverseCard: true,
  208. selectPlayer: card.Owner,
  209. cardEffect: activateClass);
  210. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  211. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  212. yield return StartCoroutine(selectCardEffect.Activate());
  213. IEnumerator SelectCardCoroutine(CardSource cardSource)
  214. {
  215. selectedCards.Add(cardSource);
  216. yield return null;
  217. }
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  219. cardSources: selectedCards,
  220. activateClass: activateClass,
  221. payCost: false,
  222. isTapped: false,
  223. root: SelectCardEffect.Root.Trash,
  224. activateETB: true));
  225. }
  226. }
  227. }
  228. #endregion
  229. return cardEffects;
  230. }
  231. }
  232. }