BT5_111.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 BT5_111 : 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.None)
  14. {
  15. bool Condition()
  16. {
  17. return card.Owner.HandCards.Contains(card);
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent))
  22. {
  23. if (targetPermanent.TopCard.ContainsCardName("Omnimon"))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  31. permanentCondition: PermanentCondition,
  32. digivolutionCost: 3,
  33. ignoreDigivolutionRequirement: true,
  34. card: card,
  35. condition: Condition));
  36. }
  37. if (timing == EffectTiming.OnAllyAttack)
  38. {
  39. int maxDP()
  40. {
  41. int maxDP = -100;
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. maxDP = card.PermanentOfThisCard().DP;
  45. }
  46. return maxDP;
  47. }
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect($"Delete 1 Digimon with {maxDP()} DP or less", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  51. cardEffects.Add(activateClass);
  52. string EffectDiscription()
  53. {
  54. return "[When Attacking] Delete 1 of your opponent's Digimon with DP less than or equal to this Digimon's DP.";
  55. }
  56. bool CanSelectPermanentCondition(Permanent permanent)
  57. {
  58. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  59. {
  60. if (permanent.DP <= maxDP())
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  70. }
  71. bool CanActivateCondition(Hashtable hashtable)
  72. {
  73. if (CardEffectCommons.IsExistOnBattleArea(card))
  74. {
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  76. {
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  83. {
  84. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  85. {
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Destroy,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.OnAllyAttack)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Trash 2 digivolution cards to end the attack", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[Opponent's Turn] When your opponent's Digimon attacks, you may trash 2 of this Digimon's digivolution cards to end the attack.";
  113. }
  114. bool CanSelectCardCondition(CardSource cardSource)
  115. {
  116. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  117. }
  118. bool PermanentCondition(Permanent permanent)
  119. {
  120. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleArea(card))
  125. {
  126. if (CardEffectCommons.IsOpponentTurn(card))
  127. {
  128. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. return false;
  135. }
  136. bool CanActivateCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  152. {
  153. Permanent selectedPermanent = card.PermanentOfThisCard();
  154. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  155. {
  156. List<CardSource> selectedCards = new List<CardSource>();
  157. int maxCount = Math.Min(2, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: CanSelectCardCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => true,
  164. selectCardCoroutine: SelectCardCoroutine,
  165. afterSelectCardCoroutine: null,
  166. message: "Select cards to discard.",
  167. maxCount: maxCount,
  168. canEndNotMax: false,
  169. isShowOpponent: true,
  170. mode: SelectCardEffect.Mode.Custom,
  171. root: SelectCardEffect.Root.Custom,
  172. customRootCardList: selectedPermanent.DigivolutionCards,
  173. canLookReverseCard: true,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. selectCardEffect.SetNotShowCard();
  177. yield return StartCoroutine(selectCardEffect.Activate());
  178. IEnumerator SelectCardCoroutine(CardSource cardSource)
  179. {
  180. selectedCards.Add(cardSource);
  181. yield return null;
  182. }
  183. if (selectedCards.Count >= 1)
  184. {
  185. if (selectedCards.Count == 2)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  188. }
  189. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
  190. selectedPermanent,
  191. selectedCards,
  192. activateClass).TrashDigivolutionCards());
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. return cardEffects;
  200. }
  201. }