BT22_041.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kentaurosmon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_041 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.EqualsCardName("Chirinmon")) return true;
  19. if (targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasCSTraits) return true;
  20. return false;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Play Cost Reduction
  26. if (timing == EffectTiming.None)
  27. {
  28. int securityCount = card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count;
  29. ChangeCostClass changeCostClass = new ChangeCostClass();
  30. changeCostClass.SetUpICardEffect($"Play Cost -6", CanUseCondition, card);
  31. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost,
  32. cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: IsUpDown,
  33. isCheckAvailability: () => false, isChangePayingCost: () => true);
  34. cardEffects.Add(changeCostClass);
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnHand(card) &&
  38. securityCount <= 6;
  39. }
  40. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  41. List<Permanent> targetPermanents)
  42. {
  43. if (CardSourceCondition(cardSource))
  44. {
  45. if (RootCondition(root))
  46. {
  47. if (PermanentsCondition(targetPermanents))
  48. {
  49. cost -= 6;
  50. }
  51. }
  52. }
  53. return cost;
  54. }
  55. bool PermanentsCondition(List<Permanent> targetPermanents)
  56. {
  57. if (targetPermanents == null)
  58. {
  59. return true;
  60. }
  61. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. bool CardSourceCondition(CardSource cardSource)
  68. {
  69. return cardSource == card;
  70. }
  71. bool RootCondition(SelectCardEffect.Root root)
  72. {
  73. return true;
  74. }
  75. bool IsUpDown()
  76. {
  77. return true;
  78. }
  79. }
  80. #endregion
  81. #region Blocker
  82. if (timing == EffectTiming.None)
  83. {
  84. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  85. }
  86. #endregion
  87. #region Barrier
  88. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  89. {
  90. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(false, card, null));
  91. }
  92. #endregion
  93. #region On Play
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Place 1 yellow card from hand as top security card", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  99. cardEffects.Add(activateClass);
  100. string EffectDiscription()
  101. {
  102. return "[On Play] You may place 1 yellow card from your hand as your top security card.";
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  112. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsYellowCard);
  113. }
  114. bool IsYellowCard(CardSource cardSource) => cardSource.HasCardColor(CardColor.Yellow);
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsYellowCard))
  118. {
  119. CardSource selectedCard = null;
  120. #region Select Hand Card
  121. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsYellowCard));
  122. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  123. selectHandEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: IsYellowCard,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: true,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. selectCardCoroutine: SelectCardCoroutine,
  133. afterSelectCardCoroutine: null,
  134. mode: SelectHandEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. IEnumerator SelectCardCoroutine(CardSource cardSource)
  137. {
  138. selectedCard = cardSource;
  139. yield return null;
  140. }
  141. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of security.", "The opponent is selecting 1 card to place on top of security.");
  142. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  143. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  144. #endregion
  145. if (selectedCard != null)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard));
  148. }
  149. }
  150. }
  151. }
  152. #endregion
  153. #region When Digivolving
  154. if (timing == EffectTiming.OnEnterFieldAnyone)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("Place 1 yellow card from hand as top security card", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  159. cardEffects.Add(activateClass);
  160. string EffectDiscription()
  161. {
  162. return "[When Digivolving] You may place 1 yellow card from your hand as your top security card.";
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  167. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  172. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsYellowCard);
  173. }
  174. bool IsYellowCard(CardSource cardSource) => cardSource.HasCardColor(CardColor.Yellow);
  175. IEnumerator ActivateCoroutine(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsYellowCard))
  178. {
  179. CardSource selectedCard = null;
  180. #region Select Hand Card
  181. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsYellowCard));
  182. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  183. selectHandEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: IsYellowCard,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: maxCount,
  189. canNoSelect: true,
  190. canEndNotMax: false,
  191. isShowOpponent: true,
  192. selectCardCoroutine: SelectCardCoroutine,
  193. afterSelectCardCoroutine: null,
  194. mode: SelectHandEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. IEnumerator SelectCardCoroutine(CardSource cardSource)
  197. {
  198. selectedCard = cardSource;
  199. yield return null;
  200. }
  201. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of security.", "The opponent is selecting 1 card to place on top of security.");
  202. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  203. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  204. #endregion
  205. if (selectedCard != null)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard));
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region All turns - OPT
  214. if (timing == EffectTiming.OnTappedAnyone)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("By trashing top security, unsuspend", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  219. activateClass.SetHashString("BT22_041_Untap");
  220. cardEffects.Add(activateClass);
  221. string EffectDiscription()
  222. {
  223. return "[All Turns] [Once Per Turn] When this Digimon suspends, by trashing your top security card, it unsuspends.";
  224. }
  225. bool CanUseCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  228. && CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card);
  229. }
  230. bool CanActivateCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  233. && card.Owner.SecurityCards.Any();
  234. }
  235. IEnumerator ActivateCoroutine(Hashtable hashtable)
  236. {
  237. yield return ContinuousController.instance.StartCoroutine(
  238. new IDestroySecurity(card.Owner, 1, activateClass, true).DestroySecurity());
  239. yield return ContinuousController.instance.StartCoroutine(
  240. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }