BT19_043.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.BT19
  8. {
  9. public class BT19_043 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.ContainsCardName("Lucemon");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. minLevel: 5,
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null));
  28. }
  29. #endregion
  30. #region All Turns
  31. if (timing == EffectTiming.WhenRemoveField)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Trash both players top security card to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  36. activateClass.SetHashString("TrashSecurityToStay_LucemonXAntibody_BT19_043");
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[All Turns][Once Per Turn] When this Digimon would leave the battle area, if a card with [Lucemon] in its name is in this Digimon's digivolution cards, by trashing both players' top security cards, it doesn't leave.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  45. {
  46. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  56. {
  57. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.ContainsCardName("Lucemon")) >= 1)
  58. {
  59. if (card.Owner.SecurityCards.Count >= 1 && card.Owner.Enemy.SecurityCards.Count >= 1)
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  68. player: card.Owner,
  69. destroySecurityCount: 1,
  70. cardEffect: activateClass,
  71. fromTop: true).DestroySecurity());
  72. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  73. player: card.Owner.Enemy,
  74. destroySecurityCount: 1,
  75. cardEffect: activateClass,
  76. fromTop: true).DestroySecurity());
  77. Permanent thisCardPermanent = card.PermanentOfThisCard();
  78. thisCardPermanent.willBeRemoveField = false;
  79. thisCardPermanent.HideDeleteEffect();
  80. thisCardPermanent.HideHandBounceEffect();
  81. thisCardPermanent.HideDeckBounceEffect();
  82. thisCardPermanent.HideWillRemoveFieldEffect();
  83. yield return null;
  84. }
  85. }
  86. #endregion
  87. #region End of Your Turn
  88. if (timing == EffectTiming.OnEndTurn)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Opponent may trash 1 card from security or Recovery +1 and delete 1 Digimon or Tamer", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  93. activateClass.SetHashString("TrashSecurity_LucemonXAntibody_BT19_043");
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[End of Your Turn] [Once Per Turn] Your opponent may trash their top security card. If this effect didn't trash, <Recovery +1 (Deck)>, and delete 1 of their Digimon or Tamers.";
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  102. {
  103. if (CardEffectCommons.IsOwnerTurn(card))
  104. {
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  113. {
  114. return true;
  115. }
  116. return false;
  117. }
  118. bool CanSelectPermanentCondition(Permanent permanent)
  119. {
  120. if (permanent != null)
  121. {
  122. if (permanent.TopCard != null)
  123. {
  124. if (permanent.TopCard.Owner == card.Owner.Enemy)
  125. {
  126. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  127. {
  128. if (permanent.IsDigimon || permanent.IsTamer)
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  139. {
  140. if(card.Owner.Enemy.SecurityCards.Count > 0)
  141. {
  142. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  143. {
  144. new SelectionElement<bool>(message: $"Discard", value : true, spriteIndex: 0),
  145. new SelectionElement<bool>(message: $"Not Discard", value : false, spriteIndex: 1),
  146. };
  147. string selectPlayerMessage = "Will you discard the top card of your security?";
  148. string notSelectPlayerMessage = "The opponent is choosing whether to discard security.";
  149. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner.Enemy, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  150. }
  151. else
  152. {
  153. GManager.instance.userSelectionManager.SetBool(false);
  154. }
  155. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  156. bool doDiscard = GManager.instance.userSelectionManager.SelectedBoolValue;
  157. if (!doDiscard)
  158. {
  159. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  160. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  161. {
  162. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectPermanentCondition,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: maxCount,
  170. canNoSelect: false,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: null,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Destroy,
  175. cardEffect: activateClass);
  176. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  177. }
  178. }
  179. else
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  182. player: card.Owner.Enemy,
  183. destroySecurityCount: 1,
  184. cardEffect: activateClass,
  185. fromTop: true).DestroySecurity());
  186. }
  187. }
  188. }
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }