BT22_034.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Reppamon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_034 : 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.IsLevel3 && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, 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("Play Card", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "When effects trash this card from the security stack, you may play this card without paying the cost.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnTrash(card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { card }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Execution, activateETB: true));
  45. }
  46. }
  47. #endregion
  48. #region OP/WD Shared
  49. bool SharedIsOpponentDigimon(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  52. }
  53. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  54. {
  55. bool isTrashingSecurity = false;
  56. int dpChange = 3000;
  57. if (card.Owner.SecurityCards.Any())
  58. {
  59. #region Make Selection for Trashing Security
  60. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  61. {
  62. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  63. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  64. };
  65. string selectPlayerMessage = "Trash top security to -6K DP instead of 3K?";
  66. string notSelectPlayerMessage = "The opponent is choosing to trash top security.";
  67. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  69. isTrashingSecurity = GManager.instance.userSelectionManager.SelectedBoolValue;
  70. #endregion
  71. }
  72. if (isTrashingSecurity)
  73. {
  74. CardSource topSec = card.Owner.SecurityCards.FirstOrDefault();
  75. #region Trash Top Security
  76. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  77. player: card.Owner,
  78. destroySecurityCount: 1,
  79. cardEffect: activateClass,
  80. fromTop: true).DestroySecurity());
  81. #endregion
  82. if (CardEffectCommons.IsExistOnTrash(topSec)) dpChange = 6000;
  83. }
  84. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon))
  85. {
  86. Permanent selectedPermament = null;
  87. #region Select Permanent
  88. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, SharedIsOpponentDigimon));
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: SharedIsOpponentDigimon,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: maxCount,
  96. canNoSelect: false,
  97. canEndNotMax: false,
  98. selectPermanentCoroutine: SelectPermanentCoroutine,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.Custom,
  101. cardEffect: activateClass);
  102. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  103. {
  104. selectedPermament = permanent;
  105. yield return null;
  106. }
  107. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to -{dpChange} DP", $"The opponent is selecting 1 Digimon to -{dpChange} DP");
  108. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  109. #endregion
  110. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  111. targetPermanent: selectedPermament,
  112. changeValue: -dpChange,
  113. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  114. activateClass: activateClass
  115. ));
  116. }
  117. }
  118. #endregion
  119. #region On Play
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Trash top sec for -6K DP, otherwise -3K DP", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[On Play] 1 of your opponent's Digimon gets -3000 DP until their turn ends. By trashing your top security card, instead 1 of your opponent's Digimon gets -6000 DP until their turn ends.";
  129. }
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  133. }
  134. bool CanActivateCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable hashtable)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  141. }
  142. }
  143. #endregion
  144. #region When Digivolving
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Trash top sec for -6K DP, otherwise -3K DP", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  150. cardEffects.Add(activateClass);
  151. string EffectDiscription()
  152. {
  153. return "[When Digivolving] 1 of your opponent's Digimon gets -3000 DP until their turn ends. By trashing your top security card, instead 1 of your opponent's Digimon gets -6000 DP until their turn ends.";
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  158. }
  159. bool CanActivateCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  162. }
  163. IEnumerator ActivateCoroutine(Hashtable hashtable)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  166. }
  167. }
  168. #endregion
  169. #region ESS
  170. if (timing == EffectTiming.OnAllyAttack)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("-2K DP", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  175. activateClass.SetHashString("BT22_034_WA");
  176. activateClass.SetIsInheritedEffect(true);
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon gets -2000 DP for the turn.";
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  189. }
  190. bool IsOpponentDigimon(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  197. {
  198. Permanent selectedPermament = null;
  199. #region Select Permanent
  200. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: IsOpponentDigimon,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  215. {
  216. selectedPermament = permanent;
  217. yield return null;
  218. }
  219. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -2K DP", "The opponent is selecting 1 Digimon to -2K DP");
  220. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  221. #endregion
  222. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  223. targetPermanent: selectedPermament,
  224. changeValue: -2000,
  225. effectDuration: EffectDuration.UntilEachTurnEnd,
  226. activateClass: activateClass
  227. ));
  228. }
  229. }
  230. }
  231. #endregion
  232. return cardEffects;
  233. }
  234. }
  235. }