EX6_059.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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_059 : 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. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Trash 1 card in your opponent's hand", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Trash 1 card in your opponent's hand without looking.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  39. {
  40. if(card.Owner.Enemy.HandCards.Count >= 1)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. if (card.Owner.isYou)
  50. {
  51. foreach (CardSource cardSource in card.Owner.Enemy.HandCards)
  52. {
  53. cardSource.SetReverse();
  54. }
  55. }
  56. card.Owner.Enemy.HandCards = RandomUtility.ShuffledDeckCards(card.Owner.Enemy.HandCards);
  57. List<CardSource> selectedCards = new List<CardSource>();
  58. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  59. selectCardEffect.SetUp(
  60. canTargetCondition: (cardSource) => true,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. canNoSelect: () => false,
  64. selectCardCoroutine: null,
  65. afterSelectCardCoroutine: null,
  66. message: "Select 1 card in your opponent's hand to trash.",
  67. maxCount: 1,
  68. canEndNotMax: false,
  69. isShowOpponent: false,
  70. mode: SelectCardEffect.Mode.Discard,
  71. root: SelectCardEffect.Root.Custom,
  72. customRootCardList: card.Owner.Enemy.HandCards,
  73. canLookReverseCard: false,
  74. selectPlayer: card.Owner,
  75. cardEffect: activateClass);
  76. selectCardEffect.SetNotShowCard();
  77. selectCardEffect.SetUseFaceDown();
  78. if (card.Owner.isYou)
  79. {
  80. selectCardEffect.SetNotAddLog();
  81. }
  82. selectCardEffect.SetUpCustomMessage(
  83. "Select 1 card to trash.",
  84. "The opponent is selecting 1 card to trash.");
  85. yield return StartCoroutine(selectCardEffect.Activate());
  86. }
  87. }
  88. #endregion
  89. #region When Digivolving
  90. if (timing == EffectTiming.OnEnterFieldAnyone)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Trash 1 card in your opponent's hand", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  95. cardEffects.Add(activateClass);
  96. string EffectDiscription()
  97. {
  98. return "[When Digivolving] Trash 1 card in your opponent's hand without looking.";
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  107. {
  108. if (card.Owner.Enemy.HandCards.Count >= 1)
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. if (card.Owner.isYou)
  118. {
  119. foreach (CardSource cardSource in card.Owner.Enemy.HandCards)
  120. {
  121. cardSource.SetReverse();
  122. }
  123. }
  124. card.Owner.Enemy.HandCards = RandomUtility.ShuffledDeckCards(card.Owner.Enemy.HandCards);
  125. List<CardSource> selectedCards = new List<CardSource>();
  126. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  127. selectCardEffect.SetUp(
  128. canTargetCondition: (cardSource) => true,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: () => false,
  132. selectCardCoroutine: null,
  133. afterSelectCardCoroutine: null,
  134. message: "Select 1 card in your opponent's hand to trash.",
  135. maxCount: 1,
  136. canEndNotMax: false,
  137. isShowOpponent: false,
  138. mode: SelectCardEffect.Mode.Discard,
  139. root: SelectCardEffect.Root.Custom,
  140. customRootCardList: card.Owner.Enemy.HandCards,
  141. canLookReverseCard: false,
  142. selectPlayer: card.Owner,
  143. cardEffect: activateClass);
  144. selectCardEffect.SetNotShowCard();
  145. selectCardEffect.SetUseFaceDown();
  146. if (card.Owner.isYou)
  147. {
  148. selectCardEffect.SetNotAddLog();
  149. }
  150. selectCardEffect.SetUpCustomMessage(
  151. "Select 1 card to trash.",
  152. "The opponent is selecting 1 card to trash.");
  153. yield return StartCoroutine(selectCardEffect.Activate());
  154. }
  155. }
  156. #endregion
  157. #region All Turns
  158. if (timing == EffectTiming.OnDiscardHand)
  159. {
  160. ActivateClass activateClass = new ActivateClass();
  161. activateClass.SetUpICardEffect("Play 1 purple card with a play cost of 10 or less from your trash", CanUseCondition, card);
  162. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  163. activateClass.SetHashString("PlayFromTrash_059");
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. {
  167. return "[All Turns] [Once Per Turn] When a card is trashed from your opponent's hand, you may play 1 purple card with a play cost of 10 or less from your trash without paying the cost. For each card in your opponent's hand, reduce this effect's play cost maximum by 1.";
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  172. {
  173. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, cardEffect => true, cardSource => cardSource.Owner == card.Owner.Enemy))
  174. {
  175. return true;
  176. }
  177. }
  178. return false;
  179. }
  180. bool CanSelectCardInTrash(CardSource cardSource)
  181. {
  182. int maxCost = 10 - card.Owner.Enemy.HandCards.Count();
  183. if(cardSource.IsDigimon || cardSource.IsTamer)
  184. {
  185. if (cardSource.HasCardColor(CardColor.Purple))
  186. {
  187. if (cardSource.GetCostItself <= maxCost)
  188. {
  189. return true;
  190. }
  191. }
  192. }
  193. return false;
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  198. }
  199. IEnumerator ActivateCoroutine(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  202. {
  203. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  206. selectCardEffect.SetUp(
  207. canTargetCondition: CanSelectCardInTrash,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. canNoSelect: () => true,
  211. selectCardCoroutine: SelectCardCoroutine,
  212. afterSelectCardCoroutine: null,
  213. message: "Select 1 card to play.",
  214. maxCount: maxCount,
  215. canEndNotMax: false,
  216. isShowOpponent: true,
  217. mode: SelectCardEffect.Mode.Custom,
  218. root: SelectCardEffect.Root.Trash,
  219. customRootCardList: null,
  220. canLookReverseCard: true,
  221. selectPlayer: card.Owner,
  222. cardEffect: activateClass);
  223. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  224. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  225. yield return StartCoroutine(selectCardEffect.Activate());
  226. IEnumerator SelectCardCoroutine(CardSource cardSource)
  227. {
  228. selectedCards.Add(cardSource);
  229. yield return null;
  230. }
  231. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  232. cardSources: selectedCards,
  233. activateClass: activateClass,
  234. payCost: false,
  235. isTapped: false,
  236. root: SelectCardEffect.Root.Trash,
  237. activateETB: true));
  238. }
  239. }
  240. }
  241. #endregion
  242. return cardEffects;
  243. }
  244. }
  245. }