BT7_093.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT7_093 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Choose 1 of your Digimon with [Hybrid] in its traits. Delete 1 of your opponent's Digimon with DP less than or equal to the chosen Digimon's DP.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.CardTraits.Contains("Hybrid"))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  41. {
  42. Permanent selectedPermanent = null;
  43. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  44. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  45. selectPermanentEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: CanSelectPermanentCondition,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: maxCount,
  51. canNoSelect: false,
  52. canEndNotMax: false,
  53. selectPermanentCoroutine: SelectPermanentCoroutine,
  54. afterSelectPermanentCoroutine: null,
  55. mode: SelectPermanentEffect.Mode.Custom,
  56. cardEffect: activateClass);
  57. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon with [Hybrid] in its traits.", "The opponent is selecting 1 Digimon with [Hybrid] in its traits.");
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  60. {
  61. selectedPermanent = permanent;
  62. yield return null;
  63. }
  64. if (selectedPermanent != null)
  65. {
  66. int maxDP = selectedPermanent.DP;
  67. bool CanSelectPermanentCondition1(Permanent permanent)
  68. {
  69. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  70. {
  71. if (permanent.DP <= maxDP)
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  79. {
  80. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition1,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: CanEndSelectCondition1,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Destroy,
  92. cardEffect: activateClass);
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. bool CanEndSelectCondition1(List<Permanent> permanents)
  95. {
  96. if (permanents.Count <= 0)
  97. {
  98. return false;
  99. }
  100. return true;
  101. }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. if (timing == EffectTiming.SecuritySkill)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect($"Play 1 [Takuya Kanbara] from hand or trash", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  112. activateClass.SetIsSecurityEffect(true);
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[Security] You may play 1 [Takuya Kanbara] from your hand or trash without paying its memory cost.";
  117. }
  118. bool CanSelectCardCondition(CardSource cardSource)
  119. {
  120. if (cardSource.CardNames.Contains("Takuya Kanbara") || cardSource.CardNames.Contains("TakuyaKanbara"))
  121. {
  122. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  136. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  137. if (canSelectHand || canSelectTrash)
  138. {
  139. if (canSelectHand && canSelectTrash)
  140. {
  141. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  142. {
  143. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  144. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  145. };
  146. string selectPlayerMessage = "From which area do you play a card?";
  147. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  148. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  149. }
  150. else
  151. {
  152. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  153. }
  154. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  155. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  156. List<CardSource> selectedCards = new List<CardSource>();
  157. IEnumerator SelectCardCoroutine(CardSource cardSource)
  158. {
  159. selectedCards.Add(cardSource);
  160. yield return null;
  161. }
  162. if (fromHand)
  163. {
  164. int maxCount = 1;
  165. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  166. selectHandEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectCardCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. mode: SelectHandEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  180. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  181. yield return StartCoroutine(selectHandEffect.Activate());
  182. }
  183. else
  184. {
  185. int maxCount = 1;
  186. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  187. selectCardEffect.SetUp(
  188. canTargetCondition: CanSelectCardCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. canNoSelect: () => true,
  192. selectCardCoroutine: SelectCardCoroutine,
  193. afterSelectCardCoroutine: null,
  194. message: "Select 1 card to play.",
  195. maxCount: maxCount,
  196. canEndNotMax: false,
  197. isShowOpponent: true,
  198. mode: SelectCardEffect.Mode.Custom,
  199. root: SelectCardEffect.Root.Trash,
  200. customRootCardList: null,
  201. canLookReverseCard: true,
  202. selectPlayer: card.Owner,
  203. cardEffect: activateClass);
  204. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  205. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  206. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  207. }
  208. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  209. if (!fromHand)
  210. {
  211. root = SelectCardEffect.Root.Trash;
  212. }
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  214. cardSources: selectedCards,
  215. activateClass: activateClass,
  216. payCost: false,
  217. isTapped: false,
  218. root: root,
  219. activateETB: true));
  220. }
  221. }
  222. }
  223. return cardEffects;
  224. }
  225. }