Ryudamon_BT15_056.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 Ryudamon_BT15_056 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. //Black box Digivolution requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.CardNames.Contains("Kyokyomon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if(timing == EffectTiming.OnStartMainPhase)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Place cards under this Digimon's digivolution cards to make this Digimon unaffected by your opponent's effects until the end of your opponent's turn.", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[Start of Your Main Phase] By placing 1 [Shuu Yulin] from your hand or trash as this Digimon's bottom digivolution card, this Digimon isn't affected by the effects of your opponent's Digimon until the end of your opponent's turn.";
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. if (cardSource.CardNames.Contains("Shuu Yulin"))
  35. {
  36. return true;
  37. }
  38. if (cardSource.CardNames.Contains("ShuuYulin"))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (CardEffectCommons.IsOwnerTurn(card))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. //Check if Xu is in hand
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  70. if (canSelectHand)
  71. {
  72. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  73. }
  74. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  75. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  76. List<CardSource> selectedCards = new List<CardSource>();
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. if (fromHand)
  83. {
  84. int maxCount = 1;
  85. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectHandEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectCardCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  100. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. }
  103. if (selectedCards.Count >= 1)
  104. {
  105. Permanent selectedPermanent = card.PermanentOfThisCard();
  106. if (selectedPermanent != null)
  107. {
  108. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  109. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effect", CanUseCondition1, card);
  110. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  111. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  112. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  113. bool CanUseCondition1(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  116. }
  117. bool CardCondition(CardSource cardSource)
  118. {
  119. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  120. {
  121. if (cardSource == selectedPermanent.TopCard)
  122. {
  123. return true;
  124. }
  125. }
  126. return false;
  127. }
  128. bool SkillCondition(ICardEffect cardEffect)
  129. {
  130. if (cardEffect != null)
  131. {
  132. if (cardEffect.EffectSourceCard != null)
  133. {
  134. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  135. {
  136. if (cardEffect.IsDigimonEffect)
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. }
  146. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  147. }
  148. }
  149. }
  150. //Inherited effect
  151. if (timing == EffectTiming.OnTappedAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Suspend opponent's Digimon or Tamers with play cost less than this Digimon.", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  156. activateClass.SetIsInheritedEffect(true);
  157. activateClass.SetHashString("suspend_BT15_056_inherited");
  158. cardEffects.Add(activateClass);
  159. string EffectDiscription()
  160. {
  161. return "[All Turns][Once per turn] When this Digimon becomes suspened, suspened 1 of your opponent's Digimon or Tamers with a play cost less than or equal to this Digimon.";
  162. }
  163. bool CanSelectPermanentCondition(Permanent permanent)
  164. {
  165. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  166. {
  167. if (permanent.TopCard.GetCostItself <= card.PermanentOfThisCard().TopCard.GetCostItself)
  168. {
  169. if (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer)
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. if (CardEffectCommons.IsExistOnBattleArea(card))
  180. {
  181. if (CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card))
  182. {
  183. return true;
  184. }
  185. }
  186. return false;
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. if (CardEffectCommons.IsExistOnBattleArea(card))
  191. {
  192. return true;
  193. }
  194. return false;
  195. }
  196. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  197. {
  198. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: CanSelectPermanentCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: maxCount,
  206. canNoSelect: false,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: null,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Tap,
  211. cardEffect: activateClass);
  212. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  213. }
  214. }
  215. return cardEffects;
  216. }
  217. }