EX5_033.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 EX5_033 : 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 the top card of your security to play 1 Digimon from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  18. activateClass.SetHashString("PlayDigimon_EX5_033");
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[When Digivolving] [Once Per Turn] By trashing the top card of your security stack, you may play 1 yellow level 4 or lower card from your hand without paying the cost. Any Digimon played by this effect gain <Rush> (This Digimon can attack the turn it comes into play), for the turn.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (cardSource.HasCardColor(CardColor.Yellow))
  27. {
  28. if (cardSource.Level <= 4)
  29. {
  30. if (cardSource.HasLevel)
  31. {
  32. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (card.Owner.SecurityCards.Count >= 1)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  59. player: card.Owner,
  60. destroySecurityCount: 1,
  61. cardEffect: activateClass,
  62. fromTop: true).DestroySecurity());
  63. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  64. {
  65. List<CardSource> selectedCards = new List<CardSource>();
  66. int maxCount = 1;
  67. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  68. selectHandEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectCardCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: true,
  75. canEndNotMax: false,
  76. isShowOpponent: true,
  77. selectCardCoroutine: SelectCardCoroutine,
  78. afterSelectCardCoroutine: null,
  79. mode: SelectHandEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  82. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  83. yield return StartCoroutine(selectHandEffect.Activate());
  84. IEnumerator SelectCardCoroutine(CardSource cardSource)
  85. {
  86. selectedCards.Add(cardSource);
  87. yield return null;
  88. }
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  90. cardSources: selectedCards,
  91. activateClass: activateClass,
  92. payCost: false,
  93. isTapped: false,
  94. root: SelectCardEffect.Root.Hand,
  95. activateETB: true));
  96. foreach (CardSource cardSource in selectedCards)
  97. {
  98. Permanent permanent = cardSource.PermanentOfThisCard();
  99. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  100. targetPermanent: permanent,
  101. effectDuration: EffectDuration.UntilEachTurnEnd,
  102. activateClass: activateClass));
  103. }
  104. }
  105. }
  106. }
  107. if (timing == EffectTiming.OnAllyAttack)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Trash the top card of your security to play 1 Digimon from hand", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  112. activateClass.SetHashString("PlayDigimon_EX5_033");
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[When Attacking] [Once Per Turn] By trashing the top card of your security stack, you may play 1 yellow level 4 or lower card from your hand without paying the cost. Any Digimon played by this effect gain <Rush> (This Digimon can attack the turn it comes into play), for the turn.";
  117. }
  118. bool CanSelectCardCondition(CardSource cardSource)
  119. {
  120. if (cardSource.HasCardColor(CardColor.Yellow))
  121. {
  122. if (cardSource.Level <= 4)
  123. {
  124. if (cardSource.HasLevel)
  125. {
  126. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  127. {
  128. return true;
  129. }
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  138. }
  139. bool CanActivateCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (card.Owner.SecurityCards.Count >= 1)
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  153. player: card.Owner,
  154. destroySecurityCount: 1,
  155. cardEffect: activateClass,
  156. fromTop: true).DestroySecurity());
  157. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  158. {
  159. List<CardSource> selectedCards = new List<CardSource>();
  160. int maxCount = 1;
  161. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  162. selectHandEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: CanSelectCardCondition,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: maxCount,
  168. canNoSelect: true,
  169. canEndNotMax: false,
  170. isShowOpponent: true,
  171. selectCardCoroutine: SelectCardCoroutine,
  172. afterSelectCardCoroutine: null,
  173. mode: SelectHandEffect.Mode.Custom,
  174. cardEffect: activateClass);
  175. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  176. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  177. yield return StartCoroutine(selectHandEffect.Activate());
  178. IEnumerator SelectCardCoroutine(CardSource cardSource)
  179. {
  180. selectedCards.Add(cardSource);
  181. yield return null;
  182. }
  183. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  184. cardSources: selectedCards,
  185. activateClass: activateClass,
  186. payCost: false,
  187. isTapped: false,
  188. root: SelectCardEffect.Root.Hand,
  189. activateETB: true));
  190. foreach (CardSource cardSource in selectedCards)
  191. {
  192. Permanent permanent = cardSource.PermanentOfThisCard();
  193. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  194. targetPermanent: permanent,
  195. effectDuration: EffectDuration.UntilEachTurnEnd,
  196. activateClass: activateClass));
  197. }
  198. }
  199. }
  200. }
  201. if (timing == EffectTiming.None)
  202. {
  203. AddSkillClass addSkillClass = new AddSkillClass();
  204. addSkillClass.SetUpICardEffect("Your yellow Digimon gain Barrier", CanUseCondition, card);
  205. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  206. cardEffects.Add(addSkillClass);
  207. bool CanUseCondition(Hashtable hashtable)
  208. {
  209. if (CardEffectCommons.IsExistOnBattleArea(card))
  210. {
  211. return true;
  212. }
  213. return false;
  214. }
  215. bool PermanentCondition(Permanent permanent)
  216. {
  217. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  218. {
  219. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. bool CardSourceCondition(CardSource cardSource)
  227. {
  228. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  229. {
  230. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  231. {
  232. return true;
  233. }
  234. }
  235. return false;
  236. }
  237. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  238. {
  239. if (_timing == EffectTiming.WhenPermanentWouldBeDeleted)
  240. {
  241. bool Condition()
  242. {
  243. return CardSourceCondition(cardSource);
  244. }
  245. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: cardSource, condition: Condition));
  246. }
  247. return cardEffects;
  248. }
  249. }
  250. if (timing == EffectTiming.None)
  251. {
  252. bool Condition()
  253. {
  254. if (CardEffectCommons.IsExistOnBattleArea(card))
  255. {
  256. if (CardEffectCommons.IsOpponentTurn(card))
  257. {
  258. return true;
  259. }
  260. }
  261. return false;
  262. }
  263. bool PermanentCondition(Permanent permanent)
  264. {
  265. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  266. {
  267. if (permanent.Level >= card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count)
  268. {
  269. if (permanent.TopCard.HasLevel)
  270. {
  271. return true;
  272. }
  273. }
  274. }
  275. return false;
  276. }
  277. cardEffects.Add(CardEffectFactory.ChangeSAttackStaticEffect(
  278. permanentCondition: PermanentCondition,
  279. changeValue: -2,
  280. isInheritedEffect: false,
  281. card: card,
  282. condition: Condition));
  283. }
  284. return cardEffects;
  285. }
  286. }