BT13_084.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_084 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete your another Digimon to digivolve", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] By deleting 1 of your other purple Digimon, this Digimon may digivolve into a Digimon card with [Belphemon] in its name in your hand without paying the cost.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent != card.PermanentOfThisCard())
  27. {
  28. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.IsDigimon && cardSource.ContainsCardName("Belphemon");
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. Permanent thisCardPermanent = card.PermanentOfThisCard();
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  81. }
  82. }
  83. IEnumerator SuccessProcess()
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  86. targetPermanent: thisCardPermanent,
  87. cardCondition: CanSelectCardCondition,
  88. payCost: false,
  89. reduceCostTuple: null,
  90. fixedCostTuple: null,
  91. ignoreDigivolutionRequirementFixedCost: -1,
  92. isHand: true,
  93. activateClass: activateClass,
  94. successProcess: null));
  95. }
  96. }
  97. }
  98. }
  99. if (timing == EffectTiming.OnEnterFieldAnyone)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Delete your another Digimon to digivolve", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  104. cardEffects.Add(activateClass);
  105. string EffectDiscription()
  106. {
  107. return "[When Digivolving] By deleting 1 of your other purple Digimon, this Digimon may digivolve into a Digimon card with [Belphemon] in its name in your hand without paying the cost.";
  108. }
  109. bool CanSelectPermanentCondition(Permanent permanent)
  110. {
  111. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  112. {
  113. if (permanent != card.PermanentOfThisCard())
  114. {
  115. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. return cardSource.IsDigimon && cardSource.ContainsCardName("Belphemon");
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnBattleArea(card))
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleArea(card))
  145. {
  146. Permanent thisCardPermanent = card.PermanentOfThisCard();
  147. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  148. {
  149. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: true,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: SelectPermanentCoroutine,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.Custom,
  162. cardEffect: activateClass);
  163. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  168. }
  169. }
  170. IEnumerator SuccessProcess()
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  173. targetPermanent: thisCardPermanent,
  174. cardCondition: CanSelectCardCondition,
  175. payCost: false,
  176. reduceCostTuple: null,
  177. fixedCostTuple: null,
  178. ignoreDigivolutionRequirementFixedCost: -1,
  179. isHand: true,
  180. activateClass: activateClass,
  181. successProcess: null));
  182. }
  183. }
  184. }
  185. }
  186. if (timing == EffectTiming.OnDiscardHand)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon from trash", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  191. activateClass.SetIsInheritedEffect(true);
  192. activateClass.SetHashString("Play_BT13_084");
  193. cardEffects.Add(activateClass);
  194. string EffectDiscription()
  195. {
  196. return "[Opponent's Turn][Once Per Turn] When a card is trashed from your hand, you may play 1 level 4 or lower purple Digimon card from your trash without paying the cost.";
  197. }
  198. bool CanSelectCardCondition(CardSource cardSource)
  199. {
  200. if (cardSource.IsDigimon)
  201. {
  202. if (cardSource.HasCardColor(CardColor.Purple))
  203. {
  204. if (cardSource.Level <= 4)
  205. {
  206. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  207. {
  208. if (cardSource.HasLevel)
  209. {
  210. return true;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. if (CardEffectCommons.IsExistOnBattleArea(card))
  221. {
  222. if (CardEffectCommons.IsOpponentTurn(card))
  223. {
  224. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, cardEffect => true, cardSource => cardSource.Owner == card.Owner))
  225. {
  226. return true;
  227. }
  228. }
  229. }
  230. return false;
  231. }
  232. bool CanActivateCondition(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  237. {
  238. return true;
  239. }
  240. }
  241. return false;
  242. }
  243. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  244. {
  245. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  246. List<CardSource> selectedCards = new List<CardSource>();
  247. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  248. selectCardEffect.SetUp(
  249. canTargetCondition: CanSelectCardCondition,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. canNoSelect: () => true,
  253. selectCardCoroutine: SelectCardCoroutine,
  254. afterSelectCardCoroutine: null,
  255. message: "Select 1 card to play.",
  256. maxCount: maxCount,
  257. canEndNotMax: false,
  258. isShowOpponent: true,
  259. mode: SelectCardEffect.Mode.Custom,
  260. root: SelectCardEffect.Root.Trash,
  261. customRootCardList: null,
  262. canLookReverseCard: true,
  263. selectPlayer: card.Owner,
  264. cardEffect: activateClass);
  265. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  266. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  267. yield return StartCoroutine(selectCardEffect.Activate());
  268. IEnumerator SelectCardCoroutine(CardSource cardSource)
  269. {
  270. selectedCards.Add(cardSource);
  271. yield return null;
  272. }
  273. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  274. }
  275. }
  276. return cardEffects;
  277. }
  278. }
  279. }