BT22_037.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Chirinmon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_037 : 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. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region When trashed from security
  24. if (timing == EffectTiming.OnDiscardSecurity)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("-8K DP", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. activateClass.SetIsDigimonEffect(true);
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "When effects trash this card from the security stack, 1 of your opponent's Digimon gets -8000 DP for the turn.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnTrash(card)
  42. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon);
  43. }
  44. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. Permanent selectedPermament = null;
  48. #region Select Permanent
  49. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: IsOpponentDigimon,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: maxCount,
  57. canNoSelect: false,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: SelectPermanentCoroutine,
  60. afterSelectPermanentCoroutine: null,
  61. mode: SelectPermanentEffect.Mode.Custom,
  62. cardEffect: activateClass);
  63. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  64. {
  65. selectedPermament = permanent;
  66. yield return null;
  67. }
  68. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to -8K DP", "The opponent is selecting 1 digimon to -8K DP");
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. #endregion
  71. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(
  72. CardEffectCommons.ChangeDigimonDP(selectedPermament, -8000, EffectDuration.UntilEachTurnEnd, activateClass));
  73. }
  74. }
  75. #endregion
  76. #region When Digivolving
  77. if (timing == EffectTiming.OnEnterFieldAnyone)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("By trashing top security, digivolve into card with [Kentaurosmon]/[Mitamamon] in name or [CS] trait ", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[When Digivolving] By trashing your top security card, this Digimon may digivolve into a Digimon card with [Kentaurosmon] or [Mitamamon] in its name or the [CS] trait in the hand with the digivolution cost reduced by 2.";
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  90. }
  91. bool CanActivateCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  94. card.Owner.SecurityCards.Any();
  95. }
  96. bool CardCondition(CardSource cardSource)
  97. {
  98. return CardEffectCommons.IsExistOnHand(cardSource)
  99. && cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, true, activateClass)
  100. && (cardSource.ContainsCardName("Kentaurosmon") || cardSource.ContainsCardName("Mitamamon") || cardSource.HasCSTraits);
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable hashtable)
  103. {
  104. #region Make Selection for Trashing Security
  105. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  106. player: card.Owner,
  107. destroySecurityCount: 1,
  108. cardEffect: activateClass,
  109. fromTop: true).DestroySecurity());
  110. #endregion
  111. if(CardEffectCommons.HasMatchConditionOwnersHand(card, CardCondition))
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(
  114. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  115. targetPermanent: card.PermanentOfThisCard(),
  116. cardCondition: CardCondition,
  117. payCost: true,
  118. reduceCostTuple: (2, null),
  119. fixedCostTuple: null,
  120. ignoreDigivolutionRequirementFixedCost: -1,
  121. isHand: true,
  122. activateClass: activateClass,
  123. successProcess: null));
  124. }
  125. }
  126. }
  127. #endregion
  128. #region ESS
  129. if (timing == EffectTiming.OnAllyAttack)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("-4K DP", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  134. activateClass.SetHashString("BT22_037_WA");
  135. activateClass.SetIsInheritedEffect(true);
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  148. }
  149. bool IsOpponentDigimon(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  156. {
  157. Permanent selectedPermament = null;
  158. #region Select Permanent
  159. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  160. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  161. selectPermanentEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: IsOpponentDigimon,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: maxCount,
  167. canNoSelect: false,
  168. canEndNotMax: false,
  169. selectPermanentCoroutine: SelectPermanentCoroutine,
  170. afterSelectPermanentCoroutine: null,
  171. mode: SelectPermanentEffect.Mode.Custom,
  172. cardEffect: activateClass);
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. selectedPermament = permanent;
  176. yield return null;
  177. }
  178. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -4K DP", "The opponent is selecting 1 Digimon to -4K DP");
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. #endregion
  181. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  182. targetPermanent: selectedPermament,
  183. changeValue: -4000,
  184. effectDuration: EffectDuration.UntilEachTurnEnd,
  185. activateClass: activateClass
  186. ));
  187. }
  188. }
  189. }
  190. #endregion
  191. return cardEffects;
  192. }
  193. }
  194. }