BT15_034.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT15
  7. {
  8. public class BT15_034 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region All Turns Inherit
  14. if (timing == EffectTiming.OnLoseSecurity)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Give an opponent's Digimon card -2000 DP.", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  19. activateClass.SetHashString("-2000DP_BT15_034");
  20. activateClass.SetIsInheritedEffect(true);
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[All Turns][Once per turn] When a card is removed from your security stack, 1 of your opponents Digimon gets -2000 DP for the turn.";
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleArea(card))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
  37. {
  38. return true;
  39. }
  40. return false;
  41. }
  42. bool CanSelectPermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  47. {
  48. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  49. {
  50. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  69. }
  70. }
  71. }
  72. }
  73. #endregion
  74. #region Start of Main Phase
  75. if (timing == EffectTiming.OnStartMainPhase)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Add top card of security to hand or place a yellow Digimon with the [Vaccine] trait at the top or bottom of security.", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  80. cardEffects.Add(activateClass);
  81. string EffectDiscription()
  82. {
  83. return "[Start of Your Main Phase] If you have 3 or more security cards you may add the top card of your security stack to the hand. If you have 2 or fewer security cards, you may place 1 yellow card with the [Vaccine] trait from your hand at the top or bottom of your security stack.";
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. if (cardSource.IsDigimon)
  88. {
  89. if (cardSource.ContainsTraits("Vaccine"))
  90. {
  91. if (cardSource.HasCardColor(CardColor.Yellow))
  92. {
  93. return true;
  94. }
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (card.Owner.SecurityCards.Count >= 3)
  104. {
  105. return true;
  106. }
  107. }
  108. if (CardEffectCommons.IsExistOnBattleArea(card))
  109. {
  110. if (card.Owner.SecurityCards.Count <= 2)
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. if (CardEffectCommons.IsExistOnBattleArea(card))
  120. {
  121. if (CardEffectCommons.IsOwnerTurn(card))
  122. {
  123. return true;
  124. }
  125. }
  126. return false;
  127. }
  128. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  129. {
  130. if (card.Owner.SecurityCards.Count >= 3)
  131. {
  132. CardSource topCard = card.Owner.SecurityCards[0];
  133. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  134. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  135. player: card.Owner,
  136. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  137. activateClass).ReduceSecurity());
  138. }
  139. if (card.Owner.SecurityCards.Count <= 2)
  140. {
  141. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  142. {
  143. List<CardSource> selectedCard = new List<CardSource>();
  144. int maxCount = 1;
  145. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  146. selectHandEffect.SetUp(
  147. selectPlayer: card.Owner,
  148. canTargetCondition: CanSelectCardCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. maxCount: maxCount,
  152. canNoSelect: true,
  153. canEndNotMax: false,
  154. isShowOpponent: true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. mode: SelectHandEffect.Mode.Custom,
  158. cardEffect: activateClass);
  159. selectHandEffect.SetUpCustomMessage(
  160. "Select 1 card to place at the top or bottom of security.",
  161. "The opponent is selecting 1 card to place at the top or bottom of security.");
  162. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top/Bottom Card");
  163. yield return StartCoroutine(selectHandEffect.Activate());
  164. IEnumerator SelectCardCoroutine(CardSource cardSource)
  165. {
  166. if (selectedCard != null)
  167. {
  168. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  169. {
  170. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  171. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  172. };
  173. string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
  174. string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
  175. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  176. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  177. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  178. if (toTop)
  179. {
  180. GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
  181. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
  182. }
  183. else
  184. {
  185. GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
  186. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
  187. }
  188. yield return new WaitForSeconds(0.4f);
  189. GManager.instance.commandText.CloseCommandText();
  190. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  191. selectedCard.Add(cardSource);
  192. yield return null;
  193. foreach (CardSource card in selectedCard)
  194. {
  195. if (toTop)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: true));
  198. }
  199. if (!toTop)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. #endregion
  211. return cardEffects;
  212. }
  213. }
  214. }