BT12_083.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT12
  4. {
  5. public class BT12_083 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.HasSaveText && (targetPermanent.TopCard.CardColors.Contains(CardColor.Red) || targetPermanent.TopCard.CardColors.Contains(CardColor.Black) || targetPermanent.TopCard.CardColors.Contains(CardColor.Purple)) && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  15. }
  16. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  17. permanentCondition: PermanentCondition,
  18. digivolutionCost: 4,
  19. ignoreDigivolutionRequirement: false,
  20. card: card,
  21. condition: null));
  22. }
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Place 1 Digimon under other Digimon or Tamer as its bottom digivolution card.", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[When Digivolving] Place one of your opponent's level 3 or lower Digimon under another of your opponent's Digimon as its bottom digivolution card or under an opponent's Tamer. Add 1 to the max level of the Digimon you can choose with this effect for each differently colored Tamer you have in play.";
  32. }
  33. int maxLevel()
  34. {
  35. int maxLevel = 3;
  36. List<CardSource> tamerCards = new List<CardSource>();
  37. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  38. {
  39. if (permanent.IsTamer)
  40. {
  41. tamerCards.Add(permanent.TopCard);
  42. }
  43. }
  44. int tamersCount = Combinations.GetUniqueColorCardCount(tamerCards);
  45. return maxLevel + tamersCount;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (card.Owner.Enemy.GetBattleAreaPermanents().Count >= 2)
  56. {
  57. int _maxLevel = maxLevel();
  58. bool CanSelectPermanentCondition(Permanent permanent)
  59. {
  60. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  61. {
  62. if (permanent.Level <= _maxLevel)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (card.Owner.Enemy.GetBattleAreaPermanents().Count >= 2)
  80. {
  81. int _maxLevel = maxLevel();
  82. bool CanSelectPermanentCondition(Permanent permanent)
  83. {
  84. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  85. {
  86. if (permanent.Level <= _maxLevel)
  87. {
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  94. {
  95. Permanent selectedPermanent = null;
  96. int maxCount = 1;
  97. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  98. selectPermanentEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: CanSelectPermanentCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: maxCount,
  104. canNoSelect: false,
  105. canEndNotMax: false,
  106. selectPermanentCoroutine: SelectPermanentCoroutine,
  107. afterSelectPermanentCoroutine: null,
  108. mode: SelectPermanentEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. selectPermanentEffect.SetUpCustomMessage(
  111. "Select 1 Digimon that place under other Digimon or Tamer's digivolution cards.",
  112. "The opponent is selecting 1 Digimon that place under other Digimon or Tamer's digivolution cards.");
  113. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  114. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  115. {
  116. selectedPermanent = permanent;
  117. yield return null;
  118. }
  119. if (selectedPermanent != null)
  120. {
  121. bool CanSelectPermanentCondition1(Permanent permanent)
  122. {
  123. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  124. {
  125. if (permanent.IsDigimon || permanent.IsTamer)
  126. {
  127. if (permanent != selectedPermanent)
  128. {
  129. if (!permanent.IsToken)
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. maxCount = 1;
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition1,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectPermanentCoroutine1,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage(
  152. "Select 1 Digimon or Tamer that will get digivolution cards.",
  153. "The opponent is selecting 1 Digimon or Tamer that will get digivolution cards.");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  158. new List<Permanent[]>() { new Permanent[] { selectedPermanent, permanent } },
  159. false,
  160. activateClass).PlacePermanentToDigivolutionCards());
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. if (timing == EffectTiming.OnEndTurn)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Attack with this Digimon without suspending", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  172. activateClass.SetHashString("Attack_BT12_083");
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[End of Your Turn][Once Per Turn] If there are 4 or more digivolution cards under this Digimon, you may attack with this Digimon without suspending it.";
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. if (CardEffectCommons.IsExistOnBattleArea(card))
  181. {
  182. if (CardEffectCommons.IsOwnerTurn(card))
  183. {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleArea(card))
  192. {
  193. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 4)
  194. {
  195. if (card.PermanentOfThisCard().CanAttack(activateClass, withoutTap: true))
  196. {
  197. return true;
  198. }
  199. }
  200. }
  201. return false;
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  204. {
  205. if (CardEffectCommons.IsExistOnBattleArea(card))
  206. {
  207. if (card.PermanentOfThisCard().CanAttack(activateClass, withoutTap: true))
  208. {
  209. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  210. selectAttackEffect.SetUp(
  211. attacker: card.PermanentOfThisCard(),
  212. canAttackPlayerCondition: () => true,
  213. defenderCondition: (permanent) => true,
  214. cardEffect: activateClass);
  215. selectAttackEffect.SetWithoutTap();
  216. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  217. }
  218. }
  219. }
  220. }
  221. if (timing == EffectTiming.OnAllyAttack)
  222. {
  223. ActivateClass activateClass = new ActivateClass();
  224. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  225. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  226. activateClass.SetIsInheritedEffect(true);
  227. activateClass.SetHashString("Draw1_BT12_083");
  228. cardEffects.Add(activateClass);
  229. string EffectDiscription()
  230. {
  231. return "[When Attacking][Once Per Turn] If this Digimon has <Save> in its text, <Draw 1>. (Draw 1 card from your deck.)";
  232. }
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  236. }
  237. bool CanActivateCondition(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.IsExistOnBattleArea(card))
  240. {
  241. if (card.PermanentOfThisCard().TopCard.HasSaveText)
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  249. {
  250. yield return ContinuousController.instance.StartCoroutine(new DrawClass(
  251. card.Owner,
  252. 1,
  253. activateClass).Draw());
  254. }
  255. }
  256. return cardEffects;
  257. }
  258. }
  259. }