BT24_018.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Styracomon
  7. namespace DCGO.CardEffects.BT24
  8. {
  9. public class BT24_018: CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternate Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool Condition()
  18. {
  19. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOwenDreadnought);
  20. }
  21. bool HasOwenDreadnought(Permanent targetPermanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card) &&
  24. targetPermanent.TopCard.EqualsCardName("Owen Dreadnought");
  25. }
  26. bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.EqualsCardName("Lamiamon");
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  31. permanentCondition: PermanentCondition,
  32. digivolutionCost: 6,
  33. ignoreDigivolutionRequirement: false,
  34. card: card,
  35. condition: Condition)
  36. );
  37. }
  38. #endregion
  39. #region Progress
  40. if (timing == EffectTiming.None)
  41. {
  42. cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null));
  43. }
  44. #endregion
  45. #region Piercing
  46. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  47. {
  48. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  49. }
  50. #endregion
  51. #region Blocker
  52. if (timing == EffectTiming.None)
  53. {
  54. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(false, card, null));
  55. }
  56. #endregion
  57. #region Armor Purge
  58. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  59. {
  60. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card));
  61. }
  62. #endregion
  63. #region When Digivolving
  64. if (timing == EffectTiming.OnEnterFieldAnyone)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect("May trash 1 opponent's security. Then, this may unsuspend.", CanUseCondition, card);
  68. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  69. cardEffects.Add(activateClass);
  70. string EffectDescription()
  71. => "[When Digivolving] You may trash any 1 of your opponent's security cards. Then, this Digimon may unsuspend.";
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleArea(card);
  79. }
  80. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  81. {
  82. #region Trash Security
  83. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  84. {
  85. int maxCount = 1;
  86. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  87. CardSource selectedCard = null;
  88. selectCardEffect.SetUp(
  89. canTargetCondition: (cardSource) => true,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. canNoSelect: () => true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. message: "Select 1 card to trash.\n (cards to the left are at the top and cards to the right are at the bottom)",
  96. maxCount: maxCount,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. mode: SelectCardEffect.Mode.Custom,
  100. root: SelectCardEffect.Root.Security,
  101. customRootCardList: card.Owner.Enemy.SecurityCards,
  102. canLookReverseCard: false,
  103. selectPlayer: card.Owner,
  104. cardEffect: activateClass);
  105. selectCardEffect.SetUpCustomMessage_ShowCard("Send to trash");
  106. selectCardEffect.SetUseFaceDown();
  107. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  108. IEnumerator SelectCardCoroutine(CardSource cardSource)
  109. {
  110. selectedCard = cardSource;
  111. yield return null;
  112. }
  113. if (selectedCard != null)
  114. {
  115. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  116. player: card.Owner.Enemy,
  117. card: selectedCard,
  118. cardEffect: activateClass
  119. ).DestroySecurity());
  120. }
  121. }
  122. #endregion
  123. #region Unsuspend
  124. if (card.PermanentOfThisCard().IsSuspended)
  125. {
  126. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  127. {
  128. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  129. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  130. };
  131. string selectPlayerMessage = "Will you unsuspend this digimon?";
  132. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  133. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  134. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  135. var selectedOption = GManager.instance.userSelectionManager.SelectedBoolValue;
  136. if (selectedOption)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(
  139. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() },
  140. activateClass).Unsuspend());
  141. }
  142. }
  143. #endregion
  144. }
  145. }
  146. #endregion
  147. #region All Turns when Security is removed, delete 1
  148. if (timing == EffectTiming.OnLoseSecurity)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon?", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  153. activateClass.SetHashString("BT24_18_AT_Sec_Removed");
  154. cardEffects.Add(activateClass);
  155. string EffectDescription()
  156. => "[All Turns] [Once Per Turn] When your opponent's security stack is removed from, you may delete 1 of their Digimon.";
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  160. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy);
  161. }
  162. bool CanActivateCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  165. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  166. }
  167. bool CanSelectPermanentCondition(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  174. {
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  177. selectPermanentEffect.SetUp(
  178. selectPlayer: card.Owner,
  179. canTargetCondition: CanSelectPermanentCondition,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. maxCount: maxCount,
  183. canNoSelect: false,
  184. canEndNotMax: false,
  185. selectPermanentCoroutine: null,
  186. afterSelectPermanentCoroutine: null,
  187. mode: SelectPermanentEffect.Mode.Destroy,
  188. cardEffect: activateClass);
  189. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to send to delete.", "Your opponent is selecting 1 digimon to delete.");
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. }
  192. }
  193. }
  194. #endregion
  195. #region All Turns When Reptile or Dragonkin would leave Battle Area, delete opponent's digimon to prevent
  196. if (timing == EffectTiming.WhenRemoveField)
  197. {
  198. List<Permanent> removedPermanents = new List<Permanent>();
  199. ActivateClass activateClass = new ActivateClass();
  200. activateClass.SetUpICardEffect("Delete an opponent's Digimon, to prevent [Reptile] or [Dragonkin] trait digimon from leaving the battle area", CanUseCondition, card);
  201. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  202. activateClass.SetHashString("BT24_018_AT_Prevent_Deletion");
  203. cardEffects.Add(activateClass);
  204. string EffectDescription()
  205. => "[All Turns] [Once Per Turn] When any of your [Reptile] or [Dragonkin] trait Digimon would leave the battle area, by deleting 1 of your opponent's lowest DP Digimon, they don't leave.";
  206. bool IsReptileKin(Permanent permanent)
  207. {
  208. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  209. && (permanent.TopCard.EqualsTraits("Reptile") ||
  210. permanent.TopCard.EqualsTraits("Dragonkin"));
  211. }
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  215. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsReptileKin);
  216. }
  217. bool CanActivateCondition(Hashtable hashtable)
  218. {
  219. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(IsReptileKin);
  220. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  221. removedPermanents.Count > 0;
  222. }
  223. bool CanDeleteCondition(Permanent permanent)
  224. {
  225. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. #region By Deleting Lowest Opponent's DP Digimon
  230. if (CardEffectCommons.HasMatchConditionPermanent(CanDeleteCondition))
  231. {
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanDeleteCondition));
  234. selectPermanentEffect.SetUp(
  235. selectPlayer: card.Owner,
  236. canTargetCondition: CanDeleteCondition,
  237. canTargetCondition_ByPreSelecetedList: null,
  238. canEndSelectCondition: null,
  239. maxCount: maxCount,
  240. canNoSelect: false,
  241. canEndNotMax: false,
  242. selectPermanentCoroutine: SelectPermanentCoroutine,
  243. afterSelectPermanentCoroutine: null,
  244. mode: SelectPermanentEffect.Mode.Custom,
  245. cardEffect: activateClass);
  246. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to send to delete.", "Your opponent is selecting 1 digimon to delete.");
  247. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  248. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  249. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  250. {
  251. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  252. #endregion
  253. #region They don't leave
  254. IEnumerator SuccessProcess()
  255. {
  256. foreach (Permanent removed in removedPermanents)
  257. {
  258. removed.willBeRemoveField = false;
  259. removed.HideHandBounceEffect();
  260. removed.HideDeckBounceEffect();
  261. removed.HideDeleteEffect();
  262. removed.HideWillRemoveFieldEffect();
  263. }
  264. yield return null;
  265. }
  266. }
  267. }
  268. #endregion
  269. }
  270. }
  271. #endregion
  272. return cardEffects;
  273. }
  274. }
  275. }