BT17_076.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_076 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5)
  18. return targetPermanent.TopCard.EqualsCardName("Eosmon");
  19. return false;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 4,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region When Digivolving
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Play 1 Level 5 or lower Eosmon", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  35. activateClass.SetHashString("Play_BT17_076");
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] [Once Per Turn] You may play 1 level 5 or lower [Eosmon] from your hand without paying the cost.";
  40. }
  41. bool HasProperEosmon(CardSource source)
  42. {
  43. if (source.HasLevel && source.Level <= 5)
  44. {
  45. if (source.EqualsCardName("Eosmon"))
  46. {
  47. return CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  55. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasProperEosmon))
  64. {
  65. int maxCount = Math.Min(1, card.Owner.HandCards.Count(HasProperEosmon));
  66. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  67. selectHandEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: HasProperEosmon,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: false,
  75. isShowOpponent: false,
  76. selectCardCoroutine: null,
  77. afterSelectCardCoroutine: SelectCardCoroutine,
  78. mode: SelectHandEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectHandEffect.SetUpCustomMessage("Select [Eosmon] to play.", "The opponent is selecting an [Eosmon] to play.");
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator SelectCardCoroutine(List<CardSource> selectedCards)
  83. {
  84. if (selectedCards.Count > 0)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  87. cardSources: selectedCards,
  88. activateClass: activateClass,
  89. payCost: false,
  90. isTapped: false,
  91. root: SelectCardEffect.Root.Hand,
  92. activateETB: true));
  93. }
  94. }
  95. }
  96. }
  97. }
  98. #endregion
  99. #region When Attacking
  100. if (timing == EffectTiming.OnAllyAttack)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect("Play 1 Level 5 or lower Eosmon", CanUseCondition, card);
  104. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  105. activateClass.SetHashString("Play_BT17_076");
  106. cardEffects.Add(activateClass);
  107. string EffectDiscription()
  108. {
  109. return "[When Attacking] [Once Per Turn] You may play 1 level 5 or lower [Eosmon] from your hand without paying the cost.";
  110. }
  111. bool HasProperEosmon(CardSource source)
  112. {
  113. if (source.HasLevel && source.Level <= 5)
  114. {
  115. if (source.EqualsCardName("Eosmon"))
  116. {
  117. return CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  125. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasProperEosmon))
  134. {
  135. int maxCount = Math.Min(1, card.Owner.HandCards.Count(HasProperEosmon));
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: HasProperEosmon,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. isShowOpponent: false,
  146. selectCardCoroutine: null,
  147. afterSelectCardCoroutine: SelectCardCoroutine,
  148. mode: SelectHandEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectHandEffect.SetUpCustomMessage("Select [Eosmon] to play.", "The opponent is selecting an [Eosmon] to play.");
  151. yield return StartCoroutine(selectHandEffect.Activate());
  152. IEnumerator SelectCardCoroutine(List<CardSource> selectedCards)
  153. {
  154. if (selectedCards.Count > 0)
  155. {
  156. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  157. cardSources: selectedCards,
  158. activateClass: activateClass,
  159. payCost: false,
  160. isTapped: false,
  161. root: SelectCardEffect.Root.Hand,
  162. activateETB: true));
  163. }
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. #region All Turns - When [Eosmon] is played
  170. if (timing == EffectTiming.OnEnterFieldAnyone)
  171. {
  172. List<Permanent> playedPermanents = null;
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Delete opponents Digimon", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  176. activateClass.SetHashString("Delete_BT17_076");
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[All Turns] [Once Per Turn] When one of your [Eosmon] is played, delete 1 of your opponent's Digimon with as much or less DP as that Digimon.";
  181. }
  182. bool IsEosmon(Permanent permanent)
  183. {
  184. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  185. return permanent.TopCard.EqualsCardName("Eosmon");
  186. return false;
  187. }
  188. bool IsOpponentsDigimon(Permanent permanent)
  189. {
  190. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  191. {
  192. foreach(Permanent played in playedPermanents)
  193. {
  194. if(played.DP >= permanent.DP)
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsEosmon)
  203. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  208. }
  209. IEnumerator ActivateCoroutine(Hashtable hashtable)
  210. {
  211. playedPermanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(hashtable, null);
  212. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  213. {
  214. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  215. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  216. selectPermanentEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: IsOpponentsDigimon,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: maxCount,
  222. canNoSelect: false,
  223. canEndNotMax: false,
  224. selectPermanentCoroutine: null,
  225. afterSelectPermanentCoroutine: null,
  226. mode: SelectPermanentEffect.Mode.Destroy,
  227. cardEffect: activateClass);
  228. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to destroy.", "The opponent is selecting 1 Digimon to destroy.");
  229. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  230. }
  231. }
  232. }
  233. #endregion
  234. #region All Turns - +1000DP
  235. if (timing == EffectTiming.None)
  236. {
  237. bool Condition()
  238. {
  239. if(CardEffectCommons.IsOwnerTurn(card))
  240. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  241. return false;
  242. }
  243. bool PermanentCondition(Permanent permanent)
  244. {
  245. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  246. {
  247. if (permanent.TopCard.EqualsCardName("Eosmon"))
  248. return true;
  249. }
  250. return false;
  251. }
  252. bool IsTamer(Permanent permanent)
  253. {
  254. return permanent.IsTamer;
  255. }
  256. int DPIncrease()
  257. {
  258. return CardEffectCommons.MatchConditionPermanentCount(IsTamer) * 1000;
  259. }
  260. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  261. permanentCondition: PermanentCondition,
  262. changeValue: DPIncrease(),
  263. isInheritedEffect: false,
  264. card: card,
  265. condition: Condition,
  266. effectName: () => "[Your Turn] For each Tamer, all of your [Eosmon] get +1000 DP."));
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. }
  272. }