BT17_084.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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_084 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Turn
  13. if (timing == EffectTiming.OnStartTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  16. }
  17. #endregion
  18. #region All Turns
  19. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Play level 4 or lower Digimon card from digivolution cards of deleted Digimon",
  23. CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  25. activateClass.SetHashString("PlaySource_BT17_084");
  26. cardEffects.Add(activateClass);
  27. string EffectDescription()
  28. {
  29. return
  30. "[All Turns] When one of your level 5 or higher Digimon with the [Free] trait would be deleted in battle, by suspending this Tamer, you may play 1 level 4 or lower Digimon card from that Digimon's digivolution cards without paying the cost.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleArea(card))
  35. {
  36. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition))
  37. {
  38. if (CardEffectCommons.IsByBattle(hashtable))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool IsOwnerPermanentCondition(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  49. permanent.Level >= 5 &&
  50. permanent.TopCard.ContainsTraits("Free") &&
  51. permanent.DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1;
  52. }
  53. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  54. {
  55. return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField;
  56. }
  57. bool CanSelectSourceCardCondition(CardSource cardSource)
  58. {
  59. return cardSource.IsDigimon && cardSource.Level <= 4;
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleArea(card))
  64. {
  65. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  66. {
  67. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwnerPermanentCondition);
  68. }
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable hashtable)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(
  75. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  76. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  77. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  78. {
  79. int maxCount = Math.Min(1,
  80. CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
  81. SelectPermanentEffect selectPermanentEffect =
  82. GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage(
  96. "Select 1 Digimon which has digivolution cards.",
  97. "The opponent is selecting 1 Digimon which has digivolution cards.");
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  100. {
  101. if (permanent != null)
  102. {
  103. if (permanent.DigivolutionCards.Count(CanSelectSourceCardCondition) >= 1)
  104. {
  105. maxCount = Math.Min(1,
  106. permanent.DigivolutionCards.Count(CanSelectSourceCardCondition));
  107. List<CardSource> selectedCards = new List<CardSource>();
  108. SelectCardEffect selectCardEffect =
  109. GManager.instance.GetComponent<SelectCardEffect>();
  110. selectCardEffect.SetUp(
  111. canTargetCondition: CanSelectSourceCardCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. canNoSelect: () => true,
  115. selectCardCoroutine: SelectCardCoroutine,
  116. afterSelectCardCoroutine: null,
  117. message: "Select 1 digivolution card to play.",
  118. maxCount: maxCount,
  119. canEndNotMax: false,
  120. isShowOpponent: true,
  121. mode: SelectCardEffect.Mode.Custom,
  122. root: SelectCardEffect.Root.Custom,
  123. customRootCardList: permanent.DigivolutionCards,
  124. canLookReverseCard: true,
  125. selectPlayer: card.Owner,
  126. cardEffect: activateClass);
  127. selectCardEffect.SetUpCustomMessage(
  128. "Select 1 digivolution card to play.",
  129. "The opponent is selecting 1 digivolution card to play.");
  130. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  131. yield return StartCoroutine(selectCardEffect.Activate());
  132. IEnumerator SelectCardCoroutine(CardSource cardSource)
  133. {
  134. selectedCards.Add(cardSource);
  135. yield return null;
  136. }
  137. yield return ContinuousController.instance.StartCoroutine(
  138. CardEffectCommons.PlayPermanentCards(
  139. cardSources: selectedCards,
  140. activateClass: activateClass,
  141. payCost: false,
  142. isTapped: false,
  143. root: SelectCardEffect.Root.DigivolutionCards,
  144. activateETB: true));
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. #region End of Your Turn
  153. if (timing == EffectTiming.OnEndTurn)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("1 of your Digimon with the [Free] trait can attack a Digimon", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  158. activateClass.SetHashString("Attack_BT17_084");
  159. cardEffects.Add(activateClass);
  160. string EffectDescription()
  161. {
  162. return
  163. "[End of Your Turn] 1 of your Digimon with the [Free] trait may attack an opponent's Digimon.";
  164. }
  165. bool IsFreePermanentCondition(Permanent permanent)
  166. {
  167. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  168. {
  169. if (permanent.TopCard.ContainsTraits("Free"))
  170. {
  171. return permanent.CanAttack(activateClass);
  172. }
  173. }
  174. return false;
  175. }
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. if (CardEffectCommons.IsExistOnBattleArea(card))
  179. {
  180. if (CardEffectCommons.IsOwnerTurn(card))
  181. {
  182. return true;
  183. }
  184. }
  185. return false;
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.IsExistOnBattleArea(card))
  190. {
  191. if (CardEffectCommons.HasMatchConditionPermanent(IsFreePermanentCondition))
  192. {
  193. return true;
  194. }
  195. }
  196. return false;
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. if (CardEffectCommons.HasMatchConditionPermanent(IsFreePermanentCondition))
  201. {
  202. Permanent selectedPermanent = null;
  203. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsFreePermanentCondition));
  204. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  205. selectPermanentEffect.SetUp(
  206. selectPlayer: card.Owner,
  207. canTargetCondition: IsFreePermanentCondition,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. maxCount: maxCount,
  211. canNoSelect: false,
  212. canEndNotMax: false,
  213. selectPermanentCoroutine: SelectPermanentCoroutine,
  214. afterSelectPermanentCoroutine: null,
  215. mode: SelectPermanentEffect.Mode.Custom,
  216. cardEffect: activateClass);
  217. selectPermanentEffect.SetUpCustomMessage(
  218. "Select 1 Digimon that will attack.",
  219. "The opponent is selecting 1 Digimon that will attack.");
  220. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  221. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  222. {
  223. selectedPermanent = permanent;
  224. yield return null;
  225. }
  226. if (selectedPermanent != null)
  227. {
  228. if (selectedPermanent.CanAttack(activateClass))
  229. {
  230. if (selectedPermanent.CanAttackTargetDigimon(null, activateClass))
  231. {
  232. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  233. selectAttackEffect.SetUp(
  234. attacker: selectedPermanent,
  235. canAttackPlayerCondition: () => false,
  236. defenderCondition: _ => true,
  237. cardEffect: activateClass);
  238. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region Security Effect
  247. if (timing == EffectTiming.SecuritySkill)
  248. {
  249. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  250. }
  251. #endregion
  252. return cardEffects;
  253. }
  254. }
  255. }