BT6_086.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 BT6_086 : 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. int count()
  16. {
  17. int count = 0;
  18. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  19. {
  20. count += player.GetBattleAreaPermanents().Count((permanent) => permanent.IsTamer);
  21. }
  22. return count;
  23. }
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Place [Eosmon] from trash in digivolution cards", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] For each Tamer in play, you may place 1 level 5 or lower [Eosmon] from your trash at the top of this Digimon's digivolution cards in any order. If you place 2 or more cards with this effect, delete 1 of your opponent's Digimon.";
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. if (cardSource.CardNames.Contains("Eosmon"))
  35. {
  36. if (cardSource.Level <= 5)
  37. {
  38. if (cardSource.HasLevel)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  59. {
  60. if (count() >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  73. {
  74. int maxCount = Math.Min(count(), card.Owner.TrashCards.Count(CanSelectCardCondition));
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  77. selectCardEffect.SetUp(
  78. canTargetCondition: CanSelectCardCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: CanEndSelectCondition,
  81. canNoSelect: () => true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. message: "Select cards to place in Digivolution cards\n(cards will be placed in the digivolution cards so that cards with lower numbers are on top).",
  85. maxCount: maxCount,
  86. canEndNotMax: true,
  87. isShowOpponent: true,
  88. mode: SelectCardEffect.Mode.Custom,
  89. root: SelectCardEffect.Root.Trash,
  90. customRootCardList: null,
  91. canLookReverseCard: true,
  92. selectPlayer: card.Owner,
  93. cardEffect: activateClass);
  94. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  95. bool CanEndSelectCondition(List<CardSource> cardSources)
  96. {
  97. if (CardEffectCommons.HasNoElement(cardSources))
  98. {
  99. return false;
  100. }
  101. return true;
  102. }
  103. IEnumerator SelectCardCoroutine(CardSource cardSource)
  104. {
  105. selectedCards.Add(cardSource);
  106. yield return null;
  107. }
  108. if (selectedCards.Count >= 1)
  109. {
  110. selectedCards.Reverse();
  111. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(selectedCards, activateClass));
  112. if (selectedCards.Count >= 2)
  113. {
  114. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  115. {
  116. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  117. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  118. selectPermanentEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectPermanentCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. maxCount: maxCount,
  124. canNoSelect: false,
  125. canEndNotMax: false,
  126. selectPermanentCoroutine: null,
  127. afterSelectPermanentCoroutine: null,
  128. mode: SelectPermanentEffect.Mode.Destroy,
  129. cardEffect: activateClass);
  130. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138. if (timing == EffectTiming.None)
  139. {
  140. int count()
  141. {
  142. if (CardEffectCommons.IsExistOnBattleArea(card))
  143. {
  144. return card.PermanentOfThisCard().DigivolutionCards.Count / 3;
  145. }
  146. return 0;
  147. }
  148. bool Condition()
  149. {
  150. if (CardEffectCommons.IsExistOnBattleArea(card))
  151. {
  152. if (CardEffectCommons.IsOwnerTurn(card))
  153. {
  154. if (count() >= 1)
  155. {
  156. return true;
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect<Func<int>>(
  163. changeValue: () => count(),
  164. isInheritedEffect: false,
  165. card: card,
  166. condition: Condition));
  167. }
  168. return cardEffects;
  169. }
  170. }