BT6_093.cs 14 KB

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