BT12_064.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT12
  5. {
  6. public class BT12_064 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasSaveText && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("De-Digivolve 1 on 1 Digimon", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[When Digivolving] <De-Digivolve 1> on 1 of your opponent's level 5 or lower Digimon. For every 2 cards in this Digimon's digivolution cards, add 1 to the max level of the Digimon you can choose with this effect.";
  28. }
  29. bool CanSelectPermanentCondition(Permanent permanent)
  30. {
  31. if (permanent != null)
  32. {
  33. if (permanent.TopCard != null)
  34. {
  35. if (permanent.IsDigimon)
  36. {
  37. if (permanent.TopCard.Owner == card.Owner.Enemy)
  38. {
  39. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  40. {
  41. if (permanent.TopCard.HasLevel)
  42. {
  43. int maxLevel = 5;
  44. if (isExistOnField(card))
  45. {
  46. maxLevel += card.PermanentOfThisCard().DigivolutionCards.Count / 2;
  47. }
  48. if (permanent.Level <= maxLevel)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (isExistOnField(card))
  78. {
  79. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  80. {
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  82. {
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectPermanentCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: CanEndSelectCondition,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. bool CanEndSelectCondition(List<Permanent> permanents)
  100. {
  101. if (permanents.Count <= 0)
  102. {
  103. return false;
  104. }
  105. return true;
  106. }
  107. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  108. {
  109. Permanent selectedPermanent = permanent;
  110. if (selectedPermanent != null)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  113. }
  114. yield return null;
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. if (timing == EffectTiming.OnDestroyedAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("Save and place 1 card under your 1 Tamer from trash", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[On Deletion] <Save>. Then, place 1 Digimon card with <Save> in its text from your trash under 1 of your Tamers.";
  130. }
  131. bool CanSelectPermanentCondition(Permanent permanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  134. {
  135. if (permanent.IsTamer)
  136. {
  137. if (!permanent.IsToken)
  138. {
  139. return true;
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanSelectCardCondition1(CardSource cardSource)
  146. {
  147. if (cardSource != null)
  148. {
  149. if (cardSource.Owner == card.Owner)
  150. {
  151. if (cardSource.HasSaveText)
  152. {
  153. if (cardSource.IsDigimon)
  154. {
  155. return true;
  156. }
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanUseCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanActivateSave(hashtable, CanSelectPermanentCondition);
  169. }
  170. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SaveProcess(_hashtable, activateClass, card, CanSelectPermanentCondition));
  173. List<CardSource> selectedCards = new List<CardSource>();
  174. int maxCount = 1;
  175. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  176. selectCardEffect.SetUp(
  177. canTargetCondition: CanSelectCardCondition1,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. canNoSelect: () => false,
  181. selectCardCoroutine: SelectCardCoroutine,
  182. afterSelectCardCoroutine: null,
  183. message: "Select 1 card to place at the bottom of digivolution cards.",
  184. maxCount: maxCount,
  185. canEndNotMax: false,
  186. isShowOpponent: true,
  187. mode: SelectCardEffect.Mode.Custom,
  188. root: SelectCardEffect.Root.Trash,
  189. customRootCardList: null,
  190. canLookReverseCard: true,
  191. selectPlayer: card.Owner,
  192. cardEffect: activateClass);
  193. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  194. yield return StartCoroutine(selectCardEffect.Activate());
  195. IEnumerator SelectCardCoroutine(CardSource cardSource)
  196. {
  197. selectedCards.Add(cardSource);
  198. yield return null;
  199. }
  200. if (selectedCards.Count >= 1)
  201. {
  202. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  203. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  204. selectPermanentEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: CanSelectPermanentCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: maxCount,
  210. canNoSelect: false,
  211. canEndNotMax: false,
  212. selectPermanentCoroutine: SelectPermanentCoroutine,
  213. afterSelectPermanentCoroutine: null,
  214. mode: SelectPermanentEffect.Mode.Custom,
  215. cardEffect: activateClass);
  216. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that will get a digivolution card.", "The opponent is selecting 1 Tamer that will get a digivolution card.");
  217. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  218. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  219. {
  220. Permanent selectedPermanent = permanent;
  221. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  222. }
  223. }
  224. }
  225. }
  226. if (timing == EffectTiming.None)
  227. {
  228. bool Condition()
  229. {
  230. if (CardEffectCommons.IsExistOnBattleArea(card))
  231. {
  232. if (CardEffectCommons.IsOpponentTurn(card))
  233. {
  234. if (card.PermanentOfThisCard().TopCard.HasSaveText)
  235. {
  236. return true;
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  243. }
  244. return cardEffects;
  245. }
  246. }
  247. }