ST9_06.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 ST9_06 : 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("Play Digimon from digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may play 1 level 4 or lower blue Digimon card and 1 level 4 or lower green Digimon card from this Digimon's digivolution cards without paying their memory costs.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.Owner == card.Owner)
  28. {
  29. if (cardSource.IsDigimon)
  30. {
  31. if (cardSource.Level <= 4)
  32. {
  33. if (cardSource.HasCardColor(CardColor.Blue))
  34. {
  35. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  36. {
  37. if (cardSource.HasLevel)
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanSelectCardCondition1(CardSource cardSource)
  50. {
  51. if (cardSource != null)
  52. {
  53. if (cardSource.Owner == card.Owner)
  54. {
  55. if (cardSource.IsDigimon)
  56. {
  57. if (cardSource.Level <= 4)
  58. {
  59. if (cardSource.HasCardColor(CardColor.Green))
  60. {
  61. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  62. {
  63. if (cardSource.HasLevel)
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. if (CardEffectCommons.IsExistOnBattleArea(card))
  82. {
  83. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleArea(card))
  93. {
  94. List<CardSource> selectedCards = new List<CardSource>();
  95. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  96. {
  97. int maxCount = 1;
  98. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  99. selectCardEffect.SetUp(
  100. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. canNoSelect: () => false,
  104. selectCardCoroutine: SelectCardCoroutine,
  105. afterSelectCardCoroutine: null,
  106. message: "Select 1 level 4 or lower blue Digimon card to play.",
  107. maxCount: maxCount,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. mode: SelectCardEffect.Mode.Custom,
  111. root: SelectCardEffect.Root.DigivolutionCards,
  112. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  113. canLookReverseCard: true,
  114. selectPlayer: card.Owner,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  117. IEnumerator SelectCardCoroutine(CardSource cardSource)
  118. {
  119. selectedCards.Add(cardSource);
  120. yield return null;
  121. }
  122. }
  123. List<CardSource> remainingCards = card.PermanentOfThisCard().DigivolutionCards.Filter(cardSource => !selectedCards.Contains(cardSource));
  124. bool canNoSelect = CanSelectCardCondition1(selectedCards[0]) //If first card also fulfills the second condition
  125. && !remainingCards.Any(CanSelectCardCondition);//And was the only card that could fulfill the first condition
  126. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  127. {
  128. int maxCount = 1;
  129. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  130. selectCardEffect.SetUp(
  131. canTargetCondition: (cardSource) => CanSelectCardCondition1(cardSource),
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. canNoSelect: () => canNoSelect,
  135. selectCardCoroutine: SelectCardCoroutine,
  136. afterSelectCardCoroutine: null,
  137. message: "Select 1 level 4 or lower green Digimon card to play.",
  138. maxCount: maxCount,
  139. canEndNotMax: false,
  140. isShowOpponent: true,
  141. mode: SelectCardEffect.Mode.Custom,
  142. root: SelectCardEffect.Root.DigivolutionCards,
  143. customRootCardList: remainingCards,
  144. canLookReverseCard: true,
  145. selectPlayer: card.Owner,
  146. cardEffect: activateClass);
  147. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. selectedCards.Add(cardSource);
  151. yield return null;
  152. }
  153. }
  154. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  155. cardSources: selectedCards,
  156. activateClass: activateClass,
  157. payCost: false,
  158. isTapped: false,
  159. root: SelectCardEffect.Root.DigivolutionCards,
  160. activateETB: true));
  161. }
  162. }
  163. }
  164. return cardEffects;
  165. }
  166. }