BT7_096.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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_096 : 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] You may play 1 Tamer card or 1 Digimon card with [Hybrid] in its traits from one of your Digimon's digivolution cards as a Tamer or another Digimon without paying its memory cost.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  37. {
  38. if (cardSource.IsTamer)
  39. {
  40. return true;
  41. }
  42. if (cardSource.IsDigimon)
  43. {
  44. if (cardSource.CardTraits.Contains("Hybrid"))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon which has digivolution cards.", "The opponent is selecting 1 Digimon which has digivolution cards.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. Permanent selectedPermanent = permanent;
  79. if (selectedPermanent != null)
  80. {
  81. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  82. {
  83. maxCount = 1;
  84. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) < maxCount)
  85. {
  86. maxCount = selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition);
  87. }
  88. List<CardSource> selectedCards = new List<CardSource>();
  89. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  90. selectCardEffect.SetUp(
  91. canTargetCondition: CanSelectCardCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. canNoSelect: () => false,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. message: "Select 1 digivolution card to play.",
  98. maxCount: maxCount,
  99. canEndNotMax: false,
  100. isShowOpponent: true,
  101. mode: SelectCardEffect.Mode.Custom,
  102. root: SelectCardEffect.Root.Custom,
  103. customRootCardList: selectedPermanent.DigivolutionCards,
  104. canLookReverseCard: true,
  105. selectPlayer: card.Owner,
  106. cardEffect: activateClass);
  107. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  108. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  109. yield return StartCoroutine(selectCardEffect.Activate());
  110. IEnumerator SelectCardCoroutine(CardSource cardSource)
  111. {
  112. selectedCards.Add(cardSource);
  113. yield return null;
  114. }
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  116. cardSources: selectedCards,
  117. activateClass: activateClass,
  118. payCost: false,
  119. isTapped: false,
  120. root: SelectCardEffect.Root.DigivolutionCards,
  121. activateETB: true));
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. if (timing == EffectTiming.SecuritySkill)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect($"Play 1 [Koji Minamoto] from hand or trash", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  133. activateClass.SetIsSecurityEffect(true);
  134. cardEffects.Add(activateClass);
  135. string EffectDiscription()
  136. {
  137. return "[Security] You may play 1 [Koji Minamoto] from your hand or trash without paying its memory cost.";
  138. }
  139. bool CanSelectCardCondition(CardSource cardSource)
  140. {
  141. if (cardSource != null)
  142. {
  143. if (cardSource.Owner == card.Owner)
  144. {
  145. if (cardSource.CardNames.Contains("Koji Minamoto") || cardSource.CardNames.Contains("KojiMinamoto"))
  146. {
  147. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  148. {
  149. return true;
  150. }
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  163. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  164. if (canSelectHand || canSelectTrash)
  165. {
  166. if (canSelectHand && canSelectTrash)
  167. {
  168. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  169. {
  170. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  171. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  172. };
  173. string selectPlayerMessage = "From which area do you play a card?";
  174. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  175. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  176. }
  177. else
  178. {
  179. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  180. }
  181. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  182. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  183. List<CardSource> selectedCards = new List<CardSource>();
  184. IEnumerator SelectCardCoroutine(CardSource cardSource)
  185. {
  186. selectedCards.Add(cardSource);
  187. yield return null;
  188. }
  189. if (fromHand)
  190. {
  191. int maxCount = 1;
  192. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  193. selectHandEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectCardCondition,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. mode: SelectHandEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  207. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  208. yield return StartCoroutine(selectHandEffect.Activate());
  209. }
  210. else
  211. {
  212. int maxCount = 1;
  213. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  214. selectCardEffect.SetUp(
  215. canTargetCondition: CanSelectCardCondition,
  216. canTargetCondition_ByPreSelecetedList: null,
  217. canEndSelectCondition: null,
  218. canNoSelect: () => true,
  219. selectCardCoroutine: SelectCardCoroutine,
  220. afterSelectCardCoroutine: null,
  221. message: "Select 1 card to play.",
  222. maxCount: maxCount,
  223. canEndNotMax: false,
  224. isShowOpponent: true,
  225. mode: SelectCardEffect.Mode.Custom,
  226. root: SelectCardEffect.Root.Trash,
  227. customRootCardList: null,
  228. canLookReverseCard: true,
  229. selectPlayer: card.Owner,
  230. cardEffect: activateClass);
  231. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  232. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  233. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  234. }
  235. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  236. if (!fromHand)
  237. {
  238. root = SelectCardEffect.Root.Trash;
  239. }
  240. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  241. cardSources: selectedCards,
  242. activateClass: activateClass,
  243. payCost: false,
  244. isTapped: false,
  245. root: root,
  246. activateETB: true));
  247. }
  248. }
  249. }
  250. return cardEffects;
  251. }
  252. }