ST12_08.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 ST12_08 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("This Digimon can attack unsuspended Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] This Digimon may also attack your opponent's unsuspended Digimon for the turn.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  36. {
  37. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(card.PermanentOfThisCard()));
  38. CanAttackTargetDefendingPermanentClass canAttackTargetDefendingPermanentClass = new CanAttackTargetDefendingPermanentClass();
  39. canAttackTargetDefendingPermanentClass.SetUpICardEffect($"Can attack unsuspended Digimon", CanUseCondition1, card);
  40. canAttackTargetDefendingPermanentClass.SetUpCanAttackTargetDefendingPermanentClass(attackerCondition: AttackerCondition, defenderCondition: DefenderCondition, cardEffectCondition: CardEffectCondition);
  41. CardEffectCommons.AddEffectToPermanent(
  42. targetPermanent: card.PermanentOfThisCard(),
  43. effectDuration: EffectDuration.UntilEachTurnEnd,
  44. card: card,
  45. cardEffect: canAttackTargetDefendingPermanentClass,
  46. timing: EffectTiming.None);
  47. bool CanUseCondition1(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleArea(card);
  50. }
  51. bool AttackerCondition(Permanent permanent)
  52. {
  53. return permanent == card.PermanentOfThisCard();
  54. }
  55. bool DefenderCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  58. {
  59. if (!permanent.IsSuspended)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CardEffectCondition(ICardEffect cardEffect)
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. if (timing == EffectTiming.OnAllyAttack)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Play 1 Digimon card with [Sistermon] in its name from hand or trash", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  77. activateClass.SetIsInheritedEffect(true);
  78. activateClass.SetHashString("PlaySistermon_ST12_08");
  79. cardEffects.Add(activateClass);
  80. string EffectDiscription()
  81. {
  82. return "[When Attacking][Once Per Turn] If this Digimon has [Royal Knight] in its traits, you may play 1 Digimon card with [Sistermon] in its name from your hand or trash without paying its memory cost.";
  83. }
  84. bool CanSelectCardCondition(CardSource cardSource)
  85. {
  86. if (cardSource.IsDigimon)
  87. {
  88. if (cardSource.ContainsCardName("Sistermon"))
  89. {
  90. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (card.PermanentOfThisCard().TopCard.HasRoyalKnightTraits)
  107. {
  108. if (card.Owner.HandCards.Count >= 1)
  109. {
  110. return true;
  111. }
  112. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  121. {
  122. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  123. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  124. if (canSelectHand || canSelectTrash)
  125. {
  126. if (canSelectHand && canSelectTrash)
  127. {
  128. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  129. {
  130. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  131. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  132. };
  133. string selectPlayerMessage = "From which area do you play a card?";
  134. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  135. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  136. }
  137. else
  138. {
  139. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  140. }
  141. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  142. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  143. List<CardSource> selectedCards = new List<CardSource>();
  144. IEnumerator SelectCardCoroutine(CardSource cardSource)
  145. {
  146. selectedCards.Add(cardSource);
  147. yield return null;
  148. }
  149. if (fromHand)
  150. {
  151. int maxCount = 1;
  152. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  153. selectHandEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectCardCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: true,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. selectCardCoroutine: SelectCardCoroutine,
  163. afterSelectCardCoroutine: null,
  164. mode: SelectHandEffect.Mode.Custom,
  165. cardEffect: activateClass);
  166. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  167. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  168. yield return StartCoroutine(selectHandEffect.Activate());
  169. }
  170. else
  171. {
  172. int maxCount = 1;
  173. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  174. selectCardEffect.SetUp(
  175. canTargetCondition: CanSelectCardCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. canNoSelect: () => true,
  179. selectCardCoroutine: SelectCardCoroutine,
  180. afterSelectCardCoroutine: null,
  181. message: "Select 1 card to play.",
  182. maxCount: maxCount,
  183. canEndNotMax: false,
  184. isShowOpponent: true,
  185. mode: SelectCardEffect.Mode.Custom,
  186. root: SelectCardEffect.Root.Trash,
  187. customRootCardList: null,
  188. canLookReverseCard: true,
  189. selectPlayer: card.Owner,
  190. cardEffect: activateClass);
  191. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  192. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  193. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  194. }
  195. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  196. if (!fromHand)
  197. {
  198. root = SelectCardEffect.Root.Trash;
  199. }
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  201. }
  202. }
  203. }
  204. return cardEffects;
  205. }
  206. }