BT7_039.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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_039 : 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("Place cards to digivolution cards and Draw", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] If this Digimon has 1 digivolution card, you may place up to 2 level 4 or lower yellow Digimon cards from your hand at the bottom of this Digimon's digivolution cards in any order. Then, <Draw 1> for each Digimon card you placed. (Draw 1 card from your deck.)";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (cardSource.HasCardColor(CardColor.Yellow))
  28. {
  29. if (cardSource.Level <= 4)
  30. {
  31. if (cardSource.HasLevel)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.Owner.HandCards.Count >= 1)
  49. {
  50. if (card.PermanentOfThisCard().DigivolutionCards.Count == 1)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  61. {
  62. List<CardSource> digivolutionCards = new List<CardSource>();
  63. int maxCount = Math.Min(2, card.Owner.HandCards.Count(CanSelectCardCondition));
  64. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  65. selectHandEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CanSelectCardCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: CanEndSelectCondition,
  70. maxCount: maxCount,
  71. canNoSelect: true,
  72. canEndNotMax: true,
  73. isShowOpponent: true,
  74. selectCardCoroutine: SelectCardCoroutine,
  75. afterSelectCardCoroutine: null,
  76. mode: SelectHandEffect.Mode.Custom,
  77. cardEffect: activateClass);
  78. selectHandEffect.SetUpCustomMessage("Select cards to place on bottom of digivolution cards.", "The opponent is selecting cards to place on bottom of digivolution cards.");
  79. yield return StartCoroutine(selectHandEffect.Activate());
  80. bool CanEndSelectCondition(List<CardSource> cardSources)
  81. {
  82. if (CardEffectCommons.HasNoElement(cardSources))
  83. {
  84. return false;
  85. }
  86. return true;
  87. }
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. digivolutionCards.Add(cardSource);
  91. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(cardSource));
  92. yield return null;
  93. }
  94. if (digivolutionCards.Count >= 1)
  95. {
  96. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  97. if (digivolutionCards.Count == 1)
  98. {
  99. foreach (CardSource cardSource in digivolutionCards)
  100. {
  101. digivolutionCards_fixed.Add(cardSource);
  102. }
  103. }
  104. else
  105. {
  106. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  107. selectCardEffect.SetUp(
  108. canTargetCondition: (cardSource) => true,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. canNoSelect: () => false,
  112. selectCardCoroutine: null,
  113. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  114. 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).",
  115. maxCount: digivolutionCards.Count,
  116. canEndNotMax: false,
  117. isShowOpponent: false,
  118. mode: SelectCardEffect.Mode.Custom,
  119. root: SelectCardEffect.Root.Custom,
  120. customRootCardList: digivolutionCards,
  121. canLookReverseCard: true,
  122. selectPlayer: card.Owner,
  123. cardEffect: activateClass);
  124. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  125. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  126. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  127. {
  128. foreach (CardSource cardSource in cardSources)
  129. {
  130. digivolutionCards_fixed.Add(cardSource);
  131. }
  132. yield return null;
  133. }
  134. }
  135. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(digivolutionCards_fixed, activateClass));
  136. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, digivolutionCards_fixed.Count, activateClass).Draw());
  137. }
  138. }
  139. }
  140. }
  141. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  142. {
  143. ActivateClass activateClass = new ActivateClass();
  144. activateClass.SetUpICardEffect("Security Attack +1", CanUseCondition, card);
  145. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  146. activateClass.SetIsInheritedEffect(true);
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. return "[Your Turn] When this card is trashed due to activating this Digimon's <Digi-Burst>, 1 of your Digimon gains <Security Attack +1> for the turn. (This Digimon checks 1 additional security card.)";
  151. }
  152. bool CanSelectPermanentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsOwnerTurn(card))
  159. {
  160. if (CardEffectCommons.CanTriggerOnTrashBySelfDigiBurst(hashtable, card))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnTrash(card))
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  181. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  182. selectPermanentEffect.SetUp(
  183. selectPlayer: card.Owner,
  184. canTargetCondition: CanSelectPermanentCondition,
  185. canTargetCondition_ByPreSelecetedList: null,
  186. canEndSelectCondition: null,
  187. maxCount: maxCount,
  188. canNoSelect: false,
  189. canEndNotMax: false,
  190. selectPermanentCoroutine: SelectPermanentCoroutine,
  191. afterSelectPermanentCoroutine: null,
  192. mode: SelectPermanentEffect.Mode.Custom,
  193. cardEffect: activateClass);
  194. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack +1.", "The opponent is selecting 1 Digimon that will get Security Attack +1.");
  195. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  196. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  199. }
  200. }
  201. }
  202. return cardEffects;
  203. }
  204. }