BT23_067.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // LadyDevimon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_067 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4
  18. && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Reduce Cost
  30. bool IsAngewomonOrMirei(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  33. && (permanent.TopCard.EqualsCardName("Angewomon") || permanent.TopCard.EqualsCardName("Mirei Mikagura"));
  34. }
  35. #region Before Pay Cost - Condition Effect
  36. if (timing == EffectTiming.BeforePayCost)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Play cost reduction -3", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  41. activateClass.SetHashString("BT23_067_ReducePlayCost");
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "When this card would be played from the hand, if you have [Angewomon] or [Mirei Mikagura], reduce the play cost by 3.";
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnHand(card)
  54. && CardEffectCommons.HasMatchConditionPermanent(IsAngewomonOrMirei);
  55. }
  56. bool CardCondition(CardSource cardSource)
  57. {
  58. return CardEffectCommons.IsExistOnHand(cardSource)
  59. && cardSource == card;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. ChangeCostClass changeCostClass = new ChangeCostClass();
  64. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition1, card);
  65. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  66. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  67. bool CanUseCondition1(Hashtable hashtable)
  68. {
  69. return true;
  70. }
  71. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  72. {
  73. if (CardSourceCondition(cardSource))
  74. {
  75. if (RootCondition(root))
  76. {
  77. if (PermanentsCondition(targetPermanents))
  78. {
  79. if (CardEffectCommons.HasMatchConditionPermanent(IsAngewomonOrMirei))
  80. {
  81. Cost -= 3;
  82. }
  83. }
  84. }
  85. }
  86. return Cost;
  87. }
  88. bool PermanentsCondition(List<Permanent> targetPermanents)
  89. {
  90. if (targetPermanents == null)
  91. {
  92. return true;
  93. }
  94. else
  95. {
  96. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  97. {
  98. return true;
  99. }
  100. }
  101. return false;
  102. }
  103. bool CardSourceCondition(CardSource cardSource)
  104. {
  105. return cardSource == card;
  106. }
  107. bool RootCondition(SelectCardEffect.Root root)
  108. {
  109. return root == SelectCardEffect.Root.Hand;
  110. }
  111. bool isUpDown()
  112. {
  113. return true;
  114. }
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  116. }
  117. }
  118. #endregion
  119. #region Reduce Play Cost - Not Shown
  120. if (timing == EffectTiming.None)
  121. {
  122. ChangeCostClass changeCostClass = new ChangeCostClass();
  123. changeCostClass.SetUpICardEffect("Play Cost -3", CanUseCondition, card);
  124. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  125. changeCostClass.SetNotShowUI(true);
  126. cardEffects.Add(changeCostClass);
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. if (card.Owner.HandCards.Contains(card))
  130. {
  131. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Play cost reduction -3");
  132. if (activateClass != null)
  133. {
  134. if (CardEffectCommons.HasMatchConditionPermanent(IsAngewomonOrMirei))
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. return false;
  141. }
  142. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  143. {
  144. if (CardSourceCondition(cardSource))
  145. {
  146. if (RootCondition(root))
  147. {
  148. if (PermanentsCondition(targetPermanents))
  149. {
  150. if (CardEffectCommons.HasMatchConditionPermanent(IsAngewomonOrMirei))
  151. {
  152. Cost -= 3;
  153. }
  154. }
  155. }
  156. }
  157. return Cost;
  158. }
  159. bool PermanentsCondition(List<Permanent> targetPermanents)
  160. {
  161. if (targetPermanents == null)
  162. {
  163. return true;
  164. }
  165. else
  166. {
  167. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool CardSourceCondition(CardSource cardSource)
  175. {
  176. if (cardSource != null)
  177. {
  178. if (cardSource == card)
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool RootCondition(SelectCardEffect.Root root)
  186. {
  187. return root == SelectCardEffect.Root.Hand;
  188. }
  189. bool isUpDown()
  190. {
  191. return true;
  192. }
  193. }
  194. #endregion
  195. #endregion
  196. #region Blocker
  197. if (timing == EffectTiming.None)
  198. {
  199. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  200. }
  201. #endregion
  202. #region On Play/ When Digivolving Shared
  203. bool CanSelectPermanentConditionShared(Permanent permanent)
  204. {
  205. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  206. permanent.IsDigimon &&
  207. permanent.TopCard.HasLevel &&
  208. permanent.Level <= 4;
  209. }
  210. bool CanActivateConditionShared(Hashtable hashtable)
  211. {
  212. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  213. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  214. }
  215. IEnumerator SharedActivateDeleteDigiCoroutine(Hashtable hashtable, ActivateClass activateClass)
  216. {
  217. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  218. selectPermanentEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: CanSelectPermanentConditionShared,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: 1,
  224. canNoSelect: false,
  225. canEndNotMax: false,
  226. selectPermanentCoroutine: null,
  227. afterSelectPermanentCoroutine: null,
  228. mode: SelectPermanentEffect.Mode.Destroy,
  229. cardEffect: activateClass);
  230. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  231. "The opponent is selecting 1 Digimon to delete.");
  232. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  233. }
  234. #endregion
  235. #region On Play
  236. if (timing == EffectTiming.OnEnterFieldAnyone)
  237. {
  238. ActivateClass activateClass = new ActivateClass();
  239. activateClass.SetUpICardEffect("Delete 1 of your opponent's level 4 or lower Digimon",
  240. CanUseCondition, card);
  241. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateDeleteDigiCoroutine(hash, activateClass), -1, false, EffectDescription());
  242. cardEffects.Add(activateClass);
  243. string EffectDescription()
  244. {
  245. return
  246. "[On Play] Delete 1 of your opponent's level 4 or lower Digimon.";
  247. }
  248. bool CanUseCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  251. }
  252. }
  253. #endregion
  254. #region When Digivolving
  255. if (timing == EffectTiming.OnEnterFieldAnyone)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("Delete 1 of your opponent's level 4 or lower Digimon",
  259. CanUseCondition, card);
  260. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateDeleteDigiCoroutine(hash, activateClass), -1, false, EffectDescription());
  261. cardEffects.Add(activateClass);
  262. string EffectDescription()
  263. {
  264. return
  265. "[When Digivolving] Delete 1 of your opponent's level 4 or lower Digimon.";
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  270. }
  271. }
  272. #endregion
  273. #region Scapegoat - ESS
  274. if(timing == EffectTiming.WhenPermanentWouldBeDeleted)
  275. {
  276. string EffectDiscription()
  277. {
  278. return "<Scapegoat> (When this Digimon would be deleted other than by your own effects, by deleting 1 of your other Digimon, prevent that deletion.)";
  279. }
  280. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: true, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: EffectDiscription()));
  281. }
  282. #endregion
  283. return cardEffects;
  284. }
  285. }
  286. }