BT15_042.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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_042 : 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
  14. if (timing == EffectTiming.OnLoseSecurity)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Place 1 yellow card from your hand to the top or bottom of your security stack.", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[All Turns][Once per turn] When a card is removed from your security stack, if you have 3 or less security cards, you may place 1 yellow card from your hand at the top or bottom of your security stack.";
  23. }
  24. bool CanActivateCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. return true;
  29. }
  30. return false;
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleArea(card))
  35. {
  36. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
  37. {
  38. if (card.Owner.SecurityCards.Count() <= 3)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectCardCondition(CardSource cardSource)
  47. {
  48. if (cardSource.HasCardColor(CardColor.Yellow))
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (card.Owner.SecurityCards.Count <= 3)
  57. {
  58. if (card.Owner.CanAddSecurity(activateClass))
  59. {
  60. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  61. {
  62. List<CardSource> selectedCard = new List<CardSource>();
  63. int maxCount = 1;
  64. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  65. selectHandEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CanSelectCardCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: maxCount,
  71. canNoSelect: true,
  72. canEndNotMax: false,
  73. isShowOpponent: true,
  74. selectCardCoroutine: SelectCardCoroutine,
  75. afterSelectCardCoroutine: null,
  76. mode: SelectHandEffect.Mode.Custom,
  77. cardEffect: activateClass);
  78. selectHandEffect.SetUpCustomMessage(
  79. "Select 1 card to place at the top or bottom of security.",
  80. "The opponent is selecting 1 card to place at the bottom of security.");
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. if (selectedCard != null)
  85. {
  86. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  87. {
  88. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  89. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  90. };
  91. string selectPlayerMessage = "Will you place the card on the top or bottom of the security?";
  92. string notSelectPlayerMessage = "The opponent is selecting whether to place the card on the top or bottom of security.";
  93. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  94. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  95. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  96. if (toTop)
  97. {
  98. GManager.instance.commandText.OpenCommandText("\"Place to the top of security\" was selected.");
  99. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the top of security\n");
  100. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  101. }
  102. else
  103. {
  104. GManager.instance.commandText.OpenCommandText("\"Place to the bottom of security\" was selected.");
  105. PlayLog.OnAddLog?.Invoke($"\n{card.BaseENGCardNameFromEntity}({card.CardID}):Place the Digimon to the bottom of security\n");
  106. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  107. }
  108. yield return new WaitForSeconds(0.4f);
  109. GManager.instance.commandText.CloseCommandText();
  110. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  111. selectedCard.Add(cardSource);
  112. yield return null;
  113. foreach (CardSource card in selectedCard)
  114. {
  115. if (toTop)
  116. {
  117. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: true));
  118. }
  119. if (!toTop)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. #endregion
  132. #region On Play
  133. if (timing == EffectTiming.OnEnterFieldAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  138. activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
  139. cardEffects.Add(activateClass);
  140. string EffectDiscription()
  141. {
  142. return "[On Play] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.IsExistOnBattleArea(card))
  151. {
  152. if (card.Owner.SecurityCards.Count >= 1)
  153. {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. bool CanSelectPermanentCondition(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  162. {
  163. if (permanent.HasDP)
  164. {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  171. {
  172. if (card.Owner.SecurityCards.Count >= 1)
  173. {
  174. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  175. {
  176. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  177. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  178. };
  179. string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
  180. string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
  181. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  183. bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  184. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  185. card.Owner,
  186. 1,
  187. activateClass,
  188. fromTop).DestroySecurity());
  189. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  190. {
  191. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectPermanentCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. #region When Digivolving
  217. if (timing == EffectTiming.OnEnterFieldAnyone)
  218. {
  219. ActivateClass activateClass = new ActivateClass();
  220. activateClass.SetUpICardEffect("Trash the top or bottom of your security to reduce opponent's Digimon DP.", CanUseCondition, card);
  221. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  222. activateClass.SetHashString("TrashSecuirtyToReduceDP_BT15_042");
  223. cardEffects.Add(activateClass);
  224. string EffectDiscription()
  225. {
  226. return "[When Digivolving] By trashing the top or bottom card of your security stack, 1 of your opponent's Digimon gets -9000 DP until the end of your opponent's turn.";
  227. }
  228. bool CanUseCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  231. }
  232. bool CanActivateCondition(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. if (card.Owner.SecurityCards.Count >= 1)
  237. {
  238. return true;
  239. }
  240. }
  241. return false;
  242. }
  243. bool CanSelectPermanentCondition(Permanent permanent)
  244. {
  245. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  246. {
  247. if (permanent.HasDP)
  248. {
  249. return true;
  250. }
  251. }
  252. return false;
  253. }
  254. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  255. {
  256. if (card.Owner.SecurityCards.Count >= 1)
  257. {
  258. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  259. {
  260. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  261. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  262. };
  263. string selectPlayerMessage = "Which will you trash the top or bottom card of the security?";
  264. string notSelectPlayerMessage = "The opponent is selecting whether to trash the top or bottom card of security.";
  265. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  266. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  267. bool fromTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  268. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  269. card.Owner,
  270. 1,
  271. activateClass,
  272. fromTop).DestroySecurity());
  273. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  274. {
  275. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  276. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  277. selectPermanentEffect.SetUp(
  278. selectPlayer: card.Owner,
  279. canTargetCondition: CanSelectPermanentCondition,
  280. canTargetCondition_ByPreSelecetedList: null,
  281. canEndSelectCondition: null,
  282. maxCount: maxCount,
  283. canNoSelect: false,
  284. canEndNotMax: false,
  285. selectPermanentCoroutine: SelectPermanentCoroutine,
  286. afterSelectPermanentCoroutine: null,
  287. mode: SelectPermanentEffect.Mode.Custom,
  288. cardEffect: activateClass);
  289. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -9000.", "The opponent is selecting 1 Digimon that will get DP -9000.");
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  292. {
  293. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -9000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  294. }
  295. }
  296. }
  297. }
  298. }
  299. #endregion
  300. return cardEffects;
  301. }
  302. }
  303. }