BT12_096.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Tagiru Akashi
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_096 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Turn
  13. if (timing == EffectTiming.OnStartTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  16. }
  17. #endregion
  18. #region Your Turn
  19. if (timing == EffectTiming.BeforePayCost)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  24. activateClass.SetHashString("DigivolutionCost-1_BT12_094");
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return "[Your Turn] If one of your Digimon digivolves into a Digimon card with <Save> in its text, by suspending this Tamer and placing 1 card from under one of your Tamers under that Digimon as one of its digivolution cards, reduce the digivolution cost by 1.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  33. && CardEffectCommons.IsOwnerTurn(card)
  34. && CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  39. && CardEffectCommons.CanActivateSuspendCostEffect(card)
  40. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  41. }
  42. bool CanSelectPermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  45. && permanent.DigivolutionCards.Any();
  46. }
  47. bool PermanentCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  50. }
  51. bool CardCondition(CardSource cardSource)
  52. {
  53. return cardSource.IsDigimon
  54. && cardSource.HasSaveText;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  59. Permanent giveDigivolutionCardsTamer = null;
  60. List<CardSource> selectedDigivolutionCards = new List<CardSource>();
  61. Permanent getDigivolutionCardsDigimon = null;
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: SelectPermanentCoroutine,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that has digivolution cards.", "The opponent is selecting 1 Tamer that has digivolution cards.");
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  78. {
  79. giveDigivolutionCardsTamer = permanent;
  80. yield return null;
  81. }
  82. if (giveDigivolutionCardsTamer != null)
  83. {
  84. bool isFaceDown = false;
  85. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  86. selectCardEffect.SetUp(
  87. canTargetCondition: (cardSource) => true,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. canNoSelect: () => false,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. message: "Select 1 digivolution card.",
  94. maxCount: 1,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. mode: SelectCardEffect.Mode.Custom,
  98. root: SelectCardEffect.Root.Custom,
  99. customRootCardList: giveDigivolutionCardsTamer.DigivolutionCards,
  100. canLookReverseCard: true,
  101. selectPlayer: card.Owner,
  102. cardEffect: activateClass);
  103. selectCardEffect.SetUseFaceDown();
  104. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card.", "The opponent is selecting 1 digivolution card.");
  105. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  106. yield return StartCoroutine(selectCardEffect.Activate());
  107. IEnumerator SelectCardCoroutine(CardSource cardSource)
  108. {
  109. selectedDigivolutionCards.Add(cardSource);
  110. if(selectedDigivolutionCards[0].IsFaceDown)
  111. {
  112. isFaceDown = true;
  113. }
  114. yield return null;
  115. }
  116. bool CanSelectPermanentCondition1(Permanent permanent)
  117. {
  118. List<Permanent> Permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable);
  119. return Permanents != null
  120. && Permanents.Contains(permanent)
  121. && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  122. && !permanent.IsToken;
  123. }
  124. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  125. {
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition1,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: 1,
  132. canNoSelect: false,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: SelectPermanentCoroutine1,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  139. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  140. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  141. {
  142. getDigivolutionCardsDigimon = permanent;
  143. yield return null;
  144. }
  145. }
  146. if (getDigivolutionCardsDigimon != null
  147. && selectedDigivolutionCards.Count >= 1)
  148. {
  149. foreach (CardSource selectedCard in selectedDigivolutionCards)
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(selectedCard, giveDigivolutionCardsTamer));
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(getDigivolutionCardsDigimon.AddDigivolutionCardsBottom(selectedDigivolutionCards, activateClass, false, isFaceDown));
  154. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  155. ChangeCostClass changeCostClass = new ChangeCostClass();
  156. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  157. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  158. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  159. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  160. bool CanUseCondition1(Hashtable hashtable)
  161. {
  162. return true;
  163. }
  164. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  165. {
  166. if (CardSourceCondition(cardSource)
  167. && RootCondition(root)
  168. && PermanentsCondition(targetPermanents))
  169. {
  170. Cost -= 1;
  171. }
  172. return Cost;
  173. }
  174. bool PermanentsCondition(List<Permanent> targetPermanents)
  175. {
  176. return targetPermanents != null
  177. && targetPermanents.Count(PermanentCondition) >= 1;
  178. }
  179. bool PermanentCondition(Permanent targetPermanent)
  180. {
  181. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  182. }
  183. bool CardSourceCondition(CardSource cardSource)
  184. {
  185. return cardSource.HasSaveText;
  186. }
  187. bool RootCondition(SelectCardEffect.Root root)
  188. {
  189. return true;
  190. }
  191. bool isUpDown()
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Security
  201. if (timing == EffectTiming.SecuritySkill)
  202. {
  203. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  204. }
  205. #endregion
  206. return cardEffects;
  207. }
  208. }
  209. }