Decode.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. public partial class CardEffectCommons
  4. {
  5. static bool CanSelectSourceCardCondition(CardSource source, CardColor color, int level, ICardEffect activateClass)
  6. {
  7. return source.IsDigimon &&
  8. source.CardColors.Contains(color) &&
  9. source.HasLevel && source.Level == level &&
  10. CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass);
  11. }
  12. #region Can activate [Decode]
  13. public static bool CanActivateDecode(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
  14. {
  15. return IsExistOnBattleAreaDigimon(cardSource) &&
  16. cardSource.PermanentOfThisCard().DigivolutionCards.Some(
  17. source => CanSelectSourceCardCondition(source, color, level, activateClass));
  18. }
  19. #endregion
  20. #region Effect process of [Decode]
  21. public static IEnumerator DecodeProcess(CardColor color, int level, CardSource cardSource, ICardEffect activateClass)
  22. {
  23. List<CardSource> selectedCards = new List<CardSource>();
  24. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  25. selectCardEffect.SetUp(
  26. canTargetCondition: source => CanSelectSourceCardCondition(source, color, level, activateClass),
  27. canTargetCondition_ByPreSelecetedList: null,
  28. canEndSelectCondition: null,
  29. canNoSelect: () => true,
  30. selectCardCoroutine: SelectCardCoroutine,
  31. afterSelectCardCoroutine: null,
  32. message: "Select 1 digivolution card to play.",
  33. maxCount: 1,
  34. canEndNotMax: false,
  35. isShowOpponent: true,
  36. mode: SelectCardEffect.Mode.Custom,
  37. root: SelectCardEffect.Root.Custom,
  38. customRootCardList: cardSource.PermanentOfThisCard().DigivolutionCards,
  39. canLookReverseCard: true,
  40. selectPlayer: cardSource.Owner,
  41. cardEffect: activateClass);
  42. selectCardEffect.SetUpCustomMessage(
  43. "Select 1 digivolution card to play.",
  44. "The opponent is selecting 1 digivolution card to play.");
  45. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  46. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  47. IEnumerator SelectCardCoroutine(CardSource source)
  48. {
  49. selectedCards.Add(source);
  50. yield return null;
  51. }
  52. yield return ContinuousController.instance.StartCoroutine(
  53. PlayPermanentCards(
  54. cardSources: selectedCards,
  55. activateClass: activateClass,
  56. payCost: false,
  57. isTapped: false,
  58. root: SelectCardEffect.Root.DigivolutionCards,
  59. activateETB: true));
  60. }
  61. #endregion
  62. #region Target 1 Digimon gains [Decode]
  63. public static IEnumerator GainDecode(CardColor color, int level, Permanent targetPermanent, EffectDuration effectDuration,
  64. ICardEffect activateClass)
  65. {
  66. if (targetPermanent == null) yield break;
  67. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  68. if (activateClass == null) yield break;
  69. if (activateClass.EffectSourceCard == null) yield break;
  70. CardSource card = activateClass.EffectSourceCard;
  71. bool CanUseCondition()
  72. {
  73. return IsPermanentExistsOnBattleArea(targetPermanent) &&
  74. !targetPermanent.TopCard.CanNotBeAffected(activateClass);
  75. }
  76. ActivateClass decode = CardEffectFactory.DecodeEffect(
  77. color: color,
  78. level: level,
  79. targetPermanent: targetPermanent,
  80. isInheritedEffect: false,
  81. condition: CanUseCondition,
  82. rootCardEffect: activateClass,
  83. targetPermanent.TopCard);
  84. AddEffectToPermanent(
  85. targetPermanent: targetPermanent,
  86. effectDuration: effectDuration,
  87. card: card,
  88. cardEffect: decode,
  89. timing: EffectTiming.OnAllyAttack);
  90. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  93. .CreateBuffEffect(targetPermanent));
  94. }
  95. }
  96. #endregion
  97. }