BT7_087.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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_087 : 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.SecuritySkill)
  14. {
  15. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  16. }
  17. if (timing == EffectTiming.OnDeclaration)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Place cards from hand to digivolution cards and digivolve", CanUseCondition, card);
  21. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  22. activateClass.SetHashString("Digivolve_BT7_085");
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "[Main][Once Per Turn] You may place 5 cards with [Hybrid] in their traits from your hand under this Tamer in any order to digivolve it into a [MagnaGarurumon] in your hand for its digivolution cost as if this Tamer is a level 5 blue Digimon.";
  27. }
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. return cardSource.CardTraits.Contains("Hybrid");
  31. }
  32. bool CanSelectCardCondition1(CardSource cardSource)
  33. {
  34. return cardSource.CardNames.Contains("MagnaGarurumon");
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 5)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 5)
  52. {
  53. List<CardSource> selectedCards = new List<CardSource>();
  54. int maxCount = 5;
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: CanSelectCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: maxCount,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards to place in Digivolution cards.");
  70. selectHandEffect.SetNotShowCard();
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCards.Add(cardSource);
  75. yield return null;
  76. }
  77. List<CardSource> digivolutionCards = new List<CardSource>();
  78. if (selectedCards.Count == 5)
  79. {
  80. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  81. selectCardEffect.SetUp(
  82. canTargetCondition: (cardSource) => true,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. canNoSelect: () => false,
  86. selectCardCoroutine: null,
  87. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  88. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  89. maxCount: selectedCards.Count,
  90. canEndNotMax: false,
  91. isShowOpponent: false,
  92. mode: SelectCardEffect.Mode.Custom,
  93. root: SelectCardEffect.Root.Custom,
  94. customRootCardList: selectedCards,
  95. canLookReverseCard: true,
  96. selectPlayer: card.Owner,
  97. cardEffect: activateClass);
  98. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  99. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  100. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  101. {
  102. foreach (CardSource cardSource in cardSources)
  103. {
  104. digivolutionCards.Add(cardSource);
  105. }
  106. yield return null;
  107. }
  108. }
  109. if (digivolutionCards.Count == 5)
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  112. #region treat as blue level 5 Digimon
  113. CardSource topCard = card.PermanentOfThisCard().TopCard;
  114. #region treat as blue
  115. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  116. changeCardColorClass.SetUpICardEffect($"Treated as blue", CanUseCondition1, card);
  117. changeCardColorClass.SetUpChangeCardColorClass(ChangeCardColors: ChangeCardColors);
  118. changeCardColorClass.SetNotShowUI(true);
  119. bool CanUseCondition1(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (card == topCard)
  124. {
  125. if (topCard == card.PermanentOfThisCard().TopCard)
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. List<CardColor> ChangeCardColors(CardSource cardSource, List<CardColor> CardColors)
  134. {
  135. if (cardSource == card)
  136. {
  137. CardColors.Add(CardColor.Blue);
  138. }
  139. return CardColors;
  140. }
  141. #endregion
  142. #region treat as level 5
  143. ChangePermanentLevelClass changePermanentLevelClass = new ChangePermanentLevelClass();
  144. changePermanentLevelClass.SetUpICardEffect($"Treated as level 5", CanUseCondition1, card);
  145. changePermanentLevelClass.SetUpChangePermanentLevelClass(GetLevel: GetLevel);
  146. changePermanentLevelClass.SetNotShowUI(true);
  147. int GetLevel(Permanent permanent, int level)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (permanent == card.PermanentOfThisCard())
  152. {
  153. level = 5;
  154. }
  155. }
  156. return level;
  157. }
  158. #endregion
  159. #region treat as Digimon
  160. TreatAsDigimonClass treatAsDigimonClass = new TreatAsDigimonClass();
  161. treatAsDigimonClass.SetUpICardEffect($"Treated as Digimon", CanUseCondition1, card);
  162. treatAsDigimonClass.SetUpTreatAsDigimonClass(permanentCondition: PermanentCondition);
  163. treatAsDigimonClass.SetNotShowUI(true);
  164. bool PermanentCondition(Permanent permanent)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleArea(card))
  167. {
  168. if (permanent == card.PermanentOfThisCard())
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. #endregion
  176. #region treat as not having DP(not to show on UI)
  177. DontHaveDPClass dontHaveDPClass = new DontHaveDPClass();
  178. dontHaveDPClass.SetUpICardEffect("Doesn't have DP", CanUseCondition1, card);
  179. dontHaveDPClass.SetUpDontHaveDPClass(PermanentCondition: PermanentCondition);
  180. dontHaveDPClass.SetNotShowUI(true);
  181. #endregion
  182. List<Func<EffectTiming, ICardEffect>> GetCardEffects = new List<Func<EffectTiming, ICardEffect>>()
  183. {
  184. (_timing) => changeCardColorClass,
  185. (_timing) => changePermanentLevelClass,
  186. (_timing) => treatAsDigimonClass,
  187. (_timing) => dontHaveDPClass,
  188. };
  189. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in GetCardEffects)
  190. {
  191. card.PermanentOfThisCard().PermanentEffects.Add(GetCardEffect);
  192. }
  193. card.PermanentOfThisCard().IsPlaceToTrashDueToNotHavingDP = false;
  194. #endregion
  195. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  196. targetPermanent: card.PermanentOfThisCard(),
  197. cardCondition: CanSelectCardCondition1,
  198. payCost: true,
  199. reduceCostTuple: null,
  200. fixedCostTuple: null,
  201. ignoreDigivolutionRequirementFixedCost: -1,
  202. isHand: true,
  203. activateClass: activateClass,
  204. successProcess: null));
  205. #region release effects
  206. if (CardEffectCommons.IsExistOnBattleArea(card))
  207. {
  208. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in GetCardEffects)
  209. {
  210. card.PermanentOfThisCard().PermanentEffects.Remove(GetCardEffect);
  211. }
  212. card.PermanentOfThisCard().IsPlaceToTrashDueToNotHavingDP = true;
  213. }
  214. #endregion
  215. }
  216. }
  217. }
  218. }
  219. }
  220. if (timing == EffectTiming.OnAddHand)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect("Memory +1 and gain unblockable", CanUseCondition, card);
  224. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  225. activateClass.SetIsInheritedEffect(true);
  226. activateClass.SetHashString("Memory+1_BT7_087");
  227. cardEffects.Add(activateClass);
  228. string EffectDiscription()
  229. {
  230. return "[Your Turn][Once Per Turn] When an effect adds a card to your hand, gain 1 memory. Then, this Digimon can't be blocked for the turn.";
  231. }
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. if (CardEffectCommons.IsOwnerTurn(card))
  237. {
  238. if (CardEffectCommons.CanTriggerOnHandAdded(hashtable, card.Owner, null))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. bool CanActivateCondition(Hashtable hashtable)
  247. {
  248. if (CardEffectCommons.IsExistOnBattleArea(card))
  249. {
  250. return true;
  251. }
  252. return false;
  253. }
  254. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  257. Permanent selectedPermanent = card.PermanentOfThisCard();
  258. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeBlocked(
  259. targetPermanent: selectedPermanent,
  260. defenderCondition: null,
  261. effectDuration: EffectDuration.UntilEachTurnEnd,
  262. activateClass: activateClass,
  263. effectName: "Unblockable"));
  264. }
  265. }
  266. return cardEffects;
  267. }
  268. }