P_101.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. public class P_101 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] By trashing 1 card from your hand, <Draw 2> (Draw 2 cards from your deck).";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. return true;
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (card.Owner.HandCards.Count >= 1)
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  45. {
  46. bool discarded = false;
  47. int discardCount = 1;
  48. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  49. selectHandEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: CanSelectCardCondition,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: discardCount,
  55. canNoSelect: true,
  56. canEndNotMax: false,
  57. isShowOpponent: true,
  58. selectCardCoroutine: null,
  59. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  60. mode: SelectHandEffect.Mode.Discard,
  61. cardEffect: activateClass);
  62. yield return StartCoroutine(selectHandEffect.Activate());
  63. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  64. {
  65. if (cardSources.Count >= 1)
  66. {
  67. discarded = true;
  68. yield return null;
  69. }
  70. }
  71. if (discarded)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  74. }
  75. }
  76. }
  77. }
  78. if (timing == EffectTiming.OnEnterFieldAnyone)
  79. {
  80. ActivateClass activateClass = new ActivateClass();
  81. activateClass.SetUpICardEffect("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  82. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[When Digivolving] By trashing 1 card from your hand, <Draw 2> (Draw 2 cards from your deck).";
  87. }
  88. bool CanSelectCardCondition(CardSource cardSource)
  89. {
  90. return true;
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  95. }
  96. bool CanActivateCondition(Hashtable hashtable)
  97. {
  98. if (CardEffectCommons.IsExistOnBattleArea(card))
  99. {
  100. if (card.Owner.HandCards.Count >= 1)
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  108. {
  109. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  110. {
  111. bool discarded = false;
  112. int discardCount = 1;
  113. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  114. selectHandEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectCardCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: discardCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. isShowOpponent: true,
  123. selectCardCoroutine: null,
  124. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  125. mode: SelectHandEffect.Mode.Discard,
  126. cardEffect: activateClass);
  127. yield return StartCoroutine(selectHandEffect.Activate());
  128. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  129. {
  130. if (cardSources.Count >= 1)
  131. {
  132. discarded = true;
  133. yield return null;
  134. }
  135. }
  136. if (discarded)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  139. }
  140. }
  141. }
  142. }
  143. if (timing == EffectTiming.OnAllyAttack)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 level 3 Digimon", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  148. activateClass.SetIsInheritedEffect(true);
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[When Attacking] By trashing 1 card from your hand, delete 1 of your opponent's level 3 Digimon.";
  153. }
  154. bool CanSelectPermanentCondition(Permanent permanent)
  155. {
  156. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  157. {
  158. if (permanent.Level == 3)
  159. {
  160. if (permanent.TopCard.HasLevel)
  161. {
  162. return true;
  163. }
  164. }
  165. }
  166. return false;
  167. }
  168. bool CanUseCondition(Hashtable hashtable)
  169. {
  170. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  171. }
  172. bool CanActivateCondition(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleArea(card))
  175. {
  176. if (card.Owner.HandCards.Count >= 1)
  177. {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. if (card.Owner.HandCards.Count >= 1)
  186. {
  187. bool discarded = false;
  188. int discardCount = 1;
  189. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  190. selectHandEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: (cardSource) => true,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: discardCount,
  196. canNoSelect: true,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. selectCardCoroutine: null,
  200. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  201. mode: SelectHandEffect.Mode.Discard,
  202. cardEffect: activateClass);
  203. yield return StartCoroutine(selectHandEffect.Activate());
  204. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  205. {
  206. if (cardSources.Count >= 1)
  207. {
  208. discarded = true;
  209. yield return null;
  210. }
  211. }
  212. if (discarded)
  213. {
  214. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  215. {
  216. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  217. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  218. selectPermanentEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: CanSelectPermanentCondition,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: maxCount,
  224. canNoSelect: false,
  225. canEndNotMax: false,
  226. selectPermanentCoroutine: null,
  227. afterSelectPermanentCoroutine: null,
  228. mode: SelectPermanentEffect.Mode.Destroy,
  229. cardEffect: activateClass);
  230. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  231. }
  232. }
  233. }
  234. }
  235. }
  236. return cardEffects;
  237. }
  238. }