BT13_045.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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_045 : 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.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.ContainsCardName("Chessmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.None)
  21. {
  22. ChangeCostClass changeCostClass = new ChangeCostClass();
  23. changeCostClass.SetUpICardEffect($"Play Cost -8", CanUseCondition, card);
  24. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  25. cardEffects.Add(changeCostClass);
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (card.Owner.HandCards.Contains(card))
  29. {
  30. if (card.Owner.TrashCards.Count((cardSource) => cardSource.IsDigimon && cardSource.ContainsCardName("Chessmon")) >= 8)
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  38. {
  39. if (CardSourceCondition(cardSource))
  40. {
  41. if (RootCondition(root))
  42. {
  43. if (PermanentsCondition(targetPermanents))
  44. {
  45. Cost -= 8;
  46. }
  47. }
  48. }
  49. return Cost;
  50. }
  51. bool PermanentsCondition(List<Permanent> targetPermanents)
  52. {
  53. if (targetPermanents == null)
  54. {
  55. return true;
  56. }
  57. else
  58. {
  59. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CardSourceCondition(CardSource cardSource)
  67. {
  68. return cardSource == card;
  69. }
  70. bool RootCondition(SelectCardEffect.Root root)
  71. {
  72. if (root == SelectCardEffect.Root.Hand)
  73. {
  74. return true;
  75. }
  76. return false;
  77. }
  78. bool isUpDown()
  79. {
  80. return true;
  81. }
  82. }
  83. if (timing == EffectTiming.OnEnterFieldAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Delete your 1 Digimon to play 1 Digimon card with [Chessmon] in its name from hand", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[On Play] By deleting 1 of your other Digimon, you may play 1 Digimon card with [Chessmon] in its name, other than [KingChessmon], from your hand without paying the cost.";
  92. }
  93. bool CanSelectPermanentCondition(Permanent permanent)
  94. {
  95. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  96. {
  97. if (permanent != card.PermanentOfThisCard())
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. bool CanSelectCardCondition(CardSource cardSource)
  105. {
  106. if (cardSource.ContainsCardName("Chessmon"))
  107. {
  108. if (cardSource.IsDigimon)
  109. {
  110. if (!cardSource.CardNames.Contains("KingChessmon"))
  111. {
  112. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  139. {
  140. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  141. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectPermanentEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectPermanentCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: maxCount,
  148. canNoSelect: true,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: SelectPermanentCoroutine,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  155. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  156. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  157. {
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  159. IEnumerator SuccessProcess()
  160. {
  161. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  162. {
  163. List<CardSource> selectedCards = new List<CardSource>();
  164. maxCount = 1;
  165. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  166. selectHandEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectCardCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. mode: SelectHandEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  180. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  181. yield return StartCoroutine(selectHandEffect.Activate());
  182. IEnumerator SelectCardCoroutine(CardSource cardSource)
  183. {
  184. selectedCards.Add(cardSource);
  185. yield return null;
  186. }
  187. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. if (timing == EffectTiming.OnEnterFieldAnyone)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("Delete your 1 Digimon to play 1 Digimon card with [Chessmon] in its name from hand", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return "[When Digivolving] By deleting 1 of your other Digimon, you may play 1 Digimon card with [Chessmon] in its name, other than [KingChessmon], from your hand without paying the cost.";
  203. }
  204. bool CanSelectPermanentCondition(Permanent permanent)
  205. {
  206. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  207. {
  208. if (permanent != card.PermanentOfThisCard())
  209. {
  210. return true;
  211. }
  212. }
  213. return false;
  214. }
  215. bool CanSelectCardCondition(CardSource cardSource)
  216. {
  217. if (cardSource.ContainsCardName("Chessmon"))
  218. {
  219. if (cardSource.IsDigimon)
  220. {
  221. if (!cardSource.CardNames.Contains("KingChessmon"))
  222. {
  223. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. }
  230. return false;
  231. }
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  235. }
  236. bool CanActivateCondition(Hashtable hashtable)
  237. {
  238. if (CardEffectCommons.IsExistOnBattleArea(card))
  239. {
  240. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  241. {
  242. return true;
  243. }
  244. }
  245. return false;
  246. }
  247. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  248. {
  249. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  250. {
  251. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  252. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  253. selectPermanentEffect.SetUp(
  254. selectPlayer: card.Owner,
  255. canTargetCondition: CanSelectPermanentCondition,
  256. canTargetCondition_ByPreSelecetedList: null,
  257. canEndSelectCondition: null,
  258. maxCount: maxCount,
  259. canNoSelect: true,
  260. canEndNotMax: false,
  261. selectPermanentCoroutine: SelectPermanentCoroutine,
  262. afterSelectPermanentCoroutine: null,
  263. mode: SelectPermanentEffect.Mode.Custom,
  264. cardEffect: activateClass);
  265. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  266. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  267. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  268. {
  269. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  270. IEnumerator SuccessProcess()
  271. {
  272. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  273. {
  274. List<CardSource> selectedCards = new List<CardSource>();
  275. maxCount = 1;
  276. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  277. selectHandEffect.SetUp(
  278. selectPlayer: card.Owner,
  279. canTargetCondition: CanSelectCardCondition,
  280. canTargetCondition_ByPreSelecetedList: null,
  281. canEndSelectCondition: null,
  282. maxCount: maxCount,
  283. canNoSelect: true,
  284. canEndNotMax: false,
  285. isShowOpponent: true,
  286. selectCardCoroutine: SelectCardCoroutine,
  287. afterSelectCardCoroutine: null,
  288. mode: SelectHandEffect.Mode.Custom,
  289. cardEffect: activateClass);
  290. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  291. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  292. yield return StartCoroutine(selectHandEffect.Activate());
  293. IEnumerator SelectCardCoroutine(CardSource cardSource)
  294. {
  295. selectedCards.Add(cardSource);
  296. yield return null;
  297. }
  298. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. return cardEffects;
  306. }
  307. }
  308. }