EX6_050.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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_050 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Blocker
  16. if(timing == EffectTiming.None)
  17. {
  18. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Gain 1 memory/Opponent trashes 1 card", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] If your opponent has 5 or fewer cards in their hand, gain 1 memory. If your opponent has 7 or more cards in their hand, your opponent trashes 1 card in their hand.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable,card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (card.Owner.Enemy.HandCards.Count <= 5)
  41. {
  42. if (card.Owner.CanAddMemory(activateClass))
  43. {
  44. return true;
  45. }
  46. }
  47. if (card.Owner.Enemy.HandCards.Count >= 7)
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. if (card.Owner.Enemy.HandCards.Count <= 5)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  59. }
  60. if (card.Owner.Enemy.HandCards.Count >= 7)
  61. {
  62. int discardCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner.Enemy,
  66. canTargetCondition: (cardSource) => true,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: discardCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: null,
  74. afterSelectCardCoroutine: null,
  75. mode: SelectHandEffect.Mode.Discard,
  76. cardEffect: activateClass);
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. }
  79. }
  80. }
  81. #endregion
  82. #region On Deletion
  83. if (timing == EffectTiming.OnDestroyedAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Gain 1 memory/Opponent trashes 1 card", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[On Deletion] If your opponent has 5 or fewer cards in their hand, gain 1 memory. If your opponent has 7 or more cards in their hand, your opponent trashes 1 card in their hand.";
  92. }
  93. bool CanUseCondition(Hashtable hashtable)
  94. {
  95. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  96. }
  97. bool CanActivateCondition(Hashtable hashtable)
  98. {
  99. if (card.Owner.Enemy.HandCards.Count <= 5)
  100. {
  101. if (card.Owner.CanAddMemory(activateClass))
  102. {
  103. return true;
  104. }
  105. }
  106. if (card.Owner.Enemy.HandCards.Count >= 7)
  107. {
  108. return true;
  109. }
  110. return false;
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable hashtable)
  113. {
  114. if (card.Owner.Enemy.HandCards.Count <= 5)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  117. }
  118. if (card.Owner.Enemy.HandCards.Count >= 7)
  119. {
  120. int discardCount = 1;
  121. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  122. selectHandEffect.SetUp(
  123. selectPlayer: card.Owner.Enemy,
  124. canTargetCondition: (cardSource) => true,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: discardCount,
  128. canNoSelect: false,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. selectCardCoroutine: null,
  132. afterSelectCardCoroutine: null,
  133. mode: SelectHandEffect.Mode.Discard,
  134. cardEffect: activateClass);
  135. yield return StartCoroutine(selectHandEffect.Activate());
  136. }
  137. }
  138. }
  139. #endregion
  140. #region Inherit
  141. if (timing == EffectTiming.OnAllyAttack)
  142. {
  143. ActivateClass activateClass = new ActivateClass();
  144. activateClass.SetUpICardEffect("Your opponent trashes 1 card/Play 1 level 3 purple Digimon from your trash.", CanUseCondition, card);
  145. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  146. activateClass.SetHashString("TrashOrPlay_EX6_050");
  147. activateClass.SetIsInheritedEffect(true);
  148. cardEffects.Add(activateClass);
  149. string EffectDiscription()
  150. {
  151. return "[When Attacking] [Once Per Turn] Your opponent may trash 1 card in their hand. If they don't, you may play 1 purple level 3 Digimon card from your trash without paying the cost.";
  152. }
  153. bool CanSelectCardInTrash(CardSource cardSource)
  154. {
  155. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  156. {
  157. if (cardSource.HasCardColor(CardColor.Purple))
  158. {
  159. if (cardSource.IsDigimon)
  160. {
  161. if (cardSource.Level == 3)
  162. {
  163. if (cardSource.HasLevel)
  164. {
  165. return true;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. return false;
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. if (CardEffectCommons.IsExistOnBattleArea(card))
  180. {
  181. if (card.Owner.TrashCards.Count >= 1)
  182. {
  183. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  184. {
  185. return true;
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. bool discarded = false;
  194. if (card.Owner.Enemy.HandCards.Count >= 1)
  195. {
  196. int discardCount = 1;
  197. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  198. selectHandEffect.SetUp(
  199. selectPlayer: card.Owner.Enemy,
  200. canTargetCondition: (cardSource) => true,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: discardCount,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. isShowOpponent: true,
  207. selectCardCoroutine: null,
  208. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  209. mode: SelectHandEffect.Mode.Discard,
  210. cardEffect: activateClass);
  211. yield return StartCoroutine(selectHandEffect.Activate());
  212. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  213. {
  214. if (cardSources.Count >= 1)
  215. {
  216. discarded = true;
  217. yield return null;
  218. }
  219. }
  220. }
  221. if (!discarded)
  222. {
  223. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  224. {
  225. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  226. List<CardSource> selectedCards = new List<CardSource>();
  227. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  228. selectCardEffect.SetUp(
  229. canTargetCondition: CanSelectCardInTrash,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. canNoSelect: () => true,
  233. selectCardCoroutine: SelectCardCoroutine,
  234. afterSelectCardCoroutine: null,
  235. message: "Select 1 card to play.",
  236. maxCount: maxCount,
  237. canEndNotMax: false,
  238. isShowOpponent: true,
  239. mode: SelectCardEffect.Mode.Custom,
  240. root: SelectCardEffect.Root.Trash,
  241. customRootCardList: null,
  242. canLookReverseCard: true,
  243. selectPlayer: card.Owner,
  244. cardEffect: activateClass);
  245. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  246. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  247. yield return StartCoroutine(selectCardEffect.Activate());
  248. IEnumerator SelectCardCoroutine(CardSource cardSource)
  249. {
  250. selectedCards.Add(cardSource);
  251. yield return null;
  252. }
  253. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  254. cardSources: selectedCards,
  255. activateClass: activateClass,
  256. payCost: false,
  257. isTapped: false,
  258. root: SelectCardEffect.Root.Trash,
  259. activateETB: true));
  260. }
  261. }
  262. }
  263. }
  264. #endregion
  265. return cardEffects;
  266. }
  267. }
  268. }